> restart;

>

The Definite Integral

Maple can evaluate definite integrals with a simple command " int ". For example let's find

[Maple Math] .

We use easy-to-remember syntax:

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

[Maple Math]

>

As you see, Maple returned the exact value of the integral. That is because, whenever possible, Maple uses the Fundamental Theorem of Calculus to evaluate definite integrals. Recall that the Fundamental Theorem says that:

[Maple Math] ,

where F(x) is an antiderivative of f(x), that is, such a function that F'(x)=f(x). As you know, in many cases it is not possible to find an antiderivative and obtain the exact value of a definite integral. For example:

> int(sqrt(cos(x^2)+2), x=0..1);

[Maple Math]

>

( Note the syntax " sqrt(a) " which stands for [Maple Math] .) Maple printed out the integral but couldn't give us its exact value, as an antiderivative cannot be found. This is not a real problem as Maple can evaluate definite integrals numerically, using several sophisticated numerical integration methods, all of which, in one way or another, involve Riemann sums. We tell Maple to evaluate the integral numerically by typing:

> evalf(int(sqrt(cos(x^2)+2),x=0..1));

[Maple Math]

Maple can also find formulas for values of definite integrals with arbitrary limits of integration as shown in the next example.

> int(x*sin(x), x=a..b);

[Maple Math]

It is often useful to see a printed out version of the integral under consideration. In order to do that, we use the inert version of "int " command. The inert version is " Int ". The inert command tells Maple to print the integral but not evaluate it. (Other commands like " limit ", " diff " have their inert versions " Limit ", " Diff ", as well.) For example:

> Int(x^2,x=-1..2);

[Maple Math]

To obtain the actual value of the latter integral we have to use the command " value ".

> value(%);

[Maple Math]

>

Recall that " % " in Release 5 of Maple denotes the last executed output; that is the output of the last command that you have clicked on. (In earlier releases you type " instead of % .) The " % " notation saves a lot of retyping , but used carelessly can lead to confusion. The best way to protect yourself from such confusion is to use " % " always and only on the same command line as the command to which " % " refers. For example:

> Int(x^2,x=-1..2); value(%);

[Maple Math]

[Maple Math]

This way we see the printed out integral and its value. The command " value(%) " is always executed right after the integration command, as they are on the same command line. Hence, there is no possibility of confusion. Another example:

> Int(x^2*exp(3*x),x=1..3); value(%); evalf(%);

[Maple Math]

[Maple Math]

[Maple Math]

>

In the latter example according to our commands, Maple first prints out the integral, then finds its exact value form the Fundamental Theorem, then gives a floating point approximation of the value.

Let's use Maple's power of dealing with definite integrals to solve an applied problem.

Example 1. The rate of growth of a population of insects in a certain habitat, r(t), measured in thousands of insects per month is given by

[Maple Math] ,

where t is measured in months since January 1, 1996. Assuming that there are 40,000 insects initially, find a formula for the size of the population p(t) at time t. Plot p(t) and r(t) in one coordinate system for t between 0 and 24. Compare the behavior of both functions. When is the population of insects minimal and when is it maximal during the two year period? What are the minimal and maximal values of the population?

First we define the function r(t) and plot it in the two year period from t=0 to t=24 to get a general idea of what is happening to the population.

> r :=t->10*exp(-.03*t)*cos((Pi/6)*t-3.5);

[Maple Math]

> plot(r(t),t=0..24);

[Maple Plot]

>

Remember that the rate of change r(t) of the population is nothing else but the derivative p'(t). We see that initially the rate of change is negative, which means that the population is decreasing. Then the rate becomes positive. Hence, the population is increasing. It is increasing faster and faster as the rate is more and more positive, and so on. As we know, the total change in the population between time 0 and time t, that is, p(t)-p(0), is equal to the definite integral of the rate of change over that interval. Hence, the population p(t) at time t is:

[Maple Math] .

We denote the variable under the integral by "s" rather than "t" not to confuse the upper limit of integration with the dummy variable of integration. Let's ask Maple to evaluate the above integral.

> Int(r(s),s=0..t); value(%);

[Maple Math]

[Maple Math]
[Maple Math]

As we see, the formula, which with enough patience could be obtained by hand using the so called integration by parts, looks pretty complicated. Hence, so is the formula for the population function p(t). It does not present a problem for Maple, though. Let's define p(t) and ask Maple to plot it.

> p :=t->40+int(r(s),s=0..t);

[Maple Math]

> plot(p(t), t=0..24);

[Maple Plot]

>

We see that there are periods when the population is decreasing. These correspond to the periods when the rate of change r(t) is negative. There are periods when the population is increasing. The latter happens when the rate of change is positive. To see clearly the relationship between the rate of change r(t) of the population and the size of the population p(t) varying in time, we shall plot both functions in one coordinate system.

> plot([p(t),r(t)], t=0..24,color=[black,blue]);

[Maple Plot]

>

The graph shows clearly that the minimum of the population occurs somewhere between t=2 and t=4. The mimimum, of course, corresponds to the point where the population changes from decreasing to increasing. This is a point where the derivative of p(t), that is, the rate of change r(t) is zero. We find this value using " fsolve " command.

> fsolve(r(t)=0,t,2..4);

[Maple Math]

The minimum occurs at approximately t= 3.68, that is, in March 1996. The maximum seems to be between t=8 and t=12. Again, the maximum corresponds to the point where r(t) is zero.

> fsolve(r(t)=0,t,8..12);

[Maple Math]

The population is maximal at approximately t = 9.68, that is, sometime in September of 1996. What are the maximal and minimal values of the population? To answer that we evaluate p(t) at t =3.68 and t = 9.68.

> evalf(p(3.68)); evalf(p(9.68));

[Maple Math]

[Maple Math]

>

The minimal population is slightly over 15 thousand insects, the maximal about 46.5 thousand insects. Given how complicated the formula for p(t) is, Maple saved us a lot of work!

Homework Problems

Problem 1. Find exact values and a floating point approximations of the following integrals:

(a) [Maple Math] .

(b) [Maple Math]

(c) [Maple Math]

Problem 2. Find a formula in terms of x for the integral:

[Maple Math] .

Plot the function

[Maple Math]

for x between 0 and 10. Find the derivative g'(x). Are you surprised with the result?

Problem 3. The amount of a certain drug in the bloodstream following an injection changes at the rate

[Maple Math]

in mg per hour, where t is the time, in hours, after the injection. Assume that there was 30 mg of the drug in the bloodstream at the moment of injection.

(a) Find a function d(t) which gives the amount of the drug in the bloodstream at time t.

(b) Plot d(t) and c(t) in one coordinate system for the twelve hour period following the injection.

(c) At what point does the amount of the drug reach its maximum?

(d) What is the maximal amount of the drug?

Remark. As you can guess, Maple can easily calculate left and right Riemann sums and visualize them as areas of rectangles. The appropriate commands " leftsum ", " leftbox " , " rightsum ", " rightbox " are contained in the package " with(student) ", which, similarly as the package " with(plots) ", has to be loaded into the computer memory before you can use it. You load the package with the command: " with(student): ", if you do not want Maple to print the content of the package, or " with(student); " , if you do. Press enter on the command lines below and see what happens.

> f :=x->x^2;

> with(student);

> leftbox(f(x),x=0..1,50);

> rightbox(f(x),x=0..1,50);

> leftsum(f(x),x=0..1,50); evalf(%);

> rightsum(f(x),x=0..1,50); evalf(%);

MTH 141 Maple Worksheets written by B. Kaskosz and L. Pakula, Copyright 1998.

Last modified August 1999.

>