Legendre Transformation
Open any thermodynamics textbook and you will find four energies — internal energy, enthalpy, Helmholtz, Gibbs — where mechanics seems to need only one. Open Goldstein at Chapter 8 and you will watch the Lagrangian turn into the Hamiltonian in three lines of algebra. Both miracles are the same single operation: the Legendre transformation, the systematic way to trade a function's dependence on a variable for dependence on the corresponding slope — velocity for momentum, entropy for temperature, volume for pressure — without losing a bit of information. The geometry behind it is disarmingly concrete. A convex curve can be handed to you as a list of points, or as the family of tangent lines that envelope it. Each tangent is labelled by its slope and its intercept, and the bookkeeping of intercepts-as-a-function-of-slope is the Legendre transform. Because a strictly convex curve pairs points and tangent slopes one-to-one, the two descriptions are perfectly interchangeable — apply the transform twice and you are back where you started. In mechanics this one algebraic move is the door between two worlds. On the Lagrangian side: configuration space and second-order equations. On the Hamiltonian side: phase space and first-order equations that treat coordinates and momenta almost symmetrically — the arena for Hamilton's canonical equations, Liouville's theorem, and ultimately quantization. This article builds the transform from its tangent-line picture, states exactly when it exists, carries it out on the systems you will actually meet, and shows why the same three lines of algebra organize half of physics.
- The Legendre transformation replaces a function's dependence on a variable by dependence on the corresponding slope (derivative), trading one independent variable for its conjugate.
- Applied to the Lagrangian , it exchanges the velocity for the generalized momentum , producing the Hamiltonian .
- The transform is involutive — its own inverse — and well-defined precisely when is convex in , i.e. the velocity Hessian is nonsingular.
- Geometric meaning: a convex curve is equally described by its points or by the envelope of its tangent lines, parametrized by slope and intercept .
- The same machinery generates the thermodynamic potentials (internal energy enthalpy, Helmholtz, Gibbs free energies) and the duality at the heart of convex optimization.
- Key idea: To Legendre-transform , define , invert to get , and set . Then — the transform exchanges a variable with its conjugate slope and is its own inverse.
Where this lives today
Thermodynamics remains the transform's busiest workplace: , , and are Legendre transforms of the internal energy, each swapping a variable you cannot easily control (entropy, volume) for its conjugate that you can (temperature, pressure) — every chemistry lab that quotes a is running Legendre's 1787 trick. In statistical mechanics the transform connects the microcanonical entropy to the free energy and, through large-deviation theory, the cumulant generating function to the rate function — the modern language of fluctuation theorems. Computation leans on it twice. Convex optimization's dual problems are Legendre–Fenchel transforms, with the Fenchel–Young inequality (8) bounding every duality gap — the machinery inside support-vector machines and much of modern control. And in scientific machine learning, Hamiltonian neural networks learn directly from trajectory data precisely because the transformed, first-order structure pairs with symplectic integrators that respect conservation over long horizons — the transform deciding, two centuries on, how neural nets should parametrize mechanics.
The physical picture
Picture a convex curve . You can hand someone the list of points on it — or you can hand them the list of straight rulers tangent to it. Each ruler carries two numbers: its slope and the height at which it crosses the vertical axis. Knowing every ruler reconstructs the curve exactly, as the boundary the rulers cannot cross — their envelope. The Legendre transform is nothing more than the bookkeeping of those intercepts, indexed by slope instead of by position:
The minus sign in is not decoration — it is the intercept. The tangent through with slope crosses the vertical axis at height , so literally measures how far below the origin each tangent line reaches. Strict convexity is what makes the catalogue usable: the slope increases monotonically along a strictly convex curve, so each slope value occurs at exactly one point, and the dictionary between points and tangents has no ambiguous entries. In mechanics, velocity and momentum are a conjugate pair in exactly this sense. The Lagrangian is convex in — kinetic energy is a positive-definite quadratic — so the slope of in the velocity direction, which is precisely the generalized momentum (see Generalized Momenta), labels the tangents cleanly, and the Hamiltonian is the resulting intercept catalogue:
The deep payoff is structural. Trading for symmetrizes the dynamics: where delivered coupled second-order equations, delivers first-order equations that treat and on almost equal footing. That near-symmetry is the gateway to phase space, to canonical transformations that scramble coordinates and momenta into each other, and to Liouville's incompressible flow — the whole Hamiltonian edifice, which begins next door in Hamilton's Canonical Equations.
The transform, precisely
Start in one dimension, where every feature is already visible. Given a strictly convex, smooth , we want a new function that carries the same information but takes the slope as its input. The recipe reads off the tangent-line picture directly — slope first, then intercept:
where: — the original convex function; — the conjugate variable, the slope ; — the transform, with eliminated via the inverted slope map . Read it physically: for each slope , find the point where the curve has that slope, lay the tangent there, and record minus its intercept. The defining condition is equivalently the stationarity of over — the tangent is where the line clears the curve by the least.
We are establishing the two facts that make the Legendre transform a transform rather than a mere substitution: that the derivative of recovers the old variable, , and that transforming twice returns the original function exactly. The strategy is direct calculus — differentiate the definition and watch the chain-rule terms cancel — but the cancellation is the whole point: it is what makes the and descriptions perfectly symmetric partners. Watch the role of strict convexity: it guarantees the slope map is monotonic and hence invertible, which is what licenses writing in the first place.
Step 1. Define the slope map and invert it. For strictly convex , , so increases monotonically with and has a unique inverse . The transform is . Why strictness matters: if had a straight segment, a whole interval of would share one slope , and would be ambiguous — the catalogue would have a smeared entry.
Step 2. Differentiate with respect to , treating by the chain rule:
Why the derivative terms die: holds identically along the construction, so the bracket vanishes no matter how moves with . This insensitivity is the hallmark of a Legendre transform — the new function genuinely does not depend on the old variable.
Step 3. Transform itself. Its conjugate variable is — the original variable. So the second transform is with recovered by inverting , which is the same relation as . Substituting the definition of :
Why this is more than elegance: involutivity guarantees the Hamiltonian description contains exactly the information of the Lagrangian one — nothing lost, nothing smuggled in — which is the licence behind the equivalence theorem of the companion article on Lagrangian–Hamiltonian equivalence. *Verified: for , the slope map is , so and ; then and transforming again returns . Matches Arnold §14 and Goldstein §8.1.*
One dimension generalizes verbatim to many: for the conjugates are , and the transform may exchange any subset of the variables — a freedom thermodynamics exploits shamelessly. The price of admission is that the slope map must be invertible, which brings us to the condition that controls everything.
From Lagrangian to Hamiltonian
The mechanical application transforms in the velocities only, with and carried along as spectators. The conjugate slope in the velocity direction is a quantity you already own — the generalized momentum from the Euler–Lagrange machinery:
where: — generalized velocity; — the momentum conjugate to , the "slope" that becomes the new independent variable. For a free particle this is ; in general it is whatever delivers — the full taxonomy lives in Generalized Momenta. Applying recipe (1) in each velocity, summed over the directions, defines the Hamiltonian. Everything hinges on actually completing the elimination — the result must be expressed in the new variables:
where: — the Hamiltonian, a function of only; — the velocities solved from equation (2). The restriction bar is the most-ignored symbol in mechanics: until every has been eliminated, you do not yet have a Hamiltonian. What this function means — and when it equals the energy — is the business of The Hamiltonian Function and Hamiltonian as Total Energy; here it is simply the intercept catalogue of in the velocity directions. The solvability of (2) for the velocities is the multi-variable version of strict convexity — the velocity Hessian must be invertible:
where: the matrix is the velocity Hessian of — for the standard form it is the mass matrix , positive-definite and safely invertible. When the determinant vanishes the Lagrangian is called singular or degenerate: the momenta are not independent functions of the velocities, and relations — constraints — appear among them. Electromagnetism and every gauge theory live in that degenerate regime, which is why quantizing them requires the Dirac–Bergmann constraint formalism rather than the textbook transform.
Go deeper · Derivation B · 1 minCarrying out the transform for the standard mechanical Lagrangian
The goal is the explicit Hamiltonian for the workhorse of classical mechanics — the natural Lagrangian with a symmetric positive-definite mass matrix — and, along the way, the verification that the transform is well posed for it. The strategy follows recipe (3) literally: compute the momenta, invert for the velocities (possible because ), substitute, and simplify. Watch how the kinetic term halves and re-forms with replacing — the transform's signature self-similar structure.
Step 1. Compute the conjugate momenta from (2). Differentiating the quadratic form,
Why the Hessian appears: differentiating once more gives — condition (4) is exactly the positive-definiteness of the mass matrix, so for natural Lagrangians the transform never fails.
Step 2. Invert for the velocities: . This is the step that a degenerate Lagrangian would refuse; here guarantees a unique global solution.
Step 3. Assemble and substitute everywhere:
Why no velocity may survive: must be a function on phase space. A stray would make the differential bookkeeping of the next derivation collapse.
Step 4. Simplify using : the middle term is , so
The kinetic energy reappears written in momenta, with the inverse mass matrix, and — the total energy. This clean identification is special to Lagrangians of the form quadratic-in-velocity-minus-potential; the general accounting of when is the energy is the subject of Hamiltonian as Total Energy. Verified: for a single particle , this is ; matches Goldstein §8.1 and Landau–Lifshitz §40. Dimensions: carries .
What the transform does to the differential
The involution and the explicit formulas are useful; the differential identity is structural — it is where the first-order equations of motion come from. Take the total differential of the definition (3), before any equation of motion has been imposed, and watch which variables survive:
where: every term is pure product-rule bookkeeping. Now the definition of momentum does its one crucial job: makes the two terms cancel identically. What remains,
where: no appears — the analytic proof that genuinely depends on alone. Reading off coefficients gives , , and ; feed in the Euler–Lagrange equation and the first two become Hamilton's canonical equations. We stop at the threshold: the dynamical consequences — phase-space flow, conservation, Poisson brackets — are the story of Hamilton's Canonical Equations, for which this cancellation is the point of departure.
Go deeper · Derivation C · 1 minTime dependence of H from the structure of the transform
We derive how the Hamiltonian changes along a trajectory, using nothing but the differential identity (6) and the equations of motion, and obtain the cleanest conservation statement in mechanics: is constant whenever carries no explicit clock. The strategy is a two-line chain rule with a designed cancellation. The point to watch: two different derivatives wear the same letter — the partial probes only the explicit time stamp, while rides the actual motion. The theorem says they coincide, which is far from obvious a priori.
Step 1. Chain rule along a trajectory :
Step 2. Insert the coefficient identities from (6) together with Euler–Lagrange, i.e. and on solutions. The sum telescopes:
Why the cancellation is exact: it is the antisymmetry of the canonical pairing — each coordinate's push is its momentum's pull. This same antisymmetry, promoted to a bracket, becomes the Poisson structure of the follow-on article.
Step 3. Conclude, and connect to the Lagrangian's clock via (6):
If has no explicit time dependence, is a constant of the motion. Whether that conserved number is the energy is a separate question — it is, exactly when the transform's quadratic structure holds — dissected limb by limb in Hamiltonian as Total Energy and, on the Lagrangian side, in The Energy Function and Jacobi Integral. Verified: matches Landau–Lifshitz §40 and Taylor Ch. 13; for the statement reduces to conservation of , recomputed directly in Worked Example 1.
Which form when
| you need | reach for | notes |
|---|---|---|
| the transform of a 1D convex function | eq. (1) | slope in, intercept out |
| momenta from a given Lagrangian | eq. (2) | always the first step |
| the Hamiltonian itself | eq. (3) + eliminate | elimination is mandatory |
| does the transform exist? | eq. (4) | mass matrix invertible ⇒ yes |
| standard mechanical systems | derived above; | |
| conservation of H | no explicit ⇒ const | |
| non-convex or non-smooth | Legendre–Fenchel form |
When convexity fails — and the sup that fixes it
The tangent-line catalogue assumed every slope touches the curve exactly once. Two failure modes matter in practice, and one generalization repairs both. If has a straight segment (Hessian zero on a patch), a single slope corresponds to a continuum of points — in mechanics this is the degenerate Lagrangian of equation (4), and the cure is constraint analysis, not a better transform. If has a concave stretch, the naive has multiple stationary points and the recipe turns multivalued. The repair is to replace stationarity by optimization:
where: — the supremum over all , which for smooth convex lands exactly on the tangency condition and reproduces (1). This Legendre–Fenchel transform is defined for any ; the price is that transforming twice returns not but its convex hull — the tightest convex function below . Thermodynamics uses this feature, not merely tolerates it: the double-transform's flat segments are the Maxwell constructions of first-order phase transitions.
Complementing the sup form is the Fenchel–Young inequality, which packages the transform as a bound. For any admissible pair of values,
where: equality holds exactly when — when is a conjugate pair. In mechanics it says with equality on the physical relation between velocity and momentum; in convex optimization it is the seed of every duality gap estimate.
Limiting cases
| Case | Result | Meaning |
|---|---|---|
| strictly convex in | slope map invertible; exists, unique, involution holds | |
| quadratic kinetic energy | : transform of a quadratic is quadratic; | |
| free particle, | from | the textbook pair; transform swaps |
| singular Lagrangian | : momenta constrained by | gauge theories; Dirac–Bergmann analysis required |
| non-convex | naive transform multivalued | use form (7); double transform gives convex hull |
| with no explicit | conserved ; equals energy iff kinetic structure quadratic |
Worked examples
1 · Mass on a spring: the full transform, with numbers (confidence builder)
A block of mass on a spring of stiffness passes the point moving at . Carry out the Legendre transform of and evaluate , , and at this instant.
Step 1. Conjugate momentum from (2): . The velocity Hessian is — condition (4) holds, the transform exists.
Step 2. Invert the slope map: . Build the Hamiltonian by recipe (3): . Every velocity is gone; lives on phase space.
Step 3. Evaluate the pieces. Kinetic: . Potential: . So — the Lagrangian vanishes at this instant.
Step 4. The Hamiltonian does not: . Cross-check via the definition: ✓. The moral is vivid: and are different functions carrying the same information — here one is zero while the other is the full of conserved energy.
2 · Relativistic particle: the transform beyond quadratic Lagrangians (exam level)
The relativistic free particle has — nothing like . (a) Find the conjugate momentum and the Hamiltonian. (b) Evaluate both for an electron () at and verify the energy interpretation.
Step 1. Momentum from (2): — the transform discovers relativistic momentum. Convexity check: for all , so the transform is globally clean.
Step 2. Assemble . Eliminating the velocity via gives the phase-space form — the relativistic energy–momentum relation, produced by pure Legendre algebra.
Step 3. Numbers. At : . Momentum: , i.e. .
Step 4. Hamiltonian both ways. Direct: . Phase-space form: ✓. Definition check: ✓. Note here — there is no , and includes rest energy — yet is the total energy and is conserved. The transform never promised ; it promised the conjugate description, and the energy interpretation must be checked case by case (see Hamiltonian as Total Energy).
Origins · 1 minAdrien-Marie Legendre and how this was discovered
Legendre wielded analysis with a craftsman's economy across celestial mechanics, number theory, and elliptic integrals — his Éléments de géométrie retrained a century of schoolchildren, and the polynomials bearing his name anchor every physics curriculum. The transformation entered in a 1787 memoir on minimal surfaces, as a trick for converting one partial differential equation into a more tractable dual. He would likely be startled by its afterlife: the hinge between Lagrange's mechanics and Hamilton's, the grammar of Gibbs's thermodynamics, and the duality underneath modern optimization. Legendre spent his last years in poverty after refusing to endorse a government candidate, still correcting proofs of his treatise on elliptic functions — a body of work Abel and Jacobi were already busy revolutionizing with, fittingly, transformations of their own.
Going further
References. Goldstein, Poole & Safko, Classical Mechanics, 3rd ed., §8.1 · Landau & Lifshitz, Mechanics, 3rd ed., §40 · Morin, Introduction to Classical Mechanics, Ch. 15 · Taylor, Classical Mechanics, Ch. 13 · Arnold, Mathematical Methods of Classical Mechanics, §14
Provenance. Equations verifiable against Goldstein §8.1 (definition and Hamilton's equations), Landau & Lifshitz §40 (energy and time-dependence), and Arnold §14 (involution, convexity). A verifier should recompute: (1) the quadratic-system result and confirm ; (2) and the double-transform identity ; (3) the cancellation using Hamilton's equations. Thermodynamic potential definitions (, , ) are standard. Worked-example numbers on this page (spring: , , ; electron at : , , ) are illustrative arithmetic recomputed from the boxed formulas.
Builds on: Generalized Momenta · The Lagrangian · Multivariable calculus & convexity Leads to: The Hamiltonian Function · Hamilton's Canonical Equations · Equivalence of Lagrangian and Hamiltonian Formulations · Phase Space
Why do textbooks define the transform sometimes as px − f and sometimes as f − px, and thermodynamics as U − TS with yet another sign?
All conventions encode the same tangent-line duality; they differ in who keeps the minus sign. Mechanics uses so that comes out positive for ordinary systems (it equals ). Thermodynamics writes — a transform with the opposite overall sign — so that the potentials stay energy-like and minimize at equilibrium. The invariant content is the pairing: a conjugate pair with , the product straddling the two descriptions, and the Fenchel–Young inequality pinning the sign relations. When reading any source, locate its definition once and track that; never mix formulas across conventions.
Is the Hamiltonian always T + V?
No — that identification holds when the Lagrangian has the natural form with purely quadratic in the velocities and velocity-independent, as in the second derivation above. Break either condition and and part company: velocity-dependent potentials (a charged particle in a magnetic field), rheonomic constraints (a bead on a wire whirled at imposed rate), or rest energy in the relativistic example all produce Hamiltonians that are conserved-when-time-independent but are not naively. The full accounting — with the rotating-bead counterexample worked in detail — is the companion article Hamiltonian as Total Energy.
What actually goes wrong for a singular Lagrangian, and why should a mechanics student care about gauge theories here?
When , the momentum map squashes some velocity directions: certain combinations of momenta are fixed functions of regardless of velocity — primary constraints . The velocities along the squashed directions simply cannot be recovered from the momenta, so recipe (3) stalls. Electromagnetism is the canonical example: the momentum conjugate to the scalar potential vanishes identically. The Dirac–Bergmann procedure classifies the constraints, identifies which generate gauge transformations, and builds a consistent Hamiltonian on the constraint surface. The mechanics-course moral: condition (4) is not pedantry — it is the exact boundary between textbook Hamiltonian mechanics and the constrained formalism that quantum field theory requires.
Why is the sup definition better than the stationarity definition — do they ever disagree?
For smooth, strictly convex they agree exactly: the supremum of over is attained where the derivative vanishes, i.e. at . The sup form earns its keep when smoothness or convexity fails. For non-differentiable (kinks) it still returns a well-defined ; for non-convex it selects, for each slope, the best tangent — equivalent to transforming the convex hull. The price: the double transform returns the convex hull rather than itself, so involution holds only on convex functions. In thermodynamics that "loss" is physics — the hull's flat segments are Maxwell's equal-area construction across a first-order phase transition.
The involution proof shows g′(p) = x. What is the corresponding statement for H, and what does it buy?
In the mechanical transform the roles are (in ), (in ), so becomes : differentiating the Hamiltonian in a momentum returns the velocity that momentum replaced. That identity is one half of Hamilton's canonical equations, obtained before any dynamics — it is pure transform structure, valid off-shell. The other half, , needs the Euler–Lagrange equation as physical input. Keeping the two origins straight (structure vs dynamics) is the cleanest way to understand the equivalence proof in Equivalence of Lagrangian and Hamiltonian Formulations.
Why does the mass matrix invert, M → M⁻¹, under the transform? Is there intuition beyond the algebra?
Yes: slopes invert scales. If is a steep parabola (large in ), a small change in sweeps a huge range of slopes, so the intercept catalogue is a shallow parabola in — steepness and shallowness swap. Mechanically: a heavy particle (large ) needs little velocity range to cover a wide band of momenta, so varies gently with . The rule is also a self-consistency check on any computed Hamiltonian: for quadratic kinetic energies, transform twice and the original mass matrix must reappear.
Is the Legendre transform like a Fourier or Laplace transform?
Only in name. Fourier and Laplace are integral transforms: the output at one frequency gathers contributions from the entire input function. Legendre is pointwise-geometric: at slope depends only on the single point of where the tangent has that slope (or, in the sup form, on one maximizing point). That is why it can exchange thermodynamic variables and mechanical velocities without any notion of superposition, and why its inverse is itself rather than a different integral kernel. There is, however, a deep asymptotic bridge: in the semiclassical limit a Laplace-type integral is dominated by its stationary point, and the exponent evaluated there is precisely a Legendre transform — the saddle-point method turns one into the other, which is how and swap roles inside path integrals.
How do I Legendre-transform in only some of the variables, and why would I?
Transform exactly the variables whose conjugates you would rather control, and carry the rest as spectators. The recipe is unchanged per transformed variable: new function = (sum of conjugate products over the chosen variables) − old function, then eliminate the chosen variables. Mechanics transforms all velocities but none of the coordinates — that is what makes phase space. Thermodynamics transforms one pair at a time: swaps only entropy, swaps only volume, swaps both. A partial transform in mechanics is also standard practice: the Routhian transforms only the cyclic coordinates' velocities, hybridizing Lagrangian and Hamiltonian descriptions — the natural tool once you have met cyclic coordinates and their conserved momenta.