Runge-Kutta method (RK4)

The classical Runge-Kutta combines four slopes per step to reach order 4. Full derivation from Simpson's rule and direct extension to ODE systems.

Four slopes per step

The classical fourth-order Runge-Kutta method evaluates the slope ff four times per step: once at the start, twice at the midpoint and once at the end, each using the previous one to estimate where to evaluate:

k1=f(tk,yk)k2=f ⁣(tk+h2,yk+h2k1)k3=f ⁣(tk+h2,yk+h2k2)k4=f(tk+h,yk+hk3)\begin{aligned} k_1&=f(t_k,\,y_k)\\ k_2&=f\!\left(t_k+\tfrac{h}{2},\,y_k+\tfrac{h}{2}k_1\right)\\ k_3&=f\!\left(t_k+\tfrac{h}{2},\,y_k+\tfrac{h}{2}k_2\right)\\ k_4&=f(t_k+h,\,y_k+h\,k_3) \end{aligned}
yk+1=yk+h6(k1+2k2+2k3+k4)y_{k+1}=y_k+\frac{h}{6}\bigl(k_1+2k_2+2k_3+k_4\bigr)
Classical fourth-order Runge-Kutta (RK4).
tₖtₖ+h/2tₖ₊₁k₁k₂k₃k₄internal stagesweights 1, 2, 2, 1
RK4 takes one slope at the start, two midpoint estimates and one final slope; the weighted combination imitates Simpson on the integral form.
Expand diagram

RK4 takes one slope at the start, two midpoint estimates and one final slope; the weighted combination imitates Simpson on the integral form.

Derivation

The 1,2,2,11,2,2,1 structure with denominator 66 comes from the weights of Simpson's rule applied to the integral form of the IVP.

DerivationDerivation: fourth-order Runge-KuttaView as its own page →
tₖtₖ+h/2tₖ₊₁k₁k₂k₃k₄internal stagesweights 1, 2, 2, 1
The four RK4 stages replace Simpson's exact slopes by chained internal evaluations.
Expand diagram

The four RK4 stages replace Simpson's exact slopes by chained internal evaluations.

  1. First integrate the differential equation over the subinterval [tk,tk+1][t_k,t_{k+1}]:

    tktk+1y(τ)dτ=tktk+1f(τ,y(τ))dτ\int_{t_k}^{t_{k+1}} y'(\tau)\,d\tau=\int_{t_k}^{t_{k+1}} f\bigl(\tau,y(\tau)\bigr)\,d\tau
  2. Applying the Fundamental Theorem of Calculus to the left-hand side gives the exact integral form of the IVP:

    y(tk+1)=y(tk)+tktk+1f(τ,y(τ))dτy(t_{k+1})=y(t_k)+\int_{t_k}^{t_{k+1}} f\bigl(\tau,y(\tau)\bigr)\,d\tau
  3. Approximate the integral with Simpson's rule, which uses the endpoints and the midpoint tk+12=tk+h2t_{k+\frac12}=t_k+\frac{h}{2}:

    tktk+1fdτh6(f(tk,yk)+4f(tk+12,yk+12)+f(tk+1,yk+1))\int_{t_k}^{t_{k+1}} f\,d\tau\approx\frac{h}{6}\Bigl(f(t_k,y_k)+4f\bigl(t_{k+\frac12},y_{k+\frac12}\bigr)+f(t_{k+1},y_{k+1})\Bigr)
  4. Problem: we know neither yk+12y_{k+\frac12} nor yk+1y_{k+1}. Runge-Kutta's solution is to estimate them with chained internal slopes, each built by advancing with the previous one:

    k1=f(tk,yk)k2=f(tk+h2,yk+h2k1)k3=f(tk+h2,yk+h2k2)k4=f(tk+h,yk+hk3)\begin{aligned} k_1&=f(t_k,\,y_k)\\ k_2&=f\bigl(t_k+\tfrac{h}{2},\,y_k+\tfrac{h}{2}k_1\bigr)\\ k_3&=f\bigl(t_k+\tfrac{h}{2},\,y_k+\tfrac{h}{2}k_2\bigr)\\ k_4&=f(t_k+h,\,y_k+h\,k_3) \end{aligned}
  5. Simpson's central slope is approximated by averaging the two midpoint estimates, and the final one by k4k_4:

    f(tk+12,yk+12)k2+k32,f(tk+1,yk+1)k4f\bigl(t_{k+\frac12},y_{k+\frac12}\bigr)\approx\frac{k_2+k_3}{2},\qquad f(t_{k+1},y_{k+1})\approx k_4
  6. Substituting into Simpson, the midpoint weight 44 splits as 4k2+k32=2k2+2k34\cdot\frac{k_2+k_3}{2}=2k_2+2k_3, and the classical RK4 appears with its 1,2,2,11,2,2,1 weights:

    yk+1=yk+h6(k1+2k2+2k3+k4)y_{k+1}=y_k+\frac{h}{6}\bigl(k_1+2k_2+2k_3+k_4\bigr)
  7. A Taylor analysis analogous to Heun's (but up to fourth order) confirms that these internal approximations preserve the O(h5)\mathcal{O}(h^5) local error, so the method is fourth order.

Order 4 and cost

The price of order 4 is four evaluations of ff per step, versus one for Euler. When evaluating ff is expensive, multistep methods like Adams-Bashforth reuse already-computed slopes and reach high order with a single new evaluation per step; in exchange they need a one-step method such as RK4 to provide their starting values.

ODE systems

The extension to first-order systems is immediate: replace yky_k and ff by their vector versions YkY_k and FF, and the four slopes K1,,K4K_1,\dots,K_4 become vectors. With Euler, for instance, Yk+1=Yk+hF(tk,Yk)Y_{k+1}=Y_k+h\,F(t_k,Y_k). The SIR model exercise compares Euler, Heun and RK4 on the same system, and the hand-computation exercise integrates a second-order equation reduced to a system.