Example

Let us compare the midpoint method on an example:

[Maple Math] ;

[Maple Math] ;

>

> f:=(t,y)->-y+t+1;w[0]:=1;t[0]:=0;wt[0]:=1;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> d1:=diff(f(t,y(t)),t);d2:=subs(diff(y(t),t)=f(t,y),y(t)=y,d1);

[Maple Math]

[Maple Math]

> df:=unapply(d2,(t,y));

[Maple Math]

> h:=0.1:for i from 0 to 9 do wt[i+1]:=wt[i]+h*(f(t[i],w[i])+h*df(t[i],wt[i])/2):w[i+1]:=w[i]+h*f(t[i]+h/2,w[i]+h*f(t[i],w[i])/2):t[i+1]:=t[i]+h: print(t[i+1],w[i+1],wt[i+1]) od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

Both Taylor's method and the Midpoint method yield the same result, but one does not need to evaluate the derivative of [Maple Math] analytically when using the Midpoint method.

>