TL;DR
A convex function can be described in two ways: by its value at each point, or by the lines that support it. The Legendre transform converts between these descriptions. For each slope , it records the largest gap between and , and that record is a new function . Applying the transform twice returns the original function when is convex and closed.
Where you'll see it: in convex optimization, where it produces dual problems and lower bounds; in classical mechanics, where it turns a Lagrangian into a Hamiltonian; and in statistical mechanics, where it links free energy to entropy.
Intuition
Describing a curve by its tangents
A convex function is a bowl. You can describe the bowl in the usual way, as a height at each horizontal position . But you can also describe it by the family of tangent lines that touch it. Each tangent line has a slope and a height where it crosses the vertical axis. If you know, for every slope, where the tangent with that slope sits, you know the whole bowl.
The Legendre transform takes that second description and turns it into a function. Feed in a slope , and it returns the negative of the intercept of the tangent with that slope. The bowl is recoverable from the same information, so no detail is lost.
flowchart LR F["f(x): height at each point"] -->|"tangent lines"| S["slope p and intercept"] S -->|"Legendre transform"| G["f*(p): one number per slope"] G -->|"transform again"| F
The picture for shows the idea. The curve is the bowl, the dashed line is the tangent at , which has slope . The tangent crosses the vertical axis at , so the transform at slope 3 equals .
- f(x) = x²/2
- tangent at x = 3, slope 3
Why it is useful
A minimization problem in one form can be hard, and the same problem seen through the transform can be easy. In optimization, the transform gives a lower bound on a problem that cannot be solved directly, and that bound can often be optimized. In mechanics, it changes which variables are used, from velocities to momenta, which makes some equations of motion simpler. The transform is the tool that switches between these views.
The math
Let be a Convex Function. Its Legendre transform (also called the convex conjugate) is
Here is a slope, is the supremum, the least upper bound of the expression over all , and is a new function of . For each slope , the expression measures how far the line lies above the graph of at . The transform takes the largest such gap.
Geometric meaning
The tangent to at a point with slope is the line . Rearranged, this is , so its intercept on the vertical axis is . A line lies on or below the graph of exactly when for every , that is, when . The best line of slope under the graph has , so its intercept is , and it is the tangent. The transform value is the negative of that intercept.
Derivative relation
If is differentiable and strictly convex, the supremum occurs where the derivative of is zero, which gives . Let be the point where . Then
The derivative of the transform is the inverse of the derivative of . The slope of one function is the position of the other, which is why the two views carry the same information.
Recall that a Derivative is the slope of the curve at a point. The first-order condition above uses exactly that fact.
Involution
For a convex function that is also closed (its sublevel sets are closed), the transform is its own inverse:
This is the Fenchel–Moreau theorem. Two representations, values and supporting lines, are therefore equivalent. Without convexity, the second transform gives the lower convex envelope of instead of itself.
Inequality
From the definition, for any and ,
This is Fenchel's inequality. It holds because is at least by construction, rearranged. Equality holds exactly when , which is the condition that the line touches the bowl at .
Worked examples
Take . This function is convex.
- The expression to maximize is .
- Differentiate: . Setting this to zero gives .
- Substitute back: .
- Numerical check at : is largest at , where . The formula gives .
- Check the derivative relation: , and . It holds.
- Transform again: is attained at , giving . The function is its own dual.
Interpretation: a quadratic bowl is self-dual. The slope-value description has the same shape as the original, so the transform does not change the curve's form.
Take , which is convex and differentiable.
- Maximize for . Differentiate: .
- Set : , so .
- Substitute: .
- Numerical check at : . Then . The formula gives .
- For , grows without bound as goes to minus infinity, so . For , , approached as goes to minus infinity.
- The domain of is therefore . The transform of a function defined on all of the real line can have a restricted domain. Here is increasing everywhere, so no tangent has a negative slope, and no line of negative slope stays below the graph.
Interpretation: the transform records the slopes at which the exponential has tangent lines. Only nonnegative slopes occur, and the transform at each of them is . This is the same expression that appears as negative entropy in information theory, and it is why exponential families and entropy are linked through conjugates.
Tradeoffs and failure modes
The transform is only as useful as the assumptions behind it. Convexity is the main one. Outside that setting, the transform still exists, but it loses information.
| Situation | What goes wrong | Better choice |
|---|---|---|
| is not convex | is the convex envelope, not ; the bowl description is incomplete | Use the convex hull explicitly, or accept the bound |
| is not strictly convex | is flat somewhere, so the slope does not pin down a single point | Use subdifferentials instead of derivatives |
| is not invertible | Solving for is hard or ambiguous | Work numerically, or change variables |
| takes the value outside a set | The conjugate picks up that domain restriction | Track the domain of explicitly |
The main practical use is duality. The Fenchel inequality gives a bound that holds for every and , and optimizing over produces the tightest such bound. That is the core of Lagrangian Duality. The bound is a lower bound only: the dual value can be strictly below the primal optimum when the problem is not convex, and the gap has to be checked separately.
History
The transform is named after Adrien-Marie Legendre, who studied transformations of this kind in the late eighteenth and early nineteenth centuries, in work connected to differential equations and mechanics. Its mechanical use grew through the nineteenth century, when the Lagrangian and Hamiltonian formulations of mechanics were developed and the transform was the bridge between them.
The version used in modern convex analysis was built by Werner Fenchel, who worked on the convex conjugate in the late 1940s, and by later authors including Jean-Jacques Moreau and R. Tyrrell Rockafellar, who extended it to general convex functions in the 1960s and 1970s. The result caught on in optimization because duality turns difficult problems into bounds that can be computed, and the same mathematics later appeared in statistical mechanics and machine learning, where the log-partition function and entropy are conjugate to each other.