Mathwords logoMathwords

Runge-Kutta-Fehlberg Method — Definition, Formula & Example

The Runge-Kutta-Fehlberg method (RKF45) is a Runge-Kutta solver for differential equations that sets its own step size. On each step it builds a fourth-order and a fifth-order estimate from the same six slope evaluations. It treats their difference as an error estimate and grows or shrinks the step to keep that error below a tolerance.

RKF45 is a six-stage explicit embedded Runge-Kutta pair of orders 4 and 5, published by Erwin Fehlberg in 1969. For the initial value problem y′=f(t,y)y' = f(t, y), it computes stages k1,…,k6k_1, \dots, k_6 at nodes tn+ciht_n + c_i h with c=(0,14,38,1213,1,12)c = (0, \tfrac14, \tfrac38, \tfrac{12}{13}, 1, \tfrac12). Two weight vectors then produce yn+1y_{n+1} (order 4) and zn+1z_{n+1} (order 5). The local error estimate is E=∣zn+1−yn+1∣E = |z_{n+1} - y_{n+1}|. You accept the step if E≤tolE \le \text{tol}, and you set the next step size from the ratio tol/E\text{tol}/E.

Key Formula

yn+1=yn+h(25216k1+14082565k3+21974104k4−15k5)zn+1=yn+h(16135k1+665612825k3+2856156430k4−950k5+255k6)E=∣zn+1−yn+1∣\begin{aligned} y_{n+1} &= y_n + h\left(\tfrac{25}{216}k_1 + \tfrac{1408}{2565}k_3 + \tfrac{2197}{4104}k_4 - \tfrac{1}{5}k_5\right) \\ z_{n+1} &= y_n + h\left(\tfrac{16}{135}k_1 + \tfrac{6656}{12825}k_3 + \tfrac{28561}{56430}k_4 - \tfrac{9}{50}k_5 + \tfrac{2}{55}k_6\right) \\ E &= |z_{n+1} - y_{n+1}| \end{aligned}
Where:
  • yny_n = Current approximation of the solution at time tnt_n
  • hh = Current step size
  • k1,…,k6k_1, \dots, k_6 = Slope evaluations of ff at the nodes tn+ciht_n + c_i h. Both formulas share these six values.
  • yn+1y_{n+1} = Fourth-order estimate. Fehlberg's original method advances with this one.
  • zn+1z_{n+1} = Fifth-order estimate. Many codes advance with this more accurate value instead.
  • EE = Estimated local error, used to accept or reject the step and to choose the next h

Worked Example

Problem: Take one trial RKF45 step for y′=5t4y' = 5t^4, y(0)=0y(0) = 0, with h=1h = 1 and tolerance 10−410^{-4}. The exact solution is y=t5y = t^5, so y(1)=1y(1) = 1. Because ff depends only on tt, each stage reduces to ki=5(cih)4k_i = 5(c_i h)^4. This lets you see clearly how the two embedded formulas differ.
Step 1: Evaluate the six stages at the nodes cih=0,14,38,1213,1,12c_i h = 0, \tfrac14, \tfrac38, \tfrac{12}{13}, 1, \tfrac12.
k1=0,  k2=5256,  k3=4054096,  k4=10368028561,  k5=5,  k6=516k_1 = 0,\; k_2 = \tfrac{5}{256},\; k_3 = \tfrac{405}{4096},\; k_4 = \tfrac{103680}{28561},\; k_5 = 5,\; k_6 = \tfrac{5}{16}
Step 2: Apply both weight sets to the same six stages. The fifth-order formula reproduces the exact value, but the fourth-order formula does not.
y1=33608+480247−1=415416≈0.99760,z1=39760+384209−910+188=1y_1 = \tfrac{33}{608} + \tfrac{480}{247} - 1 = \tfrac{415}{416} \approx 0.99760, \qquad z_1 = \tfrac{39}{760} + \tfrac{384}{209} - \tfrac{9}{10} + \tfrac{1}{88} = 1
Step 3: Estimate the error and compare it with the tolerance. Since E>10−4E > 10^{-4}, reject the step. One common update rule uses a safety factor of 0.9 and the exponent 1/51/5.
E=1416≈0.00240,hnew=0.9 h(10−4E)1/5≈0.476E = \tfrac{1}{416} \approx 0.00240, \qquad h_{\text{new}} = 0.9\,h\left(\frac{10^{-4}}{E}\right)^{1/5} \approx 0.476
Answer: Reject the trial step, because E≈0.00240E \approx 0.00240 exceeds 10−410^{-4}. Retry with h≈0.476h \approx 0.476. For this problem the error scales exactly as h5h^5, so the new estimate is about 5.9×10−55.9 \times 10^{-5}, and the retried step passes.

Why It Matters

RKF45 is the standard first example of adaptive step-size control in numerical analysis courses, for instance in Burden and Faires. It also appears in classic library routines, such as the Shampine–Watts RKF45 code. Adaptive solvers like this take small steps where the solution changes rapidly and large steps where it is smooth, which is essential when you simulate orbits, chemical reactions, or circuits.

Common Mistakes

Mistake: Running a separate RK4 step and a separate RK5 step to get the two estimates.
Correction: The two estimates in RKF45 come from one shared set of six stages. Only the final weights differ. This sharing is the reason the error estimate costs almost nothing extra.

Related Terms