Variational integrators are numerical integrators for Hamiltonian systems derived from the Euler–Lagrange equations of a discretized Hamilton's principle.
Variational integrators are momentum-preserving and symplectic.
Consider a mechanical system with a single particle degree of freedom described by the Lagrangian where
is the mass of the particle, and
To construct a variational integrator for this system, we begin by forming the discrete Lagrangian.
The discrete Lagrangian approximates the action for the system over a short time interval: Here we have chosen to approximate the time integral using the trapezoid method, and we use a linear approximation to the trajectory, between
, resulting in a constant velocity
Different choices for the approximation to the trajectory and the time integral give different variational integrators.
The order of accuracy of the integrator is controlled by the accuracy of our approximation to the action; since our integrator will be second-order accurate.
Evolution equations for the discrete system can be derived from a stationary-action principle.
The discrete action over an extended time interval is a sum of discrete Lagrangians over many sub-intervals: The principle of stationary action states that the action is stationary with respect to variations of coordinates that leave the endpoints of the trajectory fixed.
So, varying the coordinate
, we have Given an initial condition
, and a sequence of times
this provides a relation that can be solved for
The solution is We can write this in a simpler form if we define the discrete momenta, and Given an initial condition
, the stationary action condition is equivalent to solving the first of these equations for
This evolution scheme gives and This is a leapfrog integration scheme for the system; two steps of this evolution are equivalent to the formula above for