Skip to content
Oakfield Operator Calculus Function Reference Site

Heun Method

For ut=F(u,t)u_t = F(u,t) and timestep Δt\Delta t,

k1=F(un,tn),u~=un+Δtk1,k2=F(u~,tn+Δt),un+1=un+Δt2(k1+k2)\begin{aligned} k_1 &= F(u^{n}, t_n),\\ \tilde{u} &= u^{n} + \Delta t\,k_1,\\ k_2 &= F(\tilde{u}, t_n + \Delta t),\\ u^{n+1} &= u^{n} + \frac{\Delta t}{2}(k_1 + k_2) \end{aligned}

Applies to unRmu^n \in \mathbb{R}^m (or function spaces) with locally Lipschitz FF. Output un+1u^{n+1} resides in the same space.


Heun’s method is second-order accurate in time, with local truncation error O(Δt3)\mathcal{O}(\Delta t^3).

For the linear test equation ut=λuu_t = \lambda u, the stability function is

R(z)=1+z+12z2,z=λΔtR(z) = 1 + z + \tfrac{1}{2}z^2, \qquad z = \lambda \Delta t

Stability requires R(z)<1|R(z)| < 1, so timesteps remain restricted on stiff problems.

Two drift evaluations per step; no linear or nonlinear solves.


As Δt0\Delta t \to 0, the method converges to the exact flow under standard smoothness assumptions. Its leading term matches forward Euler, with the second stage acting as an explicit trapezoidal correction.


Interpolates between forward Euler (predictor) and RK4 in cost-versus-accuracy; shares the trapezoidal averaging idea with Crank–Nicolson but remains explicit.


Oakfield exposes Heun as a built-in explicit integrator:

  • Integrator name: heun (created via sim.sim_create_context_integrator(ctx, "heun", {...})).
  • Optional adaptivity: when adaptive = true, Oakfield uses the difference between the Euler predictor and Heun corrector as an error proxy for step acceptance.
  • Complex + stochastic support: the implementation handles real and complex fields and can apply stochastic increments after the deterministic update.

Heun popularized this explicit second-order approach in the early 20th century as a practical predictor–corrector alternative to first-order stepping.

It is now commonly classified as an explicit Runge–Kutta method of order 2 (explicit trapezoidal / improved Euler) and is frequently used when a small accuracy upgrade over Euler is needed.


  • Hairer, Nørsett, Wanner, Solving Ordinary Differential Equations I
  • Butcher, Numerical Methods for Ordinary Differential Equations