Skip to content
Calcrivo

Differential Equation Solver

Solve first-order ODEs numerically using RK4 given dy/dx = f(x,y) and an initial condition.

Inputs

Enter the right-hand side using x and y.

y(target x)

3.43656366

Steps used

100

Step size h

0.01000000

Step by step

  1. Values used

    dy/dx = f(x, y) = x + y; Initial x₀ = 0; Initial y₀ = y(x₀) = 1; Target x = 1; Number of steps = 100

  2. RK4 method

    y(n+1) = y(n) + (h/6)(k1 + 2k2 + 2k3 + k4)

  3. y(target x)

    = 3.43656366

  4. Steps used

    = 100

  5. Step size h

    = 0.01000000

How it works

Solves the initial value problem dy/dx = f(x,y), y(x₀) = y₀ using the classical 4th-order Runge-Kutta method (RK4). This method has local error O(h⁵) and global error O(h⁴), making it highly accurate for smooth ODEs. Enter f(x,y) using x and y as variables.

Formula

RK4 method

y(n+1) = y(n) + (h/6)(k1 + 2k2 + 2k3 + k4)

k1
h·f(xn, yn)
k2
h·f(xn+h/2, yn+k1/2)
k3
h·f(xn+h/2, yn+k2/2)
k4
h·f(xn+h, yn+k3)

Frequently Asked Questions

How many steps should I use?

More steps give higher accuracy but take longer. For most problems, 100-1000 steps suffice. If the solution diverges, try more steps (smaller h).

Can this solve higher-order ODEs?

Convert a second-order ODE y'' = g(x,y,y') into a system of first-order ODEs by substituting v = y', then solve iteratively.

You might also need