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

- Introduction
- Partitions and rectangular approximations to area
- Computing areas as definite integrals with Maple

- Finding the mass of a body in two or three dimensions, whose density is not a constant.
- Computing net or total distance traveled by a moving object.
- Computing work involved in moving an object, compressing a gas, or pumping a liquid.
- Computing average values, e.g. centroids and centers of mass, moments of inertia, and averages of probability distributions.

Of course, when we use a definite integral to compute an area or a volume, we are adding up area or volume. So you might ask why make a distinction? The answer is that the notion of an integral as a means of computing an area or volume is much more concrete and is easier to understand.

We will learn in class that the definite integral is actually defined as a (complicated) limit of sums, so it makes sense that the integral should be thought of as a sum. We will also learn in class that the indefinite integral, or anti-derivative, can be used to evaluate definite integrals. Students often concentrate on techniques for evaluating integrals, and ingnore the definition of the integral as a sum. This is a mistake, for the following reasons.

- 1.
- Many functions don't have anti-deriviatives that can be written down as formulas. Definite integrals of such function must be done using numerical techniques, which always depend on the definition of the integral as a sum.
- 2.
- In many applications of the integral in engineering and science, you aren't given the function which is to be integrated and must derive it. The derivation always depends on the definition of the integral as a sum.

The rectangular area approximations we will describe in this section
depend on subdividing the
interval [*a*,*b*] into subintervals of equal length. For example,
dividing the interval [0,4] into four uniform pieces produces the
subintervals [0,1], [1,2], [2,3], and [3,4]. The next step is
to approximate the area above each subinterval with a rectangle, with
the height of the rectangle being chosen according to some rule.
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. Even the midpoint
rule, whose rectangles usually have heights more appropriate than
those for the left endpoint and right endpoint rules, will produce an
approximation which is not exact.

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

The Maple commands above use the short-hand summation notation. Since there are only four terms in the sums above, it isn't hard to write them out explicitly, as follows.

However, if the number of terms in the sum is large, summation notation saves a lot of time and space.

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

We will learn later on that if the function
The Fundamental Theorem of Calculus (FTOC) provides a connection
between the definite integral and the indefinite integral we studied
earlier. That is, the FTOC provides a way to evaluate definite
integrals if an anti-derivative can be found for *f*(*x*). We'll spend a
lot of time later in the course developing ways to do this, but for
now we'll let Maple do the work and won't worry too much about how it
is done.

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*=*x ^{2}* on the interval [0,4]
and the second was the function

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

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

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

Notice that Maple gives an exact answer, as a fraction. If you want a decimal approximation to an integral, you just put an

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

In the exercises, we'll ask you to compare rectangular approximations
to integrals. 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);

and then use this definition to save typing as shown below.

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

> evalf(leftsum(f(x),x=0..Pi,4));

You can also simply give the expression corresponding to *f*(*x*) a
label in Maple, and then use that label in subsequent commands as
shown below. However, notice the difference between the two
methods. You are urged you to choose one or the other, so you don't
mix the syntax up.

> p := x*sin(x);

> int(p,x=0..Pi);

1/9/1998