DISP Mathematics (Scie 1500R)

MAPLE Lab. Tutorial 5 Integration Monday February 14.



1 SUMS.

MAPLE can evaluate most of the summations that one finds in Calculus books. To evaluate

\begin{displaymath}\sum_{i=1}^n f(i) \end{displaymath}

use the command > sum(f(i), i=1..n); . Note that what goes in the first place (before the comma) is an expression.

As we saw last week for limits, there is a useful way of getting MAPLE to write out such things nicely (we shall see the same thing with integrals below). This is to use the command > Sum(f(i), i=1..n); This returns a nicely formatted expression for the sum. Therefore, if you want the whole thing to look good, try > Sum(f(i), i=1..n)= sum(f(i), i=1..n); .

Try the following commands:
> sum(i$\,^{\wedge}$2,i=1..10);
> Sum(i$\,^{\wedge}$2,i=1..10);
> value(%);
> evalf(%%);
> Sum(i$\,^{\wedge}$2,i=1..10) = sum(i$\,^{\wedge}$2,i=1..10);

2 INTEGRATION

The command for indefinite integration is
> int(f(x), x);
but this does NOT give you an arbitrary constant at the end (you must supply that). For definite integration, the command is
> int(f(x), x=a..b);
Note that in both of these, $f(x)$ is an expression.
MAPLE will try and do the definite integral symbolically and give an exact answer. If it cannot do so, it will return the expression for the integral. To evaluate integrals exactly, use > value(.); to get a decimal approximation use > evalf(.);

There is a special MAPLE package to help students with Calculus exercises. Type
> ?student; to see what it has.

3 EXERCISES

NAME STUDENT #

Before you start these exercises type
> restart;
> with(student);

Now define the expressions $f$ and $g$ to be

\begin{displaymath}f := 1 + x^2\sin(x); \quad g:= \exp(\sin(x))\end{displaymath}

1. Riemann sums. Type the following commands:
> leftbox(f,x=0..2,8);
> leftsum(f,x=0..2,8);
> evalf(%);
> rightbox(f,x=0..2,8);
> rightsum(f,x=0..2,8);
> evalf(%);


Write down two inequalities for $I = \displaystyle \int_0^2 f(x) dx$

2. Repeat question 1. with 80 subintervals.

Write down two new inequalities for $I = \displaystyle \int_0^2 f(x) dx$

3. Type the following commands:
> int(f,x=0..2);
(i) Find a decimal approximation for this integral
> Int(f,x=0..2);
> value(%);
> Int(f,x=0..2)= int(f,x=0..2);
> int(f,x);
> diff(%,x);

(ii) What theorem is verified by the last two formulas?

4. Type the following command:
> int(g,x=1..3);
What does this tell you about this integral?
§5.9 of the text is called Numerical Integration. It talks about two methods for finding numerical approximations to integrals. These are the Trapezoid Rule and Simpson's Rule. There is not much point in talking about them in class when you have MAPLE available. MAPLE will do both as follows:
> trapezoid(g,x=1..3,12);
> simpson(g,x=1..3,12);

Give the decimal approximation to this integral using these two methods:

Trapezoid: Simpson:
$\,$ [OVER] But the following is most powerful; it attempts to achieve 10 digits of accuracy (or more, depending on the currrent value of Digits), using a very sophisticated algorithm. You just type "evalf" outside of "Int":
> evalf(Int(g,x=1..3));
Which of the two rules used above (Trapezoid and Simpson) is the more accurate?

5. Areas Between Curves: Type
> restart:
> f := x$\,^{\wedge}$4 - 3*x$\,^{\wedge}$2 + 2*x + 1;
> g := x$\,^{\wedge}$2 + cos(x);

Find the area trapped between these two curves.
> plot({f,g},x=-3..3);
> plot({f,g},x=-3..2,y=-5..5);
> x0 := fsolve(f=g,x,-3..-2);
> x1 := fsolve(f=g,x,-2..0.5);
> A1 := int(g-f,x=x0..x1);
> x2 := fsolve(f=g,x,0.5..1);
> A2 := int(f-g,x=x1..x2);
> x3 := fsolve(f=g,x,1..2);
> A3 := int(g-f,x=x2..x3);

What is the area between the curves?
Theoretically, the following should give the same answer:
> Int(abs(f-g),x=x0..x3) = int(abs(f-g),x=x0..x3);
But it didn't!? Maple, while pretty smart, has difficulty doing Calculus with absolute values.



Tony Thompson
2000-08-16