A simulation's physics is only as good as the algorithm stepping it forward.
This top-down 2D view integrates the same inverse-square gravity orbit with three
different numerical schemes at the timestep you choose. Plain (explicit) Euler is
the simplest but visibly gains energy and spirals outward; semi-implicit Euler is a
one-line fix that stays stable indefinitely; RK4 is far more accurate per step but
costs 4x the force evaluations.
Euler: v += a(x)*dt; x += v_old*dt
Semi-implicit: v += a(x)*dt; x += v_new*dt
RK4: 4-stage weighted average of a(x) across the step
- Timestep — how coarse each integration step is; larger steps expose each algorithm's error faster.
- Orbit eccentricity — how elliptical the orbit is; higher eccentricity stresses the integrator more at close approach.
- Algorithm — pick which integration scheme drives the orbiting body.
This is the exact trade-off every physics/game engine makes when choosing its
integrator — accuracy, stability and cost per frame all pull in different
directions.