Interactive Educational Modules in
Scientific Computing

Euler's Method

This module illustrates Euler's method for numerically solving initial value problems for ordinary differential equations. A numerical method for an ordinary differential equation (ODE) generates an approximate solution step-by-step in discrete increments across the interval of integration, in effect producing a discrete sample of approximate values of the solution function. Euler's method is the simplest example of this approach, in which the approximate solution is advanced at each step by extrapolating along the tangent line whose slope is given by the ODE. Specifically, from an approximate solution value yk at time tk for an ODE y′ = f(t, y), Euler's method approximates the solution y(tk+1) at time tk+1 = tk + hk by yk+1 = yk + hk f(tk, yk).

The user begins by selecting a differential equation from the menu provided. A solution value y0 for the selected ODE at an initial time t0 is marked with a black dot, and the exact solution curve for the resulting initial value problem is drawn in black. Starting from this initial value, the user advances the solution through successive steps using Euler's method. Each step of Euler's method is presented as a three-stage process. Each stage is executed by clicking either Next or the currently highlighted stage:

  1. Using the slider, the user can select any desired size hk for the step from tk to tk+1, subject to minimum and maximum allowed values. The provisional solution value that would result from the currently selected step size is shown in red, and it varies as the step size varies. Once the user has set the slider for the desired step size, this choice takes effect by clicking Choose Step Size or Next, at which point the solution value so determined changes color from red to black.
  2. The current step is concluded by clicking Take Step or Next, which prints in the table below the approximate and true solution values at the new point, and draws in gray the exact solution to the ODE passing through the new point.
  3. Preparation for another step is initiated by clicking Next Step or Next, which displays the new step in red, ready for selecting the new step size, with a default step size equal to the size of the previous step, if possible.

Successive steps may be continued until the the interval has been fully traversed.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 9.3.1, especially Example 9.8 and Figures 9.4 and 9.5.

Developers: Evan VanderZee and Michael Heath