Computing Solutions Honestly
Euler: follow the tangent, — global error . Improved Euler (Heun): predict with Euler, evaluate the slope at the prediction, use the average of the two slopes — : on , , it gives where Euler gives and the truth is .
RK4 blends four slope samples per step for — the workhorse default. Order buys compounding accuracy: halving improves Euler but RK4 .
Accuracy is not the only concern. On decay , Euler iterates : if the multiplier exceeds in size and the computed solution oscillates and grows while the true one dies quietly.
Stiff problems (mixing fast and slow decay) force explicit methods to tiny steps for stability alone — the reason implicit methods (backward Euler: , stable for every ) exist.
Solve , to (truth: ).
Step 1 — Euler with : , error .
Step 2 — Euler with : , error — roughly halved, as promises.
Step 3 — Heun with : multiplier per step, , error .
Step 4 — Heun with : multiplier per step, , error — about of the previous error, approaching a quarter as shrinks — verified numerically. Running two step sizes and comparing is the standard self-check every real computation should include.
Weather forecasts, spacecraft trajectories, protein folding, and car-crash simulations never see a closed-form solution — they are RK-style steppers running billions of steps. The stability theory of this topic is not academic: an unstable integrator once meant exploding simulations and, historically, real engineering failures.
For , , take one Euler step and one Heun step with , and compare both with the exact value .
Show the answerHide the answer
Euler uses the slope at the start, : . Heun uses that as a predictor, evaluates the slope there, , and averages: . The exact value is . Euler's error is about , Heun's about — some times smaller for one extra slope evaluation, because averaging the slopes at both ends of the step captures the curvature that the single tangent misses.
Euler's Method Step by Step
For , and step :
Each step replaces the solution curve by its tangent line over one step, then recomputes the slope at the new point. The same formula works for systems, with and vectors.
Why it approximates: Taylor's theorem gives , and , so an Euler step is the Taylor expansion with the term dropped. The dropped term bends toward the concave side: where solutions curve upward, Euler lands below them, and where they curve downward, above. Laying the computation out as a table — , , slope, next — keeps every step checkable.
Use Euler's method with on , , up to , and compare with the exact solution .
Each row uses the slope at the current point: .
Step 1 — the first step heads down with slope , to .
Step 2 — at the slope is , so the second step is flat: Euler cannot see that the true solution, which turns around near , is already rising again.
Step 3 — from there the slopes are positive and each step climbs.
Step 4 — read the errors: they grow while the solution bends sharply (the first second), then shrink, because this equation pulls every solution toward the line (the difference decays like ), which also pulls the Euler values toward it. Whether errors accumulate or heal depends on the equation, not only on the method.
Apply Euler with to the oscillator , from , whose exact solutions are circles.
One step: , . From : , then , then .
Step 1 — compute the radius: , because the cross terms cancel.
Step 2 — so every step multiplies the radius by .
Step 3 — after steps (, just short of one period ) the radius is instead of .
Step 4 — the reason is geometric: each step moves along the tangent to the circle, and a tangent segment always ends outside the circle. For a model of a frictionless system this is a qualitative failure — Euler adds energy every step — and a smaller only slows the spiral, it never removes it.
, has exact solution , which is infinite at . Euler with knows nothing of this: , a perfectly finite value at , and it will happily continue beyond. Already at it gives against the true . A numerical method follows the formula it is given; checking where the exact solution can exist (here, only for ) is the user's job, and halving to see whether the numbers settle is the cheapest warning.
Take two Euler steps with on , , and compare with the exact .
Show the answerHide the answer
First step: slope , so . Second step: slope , so . The exact value is , so the error is about . Euler overshoots here because the solution curves downward (it is concave, flattening toward ), so the tangent lines lie above it.
Runge–Kutta Methods in Practice
Four slope evaluations per step; global error .
Why these weights: when depends on alone, the step is approximated by Simpson's rule, , with the midpoint weight split between the two midpoint estimates and . In general, the stages are arranged so that the step agrees with the Taylor expansion of the true solution through the term; the local error is , and the global error, after steps, is .
Solve , to (exact ) with exactly slope evaluations each: Euler with ( steps), Heun with ( steps of ), RK4 with ( steps of ).
RK4's first step, from : , , , , so .
Step 1 — RK4's second step, from , gives (exactly ): error .
Step 2 — Heun with gives : error .
Step 3 — Euler with gives : error .
Step 4 — at equal cost, each step up the ladder buys roughly one more correct digit here, and the gap widens as the work increases: halving divides the errors by about , and . This is why RK4, not a finer Euler grid, is the default.
Repeat the oscillator , from with RK4 and . How much does the radius change per step?
For a linear system , all four stages are linear in , and one RK4 step multiplies by — the Taylor series of cut after four terms.
Step 1 — for the rotation , the powers cycle (), so the step matrix is with and , and it scales every radius by .
Step 2 — with : , so the radius shrinks by the factor per step.
Step 3 — after the same steps where Euler reached radius , RK4's radius is : a drift of about instead of , for four times the work per step.
Step 4 — note the sign: RK4 loses a trace of energy while Euler gains it. Neither conserves it exactly; long simulations of orbits use methods designed to (symplectic methods).
A natural simplification is . On , , : , , , . The correct weights give (error ); the plain average gives (error ). Worse than the numbers suggest: expanding in , the plain average matches the true coefficient with instead, so it is only a second-order method — four evaluations for Heun's accuracy.
Take one RK4 step with on , , and compare with the exact .
Show the answerHide the answer
. . . . Then . The exact value is : error after one large step. (Euler with the same step would give , error .) In general, RK4 on multiplies by with , which is .
Proofs & Why It Matters
One step from the true solution commits local error — the first Taylor term the tangent line drops.
Reaching a fixed time takes steps; local errors accumulate (amplified at most by a bounded factor from the Lipschitz constant), totalling . The same bookkeeping with a sharper local error yields global order — which is exactly how Heun () and RK4 () earn their labels.
Heun's update is . Expand the second slope: , so the update is .
The true solution expands as , and — the terms match. Local error drops to , hence global : averaging the two slopes secretly reproduces the second Taylor coefficient.
Going Deeper: Worked Problems
Apply one RK4 step with to , (exact solution ).
Step 1 — the four slopes: ; ; ; .
Step 2 — weighted average: .
Step 3 — exact: — RK4 agrees to about five significant figures in one step; Euler would have given (error ).
Step 4 — the pattern: slopes at start, two midpoint estimates, and end, weighted — Simpson's rule in disguise, which is why the order is four.
For (a stiff decay), find the largest Euler step that stays stable, and compare with backward Euler.
Step 1 — Euler: ; stability needs , i.e. . With the multiplier is : the numbers alternate sign and grow per step — nonsense for a decaying solution.
Step 2 — backward Euler: , so ; the multiplier is below for every — unconditionally stable.
Step 3 — the trade: backward Euler costs an algebraic solve per step (trivial here, a Newton iteration in general) but lets the step size follow accuracy instead of stability.
Step 4 — this is why "stiff" is a word every simulation engineer knows: the fast-decaying mode is boring but still dictates explicit step sizes.