Skip to main tool

NUMERICAL METHODS GUIDE

How the Runge–Kutta RK4 method improves an ODE estimate

Classical fourth-order Runge–Kutta, often called RK4, samples several slopes inside each interval. It is a practical fixed-step method for many smooth ordinary differential equations and two-state systems.

FORMULA

yₙ₊₁ = yₙ + h(k₁ + 2k₂ + 2k₃ + k₄) / 6

WORKED EXAMPLE

For y′ = −2y + sin(x), RK4 evaluates the slope at the start, two midpoint estimates, and the end of each step before combining them into the next y value.

STEP BY STEP

01

Set the model and initial values

Enter the equation right-hand side, such as −2y + sin(x), along with x₀, y₀, final x, and step size.

02

Calculate the first slope

k₁ is the slope at the beginning of the interval.

03

Sample two midpoint slopes

k₂ and k₃ estimate the slope halfway through the step using updated state estimates.

04

Calculate the ending slope

k₄ estimates the slope at the end of the step using the third provisional state.

05

Combine the weighted slopes

RK4 combines the four estimates with greater weight on the midpoint slopes, then repeats for the full interval.