ODE Step Solver (Euler and RK4)

Solve y' = f(x, y) step by step with Euler, improved Euler or Runge-Kutta 4.

How it works

Type y' as a formula in x and y, the start point, the step size h and where to stop. Pick Euler, improved Euler (Heun) or Runge-Kutta 4. The tool steps forward and shows a table.

The formula

Euler: y1 = y0 + h f(x0, y0)
Heun: y1 = y0 + h/2 (k1 + k2)
RK4: y1 = y0 + h/6 (k1 + 2 k2 + 2 k3 + k4)

Worked example

For y' = y with y(0) = 1, RK4 with h = 0.1 gives y(1) = 2.71828, very close to e. Euler gives 2.59374.

Good to know

Common questions

Which method should I use?
RK4 for accuracy. Euler to learn the idea.
Why must the range be a whole number of steps?
So the last step lands exactly on the stop x.
Can it solve second-order equations?
Not directly. Rewrite as two first-order equations.

More in Math, Science & Engineering.