MATH 134 -- Intensive Calculus for Science 2
An Euler's Method Example
April 5, 2006
We study the approximate solution of  
y
' = 
 
with initial condition y (0) = 1 . First, we load the plotting
packages. Then we do 10 steps of Euler's method with
 to approximate the solution:
  to approximate the solution:
| > | with(DEtools): | 
| > | with(plots): | 
| > | xl[0]:=0; yl[0]:=1; | 
![xl[0] := 0](images/Euler3.gif) 
![yl[0] := 1](images/Euler4.gif) 
| > | for i to 10 do xl[i]:=xl[i-1]+.1; yl[i]:= eval(yl[i-1]+(xl[i-1]^2+yl[i-1]^2)*(.1)); end do; | 
![xl[1] := .1](images/Euler5.gif) 
![yl[1] := 1.1](images/Euler6.gif) 
![xl[2] := .2](images/Euler7.gif) 
![yl[2] := 1.222](images/Euler8.gif) 
![xl[3] := .3](images/Euler9.gif) 
![yl[3] := 1.3753284](images/Euler10.gif) 
![xl[4] := .4](images/Euler11.gif) 
![yl[4] := 1.573481221](images/Euler12.gif) 
![xl[5] := .5](images/Euler13.gif) 
![yl[5] := 1.837065536](images/Euler14.gif) 
![xl[6] := .6](images/Euler15.gif) 
![yl[6] := 2.199546514](images/Euler16.gif) 
![xl[7] := .7](images/Euler17.gif) 
![yl[7] := 2.719347001](images/Euler18.gif) 
![xl[8] := .8](images/Euler19.gif) 
![yl[8] := 3.507831812](images/Euler20.gif) 
![xl[9] := .9](images/Euler21.gif) 
![yl[9] := 4.802320214](images/Euler22.gif) 
![xl[10] := 1.0](images/Euler23.gif) 
![yl[10] := 7.189548158](images/Euler24.gif) 
| > | SField:=DEplot(diff(y(x),x)= x^2 + y(x)^2,[y(x)],x=-.1..1,y=0..10): | 
| > | 
| > | Pts:=plot([seq([xl[i],yl[i]],i=0..10)],style=point,symbol=circle,color=blue): | 
| > | Lines:=plot([seq([xl[i],yl[i]],i=0..10)],color=black): | 
| > | display(SField,Pts,Lines); | 
![[Maple Plot]](images/Euler25.gif) 
We would get a better approximation with smaller 
 .  For instance, with  .01:
.  For instance, with  .01:
| > | xl[0]:=0: yl[0]:=1: | 
| > | for i to 100 do xl[i]:=xl[i-1]+.01; yl[i]:= eval(yl[i-1]+(xl[i-1]^2+yl[i-1]^2)*(.01)); end do: | 
| > | Pts:=plot([seq([xl[i],yl[i]],i=0..100)],style=point,symbol=circle,color=blue): | 
| > | Lines:=plot([seq([xl[i],yl[i]],i=0..100)],color=black): | 
| > | display(SField,Pts,Lines); | 
![[Maple Plot]](images/Euler27.gif) 
| > |