Euler's Method and Local vs Global Error
Learning Objectives
- Define the local truncation error of Euler's method, and recognize the two conventions in use.
- State the global error theorem with its hypotheses, and explain why order 2 per step becomes order 1 overall.
- Measure both orders from a table, and show the global order dropping when is unbounded.
- Read Euler's result as the exact solution of a nearby equation, which is its backward error.
- Derive the stability condition , including complex , and show a real step size at which Euler blows up.
- Recognize stiffness, and see what an implicit step changes.
- Separate truncation from rounding when the step gets very small.
Context & Motivation
The lesson differential-equations-and-initial-value-problems introduced the update , saw the error at a fixed time halve with , and saw the gradient-descent iteration fail for . Those were observations. This lesson supplies the reasons, in three questions.
Why is the method first order when one step looks second order? When is the classical error bound useful, and when is it wildly pessimistic? And why can a perfectly smooth, slowly varying solution force a tiny step? The same three questions come back for every solver, including those in runge-kutta-methods.
Core Theory
Local truncation error
The local truncation error measures one step started from the exact solution:
If , Taylor's theorem with gives for some in the step. Since along the solution, is enough for this.
Conventions differ. Some books, including Fundamentals of Numerical Computation, define the truncation error as the residual per unit step, , which is for Euler. Others use itself, which is . Both describe the same method, so check which one a source means. This lesson uses .
From local to global
The global error is . Subtract the method from the definition of :
Theorem. Suppose is continuous and Lipschitz in with constant on , the solution is with on , and . Then for ,
The proof takes absolute values, , unrolls the recurrence into a geometric sum, and uses .
Two separate things happen. About steps each inject , which loses one power of . And the factor lets old errors grow while they travel, which is where the exponential comes from. So global error is not simply the sum of local errors, as Example 2 shows.
An initial error adds . If each step also commits a rounding error of at most , the term becomes : the truncation part shrinks with , and the rounding part grows.
Forward and backward error
Using the terms of conditioning-and-numerical-stability, is a forward error. For there is also a clean backward statement. With , Euler's is the exact solution at of
The method solves a nearby equation exactly, and the nearness is . With and , . Over a time , the relative forward error is . When no real exists, which is the first sign of the next topic.
Stability
Apply Euler to with : with . The iterates stay bounded exactly when , a disk of radius 1 centered at . This is the stability region. It is a property of the method applied to a test equation, and for a nonlinear or a system, it applies through the eigenvalues of the Jacobian, as a local guide.
- Real : the condition is . The gradient-descent limit for is this case, with itself sitting on the boundary: bounded, not convergent.
- Imaginary : for every . The disk touches the imaginary axis only at the origin, so no step is stable for an undamped oscillation.
Stiffness
A problem is stiff when stability, not accuracy, dictates the step. It is a matter of degree, not a yes-or-no property. The typical shape is a slow solution with a fast mode that has already decayed. The fast mode no longer matters to the answer, but it still sets , and therefore .
Backward Euler, , has , so it is stable for all when . It is still order 1. The price is solving an equation at each step, a linear system for a linear problem.
Worked Examples
Example 1: one step by hand
Take , , whose solution is . With , Euler gives , while . So . The prediction is , since equals 1 at .
Example 2: local and global orders, measured
On the same problem up to , the table shows the largest local error over all steps, the sum of the absolute local errors, and the global error at .
textn h max|l| order sum|l| |e_n| order 10 0.20000 5.314e-02 2.895e-01 1.482e-01 20 0.10000 1.354e-02 1.97 1.468e-01 7.467e-02 0.99 40 0.05000 3.397e-03 1.99 7.354e-02 3.746e-02 1.00 80 0.02500 8.491e-04 2.00 3.683e-02 1.876e-02 1.00 160 0.01250 2.124e-04 2.00 1.843e-02 9.386e-03 1.00 320 0.00625 5.309e-05 2.00 9.217e-03 4.695e-03 1.00 640 0.00313 1.327e-05 2.00 4.609e-03 2.348e-03 1.00
Local order 2, global order 1, as the theorem says. The global error is about half the sum of the local errors: changes sign near , so local errors partly cancel, and each one is then carried by the flow. With and (the maximum of on , at ), the bound at is , about 12 times the true error.
Example 3: when the bound is useful
Take and , . The theorem has in both cases, but the flows are opposite.
texty' = y (growing) y' = -y (decaying) T |e_n| rel. error bound |e_n| rel. error bound 1 1.35e-02 0.0050 2.3e-02 1.85e-03 0.0050 8.6e-03 5 3.64e+00 0.025 1.1e+02 1.67e-04 0.025 7.4e-01 10 1.07e+03 0.048 2.4e+06 2.23e-06 0.049 1.1e+02 20 4.59e+07 0.095 1.2e+15 1.97e-10 0.096 2.4e+06
For the growing case the exponential is real: the absolute error grows along with the solution, though the bound is still far too large by . For the decaying case, the bound says when the error is . It cannot see the flow contracting, because a Lipschitz constant has no sign. The relative errors agree with the backward-error estimate , which is at . For , , matching the table.
Example 4: a stiff problem and a real blow-up
Consider , . The exact solution is , as substitution confirms, and nearby solutions are . The solution varies on a scale of order 1, yet , so Euler needs , which is steps to reach . Errors at :
textn h 1-1000h explicit Euler backward Euler 10 0.10000 -99.000 4.52e+15 2.84e-05 100 0.01000 -9.000 1.33e+90 2.72e-06 400 0.00250 -1.500 3.42e+64 6.77e-07 476 0.00210 -1.101 7.62e+13 5.69e-07 490 0.00204 -1.041 3.33e+02 5.53e-07 500 0.00200 -1.000 4.59e-07 5.42e-07 1000 0.00100 +0.000 2.70e-07 2.71e-07 2000 0.00050 +0.500 1.35e-07 1.35e-07
The initial condition is exact and is smooth, and still gives : the local truncation error of each step seeds a mode amplified by per step. The threshold is sharp. Once stable, explicit and backward Euler have about the same accuracy here (compare ), so the step limit is not about accuracy. Backward Euler already gets with , where explicit Euler is hopeless.
Example 5: energy in a simulated spring
Physics simulations integrate oscillators, and is the simplest: , , with eigenvalues . Euler multiplies the energy by exactly at each step, so the energy grows for every :
texth T energy after T (start 1) (1+h^2)^(T/h) 0.1 10 2.7048 2.7048 0.01 10 1.1052 1.1052 0.1 100 20959.2 20959.2 0.01 100 2.7181 2.7181
A spring in such a simulation gains energy from nothing. A small change fixes the drift: update first, then . This semi-implicit (symplectic) Euler keeps the energy between and up to at , and is still first order.
Example 6: when the order drops
The theorem asks for bounded . Take , , with solution , so . Here and are unbounded at , though the method never evaluates there. Each row quadruples :
textn |e_n| order 100 1.410e-01 400 7.177e-02 0.49 1600 3.620e-02 0.49 6400 1.818e-02 0.50
The order is . A milder failure leaves Euler unharmed. Take up to and after it, integrated to . One step per run straddles the jump, with local error instead of . That is one bad step, so the errors scatter but the fitted order over , , is still . The fit varies with these choices: other end times, or the opposite sign order, give values from to .
Uniqueness matters too. For with , the case in differential-equations-and-initial-value-problems, Euler stays at for every , because . That is one valid solution, and is another, which no step size will find. Starting from instead, 1000 steps reach at , against the exact for that start. The theorem does not apply: is not Lipschitz at .
Example 7: rounding takes over
For , , to , compare the same loop in float32 and float64. The truncation estimate is .
textn float32 error float64 error truncation 1000 1.840e-04 1.840e-04 1.839e-04 10000 1.889e-05 1.839e-05 1.839e-05 30000 6.041e-06 6.131e-06 6.131e-06 100000 4.264e-07 1.839e-06 1.839e-06 300000 3.506e-05 6.131e-07 6.131e-07 1000000 2.565e-05 1.839e-07 1.839e-07
Until float32 tracks the truncation. Then rounding, not , decides. The value at is lucky cancellation, not a real gain, and more steps make the result worse. In float64 the truncation line continues to at least (). With Euler's first-order rate, reaching that accuracy takes ten million steps, which is the practical reason for runge-kutta-methods.
Common Misconceptions & Pitfalls
- "Local error means the answer is second-order accurate." The steps add up: the global order is 1.
- "Global error is the sum of the local errors." Errors are carried and scaled by the flow. Example 2 has a sum twice the error, and Example 3 has decaying problems forgetting old errors.
- "The bound predicts the error." It is a worst case. For decaying solutions it can be off by 16 orders of magnitude.
- "A smooth solution allows a large step." Accuracy would, stability does not. Example 4 is .
- "A stable step is an accurate step." On there is no stable at all, and on with the iterates are bounded but flip sign.
- "Implicit methods are more accurate." Backward Euler has the same order, and in Example 4 the same error at . What it gains is stability.
- "Smaller is always better." Example 7.
Summary
Euler's method commits a local error of per step. If is Lipschitz and is bounded, the global error is , with a factor that describes worst-case growth and can be far too large when the flow contracts. Both orders were measured (2.00 and 1.00), and the global order fell to with unbounded . For the method solves a nearby equation exactly, with backward error . Stability requires , which rules out every for pure oscillation and forces on a problem whose solution is : at the result was . Such stiff problems call for implicit steps. Rounding sets a floor, and in float32 it arrives around .
Documentation Links
- Driscoll & Braun: Fundamentals of Numerical Computation, 6.2 Euler's method
- Driscoll & Braun: Fundamentals of Numerical Computation, 11.3 Absolute stability
- Driscoll & Braun: Fundamentals of Numerical Computation, 11.4 Stiffness
- Demanet (2012): MIT OCW 18.330, Chapter 5, Methods for ordinary differential equations
- SciPy: scipy.integrate.solve_ivp