Calculus & Numerical Methods

Runge-Kutta 4 (ODE)

Solve y' = f(x, y) with the classic RK4 method.

Formula

Formula
yn+1 = yn + h6(k1+2k2+2k3+k4)

Variables

SymbolDefinitionType & rangeUnitsRole
f derivative function expression / text x, y input
x₀, y₀ initial condition real number (ℝ) input
x target real number (ℝ) input

Try it yourself

Interactive calculator
math expression (e.g. x*x, sin(x))
Result

Worked examples

Example 1
Givenf(x, y) = x + y, x₀ = 0, y₀ = 1, target x = 1, steps = 100
Result3.436563656
Example 2
Givenf(x, y) = y, x₀ = 0, y₀ = 1, target x = 1, steps = 100
Result2.718281828