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


The Definite Integral Revisitied


The purpose of this lab is to remind you of Maple commands for computing definite and indefinite integrals, including volumes of solids of revolution.


Definite and indefinite integrals with Maple

The basic Maple command for computing definite and indefinite integrals is the int command. 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);

Maple Commands for Solids of Revolution

To help you with plotting solids of revolution, a Maple procedure called revolve has been written. This procedure is part of the CalcP package, which must be loaded first. Some simple examples using this procedure are shown below. The last line in the example below shows the optional argument for revolving the graph of $f(x)$ about the line $y=-2$ instead of the default $y=0$.

> with(CalcP7):
> f := x -> x^2+1;
> plot(f(x),x=-2..2);
> revolve(f(x),x=-2..2);
> revolve(f(x),x=-2..2,y=-2);

The revolve command has other options that you should read about in the help screen. For example, you can speed the command up by only plotting the surface generated by revolving the curve with the nocap argument, and you can also plot a solid of revolution formed by revolving the area between two functions. Try the following examples. (Note: The last example shows how to use revolve with a function defined piecewise using the piecewise command.)

> revolve({f(x),0.5},x=-2..2,y=-1);
>  revolve(cos(x),x=0..4*Pi,y=-2,nocap);
> revolve({5,x^2+1},x=-2..2);
> g := x -> piecewise(x<0,-x+1/2,x^2-x+1/2);
> revolve(g(x),x=-1..2);

Recall that if you revolve the area under the graph of $g(x)$ for $ a \leq x \leq b$ about the x-axis, the volume is given by

\begin{displaymath}\pi \int_{a}^{b} (g(x))^2 \, dx.\end{displaymath}

The easiest way to compute volumes of solids of revolution in Maple is just to use the int command, as shown below.
> f:= x-> sqrt(x) +1;
> vol:= int(Pi*f(x)^2, x=0..9);
> evalf(vol);


  1. Use Maple to compute the following definite integrals.
    1. $\displaystyle \int_{0}^{3} x^2 \exp(x) \, dx $
    2. $\displaystyle \int_{0}^{\pi}\cos(x) \cos(3x) \, dx $
  2. Several years ago, Frankie Kumala (class of '98) was asked to design a drinking glass by revolving a suitable function about the $x$ axis. Here is the function he came up with.

    \begin{displaymath}f(x) = \left\{ \begin{array}{ll}
x^2+0.05 & \mbox{if $x < 0$...
...q x < 1$} \\
\cos(x) & \mbox{if $x > 1$}
\end{array}\right. \end{displaymath}

    He obtained the shape of his glass by revolving this function about the $x$ axis over the interval $[-1,1]$. The Maple command he used to define this function is given below.

    > f := x -> piecewise(x<0,x^2+0.05,x<1,0.05,cos(x));

    Plot this function (without revolving it) over the interval $[-1,1]$ and identify the formula for each part of the graph. Then, revolve this function about the $x$ axis over the same interval and comment on the glass Frankie designed. Finally, compute the volume of the part of this glass that could be filled with liquid, assuming the stem is solid. (Hint - your integral will involve only one of the formulas used to define the function.)

  3. If you have time, design your own drinking glass by defining a function that, when revolved, produces a pleasing shape.

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