The Legendre Transform
Optimization
One geometric idea sits under the Hamiltonian of mechanics, the free energies of thermodynamics, the universal functional of density functional theory, and the dual problem of convex optimization. It is the Legendre transform, and the whole of it is this: a convex curve can be described two equivalent ways — by its heights, or by its slopes. The transform is the dictionary between them.
1. A curve has two equal descriptions
Take a convex (bowl-shaped) function . The familiar description gives its height above each position — a cloud of points tracing the curve. But a convex curve lies above every one of its tangent lines and is recovered as their upper envelope, so a second, equally complete description is the family of tangent lines: sweep along the curve and collect, for each slope, the straight line tangent there.
A straight line is fixed by two numbers — its slope and its intercept. So "the tangent line of slope " is captured by a single number, that line's intercept. The Legendre transform records exactly that: it trades the position variable for the slope variable , and stores (minus) the intercept of the tangent line with that slope.
Predict, then reveal: for , the tangent at has slope . As runs over all reals, what slopes appear, and is the tangent-line description faithful?
The slope sweeps over every real number, each exactly once — a one-to-one match between points and slopes. So every slope picks out a unique tangent line, and the family of tangents encodes the parabola with no loss. That bijection between position and slope is precisely what strict convexity buys you, and it is the condition for the transform to be well defined.
2. Making "record the tangent" a formula
Fix a slope and look at the vertical gap between the line and the curve, namely . Maximizing that gap over defines the transform:
The maximum is where the gap stops growing — where the curve's slope matches :
At that point the value is exactly minus the intercept of the tangent line of slope — so really is "the tangent line indexed by its slope," made into a number. The maximization is the machine that, given a slope, finds the point on the curve where the tangent has that slope.
Why does maximizing the gap to the line — which runs through the origin, not along the curve — hand you the tangent line's intercept? Because at the maximizer the tangent runs parallel to (both have slope ), and two parallel lines sit a constant vertical distance apart. Maximizing slides the test line down until it grazes the curve at that parallel tangent, and the gap it leaves — measured at — is exactly minus the tangent's intercept. The origin-line and the tangent are different lines; the transform is the constant gap between them.
Predict, then reveal: compute the Legendre transform of .
Maximize : set , so , and . The function is its own transform — the quadratic is the fixed point of the Legendre map, the same way the Gaussian is the fixed point of the Fourier transform.
Worked examples
The transform is a three-step recipe. Given a slope : (1) form the gap ; (2) maximize it by setting and solving for the matching point ; (3) substitute back to get . Run it on a few functions — the first one is the one to really stare at.
Read the answer as a tangent line
Take and ask for the slope . The curve has slope 2 where , so at , where the height is . The tangent line there is
a line of slope 2 and intercept . And the transform value is — exactly minus that intercept. That is the whole transform in one picture: for each slope , find the tangent line of that slope and record (minus) where it crosses the axis. The list of slopes-and-intercepts is the same curve as the list of heights. If only one thing sticks, let it be this.
The whole transform as a table
One slope is not enough to feel it. Here is the entire transform of computed as actual numbers. First the closed form, by the three-step recipe: maximize , set so , and substitute:
Now watch the relabeling happen one row at a time. Pick a handful of points ; read off the height , the slope there , the tangent's intercept , and finally :
| slope | intercept | |||
|---|---|---|---|---|
| 4 | 4 | |||
| 1 | 1 | |||
| 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 2 | 1 | |
| 2 | 4 | 4 | 4 |
The left half of the table is described by heights; the shaded right half is described by slopes. Read the two shaded columns as pairs — — and they trace exactly, the closed form above. Nothing abstract happened: you built a dictionary, one slope per row. That is what "Legendre transform a convex function" means operationally — sweep along the curve and tabulate , or, when you are lucky, invert once and read off the formula.
A general quadratic — the stiffness inverts
Take . Maximize : set , so . Substitute:
A stiff bowl (large ) transforms to a shallow one (coefficient ), and vice versa. Stiffness in becomes softness in — the curvatures and are conjugate. (This is the same fact that makes a sharply-peaked Gaussian have a broad Fourier transform.)
A quartic — the shape genuinely changes
The quadratic is self-similar, which can fool you into thinking the transform always hands back the same kind of function. It does not. Take . Recipe: maximize , set so , and substitute:
A fourth power became a power — the transform reshaped it. Pin it down with one point by hand: at , , the height is , so . The formula agrees: . The exponents pair up as conjugates — with — the same that runs through Hölder's inequality.
The exponential — and Stirling
Take . Maximize : set , so and — which only exists for . Substitute:
Two lessons. The domain shrank: only ever has positive slopes, so its conjugate is defined only for . And the answer is the integral of — its slope is — which is the fingerprint of something familiar.
When you can't invert by hand
"General convex function" feels intimidating because usually you cannot solve in closed form. The recipe is unchanged — the same three steps; you just locate the root numerically. Take , convex, with no tidy inverse for . To get , solve
then substitute: , so . Ask instead for slope and the root of is no longer rational, but a few Newton steps give and then is just arithmetic. That is the general case in full: invert when you can, root-find when you cannot, but the transform is always "match the slope, then evaluate ."
A straight line — why convexity is required
What is the transform of a line ? Form . If this runs off to as ; only at is it finite, equal to :
A line has a single slope, so its slope-description collapses to one point. This is the extreme of the bijection from §1: when the curve is not strictly convex, a slope can be shared by many points or missing entirely, and the transform reports . Strict convexity is exactly the guarantee that "where is the slope ?" has one clean answer — which is why the transform lives on convex functions.
3. The symmetry: x and p are conjugate
At the maximizing point the gap is attained, which means — rearranged, a strikingly symmetric statement holds whenever and are matched by :
Read it and the roles of and are interchangeable. Differentiating shows the inverse relation : the slope of the transform recovers the original position. So the map is an involution — transform a convex function twice and you are back where you started:
This is why and are called conjugate variables: each is the other's slope, and the function and its transform are a matched pair carrying the same information from two points of view. (Off the matched point the equality relaxes to the inequality , the Fenchel–Young inequality — equality exactly when the variables are conjugate.)
4. The same transform, four fields
Mechanics — the Hamiltonian is the Legendre transform of the Lagrangian. Trade the velocity for its conjugate, the momentum :
That is verbatim, with and . Velocity-space and momentum-space are the two descriptions; the Legendre transform moves between them.
Thermodynamics — every potential is a Legendre transform of the energy. Trade an extensive variable for its conjugate intensive one: entropy for temperature gives the Helmholtz free energy,
and trading volume for pressure gives the enthalpy and Gibbs energy. The whole zoo of potentials is just "which variables did you transform."
One sign to watch, since it trips everyone: the Hamiltonian above is (slope times variable, minus the function — the transform verbatim), but the free energy is written (the function minus slope times variable — the opposite order). By the definition on this page the transform of is , so is precisely minus that transform. Physics keeps the extra sign on purpose: it leaves a quantity you minimize at fixed , matching how energy is minimized at fixed . Same transform, flipped sign so the variational principle stays a minimum.
Density functional theory — the universal functional is a Legendre transform. The ground-state energy as a functional of the external potential is concave (note the flip — every example so far was convex), so the transform mirrors with a in place of the : same machine, reflected. Its transform with respect to is the universal (Lieb) density functional, with the density conjugate to the potential:
Optimization — the convex conjugate is the dual. In convex analysis is literally called the convex conjugate, and Lagrangian duality, support functions, and the dual problem are all this transform. One geometric move — encode a convex function by its slopes — and the Hamiltonian, the free energies, the DFT functional, and convex duality are the same idea wearing different notation.
Necessarily true
Every statement below is forced — it follows from the definition alone, for any strictly convex . These are the coequal takeaways; none is subordinate to the narrative above.
- It is a function of the slope. is indexed by , not by position . Re-indexing the curve by its slope is the entire content of the transform.
- The maximizer is where the slope matches. The achieving the max satisfies , equivalently . Strict convexity is exactly what makes invertible, so this is unique.
- The value is minus the tangent intercept. equals the negative -intercept of the tangent line to of slope .
- The derivatives are inverse maps. going out and coming back. The slope-variable of one is the position-variable of the other; this is what "conjugate" means.
- It is an involution. Applying it twice returns the original: for convex . The two descriptions are genuinely equal, neither primary.
- Curvature inverts, exactly. . A stiff bowl maps to a shallow one and back; reciprocal second derivatives, not merely "softer."
- It only sees the convex hull. A non-convex and its convex envelope have the same . The transform discards every non-convex region — information is lost, which is why needs convexity.
- Flat directions collapse to points. A line transforms to and for every other slope. One slope, one point.
- Fenchel–Young is automatic. Because is a max over , holds for all , with equality iff . The pairing is bounded by the two descriptions and met only on the conjugate pair.
- Transform and confirm for . (Maximize ; the stationarity gives .) Notice the transform inherits the domain restriction — slopes of are always positive.
- Starting from with , show . The minus sign is the conjugate-variable bookkeeping the symmetric identity predicts.