This code will not run! You have to make these fixes first:
- Fix the function $f(x)$ to return the function you wish to integrate.
- Fix the
N= line to reflect the number of rectanges you want under your curve.
- Next fix the upper and lower limits of your integral, $a$ and $b$.
- Fix the
sum=sum+ line to add the area of the current rectangle to the running sum of areas.
Make sure this all works. Pick an integral, say like $\int_0^{10} x dx$. What do you get when you do it by hand?
The program here should give you the same result. The power here is when the computer can give you the
answer to an integral that you
cannot do by hand. How about this one? $\int_0^\pi x^2 cos(1/x)^2 dx$ (we got 8.13
for the answer)?
Also, the value of the $N$ (the number of rectangles to be tiled under your function), is very important to this program. What effects
does it have on your answers?