Learning the mechanics, not just the motion
A standard neural network can directly map a state to its time derivative. LNNs and HNNs instead predict a scalar mechanical function first, then use in-network derivatives of that learned function to reproduce the observed dynamics.
The Lagrangian model learns a function of position, velocity, and, when needed, time. The Hamiltonian model learns a function of position, momentum, and time. Their gradients are then constrained by the Euler-Lagrange or Hamilton equations.
This lets us ask a more interesting question than whether the trajectory is accurate: what hidden physical function did the network actually recover?