Examples of use

Let us calculate the following integral using the formulae listed above:

> restart:int1:=Int(sin(x),x=0..Pi/4);f:=x->evalf(sin(x)):

[Maple Math]

> value(int1);exact:=evalf(%);

[Maple Math]

[Maple Math]

n=0 (open):

> h:=evalf((Pi/4-0)/2):intn0:=2*h*f(Pi/8.);

[Maple Math]

n=1 (Trapezoidal Rule):

> h:=evalf((Pi/4-0)):intn1:=h*(f(0.)+f(Pi/4.))/2.;

[Maple Math]

n=2 (Simpson's Rule):

> h:=evalf((Pi/4-0)/2.):intn2:=h*(f(0.)+4*f(Pi/8.)+f(Pi/4.))/3.;

[Maple Math]

n=3 :

> h:=evalf((Pi/4-0)/3.):intn3:=3*h*(f(0.)+3*f(Pi/12.)+3*f(Pi/6.)+f(Pi/4.))/8.;

[Maple Math]

n=4 :

> h:=evalf((Pi/4-0)/4.):intn4:=2*h*(7*f(0.)+32*f(Pi/16.)+12*f(Pi/8.)+32*f(3*Pi/16.)+7*f(Pi/4.))/45.;

[Maple Math]

And for the errors:

> for i from 0 to 4 do print(`n=`.i, intn.i, abs(intn.i-exact)); od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

This again shows that the more points are used, the better the results, but increasing the number of points from an odd number (even [Maple Math] ) by one does not make a major impact on the error.

>