Euler Midpoint (RK2) RK4 True ellipse
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

ODE Integrator Race — Euler vs RK2 vs RK4

Three numerical integrators — first-order Euler, second-order midpoint (RK2), and classical fourth-order Runge-Kutta — chase the same inverse-square gravitational orbit from an identical starting point, using the identical step size h. Because they discretize the same differential equation with different local truncation error (O(h), O(h²) and O(h⁴) respectively), their trajectories peel away from the true Kepler ellipse at very different rates: Euler visibly spirals outward within a few orbits, RK2 tracks the ellipse much longer before drifting, and RK4 stays locked to it well past both. Live energy-drift readouts turn "which method is more accurate" from an abstract claim into a number you can watch grow in real time as you push the step size or eccentricity higher.