Numerical Solutions by Euler's Method

We can also use this command to use a specified computational procedure. Most of these that are numerical (there are plenty of "symbolic" methods as well) require you to tell Maple how large the change in the independent variable should be (" stepsize "). So far the only method we know is Euler's, known to Maple as the "forward" Euler method from its " classical " collection. The main thing to investigate here is how the accuracy of the solution (and the time of computation) is affected by the stepsize. Let's recall what we are working with.

> MODEL;

[Maple Math]

> IC1;

[Maple Math]

> VAR;

[Maple Math]

> DOMAIN;

[Maple Math]

>

DO NOT CHANGE ANYTHING IN THE FOLLOWING INPUT REGION - YOU HAVE BEEN WARNED !!!

> Euler := proc( MODEL, IC, DOMAIN, N )

> local a, b, dt, dy, f, i, tt, yy, LISTpts, vars;

> vars := (op(2,lhs(MODEL) ), op([1,0],lhs(MODEL) ) );

> f := unapply( rhs(MODEL), vars );

> a := op(1,rhs(DOMAIN)); b := op(2,rhs(DOMAIN));

> dt := (b-a)/N;

> tt := a;

> yy := rhs(IC);

> LISTpts := [ tt, yy ];

> for i from 1 to N do

> dy := evalf( f(tt,yy) ) * dt;

> yy := yy + dy;

> tt := tt + dt;

> LISTpts := LISTpts, [ tt, yy ];

> od; RETURN( [ LISTpts ] );

> end:

DO NOT CHANGE ANYTHING IN THE PRECEDING INPUT REGION - YOU HAVE BEEN WARNED !!!

>

Fill in the the appropriate number of steps to be used in Euler's method.

> Nsteps := ? ;

>

The points generated by Euler's method are

> ptsE := Euler( MODEL, IC1, DOMAIN, Nsteps );

>

These data points can be plotted using the command

> plotE := plot( ptsE, color = GREEN, thickness = 2 ):

> plotE;

>

Another way to view the approximate solution is to overlay the computed solution on the slope field..

> display( [ plotSLOPE, plotE ] );

> display( [ plotSOLN, plotE ] );

>