Mathwords logoMathwords

Runge-Kutta Method — Definition, Formula & Examples

The Runge-Kutta method is a numerical technique for approximating solutions to ordinary differential equations when an exact analytical solution is difficult or impossible to find. The most widely used version, called RK4 (fourth-order Runge-Kutta), computes four weighted slope estimates at each step to achieve high accuracy.

Given an initial value problem y=f(t,y)y' = f(t, y) with y(t0)=y0y(t_0) = y_0, the classical fourth-order Runge-Kutta method advances the solution from tnt_n to tn+1=tn+ht_{n+1} = t_n + h by computing a weighted average of four intermediate slope evaluations k1,k2,k3,k4k_1, k_2, k_3, k_4, yielding a local truncation error of order O(h5)O(h^5) and a global error of order O(h4)O(h^4).

Key Formula

y_{n+1} = y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$ $$k_1 = f(t_n,\, y_n)$$ $$k_2 = f\!\left(t_n + \frac{h}{2},\, y_n + \frac{h}{2}k_1\right)$$ $$k_3 = f\!\left(t_n + \frac{h}{2},\, y_n + \frac{h}{2}k_2\right)$$ $$k_4 = f(t_n + h,\, y_n + h\,k_3)
Where:
  • yny_n = Approximate solution value at step n
  • tnt_n = Current value of the independent variable
  • hh = Step size
  • f(t,y)f(t, y) = The derivative function from y' = f(t, y)
  • k1,k2,k3,k4k_1, k_2, k_3, k_4 = Slope estimates at different points in the interval

How It Works

At each step, you evaluate the slope f(t,y)f(t, y) at four strategic points within the interval. First, k1k_1 uses the slope at the current point. Then k2k_2 and k3k_3 each use slopes at the midpoint of the interval, but based on different estimates. Finally, k4k_4 uses the slope at the end of the interval. The next yy-value is a weighted combination that gives the midpoint slopes four times the weight of the endpoint slopes. You repeat this process for as many steps as needed to cover your desired range of tt.

Worked Example

Problem: Use one step of RK4 with h = 0.1 to approximate y(0.1), given y' = t + y, y(0) = 1.
Compute k₁: Evaluate f at the starting point.
k1=f(0,1)=0+1=1k_1 = f(0,\, 1) = 0 + 1 = 1
Compute k₂: Evaluate f at the midpoint using k₁.
k2=f(0.05,1+0.051)=f(0.05,1.05)=0.05+1.05=1.1k_2 = f(0.05,\, 1 + 0.05 \cdot 1) = f(0.05,\, 1.05) = 0.05 + 1.05 = 1.1
Compute k₃: Evaluate f at the midpoint using k₂.
k3=f(0.05,1+0.051.1)=f(0.05,1.055)=0.05+1.055=1.105k_3 = f(0.05,\, 1 + 0.05 \cdot 1.1) = f(0.05,\, 1.055) = 0.05 + 1.055 = 1.105
Compute k₄: Evaluate f at the endpoint using k₃.
k4=f(0.1,1+0.11.105)=f(0.1,1.1105)=0.1+1.1105=1.2105k_4 = f(0.1,\, 1 + 0.1 \cdot 1.105) = f(0.1,\, 1.1105) = 0.1 + 1.1105 = 1.2105
Combine: Apply the RK4 formula.
y1=1+0.16(1+2(1.1)+2(1.105)+1.2105)=1+0.16(6.6205)1.11034y_1 = 1 + \frac{0.1}{6}(1 + 2(1.1) + 2(1.105) + 1.2105) = 1 + \frac{0.1}{6}(6.6205) \approx 1.11034
Answer: y(0.1) ≈ 1.11034. The exact solution is y = 2e^t − t − 1, giving y(0.1) ≈ 1.11034, so RK4 is extremely accurate even in one step.

Why It Matters

RK4 is the default numerical ODE solver taught in differential equations courses and used in engineering, physics simulations, and computational biology. Many software tools (MATLAB's ode45, Python's scipy.integrate) build on Runge-Kutta variants. Understanding it prepares you for any field where differential equations lack closed-form solutions.

Common Mistakes

Mistake: Using k₁ instead of k₂ when computing k₃.
Correction: Each k-value feeds into the next: k₃ depends on k₂ (not k₁), and k₄ depends on k₃. Follow the chain carefully.