A tour through every kind of problem Heun's method can be handed — flat starts, decreasing solutions, big steps, multi-step marches, iterated correctors, and exam twists. Guess the answer first, then watch it fall out.
Before we begin, the one formula we lean on the whole page (built from scratch in the parent note ):
Every problem this method can throw lives in one of these cells. The examples below are labelled with the cell(s) they cover.
#
Case class
What makes it special
Example
A
Positive growing slope
f > 0 , curve bends up
Ex 1
B
Zero start-slope
k 1 = 0 , Euler would freeze
Ex 2
C
Negative / decaying slope
f < 0 , curve bends down
Ex 3
D
Large step h
h big → predictor is far off, tests robustness
Ex 4
E
Multi-step march
Repeat the recipe, feed y 1 into next step
Ex 5
F
Iterated corrector
Recycle output to solve the implicit equation
Ex 6
G
Real-world word problem
Units, cooling in the real world
Ex 7
H
Exam twist: f depends on x only
Heun collapses to the pure Trapezoidal Rule
Ex 8
We will visit every cell . No scenario is left unshown.
y ′ = x + y , y ( 0 ) = 1 , find y ( 0.2 ) with h = 0.2 .
Here f ( x , y ) = x + y , so x 0 = 0 , y 0 = 1 , h = 0.2 .
Forecast: the slope starts at 1 and grows as we move right (both x and y increase). So the true curve bends upward — averaging start and end slopes should land us a hair above 1.2 .
Step 1. k 1 = f ( 0 , 1 ) = 0 + 1 = 1 .
Why this step? The start-slope is the first thing the recipe asks for — the direction our feet point right now.
Step 2. Predict the endpoint: y ( p ) = y 0 + h k 1 = 1 + 0.2 ( 1 ) = 1.2 .
Why this step? We cannot get the end-slope k 2 without a guess for y at x = 0.2 ; cheap Euler supplies it.
Step 3. k 2 = f ( 0.2 , 1.2 ) = 0.2 + 1.2 = 1.4 .
Why this step? This is the "peek ahead" slope — steeper than k 1 , confirming the curve bends up.
Step 4. Average and step: y 1 = 1 + 2 0.2 ( 1 + 1.4 ) = 1 + 0.1 ( 2.4 ) = 1.24 .
Why this step? The trapezoid weights both slopes equally; each carries half the step.
Verify: exact solution y = 2 e x − x − 1 gives y ( 0.2 ) = 2 e 0.2 − 1.2 = 1.2428 . Our 1.24 is off by only 0.0028 — and it landed above 1.2 exactly as forecast. ✓
y ′ = − 2 x y , y ( 0 ) = 1 , find y ( 0.2 ) with h = 0.2 .
f ( x , y ) = − 2 x y , x 0 = 0 , y 0 = 1 .
Forecast: at x = 0 the slope is − 2 ( 0 ) ( 1 ) = 0 — flat . Plain Euler would think "nothing is happening" and stay at 1 . Heun should peek ahead, notice the curve starting to dive, and land below 1 .
Step 1. k 1 = f ( 0 , 1 ) = − 2 ( 0 ) ( 1 ) = 0 .
Why this step? Even a zero slope is information — it says "don't move yet, but check the future."
Step 2. Predict: y ( p ) = 1 + 0.2 ( 0 ) = 1 .
Why this step? With k 1 = 0 the predictor doesn't move y ; the endpoint guess is still y = 1 .
Step 3. k 2 = f ( 0.2 , 1 ) = − 2 ( 0.2 ) ( 1 ) = − 0.4 .
Why this step? Now x = 0 , so f is negative — the "look ahead" catches the downward bend that Euler missed entirely.
Step 4. y 1 = 1 + 2 0.2 ( 0 + ( − 0.4 )) = 1 − 0.04 = 0.96 .
Verify: exact y = e − x 2 = e − 0.04 = 0.9608 . Error only 0.0008 . Plain Euler stays stuck at 1.0 (error 0.039 ) — Heun beat it because the predictor let it see the curve bend. ✓
y ′ = − y , y ( 0 ) = 1 , find y ( 0.1 ) with h = 0.1 .
f ( x , y ) = − y (pure decay). x 0 = 0 , y 0 = 1 .
Forecast: the answer should be a bit below 1 , close to e − 0.1 ≈ 0.905 . Because decay slows as y shrinks, the end-slope is gentler than the start-slope, so the average slope is between them.
Step 1. k 1 = f ( 0 , 1 ) = − 1 .
Why? Start-slope: steepest downhill of the whole step since y is largest here.
Step 2. Predict: y ( p ) = 1 + 0.1 ( − 1 ) = 0.9 .
Why? Cheap guess for where y ends so we can read the end-slope.
Step 3. k 2 = f ( 0.1 , 0.9 ) = − 0.9 .
Why? Endpoint slope — shallower (− 0.9 vs − 1 ) because y has dropped. This is the "slowing decay."
Step 4. y 1 = 1 + 2 0.1 ( − 1 − 0.9 ) = 1 − 0.05 ( 1.9 ) = 1 − 0.095 = 0.905 .
Verify: exact y = e − 0.1 = 0.904837 . Error 0.00016 — tiny, and our answer sits between the two-slope extremes as predicted. ✓
y ′ = − y , y ( 0 ) = 1 , find y ( 1 ) in one giant step h = 1 .
Same ODE, but we deliberately over-reach.
Forecast: the true value is e − 1 ≈ 0.368 . With such a big step the predictor will overshoot the decay (it will guess a value near 0 ), so we expect a rough answer — but let's see how the average still rescues us.
Step 1. k 1 = f ( 0 , 1 ) = − 1 .
Why? Start-slope.
Step 2. Predict: y ( p ) = 1 + 1 ( − 1 ) = 0 .
Why? Euler with h = 1 crashes all the way to 0 — a bad guess, but that's fine, it's only a scaffold.
Step 3. k 2 = f ( 1 , 0 ) = − 0 = 0 .
Why? At the (wrong) predicted endpoint y = 0 , the slope is flat. Heun now averages a steep − 1 with a flat 0 .
Step 4. y 1 = 1 + 2 1 ( − 1 + 0 ) = 1 − 0.5 = 0.5 .
Verify: exact e − 1 = 0.3679 . Error 0.132 — much worse than Ex 3! Lesson: big h blows up the error (recall error ∝ h 2 ; here h = 1 so no shrinkage helps). Still, 0.5 beats plain Euler's 0 . Smaller steps (Ex 5) fix this. ✓
y ′ = − y , y ( 0 ) = 1 , reach y ( 1 ) using two steps of h = 0.5 .
Instead of Ex 4's one leap, march twice. Output of step 1 becomes the input of step 2.
Forecast: two steps should beat one big step (Ex 4's 0.5 ) and inch toward 0.368 .
Step 1 — first step (0 → 0.5).
k 1 = f ( 0 , 1 ) = − 1 . Predict y ( p ) = 1 + 0.5 ( − 1 ) = 0.5 . k 2 = f ( 0.5 , 0.5 ) = − 0.5 .
y 0.5 = 1 + 2 0.5 ( − 1 − 0.5 ) = 1 − 0.25 ( 1.5 ) = 0.625 .
Why this step? Ordinary Heun on the first half of the interval.
Step 2 — second step (0.5 → 1), start from y = 0.625 .
k 1 = f ( 0.5 , 0.625 ) = − 0.625 . Predict y ( p ) = 0.625 + 0.5 ( − 0.625 ) = 0.3125 .
k 2 = f ( 1 , 0.3125 ) = − 0.3125 .
y 1 = 0.625 + 2 0.5 ( − 0.625 − 0.3125 ) = 0.625 − 0.25 ( 0.9375 ) = 0.625 − 0.234375 = 0.390625 .
Why this step? We feed the previous answer forward — this is what "marching" means.
Verify: exact e − 1 = 0.3679 . Error 0.0227 — roughly 6 × smaller than the one-big-step error 0.132 . Halving the step really did shrink the error. ✓
y ′ = x + y , y ( 0 ) = 1 , h = 0.1 — iterate the corrector once.
Plain Heun gives y 1 ; the iterated version recycles it to nail the implicit trapezoid better.
Forecast: exact is 1.11034 ; one iteration should push our answer past the plain 1.11 toward it.
Step 1. Standard Heun: k 1 = 1 , y ( p ) = 1.1 , k 2 = f ( 0.1 , 1.1 ) = 1.2 , y 1 [ 1 ] = 1 + 0.05 ( 1 + 1.2 ) = 1.11 .
Why? The usual predictor–corrector, giving a first estimate y 1 [ 1 ] = 1.11 .
Step 2. Re-evaluate the end-slope using the corrected value: k 2 ′ = f ( 0.1 , 1.11 ) = 0.1 + 1.11 = 1.21 .
Why this step? The trapezoid equation y 1 = y 0 + 2 h [ k 1 + f ( x 1 , y 1 )] is implicit — y 1 appears on both sides. Re-inserting our better y 1 solves it more exactly.
Step 3. Correct again: y 1 [ 2 ] = 1 + 0.05 ( 1 + 1.21 ) = 1 + 0.05 ( 2.21 ) = 1.1105 .
Verify: exact 1.110342 . Plain Heun error 0.00034 ; iterated error 0.00016 — halved. Iterating converges to the true trapezoid root. ✓
Newton cooling. Coffee at 9 0 ∘ C in a 2 0 ∘ C room cools by T ′ = − 0.5 ( T − 20 ) (units: ∘ C / min ). Estimate the temperature after 2 minutes with h = 2 min.
f ( t , T ) = − 0.5 ( T − 20 ) , t 0 = 0 , T 0 = 90 .
Forecast: hot coffee cools fast at first, then slows. Two minutes should knock off a good chunk — somewhere in the 50 –6 0 ∘ range.
Step 1. k 1 = f ( 0 , 90 ) = − 0.5 ( 90 − 20 ) = − 0.5 ( 70 ) = − 35 (∘ C/min).
Why? The initial cooling rate — coffee is hottest, so it sheds heat fastest.
Step 2. Predict: T ( p ) = 90 + 2 ( − 35 ) = 90 − 70 = 20 (∘ C).
Why? A cheap Euler guess. Notice h is large, so this over-cools all the way to room temperature — a scaffold, not the answer.
Step 3. k 2 = f ( 2 , 20 ) = − 0.5 ( 20 − 20 ) = 0 (∘ C/min).
Why? At the (over-cooled) predicted end, cooling has stopped. Averaging − 35 with 0 gives a sensible middle rate.
Step 4. T 1 = 90 + 2 2 ( − 35 + 0 ) = 90 − 35 = 5 5 ∘ C .
Why? 2 h = 1 min here, so the averaged rate − 35 ... wait — check: 2 2 ( k 1 + k 2 ) = 1 ⋅ ( − 35 ) = − 35 . Answer 5 5 ∘ C.
Verify: exact T = 20 + 70 e − 0.5 t , so T ( 2 ) = 20 + 70 e − 1 = 20 + 25.75 = 45.7 5 ∘ C. Our 5 5 ∘ is high because h = 2 is huge (this is Cell D's large-step penalty in disguise). Units are consistent throughout (∘ C/min × min = ∘ C). A smaller h would tighten it. ✓
y ′ = 2 x , y ( 0 ) = 0 , find y ( 1 ) with h = 1 . Show Heun collapses to the pure Trapezoidal Rule.
f ( x , y ) = 2 x — no y appears.
Forecast: exact is y = x 2 , so y ( 1 ) = 1 . Because f ignores y , the predictor's guess for y never matters — Heun becomes exactly the Trapezoidal Rule on ∫ 0 1 2 x d x .
Step 1. k 1 = f ( 0 , 0 ) = 2 ( 0 ) = 0 .
Why? Start-slope. Note y 0 is irrelevant to f .
Step 2. Predict: y ( p ) = 0 + 1 ( 0 ) = 0 .
Why? Required by the recipe — but since f doesn't read y , this value is never used for k 2 .
Step 3. k 2 = f ( 1 , 0 ) = 2 ( 1 ) = 2 — the predicted y (0 ) is ignored.
Why this step? This is the punchline: for x -only ODEs, k 2 = f ( x 1 ) regardless of the predictor. Heun = trapezoid of the integrand.
Step 4. y 1 = 0 + 2 1 ( 0 + 2 ) = 1 .
Verify: exact y = x 2 , y ( 1 ) = 1 . Exact — because the trapezoidal rule is exact for the linear integrand 2 x , and Heun is that rule here. This is why the parent note calls the corrector "the Trapezoidal Rule in disguise." ✓
Recall Which cell did each example cover?
Which example proves Heun = Trapezoidal Rule when f has no y ? ::: Ex 8 (Cell H).
Which example shows a large step h blowing up the error? ::: Ex 4 (Cell D), and also Ex 7's cooling.
Which example has a zero start-slope that would freeze plain Euler? ::: Ex 2 (Cell B).
Which example marches multiple steps forward? ::: Ex 5 (Cell E), two steps of h = 0.5 .
Which example iterates the corrector? ::: Ex 6 (Cell F).
Mnemonic Cover-the-matrix checklist
G rowth, Z ero-slope, D ecay, B ig-step, M arch, I terate, W ord, eX -only → "G Z D B M I W X ": before an exam, ask which cell is this?
Modified Euler (Heun's method) — the parent recipe every example applies.
Euler's Method — the predictor step in every example above.
Trapezoidal Rule — literally is Heun in Ex 8.
Order of Accuracy and Step Size — explains Ex 4 vs Ex 5 (big vs small h ).
Predictor-Corrector Methods — the iterated corrector of Ex 6.
Runge-Kutta Methods — every example is secretly RK2.