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 : error , close to a QUARTER — 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 with , then one Heun step. Work: Euler: . Heun: predictor slope ; corrector slope ; .
True value: — Heun lands within at a tenth the step cost of high-accuracy Euler.
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.