Skip to content
Calcrivo

Runge-Kutta Calculator

Solve an ODE numerically using the classical 4th-order Runge-Kutta method (RK4).

Inputs

Right-hand side using x and y.

y(target x)

5.3053630007

Step size h

0.20000000

Steps used

10

Step by step

  1. Values used

    dy/dx = f(x, y) = y - x^2 + 1; Initial x₀ = 0; Initial y₀ = 0.5000; Target x = 2; Steps = 10

  2. RK4 formulas

    k1=f(x,y); k2=f(x+h/2,y+h·k1/2); k3=f(x+h/2,y+h·k2/2); k4=f(x+h,y+h·k3); y(n+1)=y(n)+(h/6)(k1+2k2+2k3+k4)

  3. y(target x)

    = 5.3053630007

  4. Step size h

    = 0.20000000

  5. Steps used

    = 10

How it works

The classical 4th-order Runge-Kutta (RK4) method computes four slope estimates per step and combines them with weights 1:2:2:1 for O(h⁴) global accuracy. It is the workhorse of ODE solving — balancing accuracy, stability, and simplicity. Even 10 steps often gives 6+ digits of accuracy for smooth problems.

Formula

RK4 formulas

k1=f(x,y); k2=f(x+h/2,y+h·k1/2); k3=f(x+h/2,y+h·k2/2); k4=f(x+h,y+h·k3); y(n+1)=y(n)+(h/6)(k1+2k2+2k3+k4)

h
Step size
f(x,y)
ODE right-hand side

Frequently Asked Questions

How accurate is RK4?

Local error is O(h⁵), global error O(h⁴). Doubling steps (halving h) improves accuracy by a factor of 16. For most smooth ODEs, 10-100 steps suffice.

What about stiff equations?

RK4 can be unstable for stiff equations (those with widely separated time scales). Implicit methods like backward Euler are preferred for stiff problems.

You might also need