Comparison

Consider the function

> f:=x->sin(4.*x)*exp(x);plot(f(x),x=-1..1);

[Maple Math]

[Maple Plot]

> exact:=int(f(x),x=-1..1);

[Maple Math]

> gauss2;gauss3,gauss4;

[Maple Math]

[Maple Math]

> for i from 2 to 4 do err.i:=abs(exact-gauss.i); od;

[Maple Math]

[Maple Math]

[Maple Math]

To obtain a similar error using the composite rules, one needs:

> with(student):mid:=evalf(middlesum(f(x),x=-1..1,9)):errmid:=abs(exact-mid);

Warning, new definition for D

[Maple Math]

9 subintervals for the Composite Midpoint Rule.

> tr:=evalf(trapezoid(f(x),x=-1..1,12)):errtrap:=abs(exact-tr);

[Maple Math]

12 subintervals for the Composite Trapezoidal Rule.

> si:=evalf(simpson(f(x),x=-1..1,6)):errsi:=abs(exact-si);

[Maple Math]

3 subintervals for the Composite Simpson's Rule.

>