How to use this calculator
Type the slope function y′ = f(x, y), the starting point, the step size and how many steps to take. The final x is x₀ + n·h. Compare Euler with RK4, then halve h to see how each one converges.
Methods
Euler’s methodyi+1 = yi + h f(xi, yi)
Runge–Kutta 4yi+1 = yi + h6(k1 + 2k2 + 2k3 + k4)
Worked example
y′ = x + y, y(0) = 1, h = 0.1, 10 steps (the default)
- First Euler step: y1 = 1 + 0.1 × (0 + 1) = 1.1.
- After 10 steps Euler gives y(1) ≈ 3.1875; RK4 gives 3.43656.
- The exact solution is y = 2ex − x − 1, so y(1) = 3.43656: RK4 is correct to 5 decimals, Euler is off by 7%.
Frequently asked questions
When should I use Euler’s method?
For learning and quick estimates. Its error is proportional to h, so accurate answers need very small steps. RK4 is the standard workhorse for real problems.
Why does my solution blow up?
Either the true solution does (y′ = y² reaches infinity in finite time), or the step is too large for a fast-decaying equation such as y′ = −50y. Try a smaller h.