The classical fourth-order Runge-Kutta method evaluates four slopes per step and takes a weighted average. Example: y'=x+y, y(0)=1, h=1/2; one step gives y(1/2)≈115/64≈1.797 versus true 2√e−3/2≈1.797.

Global error O(h⁴); highly accurate for smooth ODEs.

Example

Combine four weighted slopes for one fourth-order step.

highlighted = computed this step

Step 1 — Set up

Set up the Runge-Kutta method for one step.

y=x+yy(0)=1h=12y'= x+y \quad y( 0 )= 1 \quad h= \frac{1}{2}

Step 2 — Compute k1

Compute the next Runge-Kutta slope.

k1=12(0+1)=12k_1= \frac{1}{2} \cdot( 0 + 1 )= \hlmath{\frac{1}{2}}

Step 3 — Compute k2

Compute the next Runge-Kutta slope.

k2=12(14+54)=34k_2= \frac{1}{2} \cdot( \frac{1}{4} + \frac{5}{4} )= \hlmath{\frac{3}{4}}

Step 4 — Compute k3

Compute the next Runge-Kutta slope.

k3=12(14+118)=1316k_3= \frac{1}{2} \cdot( \frac{1}{4} + \frac{11}{8} )= \hlmath{\frac{13}{16}}

Step 5 — Compute k4

Compute the next Runge-Kutta slope.

k4=12(12+2916)=3732k_4= \frac{1}{2} \cdot( \frac{1}{2} + \frac{29}{16} )= \hlmath{\frac{37}{32}}

Step 6 — Weighted update

Combine k values with weights 1, 2, 2, 1 over 6.

y1=1+16(12+234+21316+3732)=11564y_1= 1 + \frac{1}{6} ( \frac{1}{2} + 2 \cdot \frac{3}{4} + 2 \cdot \frac{13}{16} + \frac{37}{32} )= \hlmath{\frac{115}{64}}

Step 7 — Result

State the Runge-Kutta approximation.

y(12)=11564y( \frac{1}{2} )= \hlmath{\frac{115}{64}}
runge-kutta-rk4 RK4 computes four slope estimates k1..k4 then advances: k1 = h·f(x_n, y_n) k2 = h·f(x_n+h/2, y_n+k1/2) k3 = h·f(x_n+h/2, y_n+k2/2) k4 = h·f(x_n+h, y_n+k3) y_{n+1} = y_n + (1/6)(k1+2k2+2k3+k4)