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

THE LEGENDRE TRANSFORMATION

The exact change of variables that turns velocity into momentum, and the Lagrangian into the Hamiltonian. For a convex L(v) the transform is H(p) = maxv[ p·v − L(v) ] with the conjugate variable p = dL/dv — and it is an involution: do it twice and you are exactly back where you started. The same move relates the thermodynamic potentials. Down the center, data flows: a Lagrangian goes in, the transform runs, the Hamiltonian comes out. The blue team builds and defends it; the red team tries to break it.

source A.-M. Legendre, "Sur la manière de distinguer les maxima des minima dans le calcul des variations" (1786) & "Mémoire sur l'intégration de quelques équations aux différences partielles," Mém. Acad. Roy. Sci. (Paris), 1787 — no stable primary scan; author/title/year cited AMBER. Ref: mathshistory.st-andrews.ac.uk/Biographies/Legendre. Rendered, not quoted.

◧ blue team · builds & defends
3

THE MODEL — tangent lines

A convex curve L(v) is equally well described by its tangent lines. Each point v gives a tangent of slope p = dL/dv; that tangent's y-intercept is exactly −H(p). The transform trades the graph (point set) for the envelope (line set) — no information lost, because a convex curve is the envelope of its tangents.

For the current point, the live tangent read-out:

quantityvalue

Slope becomes the new coordinate; the old intercept becomes the new value. That is the whole trade.

5

THE LINEAGE — v ⇒ p AVAN

Velocity becomes momentum. Starting from the-lagrangian L(q,q̇), define p = dL/dq̇ and form H = p·q̇ − L. That single Legendre step is the bridge to the-hamiltonian H(q,p), where q̇ = dH/dp reads the velocity back out.

The same transform relates the thermodynamic potentials AMBER: internal energy → Helmholtz free energy → Gibbs, each swapping a variable for its conjugate (S↔T, V↔−P). One machine, two physics. Each sphere is the next one's premise.

7

THE WITNESS live

The blue team's live check: recompute the kinetic case (H=p²/2), the involution round-trip, the derivative relation dH/dp = v, and the Fenchel bound — and confirm them against the known truth. If red tampers, this badge is where it shows.

▼ the machine ▼
4

DATA IN — the Lagrangian in ↓

Feed the machine a convex quadratic Lagrangian in the velocity v:

L(v) = ½·m·v² + b·v + c

m > 0 is the curvature (the mass) — it must be positive, because the transform needs a well-defined maximum, and that needs convexity. With m the mass and b=c=0 this is the kinetic energy ½mv², whose transform is the momentum-space Hamiltonian. Set the coefficients, then feed them to the panel below.

▼   feed the Lagrangian into the transform   ▼
0

▣ THE PANEL — the engine LIT

Curve = L(v). The moving line is the tangent at v; its slope is p, its y-intercept is −H(p). That intercept is the transform.

relationvaluecheck

Change any control — p, H, and the involution round-trip are computed from the transform on the spot, never looked up.

▼   the transform emits the Hamiltonian   ▼
8

DATA OUT — the Hamiltonian out ↓

What the machine produces, proven: for L = ½mv² the transform gives H = p²/(2m) — the correct kinetic Hamiltonian (exact to 1e-9). The map is an involution: transforming H back recovers L exactly (round-trip to 1e-9). The conjugate variable is the slope, p = dL/dv, and dH/dp = v reads the velocity back (both to 1e-6). The Fenchel bound p·v − L(v) ≤ H(p) holds for every v, tight at v*.

The blue team's witness (left) confirms these numbers live; the red team (right) tries to make them wrong.

red team · attacks & breaks ◨
1

THE ADVERSARY

WALL The transform is only invertible where L is convex. For a non-convex L the max in maxv[pv−L] may not exist (it runs off to +∞), and the double transform returns only the convex hull — the original is lost. The involution is not universal; it holds on convex functions.

Worse, when the Hessian is singular — det(∂²L/∂v²)=0, a degenerate Lagrangian, as in gauge theories — the velocities cannot all be solved for the momenta, and the naive H=pv−L is undefined. That is a real physical failure: it forces the Dirac constraint machinery. "Just swap variables" is a convex-and-regular privilege.

2

THE GRAVEYARD

"The Legendre transform is just renaming variables." Cut. It is the tangent-line / max construction; the new coordinate is a slope, not a relabelling — and it is reversible only when L is convex.

"H = pv − L, always." Cut. Only when p = dL/dv (the stationary point) and the Hessian is nonsingular. Off that point it is not the transform; with a degenerate Hessian it does not exist.

"Any function is its own double transform." Kept, corrected. The biconjugate L** is the lower convex envelope of L — equal to L only where L is already convex. On convex L the transform is a true involution, verified here to 1e-9.

6

THE TAMPER — break it

The red team's move: flip the sign to H = p·v + L (a "+" where a "−" belongs). The round-trip no longer returns L and dH/dp ≠ v. The blue team's witness (window 7) is watching.

Flip the sign and the kinetic case gives H≠p²/2, the involution stops closing, and dH/dp no longer recovers v — the witness recomputes, disagrees with the known values, and turns red. Nothing is faked; the attack is real and it is caught.