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


The Definite Integral


The purpose of this lab is to introduce you to Maple commands for computing definite and indefinite integrals.



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. The syntax is very similar to that of the leftsum and rightsum commands, except you don't need to specify the number of subintervals. 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 shown below.

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

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

To compute an indefinite integral with Maple, you just leave out the range for the limits of integration, as shown below.

> int(x^2,x);
Note that Maple does not include a constant of integration.

You can also use the Maple int command with functions or expressions you have defined in Maple. For example, suppose you wanted to find area under the curve of 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);
and then use this definition as shown below.
> int(f(x),x=0..Pi);

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

Applications - averages and centroids

If a function $f$ is integrable over an interval $[a,b]$, then we define the average value of $f$, which we'll denote as $\bar{f}$, on this interval to be

\begin{displaymath}\bar{f} = \frac{1}{b-a} \int_{a}^{b} f(x) \, dx \end{displaymath}

Note that the average value is just a number. For example, suppose you wanted to compute the average value of the function $s(t) =
-16t^2+100t$ over the interval $1 \leq t \leq 5$. The following Maple command would do the job.
> int(-16*t^2+100*t,t=1..5)/(5-1);

It is also easy to use Maple to compute centroids and centers of mass. For example, suppose you wanted to compute the coordinates of the centroid of the region bounded above by the curve $g(x) =
-3x^2+3x+36$ and below by the $x$ axis over the interval $-3 \leq x
\leq 4$. The first thing to do is to plot the region.

> q := -3*x^2+3*x+36;
> plot(q,x=-3..4);
Once you have plotted the region, you can compute the area with the following command. Note the use of a label, since we'll use the area later.
> area := int(q,x=-3..4);
Once we have the area, we can compute $\bar{x}$ and $\bar{y}$ as follows.
> x_bar := int(x*q,x=-3..4)/area;
> y_bar := int(q^2,x=-3..4)/(2*area);
A similar procedure can be used to find the centroid of a region in the $xy$ plane that is bounded by the graphs of two functions. You just have to use the following formulas for $\bar{x}$ and $\bar{y}$.

\begin{displaymath}\bar{x} = \frac{\int_a^b x (f(x)-g(x))\, dx}{\int_a^b
(f(x)-g(x))\, dx} \end{displaymath}

\begin{displaymath}\bar{y} = \frac{1}{2} \frac{\int_a^b (f(x)^2-g(x)^2)\, dx}{\int_a^b
(f(x)-g(x))\, dx} \end{displaymath}


  1. Verify that the following equation is true, and then explain why it is true, using properties of the integral.

    \begin{displaymath}\int_{-3}^{3} x^2 \sin(x) +x \cos(x) + x^4+1 \, dx = 2 \int_{0}^{3}
x^4 + 1 \, dx \end{displaymath}

  2. Find the area of the region bounded above by $y=-x-5$ and below by $y=2x^2-8x-20$. Include a plot of the region.

  3. Find the centroid of the region from the previous exercise.

  4. In the last lab, you used the middlesum rule to approximate the net distance traveled for an object whose velocity was given by $v(t) = 2 - t/12 + \sin(t^2)$. Use the Maple int command to get an exact answer for

    \begin{displaymath}\int_0^4 v(t) \, dt \end{displaymath}

    Note that the answer comes out in terms of a function FresnelS. You can find out more about this function by asking your IA or executing the command
    > ?FresnelS
    To obtain a numerical approximation to the integral, just put an evalf command on the outside of the int command.

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