Part 3: Symplectic Integration - Geometry Over Accuracy
Module 3: ODE Methods & Conservation | COMP 521
Learning Objectives¶
By the end of this section, you will be able to:
Explain Hamiltonian mechanics and phase space structure
Prove symplecticity of leapfrog/Verlet methods
Understand modified Hamiltonians and bounded energy error
Implement symplectic integrators for conservative systems
Choose between accuracy and structure preservation
The Fundamental Insight¶
Symplectic integrator: A numerical method that preserves the symplectic structure (phase space volume and geometric properties) of Hamiltonian systems.
A symplectic integrator preserves the canonical two-form, a geometric constraint stronger than volume preservation in more than one degree of freedom. It still has truncation error: geometry and accuracy are both design criteria.
Symplectic maps preserve canonical phase-space volume in exact arithmetic.
A symmetric method such as fixed-step leapfrog is also time reversible; symplecticity alone does not imply reversibility.
Near-conservation of energy over long times needs smoothness, sufficiently small fixed steps, and a trajectory in a suitable bounded region.
Stability and accurate phase still need independent checks.
These distinctions let us ask a sharper question than “does it conserve physics?”: which property is exact for the discrete map, which is approximate, and over what regime have we checked it?
Hamiltonian Mechanics Refresher¶
Hamiltonian: A function that represents the total energy of a system, where are generalized coordinates and are conjugate momenta.
Before diving into symplectic integration, let’s recall the Hamiltonian formulation of mechanics. For a system with positions and momenta , the Hamiltonian represents total energy:
where is kinetic energy and is potential energy.
For a particle of mass in potential :
Hamilton’s equations govern the evolution:
These equations have remarkable properties:
Energy conservation: for time-independent
Phase space volume preservation: Liouville’s theorem
Symplectic structure: The flow preserves a geometric structure
The Phase Space Perspective¶
Phase space: The space of all possible states of a system, with position and momentum (or velocity) as coordinates.
In phase space, each point represents a complete state of the system. Trajectories follow contours of constant energy .

Figure 1:Phase space structure of Hamiltonian systems. (Left) Harmonic oscillator: closed orbits on energy surfaces. (Middle) Pendulum: separatrix divides oscillation from rotation. (Right) Liouville’s theorem: phase space volume is preserved under Hamiltonian flow—areas deform but don’t change size. This geometric structure is what symplectic integrators preserve, without by itself guaranteeing numerical stability for any step size.
Liouville’s Theorem¶
Liouville’s theorem: The phase space volume occupied by an ensemble of states is preserved under Hamiltonian evolution.
Liouville’s theorem states that phase space volume is preserved under Hamiltonian flow. Mathematically, for a volume element :
This is equivalent to saying the flow is incompressible. Standard numerical methods violate this theorem! They artificially compress or expand phase space, leading to systematic errors.
The Leapfrog/Verlet Method¶
The leapfrog method (also called Verlet or Störmer-Verlet) staggers position and velocity updates to preserve symplectic structure.
The Algorithm¶
For a Hamiltonian where :
Why “Leapfrog”?¶
Positions and momenta “leapfrog” over each other in time:
Time: t₀ t₁/₂ t₁ t₃/₂ t₂
| | | | |
Position: q₀ q₁ q₂
Momentum: p₁/₂ p₃/₂The symplectic argument comes from composing the exact kick and drift flows, not from staggered storage alone.
Implementation tips for an orbital calculation¶
Proof of Symplecticity¶
Symplectic condition: A transformation preserves phase space structure if its Jacobian satisfies where .
A transformation is symplectic if it preserves the symplectic 2-form. We’ll prove leapfrog is symplectic by showing each sub-step preserves the symplectic structure.
Step 1: Analyze Each Sub-step¶
The leapfrog map can be decomposed into three shear transformations:
First kick:
Drift:
Second kick:
Step 2: Show Each Shear is Symplectic¶
For the momentum kick :
The Jacobian is:
Verify the symplectic condition:
Similarly for the drift step.
Step 3: Composition Preserves Symplecticity¶
Since the composition of symplectic maps is symplectic:
is symplectic. Therefore, leapfrog preserves phase space structure exactly!
Volume Preservation¶
The determinant of each Jacobian is 1:
Phase space volume is exactly preserved, satisfying Liouville’s theorem.
The Modified Hamiltonian¶
Modified Hamiltonian: A formal nearby Hamiltonian whose flow approximates the discrete symplectic map order by order. Its series need not converge.
Backward error analysis expresses a symmetric second-order method through a formal series
For smooth problems, a suitable truncation describes a nearby flow; under analyticity and bounded-trajectory assumptions, sufficiently small fixed steps can give near-energy conservation over very long times. This is not a theorem that every symplectic method exactly conserves some global energy for every step and every orbit. Hairer, Lubich, and Wanner’s analysis.
An exact discrete invariant we can derive¶
For the unit-mass oscillator , kick–drift–kick leapfrog gives
Substitute these into the quadratic form
The cross terms cancel and in exact arithmetic. This is a special exact invariant of this linear map. It differs from the physical energy by
When , is positive definite, so it bounds both coordinates and the physical energy oscillates in a bounded band. At the stability boundary it loses positive definiteness; symplecticity has not disappeared, but the energy argument no longer works. This makes the step-size condition part of the explanation, rather than a footnote.

