Improve on Euler's method with a predictor-corrector scheme: predict
y* with Euler's slope, then correct using the average of slopes at
both endpoints. Example: y'=x+y, y(0)=1, h=1/2; two steps give
y(1)≈105/32≈3.28 versus true 2e−2≈3.44.
This achieves second-order accuracy O(h²) globally.
Example
Predict with Euler's slope, then correct with an averaged slope.
highlighted = computed this step
Step 1 — Set up
Set up Heun's predictor-corrector method.
y′=x+yy(0)=1h=21
Step 2 — Predictor 1
Predict step 1 with the Euler slope.
f0=0+1=1y∗=1+21⋅1=23
Step 3 — Corrector 1
Correct step 1 by averaging endpoint slopes.
f∗=21+23=2fˉ=(1+2)/2=23
Step 4 — Update 1
Update y1 with the averaged slope.
y1=1+21⋅23=47
Step 5 — Predictor 2
Predict step 2 with the Euler slope.
f0=21+47=49y∗=47+21⋅49=823
Step 6 — Corrector 2
Correct step 2 by averaging endpoint slopes.
f∗=1+823=831fˉ=(49+831)/2=1649
Step 7 — Update 2
Update y2 with the averaged slope.
y2=47+21⋅1649=32105
Step 8 — Result
State the Heun approximation.
y(1)=32105
improved-euler-heun
Heun's method uses two slope evaluations per step: Predictor: y* = y_n + h·f(x_n, y_n) Corrector: y_{n+1} = y_n + (h/2)·(f(x_n,y_n) + f(x_{n+1},y*))