Numerical Methods & Scientific Computing

Runge–Kutta RK4 Calculator

Use classical RK4 to integrate y′ = f(x,y) from an initial condition. The tool plots the solution, reports step count and endpoint error, and lets you export the numerical trajectory.

Numerical ODE workbench

Classical RK4

4th order. Solve first-order initial-value problems of the form y′ = f(x,y).

Expression syntax: use explicit multiplication such as 2*y. Supported functions include sin, cos, tan, exp, ln, sqrt and abs.

How this tool works

RK4 combines four slope samples: k₁=f(x,y), k₂=f(x+h/2,y+hk₁/2), k₃=f(x+h/2,y+hk₂/2), k₄=f(x+h,y+hk₃), then yₙ₊₁=yₙ+h(k₁+2k₂+2k₃+k₄)/6.

Example

For y′ = −2y with h=0.1, RK4 should closely track exp(−2x) over the interval while using a fixed step size.

Common questions

What order is RK4?

Classical RK4 has fourth-order global accuracy for sufficiently smooth problems, so reducing h typically decreases truncation error rapidly until floating-point or model effects dominate.

Is RK4 good for stiff equations?

Not necessarily. RK4 is explicit and has a finite stability region. Strongly stiff problems can force impractically small time steps.