Planets that don't fly away

Same data. Same network. Only one of them knows that energy is conserved.

Black-box neural network

learns  ẋ = fθ(x)

READY
Energy drift0.0%

Physics-based AI · Hamiltonian NN

learns energy  Hθ(q,p),  ẋ = J ∇Hθ

READY
Energy drift0.0%

How it works

A planet orbits a sun. Both neural networks see the same 2,400 noisy snapshots of orbits (position, momentum and their rates of change), have the same size (two hidden layers of 128 neurons) and get the same training.

Black-box network

Directly predicts how the state changes: ẋ = fθ(x). Every prediction has a tiny error, and nothing stops those errors from adding up, so the planet slowly gains or loses energy. It spirals into the sun or drifts away.

Hamiltonian neural network

Learns a single number, the energy Hθ(q, p). Motion is then derived through Hamilton's equations: q̇ = ∂H/∂p, ṗ = −∂H/∂q. This structure conserves the learned energy by construction, so the orbit stays stable.

Both models are integrated with the same RK4 solver and step size. The drift shown is measured with the true energy E = |p|²/2 − 1/|q|. Reference: Greydanus, Dzamba & Yosinski, Hamiltonian Neural Networks, NeurIPS 2019.

Keys: Space pause · R restart · 1–3 presets · T true orbit · ↑/↓ time warp · F fullscreen · I this panel