** Next:** Exercises
**Up:** The Definite Integral -
** Previous:** The Definite Integral -

- Rectangular approximations to definite integrals
- Computing definite integrals with Maple
- Definite integrals and average values

Now, suppose we were given a function *v*(*t*) for ,and we wanted to find the net distance traveled by the object over
this time interval. If *v*(*t*) is constant, then this is easy to
determine: distance is velocity times elapsed time. If the velocity is
not constant, then it is more difficult to find the answer. The idea
of using the integral is based on breaking the elapsed time up into
subintervals. We approximate the distance traveled over each
subinterval by picking an average velocity over that subinterval and
using our formula distance equals velocity times elapsed time. Adding
up the approximations for each subinterval gives an approximation to
the net distance traveled. Intuitively, the more subintervals we use,
the better the approximation will be. Note also that how we pick the
average velocity over each subinterval can affect the accuracy of our
approximation.

For example, suppose *v*(*t*)=3-*t* for and we want the
approximate the net distance traveled. Suppose we use five
subintervals and choose the velocity at the left endpoint of each
subinterval for our average velocity. Then we can use the Maple
`leftsum` command to calculate an approximate distance as shown
below. A different approximation is obtained by using the velocity at
the right endpoint of each subinterval, using the Maple
`rightsum` command, and this is also shown below.

> v := t -> 3-t;

> plot(v(t),t=0..4);

> evalf(leftsum(v(t),t=0..4,5));

> evalf(rightsum(v(t),t=0..4,5));

Notice how different the two approximations are. However, if we increase the number of subintervals to 100, they are much closer.

> evalf(leftsum(v(t),t=0..4,100));

> evalf(rightsum(v(t),t=0..4,100));

These sums can also be interpreted geometrically, using the Maple
`leftbox` and `rightbox` commands.

> leftbox(v(t),t=0..4,5);

> rightbox(v(t),t=0..4,5);

The sums we computed above with the `leftbox` and
`rightbox` commands were obtained by adding up the areas of the
rectangles with the following important convention: if a rectangle
lies below the *t* axis, it appears in the sum with a minus sign. That
is, we interpret a rectangle above the axis as having positive area
and a rectangle below the axis as having negative area.

> int((2*x-3)^5,x=-2..4);

Sometimes you need to compute a definite integral involving a
piecewise-defined function. For example, suppose you have a function
*f*(*x*) defined as follows

> int(2-x^2,x=-5..1)+int(x,x=1..5);

If on [*a*,*b*], then the average value has the following
geometrical interpretation: is the height of a
rectangle of width *b*-*a* such that the area of this rectangle is equal
to the area under the graph of *f* from *a* to *b*. The following
example shows you how to compute an average. The last plot command
shows the function and the top of this rectangle.

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

> plot(f(x),x=0..Pi);

> f_ave := int(f(x),x=0..Pi)/Pi;

> plot({f(x),f_ave},x=0..Pi);

1/16/1998