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);
For example, suppose we want to approximate
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);
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));
Similarly for RIGHT(10):
> rs:=evalf(rightsum(sqrt(x^4+1),x=1..2,10));
Similarly for MID(10):
> ms:=evalf(middlesum(sqrt(x^4+1),x=1..2,10));
Similarly for TRAP(10):
> tr:=evalf(trapezoid(sqrt(x^4+1),x=1..2,10));
Using Maple's sophisticated numerical integration routines:
> ex:=evalf(Int(sqrt(x^4+1),x=1..2));
The errors:
> errorleft:=ex - ls;
> errorright:=ex - rs;
> errortrap:=ex - tr;
> errormid:=ex - ms;
Repeating the computations for n = 100 -- LEFT(100):
> ls:=evalf(leftsum(sqrt(x^4+1),x=1..2,100));
RIGHT(100):
> rs:=evalf(rightsum(sqrt(x^4+1),x=1..2,100));
MID(100):
> ms:=evalf(middlesum(sqrt(x^4+1),x=1..2,100));
TRAP(100):
> tr:=evalf(trapezoid(sqrt(x^4+1),x=1..2,100));
Use the same exact value as before from Maple's sophisticated numerical integration routines:
The errors with n = 100:
> errorleft:=ex - ls;
> errorright:=ex - rs;
> errortrap:=ex - tr;
> errormid:=ex - ms;
What patterns do you notice?