Jump to content

Lagrangian and Hamiltonian Neural Networks

From The Invariance Itself

Lagrangian and Hamiltonian Neural Networks: Learning an Action from Trajectories

Added to the survey on 2026-10-06 by the Research Toolkit's research pass. The scores below are that pass's assessment from the evidence cited under References, on the survey's four axes and scale; they are not the original survey's (2026-09-26), and no rule of the Principia Machina reads them. See the additions on the front page.

Overview & Architectural Fit

A Lagrangian neural network parameterizes a scalar Lθ(q,q˙) with a network and gets the dynamics from the Euler-Lagrange equations by automatic differentiation; a Hamiltonian neural network parameterizes Hθ(q,p) and uses Hamilton's equations, q˙=∂H/∂p, p˙=−∂H/∂q. Either way, energy conservation is built into the model rather than learned. They are the only tools in the survey that learn the Lagrangian or Hamiltonian itself as a network, with its structure built in; PySR, by contrast, searches for a symbolic one. The Lagrangian network's reference code is in JAX; the Hamiltonian network's is in PyTorch.

Mathematical Evaluation for TPM

  • Lagrangian / Action (8/10): Learns L itself as a network; the accelerations follow as q¨=(∇q˙∇q˙⊤L)−1[∇qL−(∇q∇q˙⊤L)q˙].
  • Field / PDE (2.5/10): The reference code targets finite-dimensional systems; fields would need graph or grid architectures.
  • Relativity (2/10): Nothing specific to relativity.
  • Quantum / Data (7/10): Learning from data is the core, for classical systems only.

Integration Pipeline

  1. Fit Lθ to trajectory data, and an unstructured network to the same data as a control.
  2. Test whether the learned Lagrangian reproduces the dynamics and conserves energy where the control does not: evidence that the data come from an action.
  3. Look for cyclic coordinates (∂L/∂qi≈0), which predict conserved momenta to confirm in the data.
  4. Distil a symbolic Lagrangian from the network with PySR.

Status, Licence and Limits

  • Status: Frozen research reference code with no releases; the Lagrangian network's README keeps the original versions to reproduce the paper's environment.
  • Licence: Apache-2.0 for both reference repositories.
  • Home: https://github.com/MilesCranmer/lagrangian_nns and https://github.com/greydanus/hamiltonian-nn
  • Limits: A Lagrangian is not unique (total time derivatives, overall scale), so a learned one is identified only up to equivalence. The inverse of the Hessian ∂2L/∂q˙2 can be ill-conditioned. Dissipative or driven systems need extensions beyond the original papers. The publication venue of the Lagrangian network paper is not confirmed.

On the Principia Machina

A tool runs only where the sponsor installed and bound it, and what it returns is untrusted input, vetted before use; its numbers are never values of the site's calculator, TPC. A law it finds is not a register record: it can enter only as the kernel of a new container, and the data it was fitted to can never be the outside value of that law's verification. See Agent/Tools and the operator's guide.

References

  • LNN2020 – Cranmer M., Greydanus S., Hoyer S., Battaglia P., Spergel D., Ho S. (2020). Lagrangian Neural Networks. arXiv:2003.04630.
  • HNN2019 – Greydanus S., Dzamba M., Yosinski J. (2019). Hamiltonian Neural Networks. NeurIPS 2019, 15353–15363. arXiv:1906.01563.