Visualizing the Rectangular Method

Estimating the area under a curve by adding up the areas of a number of rectangles can produce a crude approximation when the number of rectangles is small, but becomes more and more accurate as the number of rectangles increases. A good way to convince yourself of this is to use Maple to illustrate the process. You should start up a Maple session now if you have not already done so. When you are done, click below and we will initialize Maple to do the illustration.

Click here to set up Maple for the demonstration:

EXECUTEread `examples/integrate.m`;

We are now ready to do some experimentation:

EXECUTEanimrect(x->x^2, 0, 1, 6);

The button that you just clicked will issue a Maple command that will bring up an animation window. In the initial frame, you will see the area under the curve tex2html_wrap_inline294 between x=0 and x=1 approximated by two rectangles. Why is this a crude approximation?

Click here for the answer

You should move through the animation one frame at a time. (You can do this by clicking on the third button from the left in the animation window. You can reverse the direction of the animation by clicking on the second button from the right.) In each successive frame, the number of rectangles involved in the approximation doubles. In the sixth and final frame, 64 rectangles are used to approximate the area under the curve. As you can see, the approximation has become much better.

Feel free to experiment with animating other situations: simply use the ``rectangular'' function in the Maple window just as we did. The first argument is the function that you want to approximate, the second argument is the low bound, the third argument is the high bound, and the fourth argument is the number of frames to include in the animation. (Don't make this last argument too big or Maple will take too long to produce the animation!)

Christopher R. Johnson
Hamlet Project
Department of Computer Science
University of Utah