HomeComputer ScienceIntegrator Stability Under Frame Jitter — Phase-Space Simulator (2D)

Integrator Stability Under Frame Jitter — Phase-Space Simulator (2D)

Interactive 2D companion to the Fix-Your-Timestep simulator: a mass-spring oscillator integrated three ways — naive explicit Euler, clamped semi-implicit (symplectic) Euler, and a fixed-timestep RK4 accumulator — under the same jittery, dropped-frame conditions, with a live phase-space (position vs velocity) portrait and energy-error readouts that reveal which integration strategy actually conserves energy.

Computer Science2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-javascript-animations ↗ Open standalone

This is the 2D companion to the "Fix Your Timestep" 3D simulator, and it isolates a different half of the same real problem: not just how an animation loop handles a jittery requestAnimationFrame clock, but how the choice of numerical integrator interacts with it. A single ideal mass-spring oscillator (x'' = -ω²x, whose exact energy never changes) is stepped forward three independent ways under the identical jittered frame-time stream — naive explicit Euler with no safeguard, a clamped semi-implicit (symplectic) Euler, and a fixed-timestep RK4 accumulator — and each one's trajectory is drawn live as a phase-space portrait (position vs. velocity) alongside a scrolling position-vs-time strip chart. Sliders control frame jitter severity, the simulated FPS cap, the oscillator's stiffness, and its starting amplitude, while live readouts track each integrator's energy-conservation error against the exact analytic solution — making visible why explicit Euler's orbit spirals outward forever, why symplectic Euler stays on a closed loop, and why decoupling physics steps from rendering with RK4 all but eliminates the error.

⚙ Under the hood

2D companion to the Fix-Your-Timestep simulator: a mass-spring oscillator integrated three ways — naive explicit Euler, clamped semi-implicit (symplectic) Euler, and a fixed-timestep RK4 accumulator — under the same jittery, dropped-frame conditions, with a live phase-space (position vs velocity) portrait and energy-error readouts that reveal which integration strategy actually conserves energy.

javascriptanimationnumerical-integrationphase-spacephysics-enginegame-loop

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)