Theory

An alternative route to Sinpson's Rule uses Taylor series expansions about the middle point [Maple Math] :

> restart;

> tayl:=convert(taylor(f(xx),xx=x1,4),polynom);

[Maple Math]

The error term is given by

> err:=(D@@4)(f)(xi(xx))*(xx-x1)^4/4!;

[Maple Math]

so that,

> f(xx)=tayl+err;

[Maple Math]
[Maple Math]

We can then integrate this expansion over the interval [Maple Math] :

> expr1:=Int(f(xx),xx=x[0]..x[2])=Int(tayl+err,xx=x[0]..x[2]);

[Maple Math]
[Maple Math]

For equidistant points:

> x[1]:=x[0]+h:x[2]:=x[0]+2*h:x1:=x[1]:expr1;

[Maple Math]
[Maple Math]

The first four terms can be integrated to yield:

> expr2:=int(tayl,xx=x[0]..x[2]);

[Maple Math]

If we use a centered three point formula to obtain the second derivative,

> expr3:=(D@@2)(f)(x[0]+h)=(f(x[0])-2*f(x[1])+f(x[2]))/h^2-h^2/12*(D@@4)(f)(xi[2]);

[Maple Math]

we obtain:

> expr4:=2*h*f(x[0]+h)+h^3/3*rhs(expr3);

[Maple Math]

> expr5:=expand(expr4);

[Maple Math]

>

Meanwhile, the error term

> expr5:=Int(err, xx=x[0]..x[2]);

[Maple Math]

can be simplified since [Maple Math] is always positive over the interval [Maple Math] , so that

> expr6:=expr5=(D@@4)(f)(xi[1])/24*Int((xx-x[1])^4,xx=x[0]..x[2]);

[Maple Math]

which evaluates to

> expr7:=(D@@4)(f)(xi[1])/24*int((xx-x[1])^4,xx=x[0]..x[2]);

[Maple Math]

>

The total error term then becomes

> ierr1:=expr7-1/36*h^5*`@@`(D,4)(f)(xi[2]);

>

[Maple Math]

This term can be rewritten using only one unknown value [Maple Math] in the range [Maple Math] as (see Exercises for its derivation):

> ierr2:=-1/90*h^5*(D@@4)(f)(xi);

[Maple Math]

So the formula for Simpson's Rule becomes:

[Maple Math]

>

As estimated in the previous section, the error term is indeed proportional to [Maple Math] !

>