MATH 134 -- Intensive Calculus for Science 2

Maple Numerical Integration Techniques Demo

February 13, 2001

Today we will see how Maple can be used to compute numerical

approximations to definite integrals using the LEFT, RIGHT,

TRAP, and MID methods. We will also see that Maple can compute

very accurate approximations using its own sophisticated built-in numerical

integration command.

Most of the commands we will use are contained in the "student" package.

To load them, we use:

> with(student);

[Maple Math]
[Maple Math]
[Maple Math]

For example, suppose we want to approximate

[Maple Math]

Here's a graphical display showing the left-hand sum for this function

with n = 10

> leftbox(sqrt(x^4+1),x=1..2,10);

LEFT(10) is computed by

> leftsum(sqrt(x^4+1),x=1..2,10);

[Maple Math]

The output is a short-hand form of the summation formula for the

left-hand sum. That's interesting, but we will want a numerical

value. To get a decimal approximation:

> ls:=evalf(leftsum(sqrt(x^4+1),x=1..2,10));

[Maple Math]

Similarly for RIGHT(10):

> rs:=evalf(rightsum(sqrt(x^4+1),x=1..2,10));

[Maple Math]

Similarly for MID(10):

> ms:=evalf(middlesum(sqrt(x^4+1),x=1..2,10));

[Maple Math]

Similarly for TRAP(10):

> tr:=evalf(trapezoid(sqrt(x^4+1),x=1..2,10));

[Maple Math]

Using Maple's sophisticated numerical integration routines:

> ex:=evalf(Int(sqrt(x^4+1),x=1..2));

[Maple Math]

The errors:

> errorleft:=ex - ls;

[Maple Math]

> errorright:=ex - rs;

[Maple Math]

> errortrap:=ex - tr;

[Maple Math]

> errormid:=ex - ms;

[Maple Math]

Repeating the computations for n = 100 -- LEFT(100):

> ls:=evalf(leftsum(sqrt(x^4+1),x=1..2,100));

[Maple Math]

RIGHT(100):

> rs:=evalf(rightsum(sqrt(x^4+1),x=1..2,100));

[Maple Math]

MID(100):

> ms:=evalf(middlesum(sqrt(x^4+1),x=1..2,100));

[Maple Math]

TRAP(100):

> tr:=evalf(trapezoid(sqrt(x^4+1),x=1..2,100));

[Maple Math]

Use the same exact value as before from Maple's sophisticated numerical integration routines:

The errors with n = 100:

> errorleft:=ex - ls;

[Maple Math]

> errorright:=ex - rs;

[Maple Math]

> errortrap:=ex - tr;

[Maple Math]

> errormid:=ex - ms;

[Maple Math]

What patterns do you notice?