Next: Exercises
Up: No Title
Previous: No Title
In class you have learned about approximating areas using inscribed and circumscribed polygons, which either under- or overestimated the area of the region. As the number of polygons grew, however, the error lessened, and in the limit (of the number of polygons used) both methods converged to the same answer.
More generally, areas may be approximated by rectangles whose heights are equal to the value of the function at the left, right, or mid- point of each rectangle. In your text, for instance, the method used in Figure 7 (on page 257) uses right endpoints, and the method used in Figure 8 uses left endpoints.
Having already used these methods at least once with pencil and paper, you are surely ready to let Maple do some of the work for you!
In these simple approximation schemes, the area above each subinterval is approximated by the area of a rectangle, with the height of the rectangle being chosen according to some rule. Also, the subintervals are defined by separating the interval of interest into n intervals of equal width. In particular, we will consider the following rules:
The Maple student package has commands for visualizing these three rectangular area approximations. To use them, you first must load the package via the with command. Then try the three commands given below. Make sure you understand the differences between the three different rectangular approximations. Take a moment to see that the different rules choose rectangles which in each case will either underestimate or overestimate the area.
> with(student):
> rightbox(x^2,x=0..4);
> leftbox(x^2,x=0..4);
> middlebox(x^2,x=0..4);
There are also Maple commands leftsum, rightsum, and middlesum to sum the areas of the rectangles, see the examples below. Note the use of evalf to obtain numerical answers.
> rightsum(x^2,x=0..4);
> evalf(rightsum(x^2,x=0..4));
> middlesum(x^2,x=0..4);
> evalf(middlesum(x^2,x=0..4));
It should be clear from the graphs that adding up the areas of the rectangles only approximates the area under the curve. However, by increasing the number of subintervals the accuracy of the approximation can be increased. All of the Maple commands described so far in this lab permit a third argument to specify the number of subintervals. The default is 4 subintervals. See the example below for the area under y=x from x=0 to x=2 using the rightsum command with 4, 10, 20 and 100 subintervals. (As this region describes a right triangle with height 2 and base 2, this area can be easily calculated to be exactly 2.) Try it yourself with the leftsum and middlesum commands.
> evalf(rightsum(x,x=0..2));
> evalf(rightsum(x,x=0..2,10));
> evalf(rightsum(x,x=0..2,20));
> evalf(rightsum(x,x=0..2,100));
Since, in this trivial example, we knew that the area is exactly 2, it appears that, as the number of subintervals increases, the rectangular approximation becomes more accurate.
When this limit as the number of subintervals goes to infinity exists, we have special notation for this limit and write it as
The basic maple command for performing definite and indefinite integrals is the int command. The syntax is very similar to that of the leftsum and rightsum commands, except you don't need to specify the number of subintervals. This should make sense, if you recall that the definite integral is defined as a limit of a rectangular sum as the number of subintervals goes to infinity. In the section on rectangular approximations, we used two examples. The first was the function y=x2 on the interval [0,4] and the second was the function y=x on the interval [0,2]. We would express the areas under these two curves with our integral notation as
Using Maple, we would compute these two definite integrals as shown below.
> int(x^2,x=0..4);
> int(x,x=0..2);
> evalf(int(x^2,x=0..4));
In the exercises, you will need to make many rectangular
approximations and compare them to some definite integrals, all on the
same function. In doing so, you'll need to apply several commands to
the same function. To save typing and prevent errors, you can define the
function as a function or an expression in Maple first and then use it
in subsequent int, leftsum, etc. commands. For
example, suppose you were given the function on the
interval
. Then you can define this function in Maple with
the command
> f := x -> x*sin(x);
> int(f(x),x=0..Pi);
> evalf(leftsum(f(x),x=0..Pi,4));
Christine M Palmer