A matched-integrator evaluation of Hamiltonian neural networks on pendulum and Kepler dynamics

arXiv:2608.10235 · cs.LG · Submitted 2026-08-10 · Read on arXiv

Lenick Kemunto Nyabuto, Yae Ulrich Gaba, Birahim Tewe

African Institute for Mathematical Sciences (AIMS) Senegal

cs.LG

Submitted: 2026-08-10

Updated: 2026-08-12

Comments: 14 pages, 10 figures, 7 tables

License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/

Importance score: 75/100

The gist: This paper presents a controlled evaluation of Hamiltonian Neural Networks (HNNs) against parameter-matched standard feedforward neural networks on two conservative dynamical systems: the nonlinear

Terminology

Summary

This paper presents a controlled evaluation of Hamiltonian Neural Networks (HNNs) against parameter-matched standard feedforward neural networks on two conservative dynamical systems: the nonlinear pendulum and the three-dimensional Kepler two-body problem.

The authors establish a matched-integrator protocol in which an HNN and a parameter-matched feedforward baseline are trained on the same RK4-generated trajectories, use the same central-difference derivative targets and optimization settings, and are integrated at inference with the same RK4 scheme. Results are reported over five independent training seeds (seeds 42–46).

Model A is a standard feedforward network mapping (q, p) → (q̇, ṗ) directly, with architecture 2 → 64 → 64 → 64 → 2, tanh activations, and 8,642 trainable parameters. Model B is a Hamiltonian NN with a scalar network Ĥθ: R2 → R, architecture 2 → 64 → 64 → 64 → 1, tanh activations, and 8,577 trainable parameters (65 fewer than Model A). The vector field is derived via automatic differentiation of Hamilton's equations: q̇ = ∂Ĥ/∂p, ṗ = −∂Ĥ/∂q.

Both models are trained with Adam (learning rate 10−3, batch size 512, 300 epochs, float64 precision), using second-order central-difference derivative targets from RK4-generated trajectories with ∆t = 10−2. The training data consists of 100 initial conditions from U([−1,1] × [−1,1]) restricted to the librational regime (H0 < 2), split 70/15/15 into train/validation/test sets.

The HNN achieves validation derivative MSE of (7.69 ± 2.06) × 10−8 versus (1.35 ± 0.43) × 10−7 for the standard NN—a 1.8× improvement despite having 65 fewer parameters.

At T = 2, mean trajectory MSE is (3.12 ± 1.36) × 10−7 (Model A) versus (1.42 ± 0.97) × 10−7 (Model B), a ratio of 2.2×.

The ratio of mean trajectory MSE grows non-monotonically from 2.2× at T = 2 to 15.8× at T = 100 (approximately 16 pendulum periods). At T = 100, Model A's trajectory MSE is (3.49 ± 5.23) × 10−3 versus (2.21 ± 1.27) × 10−4 for the HNN.

For energy drift, the HNN reduces mean energy drift by 42× at T = 100. Model A's drift grows monotonically from 2.75 × 10−4 at T = 2 to 9.08 × 10−3 at T = 100 (a factor of 33×). Model B's drift saturates by T = 5 at 2.16 × 10−4 and stays flat through T = 100. The HNN's drift is also tighter across seeds (σ/µ ≈ 42%) versus the standard NN (σ/µ ≈ 85%).

Test trajectories bucketed by initial energy into terciles show that Model A's mean drift grows by 4.3× from low- (4.16 × 10−4) to high-energy (1.78 × 10−3) buckets, while the HNN's drift grows only 2.5× (1.26 × 10−4 to 3.12 × 10−4) and never exceeds 3.2 × 10−4. The architectural advantage widens in more nonlinear regions of phase space.

On a 200 × 200 grid over (q, p) ∈ [−1, 1]2, the mean-centred learned Hamiltonian matches the analytical one to RMSE 7.3 × 10−5 and L∞ error 2.0 × 10−4 (0.01% and 0.02% of the Hamiltonian range). The gradient error has mean 3.0 × 10−4 (0.04% of the true gradient norm).

At Ntraj = 8, the standard NN outperforms the HNN by approximately 2×. At Ntraj = 16, the HNN pulls ahead 3×; at Ntraj = 32, by 5.3×; at Ntraj = 64, by 2.7×. This suggests a low-data crossover below which estimating a Hamiltonian-gradient field is more difficult.

