Applying Lagrangian Mechanics
From Rigid Body Dynamics we learned that a mechanical system is described by generalized coordinates , velocities , and Lagrangian . Real motion is one that satisfies the Least Action Principle/Euler-Lagrange Equations. For rigid bodies, is not just a vector in but inside configuration space .
The theme was that mechanics is geometry (linear algebra) plus variational principles (calculus). This document takes that idea and applies it numerically to simulate physics.
Simple Numerical Methods
Standard numerical methods for solving ODEs (e.g. Forward Euler Method, or RK4) look at at a specific point in time and try to blindly guess the next geometric slope. A variational integrator is a numerical method that tries to preserve the underlying geometric structure of the system. It defines the total physical energy of the system across a span of time (“discrete action”) and uses calculus to find the trajectory that minimizes this energy over time (least action paths).
In particular, we see that in this example, when is larger (i.e. ), the system is stable in “asteroid belts”. Although the system is a good approximation, as it never explodes, it is still only an approximation. We can improve the accuracy of the system by replacing the RHS of the example with
where calculates the angle of a complex number in the complex plane. The result is that the system is stable for all , and removes the “asteroid belts” that we see in the previous example.

This image represents the exact trajectories on the position-momentum plane, where is the axis and is the axis.
Störmer-Verlet Method
What if instead of discretizing an ODE, what if we discretize the action and take the variational derivative to get the equations of motion?
Main Idea
Standard numerical methods look at the slope of the next discretized point. A variational integrator says “among all discrete paths, which one makes the discrete action stationary?”
Let denote the discrete timestep. A discrete Lagrangian is a function
approximating the total action between two positions. The continuous Lagrangian is Kinetic Energy minus Potential Energy:
Since we simulate this, time is broken up into steps of size . The discrete Lagrangian via the trapezoidal rule (from Calculus 1!) is:
So, the discrete total action of a path is
or the sum of all the discrte Lagrangian segments. Remember, we want to find the minimum of these segments.
Functional
Recall that this is the total action functional seen in here but discretized (approximating a curve with small segments)!
By the discrete least action principle, for all . We can derive this similar to how we showed the LAP. Let
Then to apply LAP, we need to find a stationary point where small pertubations to the path do not change the total action. We need to find the first variation (the derivative via multivariable chain rule) denoted as and setting it to .
The second term can be rewritten as
such that
But for this to equal , the inside terms must equal exactly.
We can now compute the first derivative of with respect to gives us
implying that
Let
This is different from RK41
This gives us an explicitly timestep march, where and so
Why is this better than RK4?
The idea is that variational integrators preserve the geometric structure of the shape of motion in configuration space better than generic ODE solvers.
Stability
See prior image. The Störmer-Verlet method is the variational integrator on the right. We see a cleaner phase portrait.
Discrete Euler-Lagrange Equation
The discrete Euler-Lagrange equation is the stationarity condition for the discrete action
For each interior index , varying while keeping the endpoints fixed gives
This is the discrete analogue of the continuous Euler-Lagrange equation. In particular, it is the general variational principle from which methods such as Störmer-Verlet Method are derived.
Interpretation
The two terms represent the two discrete action contributions meeting at the node : one contribution comes from the interval , and the other comes from the interval . Their sum vanishes because the discrete path is stationary with respect to variations of the interior point .
This is the discrete counterpart of the continuous idea that momentum is obtained from the velocity derivative of the Lagrangian:
Accordingly, the discrete Lagrangian defines two discrete Legendre transforms
by replacing the velocity description with a pair of nearby configurations. Define (the contangent bundle) by
The quantity
is the left discrete momentum at (contribution from previous state), and
is the right discrete momentum at (contribution to next state). The discrete Euler-Lagrange equation is exactly the matching condition
In terms of the maps and , this says
Therefore, if is locally invertible2, we can solve for the next pair from the previous pair by applying and then . This gives the marching rule
Thus the discrete EL equation gives an update map on , and through the maps it also induces the corresponding update on phase space . We can visualize this as
The space corresponds to the axes in the image.
Variational Integrators via Midpoint Rule
The midpoint rule is a variational integrator where the discrete Lagrangian is
The Euler-Lagrange equation is
and equivalently,
which is the implicit midpoint method. It is implicit because appears on both sides, so we cannot write a simple rule for it like in Störmer-Verlet Method.
Discrete Liouville Theorem
Marching on space preserves the enclosed area of the marched loop. In particular, the area is a section on the graphs we see above. This means that all possible positions and momentum are conserved as the system evolves over time.
The path the system takes between all the points may change, but the area of the path is preserved (even if the shape is complex). This geometric property is called symplecticity and is a consequence of the variational principle. This is precisely why variational integrators are better than generic ODE solvers: they preserve the underlying geometric structure of the system, which leads to better long-term stability and accuracy in simulations.
Discrete Noether’s Theorem
If the discrete Lagrangian has a continuous symmetry,
then is conserved (constant independent of ).
For example, if we let a particle move along a wire in empty space and then translate the entire system, the Lagrangian is invariant to this translation. Mathematically, let be a constant vector representing the direction of symmetry, and let be the start and be the end of a discrete segment. The translation is by some amount along is .
Because the Lagrangian is invariant to this translation, we have its derivative with respect to must be .
By the chain rule, this is equivalent to
Indeed, this is true for all and because of the symmetry.
We can show this is true for momentum. Recall from earlier that the discrete momentum entering the current step and leaving the current step 3 are
Substituting into the symmetry condition gives us
Indeed, momentum along the direction of symmetry is conserved across all steps .
Idea
This article gives a nice intuitive explanation of Noether’s theorem and how the ideas from Lagrangian Mechanics are used to show symmetry.
Definition (Time Reversal Symmetry)
In classical physics, the equations of motion are invariant under time reversal. If our discrete integrator satisfies the property that
then we say it is time-reversal symmetric. Indeed, the Störmer-Verlet Method is time-reversal symmetric.
Footnotes
-
Why? ↩
-
Here, “locally invertible” means that near a regular point, the phase-space data uniquely determines a nearby next configuration . For the mechanical discrete Lagrangians used in this note, this holds whenever the discrete Lagrangian is regular, which is typically true for sufficiently small timestep . ↩
-
The negative sign is from the original Discrete Euler-Lagrange equation as described previously. ↩