◄ WORLD II · THE FOLDTHE OCHO · blue builds │ the machine │ red breaks

THE HAMILTONIAN

One function — the total energy — generates the whole motion. Give Hamilton the energy H(x,p)=T+V and two equations, ẋ=∂H/∂p and ṗ=−∂H/∂x, roll the system forward as a flow in phase space. It is runnable: a symplectic integrator holds the energy flat to a millionth and closes the orbit; plain Euler leaks energy and spirals out — you can watch both. Terms go in, the flow advances, the conserved energy comes out. The blue team builds and defends; the red team attacks.

source W. R. Hamilton, On a General Method in Dynamics (1834), Phil. Trans. R. Soc. 124, 247–308 · DOI 10.1098/rstl.1834.0017 — archive.org/details/ongeneralmethodi00hami. Rendered, not quoted.

◧ blue team · builds & defends
3

THE MODEL — energy is the generator

Natural units m=1, k=1. The Hamiltonian is the total energy, kinetic plus potential:

H = p²/2m + ½kx² = T + V. It is the Legendre transform of the Lagrangian L = T − V: define the momentum p = ∂L/∂ẋ = mẋ, then H = pẋ − L.

From that one function, Hamilton's equations give the motion — no forces written by hand:

ẋ = ∂H/∂p = p/m    ṗ = −∂H/∂x = −kx. Together they are Newton's mẍ = −kx, split into two first-order flows.

Live, at the current state (x, p):

quantityvalue
5

THE LINEAGE — the dual picture AVAN

Hamilton (1834) took Lagrange's the-lagrangian and Legendre-transformed velocity into momentum, trading one second-order equation for two first-order ones. The state stops being a point in configuration space and becomes a point in phase space (x, p) — the arena the-phase-space maps.

In that arena energy is the flow: H is the generator of time-translation, formalised by the-poisson-bracket where {x,p}=1 and df/dt = {f,H}. Each sphere is the next one's premise.

7

THE WITNESS live

The blue team's live check: integrate one full period with the symplectic stepper and confirm energy stays flat to <1e-6, the orbit closes, and phase-volume is preserved. If red flips a sign, this badge is where it shows.

▼ the machine ▼
4

DATA IN — the state in ↓

A classical system is one point in phase space: position x and momentum p. Fix the two parameters and you fix the Hamiltonian:

symbolisvalue
xpositionslider
pmomentum (= mẋ)slider
mmass1
kspring constant1

The energy H = ½(p² + x²) at that point sets the orbit; ω = √(k/m) = 1, so the period is exactly T = 2π. That is what you feed the flow below.

▼   feed the state into the flow   ▼
0

▣ THE PANEL — the flow LIT

Symplectic (velocity-Verlet): energy stays flat, the orbit closes — the honest way to roll a Hamiltonian forward.

Phase portrait: x across, p up. The faint ring is the exact energy contour; the moving dot is the integrator. On EULER it spirals out — energy leaking.

Move a slider — H, the drift, and the orbit are integrated on the spot from Hamilton's equations, never looked up.

▼   the flow emits a conserved energy   ▼
8

DATA OUT — the result out ↓

What the machine produces, proven over one period (m=k=1, N=8000 steps): the symplectic integrator holds max|H−H₀| ≈ 8e−8 (<1e-6), matches the analytic SHM to ≈2e−7, and returns to its start (closed orbit) to ≈2e−7. Plain Euler drifts to ≈2.5e−3 — 30000× worse. The one-step Jacobian determinant is 1: phase-space volume is preserved (Liouville).

The blue witness (left) recomputes these live; the red team (right) tries to make energy leak.

red team · attacks & breaks ◨
1

THE ADVERSARY

WALL The Hamiltonian picture assumes the forces come from a potential. Friction, drag, any dissipation has no Hamiltonian — energy is not conserved and the whole ẋ=∂H/∂p machinery does not apply. Rayleigh dissipation is a patch, not a Hamiltonian.

Even for conservative systems the flow is not always solvable: the three-body Hamiltonian conserves H yet is chaotic — no closed form, and a symplectic integrator only bounds the error, never zeroes it. And quantise it and H becomes an operator; the crisp trajectory dissolves into an amplitude. The Hamiltonian is not the physics — it is the exact bookkeeping when a potential exists.

2

THE GRAVEYARD

"Energy is always conserved." Cut. Only for a time-independent H. If H depends explicitly on t, dH/dt = ∂H/∂t ≠ 0 — a driven oscillator pumps energy.

"H is always kinetic + potential." Cut. H = T + V only for scleronomic (time-independent) constraints with T quadratic in the velocities. With moving constraints, H is still conserved but is not the energy.

"Symplectic integrators conserve energy exactly." Kept, corrected. They conserve a nearby shadow Hamiltonian; the true H oscillates within a bound (~8e-8 here) and does not drift. Exact conservation is a limit, not a step.

6

THE TAMPER — break it

The red team's move: flip the sign in the second equation to ṗ = +∂H/∂x = +kx. The potential inverts, the flow becomes hyperbolic, energy leaks and the orbit spirals. The blue witness (window 7) is watching.

Flip ṗ to +kx and H is no longer conserved — the witness re-integrates, finds the energy blowing up and the orbit open, and turns red. Nothing is faked; the attack is real and it is caught.