ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL
Lesson 14 -- Euler's Method
Prof. Douglas B. Meade
Industrial Mathematics Institute
Department of Mathematics
University of South Carolina
Columbia, SC 29208
URL: http://www.math.sc.edu/~meade/
E-mail: meade@math.sc.edu
Copyright 2001 by Douglas B. MeadeAll rights reserved
-------------------------------------------------------------------
Outline of Lesson 14
14.A Explicit Implementation of Euler's Method
14.A-1 Example 1
14.A-2 Example 2
14.B dsolve and Euler's Method
14.B-1 Example 1 (revisited)
14.B-2 Example 2 (revisited)
14.C Example 3
Initialization
Warning, the name changecoords has been redefined
Euler's method for the solution of a first-order IVP
,
can be summarized by the formulae
where h is the stepsize.
A simple implementation of Euler's method that accepts the function F, initial time , initial position , stepsize , and number of steps as input would be
As a test, compute the Euler's Method solution to
on the interval with = 0.1.
A more sophisticated implementation of Euler's method would accept as input the ODE, the initial condition, the interval on which the solution should be computed, and the number of steps. In this case, the implementation could appear as
The approximate solution to the IVP
on the interval by Euler's Method with 10 subdivisions would be obtained with the command
For a second example, use Euler's Method with = 2, 4, and 8 subdivisions to find an approximate value for where the IVP is
and the parameters for the numeric solution are
The three stepsizes to be used appear in the list
and the results of the calculations are obtained via
Alternatively, these results are summarized in the following table.
Implementations of Euler's Method for a first-order system are not significantly different or more difficult, but will not be considered at this time.
While it is not difficult to implement Euler's Method in Maple, there is no real reason to do so. The dsolve command can be used to obtain approximate solutions to IVPs for first-order ODEs, including systems.
To illustrate, revisit Examples 1 and 2.
When an explicit table of values is needed, it is necessary to provide a list of values of the independent variable at which the approximate solution should be reported.
In Example 1, the numeric parameters were
A list of values of the independent variable at which the corresponding values of the dependent variable are to be obtained is
Then, the table of approximate solution values computed using Euler's Method is
If the results are to be plotted, then the dsolve and odeplot commands can be used as follows, resulting in Figure 14.1.
The three approximations to are obtained via
The final example illustrates the use of the full range of Maple tools to obtain, visualize, and analyze an approximate solution to an IVP obtained by Euler's Method.
Consider the problem of obtaining a solution to the IVP
on the interval .
Euler's Method with = 4 subdivisions yields Figure 14.2, provided odeplot is instructed to plot five points since the initial point must be counted.
To determine if this approximation is reasonable, superimpose this solution on the slope field, as shown in Figure 14.3.
On the interval the Euler solution does not look too bad. However, on the Euler solution does not follow the slope field and is a much poorer approximation to the true solution. Note also that the Euler solution repeatedly crosses the equilibrium solution . To obtain a reasonable approximation on the entire interval using Euler's Method, a smaller stepsize is required. Figure 14.4 shows the result of computing with a stepsize of 0.5.
To complete the evaluation of this approximate solution, the DEplot command is used to include the (Maple-generated approximate) solution curve for this initial condition. Figure 14.5 shows the Euler solution with stepsize 2 as the blue curve, the Euler solution with stepsize 0.5 as the cyan curve, and the default (adaptive) numeric solution as the brown curve.
[Back to ODE Powertool Table of Contents]