Derivation: Heun's method
Full derivation of Heun: via the Taylor expansion to second order combined with the two-variable Taylor of f, and via the trapezoidal rule with an Euler prediction.
Route 1: Taylor to second order
Expand the solution by Taylor one order further than in Euler:
We need . Differentiating with the chain rule:
Substituting and into the expansion and grouping half and half:
The bracket matches a two-variable Taylor expansion of . In general, ; choosing the increment :
Replacing the bracket by that evaluation (the error is absorbed into ):
Evaluating at with and discarding yields Heun's method, with local error and hence global error :
Route 2: trapezoid with Euler prediction
Start from the exact integral form of the IVP on one subinterval:
Approximate that integral with the trapezoidal rule:
The value 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:
Substituting the prediction into the trapezoid gives the same formula as via Taylor: Heun is a one-step predictor-corrector pair.