In mathematics, the Legendre transformation or Legendre transform, named after Adrien-Marie Legendre, is an involutive transformation on the real-valued convex functions of one real variable. Its generalisation to convex functions of affine spaces is sometimes called the Legendre-Fenchel transformation. It is commonly used in thermodynamics and to derive the Hamiltonian formalism of classical mechanics out of the Lagrangian formulation.
Specifically, let be an interval, and a convex function; then its Legendre transform is the function
with domain of definition
Here "sup" represents the supremum. is sometimes called the convex conjugate function of .
The Legendre transformation is involutive, namely is an interval, is convex on it, so that its Legendre transform is well defined, and fulfils on . Note that may differ at most on their boundaries.
For historical reasons (rooted in analytic mechanics), the conjugate variable is often denoted , instead of . If the convex function is defined on the whole line and is everywhere differentiable, then can be interpreted as the negative of the y-intercept of the tangent line to the graph of f that has slope p. In particular, the value of x that attains the maximum has the property that
That is, the derivative of the function f becomes the argument to the function f∗. In other words, f∗ satisfies the functional equation
The Legendre transformation is an application of the duality relationship between points and lines. The functional relationship specified by can be represented equally well as a set of points, or as a set of tangent lines specified by their slope and intercept values.
The generalization to convex functions of convex sets is straightforward: has domain
where is the canonical inner product (scalar product) of .
Example N.1 
Let defined on the whole , where is a fixed constant. For fixed, the function of has first derivative and second derivative; there is one stationary point at , which is always a maximum. So and where . Clearly, , namely .
Example N.2 
Let for . For fixed, is continuous on compact, hence it always takes a finite maximum on it; it follows that . The stationary point at is in the domain if and only if , otherwise the maximum is taken either at or . We find
Example N.3 
The function is convex, for every (strict convexity is not required for the Legendre transformation to be well defined). Clearly is never upper-bounded as a function of , unless . Hence is defined on and . We may check involutivity: of course is always bounded as a "function" of , hence ; then for every we have and thus .
Example N.4 (many variables) 
Let be defined on , where is a real, positive definite matrix. Then is convex. has gradient and Hessian which is negative; hence the stationary point is a maximum. We have and
An equivalent definition in the differentiable case 
in which case one writes equivalently and We can see this by first taking the derivative of :
Then this equation taken together with the previous equation resulting from the maximization condition results in the following pair of reciprocal equations:
From these we see that and are inverses, as promised. They are unique up to an additive constant which is fixed by the additional requirement that
Although in some cases (e.g. thermodynamic potentials) a non-standard requirement is used:
The standard constraint will be considered in this article unless otherwise noted. The Legendre transformation is its own inverse, and is related to integration by parts.
Behaviour of differentials under Legendre transforms 
Let be a function of two independent variables and with the differential . Assume that it is convex in for every , then one may perform the Legendre transform in . Let be the variable conjugate to . If we want to change the differentials and to and (i.e. we want to build another function with its differential expressed in terms of and ), we simply consider the function and calculate:
The function is the result of Legendre transformation of in which only the independent variable has been replaced by . This is widely used in thermodynamics.
Hamilton-Lagrange mechanics 
A Legendre transform is used in classical mechanics to derive the Hamiltonian formulation from the Lagrangian formulation, and conversely. A typical Lagrangian has the form , where are coordinates on , is a positive real matrix, and . For every fixed, is a convex function of , while plays the role of constant. Hence the Legendre transform of as a function of is the Hamiltonian function .
In a more general setting are local coordinates on the tangent bundle of a manifold . For each , is a convex function of the tangent space . The Legendre transform gives the Hamiltonian as a function of the coordinates of the cotangent bundle ; the inner product used to define the Legendre transform is inherited from the canonical symplectic structure.
The strategy behind the use of Legendre transforms is to shift, from a function with one of its parameters an independent variable, to a new function with its dependence on a new variable (the partial derivative of the original function with respect to the independent variable). The new function is the difference between the original function and the product of the old and new variables. For example, while the internal energy is an explicit function of the extensive variables entropy, volume (and chemical composition)
with the differential
the Helmholtz free energy is obtained in the following way using the Legendre transform:
Likewise, the enthalpy, the (non standard) Legendre transform of U with respect to V:
becomes a function of the entropy and the intensive quantity, (pressure), as natural variables, and is useful when the (external) pressure is constant. The free energies (Helmholtz and Gibbs), are obtained through further Legendre transforms, by subtracting TS (from U and H respectively), shift dependence from the entropy S to its conjugate intensive variable temperature T, and are useful when it is constant.
An example – variable capacitor 
As another example from physics, consider a parallel-plate capacitor in which the plates can move relative to one another. Such a capacitor would allow us to transfer the electric energy which is stored in the capacitor into external mechanical work done by the forces acting on the plates. You can think of the electric charge as analogous to the "charge" of a gas in a cylinder, and the resulting mechanical force being exerted on a piston.
Suppose we wanted to compute the force on the plates as a function of x, the distance which separates them. To find the force we will compute the potential energy and then use the definition of force as the gradient of the potential energy function.
The energy stored in a capacitor of capacitance C(x) and charge Q is
where we have abstracted away the dependence on the area of the plates, the dielectric constant of the material between the plates, and the separation x as the capacitance C(x).
The force F between the plates due to the electric field is
However, suppose the voltage between the plates V is maintained constant by connection to a battery, which is a reservoir for charge at constant potential difference. To find the force we first compute the non-standard Legendre transform
The force now becomes the negative gradient of the Legendre transform
Probability theory 
In large deviations theory, the rate function is defined as the Legendre transformation of the logarithm of the moment generating function of a random variable. An important application of the rate function is in the calculation of tail probabilities of sums of i.i.d. random variables.
Geometric interpretation 
For a strictly convex function the Legendre transformation can be interpreted as a mapping between the graph of the function and the family of tangents of the graph. (For a function of one variable, the tangents are well-defined at all but at most countably many points since a convex function is differentiable at all but at most countably many points.)
For this line to be tangent to the graph of a function f at the point (x0, f(x0)) requires
f' is strictly monotone as the derivative of a strictly convex function, and the second equation can be solved for x0, allowing to eliminate x0 from the first giving the y-intercept b of the tangent as a function of its slope m:
Here f* denotes the Legendre transform of f.
The family of tangents of the graph of f parameterized by m is therefore given by
or, written implicitly, by the solutions of the equation
The graph of the original function can be reconstructed from this family of lines as the envelope of this family by demanding
Eliminating m from these two equations gives
Identifying y with f(x) and recognizing the right side of the preceding equation as the Legendre transform of f* we find
Legendre transformation in more than one dimension 
For a differentiable real-valued function on an open subset U of Rn the Legendre conjugate of the pair (U, f) is defined to be the pair (V, g), where V is the image of U under the gradient mapping Df, and g is the function on V given by the formula
Alternatively, if X is a real vector space and Y is its dual vector space, then for each point x of X and y of Y, there is a natural identification of the cotangent spaces T*Xx with Y and T*Yy with X. If f is a real differentiable function over X, then ∇f is a section of the cotangent bundle T*X and as such, we can construct a map from X to Y. Similarly, if g is a real differentiable function over Y, ∇g defines a map from Y to X. If both maps happen to be inverses of each other, we say we have a Legendre transform.
When the function is not differentiable, the Legendre transform can still be extended, and is known as the Legendre-Fenchel transformation. In this more general setting, a few properties are lost: for example, the Legendre transform is no longer its own inverse (unless there are extra assumptions, like convexity).
Further properties 
In the following the Legendre transform of a function f is denoted as f*.
Scaling properties 
The Legendre transformation has the following scaling properties: For a>0,
It follows that if a function is homogeneous of degree r then its image under the Legendre transformation is a homogeneous function of degree s, where 1/r + 1/s = 1. Thus, the only monomial whose degree is invariant under Legendre transform is the quadratic.
Behavior under translation 
Behavior under inversion 
Behavior under linear transformations 
Let A be a linear transformation from Rn to Rm. For any convex function f on Rn, one has
where A* is the adjoint operator of A defined by
A closed convex function f is symmetric with respect to a given set G of orthogonal linear transformations,
if and only if f* is symmetric with respect to G.
Infimal convolution 
The infimal convolution of two functions f and g is defined as
Let f1, …, fm be proper convex functions on Rn. Then
See also 
- Arnol'd, Vladimir Igorevich (1989). Mathematical Methods of Classical Mechanics (second edition). Springer. ISBN 0-387-96890-3.
- Rockafellar, R. Tyrrell (1996). Convex Analysis (paperback republication of 1970 ed.). Princeton University Press. ISBN 0-691-01586-4.
- Zia, R. K. P. et al. (2009). Making Sense of the Legendre Transform. arXiv:0806.1147.
- Touchette, Hugo (2005-07-27). "Legendre-Fenchel transforms in a nutshell" (PDF). Retrieved 2007-07-24.
- Touchette, Hugo (2006-11-21). "Elements of convex analysis" (PDF). Retrieved 2008-03-26.
- "Legendre transform with figures". Retrieved 2012-09-26.
- "Legendre and Legendre-Fenchel transforms in a step-by-step explanation". Retrieved 2013-05-18.