Same data. Same network. Only one of them knows that energy is conserved.
learns ẋ = fθ(x)
learns energy Hθ(q,p), ẋ = J ∇Hθ
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.
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.
ẋ = fθ(x)
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.
Hθ(q, p)
q̇ = ∂H/∂p
ṗ = −∂H/∂q
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.
E = |p|²/2 − 1/|q|
Keys: Space pause · R restart · 1–3 presets · T true orbit · ↑/↓ time warp · F fullscreen · I this panel