Interactive Educational Modules in
Scientific Computing

Error Estimation

This module investigates the accuracy of Euler's method for numerically solving initial value problems for ordinary differential equations by estimating its local and global error. 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 advances the approximate solution at each step by extrapolating along the tangent line whose slope is given by the ODE. This module shows estimates of the local error and cumulative global error for each step of Euler's method. These quantities are defined in greater detail below.

The user begins by selecting a differential equation from the menu provided. A solution value for the selected ODE at an initial time 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 of Euler's method. Each step is presented as a three-stage process. Each stage is executed by clicking either Next or the currently highlighted stage:

  1. Subject to minimum and maximum allowed values, the slider can be used to select any desired step size. The approximate solution that would result from the currently selected step size is drawn in red. Estimates for the resulting local error and (after the first step) cumulative global error are shown as dark blue and light blue regions, respectively, around the approximate solution (the dark blue region is superimposed on the light blue region, so some of the latter is obscured by the former). Clicking Choose Step Size or Next causes the currently selected step size to take effect. The new portion of the approximate solution, now determined, changes color from red to black.
  2. The current step is concluded by clicking Take Step or Next, which draws the exact solution through the new point in pink (erasing any previous pink curve) and prints the approximate and true solution values at the new point in the table below. The local error estimate (dark blue region) is removed, but the global error estimate (light blue region) remains.
  3. Preparation for another step is initiated by clicking Next Step or Next, which displays the new step so that the user can choose its size. The default step size is equal to the size of the previous step, if possible.

Successive steps of Euler's method may be continued until the the interval has been fully traversed.

Technical Details

If an error estimate is accurate, the corresponding solution should fall within the appropriate colored region. This means that the exact solution passing through the most recent solution point should fall within the dark blue local error estimate, and the exact solution to the initial value problem should fall within the light blue global error estimate. Since the module uses error estimates rather than error bounds, this is not always the case. (True bounds are rigorous, but are often overly pessimistic.) A detailed description of the estimates used in this module follows.

For an ODE y′ = f(t, y) and initial value (t0, y0), denote the exact solution to the initial value problem by y(t), the approximate solution points by (tk, yk), and the step size by hk = tktk−1. The local error at step k is the error made by the numerical method in stepping from time tk−1 to time tk. Letting uk−1(t) be the exact solution to the ODE passing through (tk−1, yk−1), the local error is given by ykuk−1(tk). For Euler's method, the local error is approximately (hk2⁄ 2) yk″. The module estimates yk using the finite difference (f (tk, yk) − f(tk−1, yk−1)) ⁄ (tktk−1).

The global error is the total error made relative to the exact solution to the initial value problem, given by yky(tk). The global error is affected not only by the local error just discussed, but also by the propagated error of the solution uk−1(t) relative to the true solution y(t). Suppose the global error at the beginning of step k is bounded by ek−1. Setting N = | 1 + hk fy(tk−1, yk−1) |, the propagated error after step k is approximately bounded by N ek−1. Using a fixed d = 0.05, the module estimates fy(tk−1, yk−1) using the finite difference (f (tk−1, yk−1 + d) − f(tk−1, yk−1d)) ⁄ (2d).

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 9.3.2.

Developers: Evan VanderZee and Michael Heath