Averaging the initial slope and a predicted slope yields a second-order method. Full derivation via second-order Taylor and via the trapezoidal rule with an Euler prediction.
Averaging two slopes
Euler uses only the slope at the start of the subinterval, which is why it drifts as soon as the solution curves. Heun's method corrects that bias by averaging the initial slope with the slope at the point Euler would reach:
Heun's method, order 2.Heun first predicts with Euler and then corrects using the average of the initial slope and the predicted final slope.
Derivation
There are two natural routes to the formula: force the scheme to reproduce the Taylor expansion up to second order, or approximate the integral form of the IVP with the trapezoidal rule and predict the unknown value with Euler.
The value y(tk+1) on the right-hand side is unknown. Instead of solving the implicit equation (that would be AM2, the implicit trapezoid), predict it with one Euler step:
yˉk+1=yk+hf(tk,yk)
Substituting the prediction into the trapezoid gives the same formula as via Taylor: Heun is a one-step predictor-corrector pair.
yk+1=yk+2h(f(tk,yk)+f(tk+1,yˉk+1))
Order and relation to other methods
Seen from the second derivation, Heun is the simplest predictor-corrector pair: it predicts with Euler and corrects with the trapezoidal rule. It is the same idea that, with multistep methods, produces the Adams-Bashforth-Moulton pairs. It is also the best-known member of the two-stage Runge-Kutta family, and the natural step towards the classical fourth-order Runge-Kutta.
ExampleOne Heun step
Take one Heun step with h=1 for y′=(3−0.1y)y, y(0)=10.
Initial slope: k1=hf(0,10)=1⋅(3−1)⋅10=20.
Predicted slope at Euler's arrival point, y0+k1=30: k2=hf(1,30)=(3−3)⋅30=0.
Average of both slopes:
y1=10+21⋅20+21⋅0=20
The exact value is y(1)=27.2833: with a single step the error is still large, but the table in the order exercise shows that as the mesh is refined Heun's error falls like h2, much faster than Euler's.