On a single CPU core with float64 precision, RK4 with the analytical vector field costs 85 ± 46 µs per step; Model A costs 801 ± 238 µs; Model B with RK4 costs 2,193 ± 524 µs; Model B with Verlet costs 1,370 ± 335 µs. The learned surrogates are slower than analytical RK4 on this 1-DOF benchmark.

The paper examines an explicit Störmer–Verlet-style rollout of the learned HNN. Because the learned Hamiltonian is not constrained to the separable form H(q, p) = T(p) + V(q), the standard symplecticity guarantee of velocity Verlet does not directly apply. At T = 100, the diagnostic energy drift is 7.71 × 10−4 versus 2.89 × 10−4 for HNN+RK4 on the same seed—a factor of approximately 2.7 worse. The authors interpret this as an integrator-compatibility diagnostic, not a genuinely symplectic integration. They discuss two remedies: explicitly parameterizing Ĥ(q, p) = T̂(p) + V̂(q) for velocity-Verlet compatibility, or using a symplectic integrator for general Hamiltonians (e.g., implicit midpoint). They relate this to SympNets, which construct symplectic neural maps directly.

The same protocol is applied to the 3D Kepler problem with Hamiltonian H(q, p) = ½∥p∥2 − 1/∥q∥, with q, p ∈ R3. Phase space is six-dimensional, and the system conserves energy and the full angular-momentum vector L = q × p.

Both models are widened to 6 → 128 → 128 → 128 → 6, 1 with tanh activations (34,694 and 34,049 trainable parameters). Training uses 60 trajectories of length T = 6 at ∆t = 10−2 with near-circular initial conditions (q0 on spheres of radius r0 ∈ [0.9, 1.4], p0 perpendicular to q0 with circular-orbit speed perturbed by ±25%).

At T = 10, the HNN's energy drift is 8.0 ± 1.0× smaller (4.20 ± 1.4 × 10−2 versus 3.26 ± 0.80 × 10−1), its angular-momentum drift is 4.2 ± 0.5× smaller (1.82 ± 0.41 × 10−1 versus 7.63 ± 1.8 × 10−1), and its trajectory MSE is 5.5 ± 0.8× smaller (6.09 ± 0.86 × 10−1 versus 3.27 ± 0.20). Angular momentum is not included explicitly in the training loss, so the smaller drift suggests the learned Hamiltonian approximately captures part of the rotational structure of the Kepler dynamics.

  1. Controlled matched-integrator comparison: HNN reduces mean long-horizon energy drift by 42× and mean trajectory MSE by 15.8× at T = 100 on the pendulum, with tight seed-to-seed variance on the HNN column and broad variance on the standard-NN column.

  2. Bounded-versus-growing signature: The HNN's energy drift saturates by T = 5 near 3 × 10−4 and stays there through T = 100; the standard NN's drift grows monotonically from 5 × 10−4 to 2 × 10−2.

  3. Energy-stratified analysis: The standard NN's drift grows ∼5× from low- to high-energy terciles while the HNN's grows only ∼2× and never exceeds 3 × 10−4.

  4. Computational-cost comparison: Wall-clock per-step and per-rollout costs reported for all four inference paths; learned surrogates are slower than analytical RK4 on this benchmark.

  5. Negative result on HNN + Verlet: A Störmer–Verlet rollout of the trained HNN does not improve on HNN + RK4 at long horizon because the learned Hamiltonian is not constrained to separable form.

  6. Transfer to 3D: The architectural advantage transfers to the Kepler problem with energy drift 8.0 ± 1.0× smaller, angular-momentum drift 4.2 ± 0.5× smaller, and trajectory MSE 5.5 ± 0.8× smaller at T = 10.

The authors explicitly name three limitations: (i) limited benchmark diversity (only two integrable conservative systems, no chaotic, non-integrable, dissipative, stochastic, or many-body dynamics); (ii) baseline choice (only compared against a standard MLP, not LNNs, Neural ODEs, equivariant models, or SympNets); (iii) compute setting (single-CPU, float64 only, no GPU or mixed-precision characterization).

The paper concludes that under a controlled matched-integrator protocol, the HNN reduces mean long-horizon energy drift by 42× and mean trajectory error by 15.8× over a parameter-matched standard NN on the nonlinear pendulum, with bounded rather than growing drift and substantially lower seed-to-seed variability. The structural advantage widens in more nonlinear pendulum regimes. The explicit-Verlet diagnostic shows that structure preservation cannot be inferred merely from combining a learned Hamiltonian with a method usually described as symplectic—the assumptions required by the numerical method must also be compatible with the learned Hamiltonian. The authors do not claim direct transfer to molecular dynamics or general many-body systems, stating that whether similar advantages persist for chaotic, non-integrable, noisy, dissipative, and many-body dynamics remains an empirical question.

Improvements for AI systems

Improvement 1: Physics-Structured Neural Architectures with Energy-Bounded Inference

  • What to build: A hybrid neural network that combines a standard feedforward backbone with a Hamiltonian-constrained output layer (via automatic differentiation) and an explicit energy-conservation regularizer.

  • Capability gained: The system predicts time evolution of conservative systems with bounded energy drift (saturating near 3×10−4) instead of monotonically growing drift (up to 9×10−3), and reduces long-horizon trajectory error by 15.8× over parameter-matched baselines. This enables reliable long-horizon simulation (e.g., 100 pendulum periods) without divergence.


Improvement 2: Data-Efficiency-Aware Training Scheduler

  • What to build: An adaptive training pipeline that detects the low-data crossover point (e.g., Ntraj < 16 for pendulum) and switches between direct vector-field regression and Hamiltonian-gradient regression based on dataset size.

  • Capability gained: The system achieves 3–5.3× better accuracy than standard NNs when training data is moderate (16–64 trajectories), while avoiding the 2× performance penalty in ultra-low-data regimes (8 trajectories). This makes physics-aware models practical for scientific domains with scarce experimental data.

Improvement 3: Integrator-Compatibility-Aware Model Selection

  • What to build: A model-selection framework that tests learned Hamiltonians for separability (H(q,p)=T(p)+V(q)) and automatically chooses between explicit Verlet (if separable) and RK4/implicit midpoint (if non-separable).

  • Capability gained: The system avoids the 2.7× energy-drift penalty observed when applying Verlet to non-separable learned Hamiltonians. It can either enforce separability via architectural constraints (e.g., two subnetworks) or select a symplectic integrator that matches the learned structure, ensuring long-horizon stability across integrator choices.

Improvement 4: Multi-Conservation-Law Neural Surrogate

  • What to build: An extension of HNNs that adds auxiliary output heads or loss terms for conserved quantities beyond energy (e.g., angular momentum vector L = q×p).

  • Capability gained: The system reduces angular-momentum drift by 4.2× and trajectory MSE by 5.5× on 3D Kepler problems without explicitly training on L, implying implicit capture of rotational symmetries. This enables accurate simulation of orbital mechanics and rigid-body dynamics where multiple invariants must be preserved.

Improvement 5: Uncertainty-Aware Physics Surrogate

  • What to build: A Bayesian or ensemble version of the HNN that outputs predictive variance for energy drift and trajectory error, calibrated across random seeds.

  • Capability gained: The system provides reliable confidence intervals (e.g., HNN drift σ/µ ≈ 42% vs. standard NN ≈ 85%), allowing users to distinguish trustworthy predictions from high-variance ones. This is critical for safety-critical applications like spacecraft trajectory planning or long-term climate modeling.

Improvement 6: Energy-Stratified Adaptive Sampling

  • What to build: A training-data sampler that oversamples initial conditions in high-energy, strongly nonlinear regions of phase space (where standard NNs degrade 4.3× but HNNs only 2.5×).

  • Capability gained: The system maintains consistent accuracy across the entire energy spectrum, preventing performance collapse in chaotic or highly nonlinear regimes. This improves generalization to out-of-distribution initial conditions in real-world dynamical systems.

Improved AI System Summary:

The enhanced system is a physics-aware neural simulator that:

  • Predicts conservative dynamics with bounded energy error and 15.8× better long-horizon accuracy than standard NNs.

  • Automatically adapts its training strategy to data availability and its integration scheme to learned Hamiltonian structure.

  • Preserves multiple invariants (energy, angular momentum) without explicit loss terms.

  • Provides calibrated uncertainty estimates for its predictions.

  • Maintains accuracy across energy strata and transfers to higher-dimensional systems (e.g., 3D Kepler) with 4–8× improvements in conserved-quantity drift.

This makes it suitable for long-term orbital mechanics, molecular dynamics pre-screening, and any domain requiring stable, uncertainty-aware simulation of conservative physical systems.

Sources

Related papers