Embedding Lagrangian Mechanics into Neural Network Architectures

23 concepts19 papers1 proposal

When modeling physical systems—such as a maneuvering robot arm, a folding molecule, or a cluster of interacting particles—standard "black-box" neural networks face a fundamental challenge. Even with massive amounts of data, a vanilla multilayer perceptron (MLP) or recurrent neural network easily violates basic physical laws. It might predict that a system spontaneously creates energy, loses momentum, or passes through solid objects.

To prevent these unphysical predictions, a growing body of research shifts the learning target. Instead of training a network to directly predict a system's next state or acceleration vector, these architectures embed the laws of classical mechanics directly into the neural network's computational graph. By forcing the network to learn fundamental physical quantities like kinetic and potential energy, the resulting models satisfy conservation laws and physical symmetries by design.

The Core Intuition: Learning Energies Instead of Trajectories

To understand why this approach works, consider a system with generalized coordinates $q$ (positions) and velocities $\dot{q}$. A standard deep learning approach treats the mapping from current state to acceleration as an unconstrained regression problem:

$$\ddot{q} = f_\theta(q, \dot{q}, u)$$

where $u$ is an control input and $\theta$ represents the network weights. Because $f_\theta$ can approximate any function, the network must dedicate significant capacity just to learn that energy should be conserved.

In contrast, Lagrangian mechanics dictates that the behavior of a conservative physical system is entirely determined by a single scalar function called the Lagrangian, $L = T - V$, where $T$ is the kinetic energy and $V$ is the potential energy. The path the system takes through space must satisfy the Euler-Lagrange equation:

$$\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{q}}\right) - \frac{\partial L}{\partial q} = \tau$$

where $\tau$ represents external forces or control torques.

By parameterizing $L$ (or its constituent parts $T$ and $V$) with neural networks, we can use automatic differentiation to compute the exact partial derivatives $\frac{\partial L}{\partial \dot{q}}$ and $\frac{\partial L}{\partial q}$. We then analytically solve the Euler-Lagrange equation for the acceleration $\ddot{q}$.

This architectural constraint drastically shrinks the model's hypothesis space. The network is structurally incapable of exploring physically impossible states because any output it generates is passed through the crucible of classical mechanics. As emphasized by Souvik Chakraborty et al. in Discovering interpretable Lagrangian of dynamical systems from data, identifying the system's Lagrangian rather than its raw equations of motion automatically yields conserved quantities through Noether’s Theorem, providing a robust physical foundation that generalizes far better than direct trajectory fitting.

Deep Lagrangian Networks and the Manipulator Equation

A foundational realization of this paradigm is the Deep Lagrangian Network (DeLaN) framework, introduced by Michael Lutter et al. in Deep Lagrangian Networks: Using Physics as Model Prior for Deep Learning. The authors structure the network to output the components of the standard robot manipulator equation:

$$M(q)\ddot{q} + C(q, \dot{q})\dot{q} + g(q) = \tau$$

Here, the neural network explicitly parameterizes the mass matrix $M(q)$—forcing it to be positive-definite via a Cholesky decomposition—and the scalar potential energy $V(q)$, from which the gravity vector $g(q) = \nabla_q V(q)$ is derived. The Coriolis and centrifugal forces $C(q, \dot{q})\dot{q}$ are calculated analytically from the partial derivatives of $M(q)$ using Christoffel symbols.

State (q, q_dot) ───► [ Neural Network ] ───► Mass Matrix M(q) & Potential V(q)
                                                      │
                                                      ▼
                                            [ Autograd / Physics ]
                                                      │
                                                      ▼
                                            Predicted Torques (τ)

In a follow-up work, Michael Lutter et al. demonstrated in Deep Lagrangian Networks for end-to-end learning of energy-based control for under-actuated systems that this structure allows robots to learn complex control laws for under-actuated systems (like swinging up a pendulum) directly from sensor data without manual physics derivations.

Building on this, Mykel Kochenderfer et al. developed Structured Mechanical Models (SMMs) in Structured Mechanical Models for Robot Learning and Control, showing that decomposing system dynamics into separate learnable components for inertia, potential energy, and dissipative forces allows models to generalize to unseen states with up to 1,000x less error than standard black-box networks. To handle real-world variations like picking up unknown payloads, Lucas Schulze et al. introduced Context-Aware Deep Lagrangian Networks for Model Predictive Control, combining the structural priors of DeLaN with a recurrent history encoder to adapt to changing physical properties in real time.

Variational Integrators: Preserving Geometry in Discrete Time

While continuous-time formulations are elegant, computers must simulate dynamics in discrete time steps. Standard numerical integration schemes (like Euler or Runge-Kutta integration) introduce artificial energy drift over long horizons, causing simulated systems to unrealistically blow up or damp out.

