next up previous
Next: About this document ... Up: lab_template Previous: lab_template


The Definite Integral


There are two main ways to think of the definite integral. The easiest one to understand is as a means for computing areas (and volumes). The second way the definite integral is used is as a sum. That is, we use the definite integral to ``add things up''. Here are some examples. This lab is intended to introuduce you to Maple commands for computing integrals, including applications of integrals.

Definite and indefinite integrals with Maple

The basic Maple command for computing definite and indefinite integrals is the int command.

To compute the indefinite integral

\begin{displaymath}\int x^2 \, dx \end{displaymath}

with Maple:
> int(x^2,x);
Note that Maple does not include a constant of integration. Suppose you wanted to compute the following definite integral with Maple.

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

The command to use is:
> int(x^2,x=0..4);

Finding area

If you want to find the area bounded by the graph of two functions, you should first plot both functions on the same graph. You can then find the intersection points using either the solve or fsolve command. Once this is done, you can calculate the definite integral in Maple. An example below illustrates how this can be done in Maple by finding the area bounded by the graphs of $f(x)=-x^2+4x+6$ and $g(x)=x/3+2$:
> f := x-> -x^2+4*x+6; 
> g := x-> x/3+2;
> plot({f(x),g(x)},x=-2..6);
> a := fsolve(f(x)=g(x),x=-2..0);
> b := fsolve(f(x)=g(x),x=4..6);
> int(f(x)-g(x),x=a..b);

Approximating area using Riemann Sums

Last week, you learned about commands from Maple's student package, leftbox, rightbox, and middlebox, for plotting approximate area under a curve using left-endpoint, right-endpoint and midpoint rule. 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 the desired numerical answers.
> rightsum(x^2,x=0..4,7);
> evalf(rightsum(x^2,x=0..4,7));
> evalf(leftsum(x^2,x=0..4,10));
> evalf(middlesum(x^2,x=0..4,20));


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 improved. One way to measure how good the approximation is is the absolute error, which is the difference between the actual answer and the estimated answer. Later on in the course, you will learn techniques for finding the exact answer. Approximations, however, are important because exact answers cannot always be found.

All of the Maple commands described so far in this lab can include a third argument to specify the number of subintervals. The default is 4 subintervals. The example below approximates the area under $y=x^2$ from $x=0$ to $x=4$ using the rightsum command with 50, 100, 320 and 321 subintervals. As the number of subintervals increases, the approximation gets closer and closer to the exact answer. You can see this by assigning a label to the approximation, assigning a label to the exact answer $(4^3/3)$ and taking their difference. The closer you are to the actual answer, the smaller the difference. The example below shows how we can use Maple to approximate this area with an absolute error no greater than 0.1.

> with(student):
> exact := 4^3/3;
> estimate := evalf(rightsum(x^2,x=0..4,321));
> evalf(abs(exact-estimate));


  1. For the function $\displaystyle f(x)=\cos(x)+\sin(x)-x^2+12$ over the interval $[0,3]$, use the leftbox command to plot the rectangular approximation of the area above the $x$-axis and under $f(x)$ with 6 rectangles. Estimate the area under the curve with a Riemann Sum using the formula for the left-endpoint rule and show that you get the same answer when using the leftsum command.
  2. The exact area under $f(x)=-\cos(\sqrt{x^2+5})$ above the $x$ axis over the interval $-4 \leq x \leq 4$ can be found using a definite integral. Plot $f(x)$ over the given interval. Use the approximations rightsum and middlesum to determine the minimum number of subintervals required so that the estimate of this area has an error no greater than 0.001. Which method do you think is better?
  3. Find the area of the region bounded by the curves $f(x)=2\sqrt{x+10}$ and $\displaystyle g(x)=\frac{x^2}{4}-1$. Include a plot of the region bounded by the given curves.
  4. Find the area of the region bounded by the curves $\displaystyle f(x)=\frac{x^2}{2}-4$ and $\displaystyle g(x)=\sin(x)\cos(x)$. Include a plot of the region bounded by the given curves.

next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias