Numerical AnalysisDifferential Equations

Local and Global Error

Each Euler step makes a local error of order h², and the 1/h steps together leave a global error of order h.

Not started Jump to practice

In Improved Euler and Runge–Kutta Methods you met Euler's method, $y_{n+1} = y_n + hf(t_n, y_n)$, and the more accurate Heun and Runge–Kutta methods. Now we measure their error the way Truncation Error and Order of Accuracy taught: by how it shrinks with $h$. There are two different errors to keep apart.

The local error is the error of one step taken from an exact value: $y(t_n + h)$ minus the step's result when $y_n = y(t_n)$. The global error is what we actually care about: $y(T) - y_N$ at the final time, after all $N = T/h$ steps.

Key idea

For a method of order $p$, the local error is $O(h^{p+1})$ and the global error is $O(h^{p})$: summing about $1/h$ local errors costs one power of $h$. Euler: local $O(h^{2})$, global $O(h)$. Heun: global $O(h^{2})$. RK4: global $O(h^{4})$.

Why it works

For Euler, Taylor's theorem gives $y(t + h) = y(t) + hy'(t) + \frac{h^{2}}{2}y''(\xi)$, and the step keeps only the first two terms: local error $\frac{h^{2}}{2}y''$. Over $[0, T]$ there are $N = T/h$ steps. Each adds an error of size about $Ch^{2}$, and earlier errors are carried along (grown or damped by the equation by at most a factor $e^{LT}$, where $L$ bounds $|\partial f/\partial y|$). So the global error is at most about $N \cdot Ch^{2}\,e^{LT} = CTe^{LT}h$: order $h$.
Euler's method follows the slope field in straight steps. Each step misses the curve a little (local error), and the misses add up (global error).

Worked example: One step: local error

For $y' = y$, $y(0) = 1$, take one Euler step with $h = 0.1$. Find the local error.
  1. Euler: $y_1 = 1 + 0.1(1) = 1.1$.
  2. Exact: $y(0.1) = e^{0.1} = 1.105171$.
  3. Local error $\approx 0.00517$, close to $\frac{h^{2}}{2}y''(0) = 0.005$.

Answer: $\approx 0.0052$

Worked example: Many steps: global error

Solve the same problem to $t = 1$ (exact $y(1) = e \approx 2.71828$) with $h = 0.1$ and $h = 0.05$.
  1. For $y' = y$, Euler multiplies by $1 + h$ each step: $y_N = (1 + h)^{N}$.
  2. $h = 0.1$: $1.1^{10} = 2.59374$, global error $0.1245$.
  3. $h = 0.05$: $1.05^{20} = 2.65330$, global error $0.0650$, about half: order 1.
  4. The global error, $0.12$, is far bigger than one local error, $0.005$: ten of them added up and grew along the way.

Answer: $0.1245$ and $0.0650$

Worked example: A fourth-order method

RK4 on the same problem gives global errors $2.08 \times 10^{-6}$ ($h = 0.1$) and $1.36 \times 10^{-7}$ ($h = 0.05$). What is the order?
  1. Ratio: $\frac{2.08 \times 10^{-6}}{1.36 \times 10^{-7}} \approx 15.3$, close to $2^{4} = 16$.
  2. Order 4, and with $h = 0.1$ it is already 60,000 times more accurate than Euler, for 4 function values per step instead of 1.

Answer: $p = 4$

Global error at t = 1 against h for y′ = −2y. With "one step only", the plot shows the local error instead.

Common mistake

Expecting the error at the end to be the size of one step's error. The local errors of all $N = T/h$ steps add up (and can grow along the way), which costs one power of $h$: a method with local error $O(h^{2})$ has global error only $O(h)$. Check: halve $h$ and compare final values; for Euler the error should halve, not quarter.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Tobin A. Driscoll and Richard J. Braun, Fundamentals of Numerical Computation (University of Delaware, free online edition): chapter "Initial-value problems for ODEs", sections "Euler's method" and "Runge–Kutta methods"
  • MIT OpenCourseWare 18.330, Introduction to Numerical Analysis: lecture notes on numerical methods for ODEs (local and global error)
@teddyrookbook GitHub