# Leapfrog is Symplectic for the Harmonic Oscillator

Microcanonical molecular dynamics describes the motion of molecules using the Hamiltonian mechanics framework. Hamiltonian dynamics are symplectic, meaning that they preserve volume in phase space. The symplectic property relates to properties we learned in first-semeter college physics such as conservation of energy.

The harmonic oscillator is a simple symplectic model, useful for study. A plot of the path through phase space of our analytical derivation of the harmonic oscillator, demonstrates the symplectic property:

Symplectic integrators are important for bounding errors in the trajectories and resulting statistics such as transition rates^{1}. Ge and Mardsen showed that if an integrator is symplectic, then the integrator can only conserve energy exactly if it computes the exact trajectory except for a reparameterization in time. Since the error in the energy is bounded, the error of statistics calculated from trajectories are bounded.

The bound would seem to contradict our results from the analyses of the local and global truncation errors. These analyses indicate that the errors in energy and other statistics computed from the trajectories would grow without bound. It turns out that symplectic integrators **exactly** simulate *shadow Hamiltonians*, which are perturbations of the original Hamiltonians. Thus, we can use the energy and other statistics from the shadow Hamiltonian as approximations to the values for the true Hamiltonian.

Additionally, the relationship between the bounds on the errors in the energy and the trajectories implies that the error in energy can be used as a measure of error for the trajectories. For example, unbounded inncreases or decreases in the energy from a simulation are indicative of an incorrect implementation of a symplectic integrator.

Unfortunately, the mathematical definition of the symplectic property and its relation to properties like the conservation of energy are expressed using advanced areas of math such as differential geometry. Fortunately, it is much easier to prove that an integrator is symplectic than it is to state the definition of symplectiness.

## Hamiltonian Dynamics

We’re going to start with a detour. Symplectiness is described using the language of Hamiltonians and flows, so we’ll describe some basics and show how Hamiltonians relate to Newton’s equations of motion.

The Hamiltonian is a function that takes the positions and momenta . The form of the Hamiltonian commonly used in molecular dynamics is a linear combination of the kinetic and potential energies:

We can describe the dynamics of the Hamiltonian system using a pair of first-order differential equations:

The system of two first-order ODEs can be rewritten as a single second-order ODE:

By re-arranging the mass term, we get the form of Newton’s equations of motions we expect:

Thus, the Hamiltonian system is an equivalent description to Newton’s equations of motion.

## Symplectic Maps / Dynamical Systems

We can define a map that updates the state of the system over a length of time :

Let be the Jacobian matrix of :

The map is symplectic if its Jacobian satifies:

where

## Harmonic Oscillator is Symplectic

We now have the basic tools for describing Hamiltonian systems and proving symplecticness. Let’s apply these tools. As a Hamiltonian system, the map for the harmonic oscillator is symplectic. To demonstrate the proof of symplectiness for map, we will start by validating the analytical map for the harmonic oscillator is symplectic. The Hamiltonian is defined as follows:

The corresponding map for the system is given by

with Jacobian

With a bit of arithmetic, we see that the map satisfies the criteria for symplectiness:

Thus, the analytical harmonic oscillator map satisfies the conditions for symplectiness as expected.

## Leapfrog for Harmonic Oscillator

Next, we will prove that the Leapfrog method is symplectic for the harmonic oscillator system.

In our previous blog post, we derived the Leapfrog integrator. We reproduce it here, with the substitutions and to be consistent with the notation used in this blog post. We’ll re-arrange the integrator into two equations, one for and another for , so that we can form the flow equation . We will then use the Jacobian to prove that the Leapfrog integrator is symplectic.

We substitute the potential

into and of the integrator equations:

We substitute and into and , reducing our system to two equations:

We substitute into to get and in terms of and only:

Thus, we can form the flow as

with Jacobian

where

Note that we denote the map as since it is an **approximation** to the true flow . We then substitute the Jacobian into the equation for the conditions of symplectiness and solve:

where

and

Thus, the Leapfrog method is symplectic for the harmonic oscillator system.

## Conclusion

In this blog post, we covered the basics of symplectic Hamiltonians and maps. We described concepts and notation from Hamiltonian dynamics and showed how they relate to the second-order differential equations used for Newton’s equations of motion. We then discussed the conditions for proving a map is symplectic.

We then applied the framework to two problems. First, we demonstrated the approach by proving that the harmonic oscillator is symplectic. Next, we showed that the Leapfrog integrator, which is an **approximate** map, is symplectic for the harmonic oscillator.

We covered a lot of material, but we have even more to cover in the future. First and foremost, we want to prove that the Leapfrog method is symplectic for all Hamiltonians, or at least those of the form we use in molecular dynamics. We also want to dive into differential geometry and better understand the definition for symplectiness and the relationship with the conditions we expressed above.

We also want to better understand the implications of symplectiness for simulation. In particular, we mentioned that symplectiness guarantees a bound on the error in energies and other statistics computed from the resulting trajectories. We want to better understand this relationship and examine the proofs around the relationships.

1: I’ve used papers by Donnelly and Rogers, Leimkuhler, Reich, and Skeel, Sanz-Serna, Skeel, and Yoshida as guides for this blog post.