A matched-integrator evaluation of Hamiltonian neural networks on pendulum and Kepler dynamics
Lenick Kemunto Nyabuto
Abstract
Under a controlled matched-integrator protocol, a Hamiltonian Neural Network (HNN) and a parameter-matched feedforward baseline are trained on the same derivative targets and rolled out with the same RK4 integrator. Over $N_{\mathrm{seed}}=5$ independent training seeds on the nonlinear pendulum, the HNN reduces mean long-horizon energy drift by $42\times$ and mean trajectory MSE by $15.8\times$ at $T=100$ (about 16 periods); its drift is also tighter across seeds ($\sigma/\mu\approx42\%$ versus $\approx85\%$) and remains bounded rather than growing. Applying the same five-seed protocol to the three-dimensional Kepler two-body problem (6D phase space), the HNN at $T=10$ reduces energy drift by $8.0\pm1.0\times$, angular-momentum drift by $4.2\pm0.5\times$, and trajectory MSE by $5.5\pm0.8\times$. An auxiliary explicit St\"ormer--Verlet diagnostic does not improve on HNN+RK4, illustrating that the assumptions of a structure-preserving integrator must be compatible with the learned Hamiltonian. \end{abstract} \vspace{-0.55em} \section*{1\quad Setup} \vspace{-0.35em} \textbf{Pendulum.} We use the normalized nonlinear pendulum $H(q,p)=\tfrac12p^2+(1-\cos q)$, restricted to the librational regime $H_0<2$. Reference trajectories are generated with RK4 at $\Delta t=10^{-2}$ over $T=10$ from $N=100$ initial conditions and split 70/15/15 into train/validation/test sets. \textbf{Models.} The two networks are matched on width, depth, activation, optimizer, batch size, epochs, targets, and inference integrator: three hidden layers of 64 \texttt{tanh} units, Adam at $10^{-3}$, batch size 512, 300 epochs and central-difference derivative targets. Model A maps $(q,p)\mapsto(\dot q,\dot p)$ directly (8\,642 parameters). Model B (HNN) maps $(q,p)\mapsto\widehat H(q,p)$ and obtains the vector field from Hamilton's equations by automatic differentiation (8\,577 parameters). Both are rolled out with the same RK4 scheme. Primary pendulum results are reported over five independent training seeds. \textbf{Kepler transfer benchmark.} The same controlled comparison is applied to the three-dimensional Kepler two-body Hamiltonian $H(q,p)=\tfrac12\|p\|^2-\|q\|^{-1}$, with $q,p\in\mathbb{R}^3$, using 6D phase-space networks and the same $N_{\mathrm{seed}}=5$ evaluation protocol. \vspace{-0.5em} \section*{2\quad Results} \vspace{-0.35em} For the pendulum at matched RK4 rollout to $T=100$, Model A's mean energy drift is $(9.08\pm7.69)\times10^{-3}$ and grows with horizon, whereas Model B's is $(2.16\pm0.90)\times10^{-4}$ and saturates by $T=5$, remaining bounded through $T=100$. The ratio of means at $T=100$ is $42\times$ for energy drift and $15.8\times$ for trajectory MSE. Across initial-energy terciles, Model A's mean drift increases by about $4\times$, while Model B's increases by about $2\times$ and remains below $3.2\times10^{-4}$. The architectural advantage also transfers to the 3D Kepler problem. At $T=10$, the HNN shows $8.0\pm1.0\times$ lower energy drift, $4.2\pm0.5\times$ lower angular-momentum drift, and $5.5\pm0.8\times$ lower trajectory MSE than the parameter-matched standard NN. Angular momentum is not explicitly included in the training loss, so the lower drift provides an additional empirical structural diagnostic. \vspace{-0.5em} \section*{3\quad Explicit Verlet diagnostic} \vspace{-0.35em} The standard velocity-Verlet splitting is symplectic for separable Hamiltonians $H(q,p)=T(p)+V(q)$. Our HNN instead learns a generic scalar $\widehat H(q,p)$ and is not architecturally constrained to this separable form. Consequently, the standard velocity-Verlet symplecticity guarantee does not directly apply to the learned Hamiltonian. In the auxiliary diagnostic, HNN+Verlet exhibits approximately $2.7\times$ larger long-horizon energy drift than HNN+RK4. Two remedies are to explicitly parameterize a separable Hamiltonian $\widehat H(q,p)=\widehat T(p)+\widehat V(q)$, or retain a generic HNN and use a symplectic method applicable to general Hamiltonians, such as implicit midpoint.
Chat is not available.
Successful Page Load