BalanceForge · differentiable physics
The double pendulum, held upright by the model
Two model-based controllers on the SAME differentiable simulator — the physics you're watching.
Gradient-free evolution (CMA-ES/NEAT) plateaus at ~13% hold on this task no matter the budget; both of
these use the known dynamics and win.
LQR — holds foreveranalytic · provably stable
Neural — learns liveexact gradients · finite basin
backprop-through-time · ∂loss / ∂action across the rollout
— which control moments the gradient blames. Only gradient methods can show this.
t = 0 (start of rollout)—t = end
LQR (analytic). Reads the linearized dynamics straight out of the differentiable simulator (finite-
difference at the true inverted fixed point), then solves the discrete Riccati equation for a state-feedback
gain u = -K·x. Provably asymptotically stable near upright → it holds indefinitely
(verified 30s, no fall, from any small tilt). This is how real multi-pendulum rigs do it.
Engine: js/diffsim_lqr.js (proof: diffsim-lqr-probe.js).
Neural (exact gradients). Trains a small feedback MLP live by Adam backprop THROUGH the simulator —
watch the "best hold" climb. But a memoryless policy trained on a short (~1.5s, near-linear) horizon has a
finite basin: it holds cleanly ~1.5–2s, so this loops fresh catches. Same physics, learned rather than
solved. Engine: js/diffsim_trainer.js (diffsim-trainer-probe.js).