Skip to main content
Sandbox Physics

M084 · Hamiltonian / numerical geometry

Hamiltonian Phase Space & Integrators

Run Euler, RK4, symplectic Euler and Verlet side by side. Compare long-time phase or orbital fidelity, energy drift, local canonical-map geometry and reversibility; halve the step and confront a rapidly changing Kepler periapsis.

Interactive modelHamiltonian Phase Space & Integrators
Reviewed scaled timePending\text{Pending}
Actual constant stepPending\text{Pending}
Total steps per methodPending\text{Pending}
Selected methodPending\text{Pending}
Current relative energy errorPending\text{Pending}
Maximum absolute energy errorPending\text{Pending}
Current state errorPending\text{Pending}
Last retained state errorPending\text{Pending}
Local full-map determinantPending\text{Pending}
Local symplectic defectPending\text{Pending}
One-step reversal errorPending\text{Pending}
Reference constructionPending\text{Pending}
Reference refinement disagreementPending\text{Pending}
Selected method recordPending\text{Pending}
Retained record end timePending\text{Pending}
Canonical dimensionPending\text{Pending}

Physics tutorial

A numerical map has geometry as well as local order

BackgroundA numerical method replaces continuous Hamiltonian motion by a discrete canonical map.

Why it mattersGeometric numerical integration studies which structures a discrete method preserves and what that implies over long times.

Start with the essentials

Focus question
Can a small energy error hide a wrong trajectory?
One-sentence intuition
Accuracy, energy behavior, symplecticity and reversibility are related but distinct measurements.

Core mathematical model

The canonical flow

q˙=p,p˙=−∇V,H=∣p∣22+V\dot{\mathbf q}=\mathbf p,\qquad\dot{\mathbf p}=-\nabla V,\qquad H=\frac{|\mathbf p|^2}{2}+V

Unit mass and scaled units make the three conservative systems directly comparable. Harmonic frequency and Kepler gravity parameter are one.

A kick followed by a drift

pj+1=pj−h∇V(qj),qj+1=qj+hpj+1\mathbf p_{j+1}=\mathbf p_j-h\nabla V(\mathbf q_j),\qquad\mathbf q_{j+1}=\mathbf q_j+h\mathbf p_{j+1}

Symplectic Euler is first order. The use of updated momentum in the drift distinguishes it from explicit Euler.

Symmetric Verlet steps

pj+1/2=pj−h2∇V(qj),qj+1=qj+hpj+1/2,pj+1=pj+1/2−h2∇V(qj+1)\mathbf p_{j+1/2}=\mathbf p_j-\frac h2\nabla V(\mathbf q_j),\quad\mathbf q_{j+1}=\mathbf q_j+h\mathbf p_{j+1/2},\quad\mathbf p_{j+1}=\mathbf p_{j+1/2}-\frac h2\nabla V(\mathbf q_{j+1})

Two half-kicks make a second-order reversible map. This does not make the true Hamiltonian exactly conserved or an unresolved periapsis accurate.

Test the full symplectic geometry

DΦhTJDΦh=J,J=(0I−I0)D\Phi_h^{\mathsf T}J D\Phi_h=J,\qquad J=\begin{pmatrix}0&I\\-I&0\end{pmatrix}

The readout reports the largest entrywise defect using central differences. A unit determinant alone is weaker in four dimensions. The Kepler patch is a two-dimensional projection, never a full-volume measurement.

Energy and state are different errors

ϵH=Hj−H0max⁡(∣H0∣,10−6),ϵz=∥zj−zref(tj)∥2\epsilon_H=\frac{H_j-H_0}{\max(|H_0|,10^{-6})},\qquad\epsilon_z=\|\mathbf z_j-\mathbf z_{\rm ref}(t_j)\|_2

All steps contribute to the maximum energy error; plots retain at most about 600 samples per method. A stable energy trace can hide accumulating phase error. Stopped records have no predicted continuation.

Read the logarithmic axes

yH=sgn⁡(ϵH)log⁡10(1+∣ϵH∣10−8),yz=log⁡10(1+ϵz10−8)y_H=\operatorname{sgn}(\epsilon_H)\log_{10}\left(1+\frac{|\epsilon_H|}{10^{-8}}\right),\qquad y_z=\log_{10}\left(1+\frac{\epsilon_z}{10^{-8}}\right)

A common logarithmic transform shows tiny and large errors together while retaining the sign of energy drift. Nominal cycles use a reference period of two pi in scaled time. Pendulum references compare 32 and 64 RK4 subdivisions of each coarse step.

Common difficulties

Energy is not the whole trajectory

Typical misconceptionSmall energy error guarantees a correct orbit.

Better mental modelPhase error can accumulate at nearly conserved energy. Compare the reference state at matching times.

Symplectic does not mean exact energy

Typical misconceptionA symplectic method conserves the exact Hamiltonian every step.

Better mental modelA resolved fixed-step method often has bounded oscillatory energy error, while the true energy is not exact.

Resolve periapsis

Typical misconceptionPreserving geometry cures a large time step.

Better mental modelThe fast near-center encounter still needs a short step. Halve the step and compare orbital error, not just determinant.

Projection is not canonical volume

Typical misconceptionThe area of a projected Kepler patch proves symplecticity.

Better mental modelKepler phase space has four dimensions. The full matrix test supplies the relevant local evidence.

Run the experiment

  1. 01

    Compare all methods

    Review a full harmonic record and change the selected method.

    What to observe: All colors keep the same step; energy growth, drift and bounded oscillation differ.
  2. 02

    Halve the step

    Use the long RK4 record, then halve the fixed step.

    What to observe: Both state error and energy drift respond to resolution; high local order is not the only criterion.
  3. 03

    Leave the small-angle limit

    Compare large-amplitude libration and rotating pendulum presets.

    What to observe: The numerical reference is explicitly refined rather than replaced by a harmonic approximation.
  4. 04

    Challenge a Kepler periapsis

    Compare resolved and unresolved periapsis; inspect the full-map defect and halve the step.

    What to observe: A symplectic map can preserve its geometry while producing a poor trajectory.