MapleDENumMeth.mws

Euler's Method Using Maple

Some Comparisons

>    with(plots):

>    eq1:=diff(y(x),x)=cos(x);

eq1 := diff(y(x),x) = cos(x)

>    ini1:=y(0)=0;

ini1 := y(0) = 0

>    dsolve({eq1,ini1},{y(x)});

y(x) = sin(x)

>    AnalSoln:=plot(sin(x),x=0..2*Pi,y=-1.5..1.5,color=blue,thickness=2):

>    sol:=dsolve({eq1,ini1},{y(x)},type=numeric,method=classical[foreuler],stepsize=Pi/16);

sol := proc (x_classical) local res, solnproc, outpoint, ndsol, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 14; if _EnvInFso...

>    EulerSoln:=odeplot(sol,[x,y(x)],0..2*Pi,thickness=2):

>    sol(Pi/2);

[x = 1.5707963267949, y(x) = 1.09495994231084824]

>    display(AnalSoln,EulerSoln);

[Maple Plot]

>    sol2:=dsolve({eq1,ini1},{y(x)},type=numeric,method=classical[foreuler],stepsize=Pi/32);

sol2 := proc (x_classical) local res, solnproc, outpoint, ndsol, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 14; if _EnvInFs...

>    EulerSoln2:=odeplot(sol2,[x,y(x)],0..2*Pi,thickness=2):

>    sol2(Pi/2);

[x = 1.5707963267949, y(x) = 1.04828406569741262]

>    display(AnalSoln,EulerSoln2);

[Maple Plot]

>    sol3:=dsolve({eq1,ini1},{y(x)},type=numeric,method=classical[foreuler],stepsize=Pi/64);

sol3 := proc (x_classical) local res, solnproc, outpoint, ndsol, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 14; if _EnvInFs...

>    EulerSoln3:=odeplot(sol3,[x,y(x)],0..2*Pi,thickness=2):

>    sol3(Pi/2);

[x = 1.5707963267949, y(x) = 1.02434288692618925]

>    display(AnalSoln,EulerSoln3);

[Maple Plot]

>    sol4:=dsolve({eq1,ini1},{y(x)},type=numeric,method=classical[foreuler],stepsize=Pi/128);

sol4 := proc (x_classical) local res, solnproc, outpoint, ndsol, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 14; if _EnvInFs...

>    EulerSoln4:=odeplot(sol4,[x,y(x)],0..2*Pi,thickness=2):

>    sol4(Pi/2);

[x = 1.5707963267949, y(x) = 1.01222164639518675]

>    display(AnalSoln,EulerSoln4);

[Maple Plot]

>