next up previous
Next: Exercises Up: No Title Previous: No Title

Subsections


The Integral and Its Properties

Purpose

In this lab you will use rectangular approximation to find areas under curves, and see the effects of various techniques on the accuracy of your approximations.

Background

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!

Rectangular approximations

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:

left endpoint rule
The height of the rectangle is the value of the function f(x) at the left-hand endpoint of the subinterval.
right endpoint rule
The height of the rectangle is the value of the function f(x) at the right-hand endpoint of the subinterval.
midpoint rule
The height of the rectangle is the value of the function f(x) at the midpoint of the subinterval.

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);

\begin{maplelatex}
\begin{displaymath}
{\displaystyle \sum_{{i}=1}^{4}} \,{i}^{2}\end{displaymath}\end{maplelatex}

  > evalf(rightsum(x^2,x=0..4));

\begin{maplelatex}
\begin{displaymath}
30.\end{displaymath}\end{maplelatex}

  > middlesum(x^2,x=0..4);

\begin{maplelatex}
\begin{displaymath}
{\displaystyle \sum_{{i}=0}^{3}} \, \left...
 ...
{\displaystyle \frac {1}{2}}\, \! \right) ^{2}\end{displaymath}\end{maplelatex}

  > evalf(middlesum(x^2,x=0..4));

\begin{maplelatex}
\begin{displaymath}
21.00000000\end{displaymath}\end{maplelatex}

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));

\begin{maplelatex}
\begin{displaymath}
2.500000000\end{displaymath}\end{maplelatex}

  > evalf(rightsum(x,x=0..2,10));

\begin{maplelatex}
\begin{displaymath}
2.200000000\end{displaymath}\end{maplelatex}

  > evalf(rightsum(x,x=0..2,20));

\begin{maplelatex}
\begin{displaymath}
2.100000000\end{displaymath}\end{maplelatex}

  > evalf(rightsum(x,x=0..2,100));

\begin{maplelatex}
\begin{displaymath}
2.020000000\end{displaymath}\end{maplelatex}

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.

Computing areas as definite integrals with Maple

In the example in the previous section, we saw that increasing the number of subintervals gave a better approximation to the area. In such a case, it seems reasonable that taking a limit as the number of subintervals goes to infinity should give the exact answer. This is exactly the idea in defining the definite integral. Of course, the actual definition of the definite integral involves more general sums than the ones we have been talking about, but the idea is the same.

When this limit as the number of subintervals goes to infinity exists, we have special notation for this limit and write it as

\begin{displaymath}
\int_{a}^{b} f(x) \, dx \end{displaymath}

As you learned in lecture, if the function f(x) is continuous on the interval [a,b], then this limit always exists and we can write

\begin{displaymath}
A = \int_{a}^{b} f(x) \, dx \end{displaymath}

where A is the area under the curve y=f(x) between x=a and x=b.

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

\begin{displaymath}
\int_{0}^{4} x^2 \, dx \end{displaymath}

and

\begin{displaymath}
\int_{0}^{2} x \, dx \end{displaymath}

Using Maple, we would compute these two definite integrals as shown below.

  > int(x^2,x=0..4);

\begin{maplelatex}
\begin{displaymath}
{\displaystyle \frac {64}{3}}\end{displaymath}\end{maplelatex}
  > int(x,x=0..2);

\begin{maplelatex}
\begin{displaymath}
2\end{displaymath}\end{maplelatex}
Notice that Maple gives an exact answer, as a fraction. If you want a decimal approximation to an integral, you just put an evalf command around the int command, as shown below.
  > evalf(int(x^2,x=0..4));

\begin{maplelatex}
\begin{displaymath}
21.33333333\end{displaymath}\end{maplelatex}

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 $f(x)=x \sin(x)$ on the interval $[0,\pi]$. Then you can define this function in Maple with the command

  > f := x -> x*sin(x);

\begin{maplelatex}
\begin{displaymath}
{f} := {x} \rightarrow {x}\,{\rm sin}(\,{x}\,)\end{displaymath}\end{maplelatex}
and then use this definition to save typing as shown below.
  > int(f(x),x=0..Pi);

\begin{maplelatex}
\begin{displaymath}
{ \pi}\end{displaymath}\end{maplelatex}
  > evalf(leftsum(f(x),x=0..Pi,4));

\begin{maplelatex}
\begin{displaymath}
2.978416600\end{displaymath}\end{maplelatex}

next up previous
Next: Exercises Up: No Title Previous: No Title

Christine M Palmer
9/8/1998