Figure 2:The oscillator at a fixed stable step separates physical energy from the leapfrog invariant . RK4 damps this example; leapfrog preserves up to floating-point effects. Both methods still accumulate phase error.
Higher-Order Symplectic Methods¶
Yoshida’s Fourth-Order Method¶
By composing leapfrog steps with carefully chosen timesteps, we can achieve higher-order accuracy while maintaining symplecticity. The coefficients come from solving order conditions to eliminate errors.
The strange values involving arise from the algebraic constraints of maintaining symplecticity while achieving fourth-order accuracy:
Let denote one whole second-order leapfrog step. Apply three steps, in order, with lengths , , and :
The coefficients satisfy (advance by total time ) and (cancel the leading symmetric composition error). The middle substep is negative; this is appropriate only when the component flows are defined for those signed substeps.
If we expand kick–drift–kick steps and merge adjacent kicks, the four kick coefficients are , while the three drift coefficients are . The four kick coefficients are not four whole-leapfrog-step lengths. Confusing these two levels loses fourth order.
Forest–Ruth and symmetric compositions¶
Forest–Ruth and Yoshida constructions belong to this family of fourth-order symmetric splitting methods. When comparing implementations, specify the actual kick/drift sequence: names alone do not identify the update ordering.
Compare diagnostics before choosing a method¶
Use the shared oscillator experiment to compare finite-time position, energy, and phase. A small bounded energy oscillation does not prove a small phase error, and higher order does not remove a method’s step-size restrictions. For an actual Kepler orbit, repeat the comparison at the required eccentricity and duration; the oscillator is a controlled benchmark, not evidence for a thousand-year Earth integration.
When to Use Symplectic Methods¶
| Problem Type | Requirement | Candidate method | What to verify |
|---|---|---|---|
| Conservative orbital model | Long-time dynamics | Suitable symplectic splitting | Encounters, step restriction, phase, and energy error |
| Satellite trajectory | Finite-time position accuracy | Adaptive RK | Position error over the requested duration and force-model adequacy |
| Collisionless galaxy model | Phase-space dynamics | Symplectic method for a compatible Hamiltonian | Force approximation, resolution, and conserved quantities |
| Conservative molecular dynamics | Statistical and dynamical observables | Verlet or another appropriate splitting | Fast modes, step size, and sampling of the intended observables |
| Dissipative system | Correct loss or relaxation | RK for non-stiff problems; implicit method when stiff | Physical decay and time-integration accuracy |
Simple Example: Pendulum Dynamics¶
Let’s see symplectic integration in action with a nonlinear pendulum:
import numpy as np
def pendulum_leapfrog(theta0, omega0, g, L, h, n_steps):
"""
Integrate pendulum with leapfrog
Second-order fixed-step method; monitor energy error under refinement
"""
theta, omega = theta0, omega0
energies = []
for _ in range(n_steps):
# Initial energy
E = 0.5*L**2*omega**2 - g*L*np.cos(theta)
energies.append(E)
# Leapfrog update
omega_half = omega - 0.5*h*(g/L)*np.sin(theta)
theta_new = theta + h*omega_half
omega_new = omega_half - 0.5*h*(g/L)*np.sin(theta_new)
theta, omega = theta_new, omega_new
return energiesFor a resolved fixed step, this experiment can show near-conservation beyond the small-angle limit. Repeat it with half the step and monitor the trajectory as well as energy, especially near the separatrix. Large steps need not preserve this behavior.
Answers and reasoning
Each exact-arithmetic kick and drift is symplectic, but their composition follows a discrete approximation to the physical flow. Preserving the two-form does not imply preserving the original Hamiltonian value.
Compare the actual observable, duration, resolution, and cost. RK4 may have smaller short-time state error; resolved leapfrog can have more favorable long-time energy behavior while still accumulating phase error.
Reversing the signed step reverses the symmetric kick–drift–kick sequence. A nonsymmetric symplectic Euler composition is a counterexample to universal reversibility.
The formal modified Hamiltonian differs by for leapfrog; its truncations describe nearby dynamics under appropriate assumptions. The oscillator’s exact quadratic invariant is a special solvable example.
A predetermined sequence of state-independent step lengths composes symplectic maps, but does not supply the same fixed-step energy analysis. Ordinary state-dependent selection generally loses symplecticity. Specialized adaptive constructions require additional variables or a separate formulation.
The two constraints and cancel the cubic composition defect. Solving them introduces the cube root; the coefficients are signed whole-step lengths.
Bridge to Part 4: Stability Analysis¶
You’ve seen the profound difference between local accuracy and geometric preservation. Symplectic methods impose a geometric constraint as well as an accuracy order. Their favorable long-time energy behavior has conditions, and accurate trajectories require enough resolution.
But choosing the right integrator is only part of the challenge. We also need to understand when methods become unstable, how to diagnose problems, and what limits our timestep choices. In Part 4, we’ll analyze stability regions to predict when methods explode and understand the special challenges of stiff equations.
Next: Part 4 - Stability Analysis