To solve this, Steindór Sæmundsson et al. in Variational Integrator Networks for Physically Structured Embeddings and Alexander Terenin et al. in Variational Integrator Networks for Physically Meaningful Embeddings proposed Variational Integrator Networks (VINs). Instead of parameterizing a continuous Lagrangian, VINs structure neural network layers to mirror discrete-time equations of motion derived from a discrete variational principle (the principle of least action applied to discrete steps).

By forcing the network updates to follow a discrete-time variational integrator, VINs guarantee that geometric properties like total energy and momentum are conserved exactly across time steps. This architectural constraint enables highly accurate long-term predictions and exceptional data efficiency, even when learning physical representations directly from raw pixel inputs.

Hamiltonian Neural ODEs and Stability Guarantees

An alternative, closely related perspective uses Hamiltonian mechanics instead of Lagrangian mechanics. The Hamiltonian $H(q, p) = T + V$ describes a system in terms of positions $q$ and generalized momenta $p$. The equations of motion are given by a system of first-order differential equations:

$$\dot{q} = \frac{\partial H}{\partial p}, \quad \dot{p} = -\frac{\partial H}{\partial q}$$

By embedding this structure into a Neural Ordinary Differential Equation (Neural ODE) framework, researchers can learn continuous-time physical systems with built-in stability properties. For example, Abdullah Altawaitan et al. demonstrated in Hamiltonian Dynamics Learning from Point Cloud Observations for Nonholonomic Mobile Robot Control that embedding Hamiltonian mechanics into Neural ODEs allows mobile robots to learn energy-consistent dynamics directly from raw LiDAR point clouds, bypassing noisy state estimation pipelines.

The primary advantage of the Hamiltonian formulation in control loops is that the learned total energy $H(q, p)$ acts as a natural, physically meaningful Lyapunov function. In Safe Autonomous Navigation for Systems with Learned SE(3) Hamiltonian Dynamics, Zhichao Li et al. exploited this property to guarantee safe robot navigation. By using the learned Hamiltonian structure for "energy-shaping" control, the authors mathematically proved system stability, forcing a robot to adaptively slow down near obstacles and speed up in open spaces, ensuring safety even when the environment's exact physics were initially unknown.

Scaling to Graphs, Particles, and Latent Spaces

The principle of embedding physical invariants extends far beyond rigid-body robotics. For multi-particle systems, Ravinder Bhattoo et al. developed the Lagrangian Graph Neural Network (LGnn) in Learning the dynamics of particle-based systems with Lagrangian graph neural networks. By mapping particles to nodes and interactions to edges within a graph, the network learns a global, parameterized Lagrangian. This allows the model to scale and generalize to systems two orders of magnitude larger than those it was trained on.

Similarly, in molecular modeling, Ziyao Li et al. integrated Hamiltonian dynamics into graph neural networks in Conformation-Guided Molecular Representation with Hamiltonian Neural Networks to reconstruct physically plausible 3D molecular conformations from 2D graphs by simulating atoms reaching a stable, low-energy state.

Even when the true physical coordinates are completely hidden, researchers can force abstract latent spaces to behave like mechanical systems:

Practical Tradeoffs and Real-World Non-Idealities

While structurally elegant, pure Lagrangian or Hamiltonian formulations introduce practical challenges when applied to real-world systems with non-conservative forces. In Newtonian and Lagrangian Neural Networks: A Comparison Towards Efficient Inverse Dynamics Identification, Andreas René Geist et al. compared Newtonian and Lagrangian neural networks for industrial robot control. The authors noted that Newtonian formulations (such as combining the Recursive Newton-Euler Algorithm with MLPs) can sometimes handle complex, non-conservative dissipative forces like joint friction more easily because friction is often bundled directly into motor torque measurements rather than derived from an energy potential.

To bridge this gap, modern frameworks combine physics-informed structural priors with residual learning architectures. For example, the OSCAR framework developed by Josiah Wong et al. in OSCAR: Data-Driven Operational Space Control for Adaptive and Robust Robot Manipulation integrates Lagrangian mechanics constraints alongside a data-driven residual network. This hybrid approach ensures the model captures unmodeled real-world effects like friction and aerodynamic drag while retaining the high sample efficiency and stability guarantees provided by the underlying physical architecture.

Key Foundational Work

Deep Lagrangian Networks for end-to-end learning of energy-based control for under-actuated systems (2019) — contributed 1 concept elements to this direction.
Structured Mechanical Models for Robot Learning and Control (2020) — contributed 1 concept elements to this direction.
Variational Integrator Networks for Physically Structured Embeddings (2020) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_lagrangian_constrained_neural_dynamics_0f7cbdf5,
  title = {Lagrangian-constrained neural dynamics},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/lagrangian-constrained-neural-dynamics/rdr_0f7cbdf56710403aa51cd2e16e2ce8f4},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-19},
}

This exact version (version 1, frozen text):

@misc{lacuna_lagrangian_constrained_neural_dynamics_0f7cbdf5_v1,
  title = {Lagrangian-constrained neural dynamics},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/lagrangian-constrained-neural-dynamics/rdr_0f7cbdf56710403aa51cd2e16e2ce8f4/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-19},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake