Runge-Kutta Methods

Runge-Kutta methods approximate IVP solutions using higher-order Taylor expansions, without evaluating derivatives of ff.

Mesh points are ti=a+iht_i = a + ih with h=b−aNh = \dfrac{b - a}{N}, as in Euler’s method.

Midpoint Method

Second-order Taylor, with the derivative term replaced using

f(t,y)+h2f′(t,y)=f(t+h2, y+h2f(t,y))+O(h2)f(t, y) + \frac{h}{2} f'(t, y) = f\left( t + \frac{h}{2},\ y + \frac{h}{2} f(t, y) \right) + O(h^2)
w0=αwi+1=wi+h f(ti+h2, wi+h2f(ti,wi))\begin{aligned} w_0 &= \alpha \\ w_{i+1} &= w_i + h\, f\left( t_i + \frac{h}{2},\ w_i + \frac{h}{2} f(t_i, w_i) \right) \end{aligned}

The local truncation error is O(h3)O(h^3). The global error is O(h2)O(h^2).

Midpoint Method Slope Estimate A curve from the current approximation at t_i to the next value. A half Euler step estimates the midpoint, where the full-step slope is sampled. y t (tᵢ, wᵢ) half step wᵢ₊₁
Midpoint method. Take a half Euler step to estimate the midpoint, then use the slope there for the full step.

Modified Euler Method

Third-order Taylor, with the derivative term replaced by an average of the endpoint slopes.

w0=αwi+1=wi+h2[f(ti,wi)+f(ti+1, wi+hf(ti,wi))]\begin{aligned} w_0 &= \alpha \\ w_{i+1} &= w_i + \frac{h}{2}\Big[ f(t_i, w_i) + f\big(t_{i+1},\ w_i + h f(t_i, w_i)\big) \Big] \end{aligned}

The local truncation error is O(h4)O(h^4). The global error is O(h3)O(h^3).

Modified Euler Slope Estimate A curve from the current approximation at t_i to the next value. Euler predicts the right endpoint, where the second slope is sampled before averaging both slopes. y t (tᵢ, wᵢ) Euler prediction wᵢ₊₁
Modified Euler method. Predict the right end with Euler, then average the left and predicted-right slopes.

Order 4 Runge-Kutta

w0=αk1=h f(ti,wi)k2=h f(ti+h2, wi+12k1)k3=h f(ti+h2, wi+12k2)k4=h f(ti+1, wi+k3)wi+1=wi+16(k1+2k2+2k3+k4)\begin{aligned} w_0 &= \alpha \\ k_1 &= h\, f(t_i, w_i) \\ k_2 &= h\, f\left( t_i + \tfrac{h}{2},\ w_i + \tfrac{1}{2} k_1 \right) \\ k_3 &= h\, f\left( t_i + \tfrac{h}{2},\ w_i + \tfrac{1}{2} k_2 \right) \\ k_4 &= h\, f\left( t_{i+1},\ w_i + k_3 \right) \\ w_{i+1} &= w_i + \tfrac{1}{6}\left( k_1 + 2k_2 + 2k_3 + k_4 \right) \end{aligned}

for i=0,1,…,N−1i = 0, 1, \ldots, N-1. The local truncation error is O(h5)O(h^5). The global error is O(h4)O(h^4).

Order 4 Runge-Kutta Slope Samples A curve with 4 Runge-Kutta slope-sampling positions: the start, 2 estimated midpoints, and an estimated endpoint. y t k₁ k₂ k₃ k₄ wᵢ₊₁
Order 4 Runge-Kutta. Sample slopes at the start, middle, middle and end, then combine them with weights 1,2,2,11, 2, 2, 1.

Error Orders

MethodGlobal errorLocal truncation error
EulerO(h)O(h)O(h2)O(h^2)
MidpointO(h2)O(h^2)O(h3)O(h^3)
Modified EulerO(h3)O(h^3)O(h4)O(h^4)
Order 4 Runge-KuttaO(h4)O(h^4)O(h5)O(h^5)

Higher order gives a better approximation for the same hh.

Worked Examples

Example 1

Apply each method to y′(t)=y−t2+1y'(t) = y - t^2 + 1, 0≤t≤20 \leq t \leq 2, y(0)=0.5y(0) = 0.5, with N=4N = 4. Exact solution y(t)=(t+1)2−0.5ety(t) = (t+1)^2 - 0.5 e^t, giving y(2)≈5.3055y(2) \approx 5.3055.

Solution Reveal Hide

h=0.5h = 0.5 and f(t,y)=y−t2+1f(t, y) = y - t^2 + 1.

Midpoint

w1=w0+0.5 f(0.25, 0.5+0.25f(0,0.5))=0.5+0.5 f(0.25, 0.875)=1.4063w2=2.5977,w3=3.9399,w4=5.2149\begin{aligned} w_1 &= w_0 + 0.5\, f\big(0.25,\ 0.5 + 0.25 f(0, 0.5)\big) = 0.5 + 0.5\, f(0.25,\ 0.875) = 1.4063 \\ w_2 &= 2.5977, \quad w_3 = 3.9399, \quad w_4 = 5.2149 \end{aligned}

Modified Euler

w1=w0+0.25[f(0,0.5)+f(0.5, 0.5+0.5f(0,0.5))]=0.5+0.25 [1.5+2.0]=1.375w2=2.5156,w3=3.7754,w4=4.9163\begin{aligned} w_1 &= w_0 + 0.25\left[ f(0, 0.5) + f\big(0.5,\ 0.5 + 0.5 f(0, 0.5)\big) \right] = 0.5 + 0.25\,[1.5 + 2.0] = 1.375 \\ w_2 &= 2.5156, \quad w_3 = 3.7754, \quad w_4 = 4.9163 \end{aligned}

Order 4

First step, t0=0t_0 = 0, w0=0.5w_0 = 0.5

k1=0.5 f(0, 0.5)=0.75k2=0.5 f(0.25, 0.5+0.375)=0.9063k3=0.5 f(0.25, 0.5+0.4531)=0.9453k4=0.5 f(0.5, 0.5+0.9453)=1.0977w1=0.5+16(k1+2k2+2k3+k4)=1.4251\begin{aligned} k_1 &= 0.5\, f(0,\ 0.5) = 0.75 \\ k_2 &= 0.5\, f(0.25,\ 0.5 + 0.375) = 0.9063 \\ k_3 &= 0.5\, f(0.25,\ 0.5 + 0.4531) = 0.9453 \\ k_4 &= 0.5\, f(0.5,\ 0.5 + 0.9453) = 1.0977 \\ w_1 &= 0.5 + \tfrac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) = 1.4251 \end{aligned}

Continuing, w2=2.6396w_2 = 2.6396, w3=4.0068w_3 = 4.0068, w4=5.3016w_4 = 5.3016.

Methodw4≈y(2)w_4 \approx y(2)Error
Euler4.43754.43750.8680.868
Midpoint5.21495.21490.0910.091
Modified Euler4.91634.91630.3890.389
Order 4 Runge-Kutta5.30165.30160.0040.004

Example 2

Apply 1 step of order 4 Runge-Kutta to y′=yy' = y, y(0)=1y(0) = 1, with h=0.1h = 0.1.

Solution Reveal Hide
k1=0.1(1)=0.1k2=0.1(1+0.05)=0.105k3=0.1(1+0.0525)=0.10525k4=0.1(1+0.10525)=0.110525w1=1+16(0.1+0.21+0.2105+0.110525)=1.105171\begin{aligned} k_1 &= 0.1(1) = 0.1 \\ k_2 &= 0.1(1 + 0.05) = 0.105 \\ k_3 &= 0.1(1 + 0.0525) = 0.10525 \\ k_4 &= 0.1(1 + 0.10525) = 0.110525 \\ w_1 &= 1 + \tfrac{1}{6}(0.1 + 0.21 + 0.2105 + 0.110525) = 1.105171 \end{aligned}

The exact value is e0.1=1.105171e^{0.1} = 1.105171. Euler gives 1.11.1.

Wolfram Mathematica notebooks

Companion notebooks for this note. Open one in Mathematica and evaluate the cells to reproduce the worked example.

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by November 3, 2026 4 min read
Was this helpful?