MATH 371 -- Numerical Analysis
Slope Fields and Euler's Method
November 14, 2001
Euler's Method is one way to approximate solutions of a differential equation
. Starting from a given ( ), and with a given step size
, we compute further points on an approximate solution graph by the
formulas:
( is the approximation to the value of the exact solution at ),
repeated as often as desired (often, you keep going until reaches some desired
stopping value). In Maple, this computation can be done as follows. Say we want
to approximate solutions of with the initial condition
> with(DEtools):
> f:=(t,y) -> 3*t^2-y:
> EulerT[0]:=0: EulerW[0]:=1: h:=.25:
> for i to 4 do EulerT[i]:=EulerT[i-1] + h; EulerW[i]:=EulerW[i-1]+f(EulerT[i-1],EulerW[i-1])*h; end do:
> pts:=[[EulerT[0],EulerW[0]],[EulerT[1],EulerW[1]],[EulerT[2],EulerW[2]],[EulerT[3],EulerW[3]],[EulerT[4],EulerW[4]]]:
> ptsplot1:=plot(pts,color=BLUE):
> ptsplot2:=plot(pts,style=point,color=BLACK,symbol=BOX):
> deplot:=DEplot(diff(y(t),t)=3*t^2-y(t),y(t),t=0..1,y=0..1.5,[[y(0)=1]],linecolor=BLACK,arrows=SLIM):
> with(plots):
The following plot shows:
1) Maple's approximate solution graph (the heavy line)
2) The Euler approximation generated above (the boxes),
which are connected by lighter lines
> display({ptsplot1,ptsplot2,deplot});
>
In fact, Maple's DEplot command uses a more sophisticated numerical method
and generates a list of approximate points on the solution graph and "connects the
dots" as here to draw the graph!