Legendre transformations are commonly used in thermodynamics (to switch between different independent variables) and classical mechanics (to switch between the Lagrange and Hamilton formalisms). But you rightly ask: what exactly is a Legendre transformation? Where does it come from? What makes it work? In (1D) classical mechanics, for example: if we have a [Lagrangian][3] $L(q,\dot{q}[t])$, why can we define a variable $$p = \frac{\partial L}{\partial\dot{q}}$$ and expect to be able to construct a new function (the [Hamiltonian][4]) $$H(q,p[t]) = p\dot{q}-L(q,\dot{q}[t])$$ that behaves well? What's the relationship between both functions? Let's look at the Lagrangian and Hamiltonian as a guiding example. I'll keep it fairly abstract/general, but the notation of Lagrangian/Hamiltonian can help make things more concrete and clearer. One thing I will do, however, is leave out the explicit time dependence. It's not important to our analysis and more often than not there will indeed be no explicit time dependence. Furthermore, I'll denote $v\equiv\dot{q}$ to put less emphasis on the relation to $q$, since it is not important for the Legendre transformation. **So what do we need for a Legendre transformation?** --- Well, first of all we need two variables $v$, $p$ that are single-valued functions of each other. Another way to put this is that $p$ must be a [monotone function][1] of $v$ and vice versa. Figure 1 shows an example of such a function. ![v and p are single-valued functions of each other][2] *Figure 1. Example of a single-valued relation between $v$ and $p$.* For such variables it is always possible to construct a pair of functions with the property that differentiation of one of the functions with respect to one of the variables yields the second variable. Equivalently, the derivative of the second function with respect to this second variable yields the first variable. In our example of classical mechanics, the functions we can construct for our two variables $v$ and $p$ are the Lagrangian $L(q,v)$ and the Hamiltonian $H(q,p)$.$^1$ They satisfy (by definition) the differential relations $$\begin{align} \frac{\partial L}{\partial v} &= p \\ \frac{\partial H}{\partial p} &= v \end{align}$$ **Why does it work?** --- Indeed, why *can* we construct such functions? Take another look at figure 1. The way the graph is set up, it looks like a graph of $p$ as a function of $v$. So if we integrate this function between $0$ and some value $v$ (shown on the graph), the answer we get is the orange area under the curve. This integral is our first function! Indeed, if we return to the notation of our classical example (I'm going to leave out the $q$ dependence from now on): $$L(v) = \int_0^v{p(v')dv'}$$ because $$\frac{\partial L}{\partial v} = \frac{\partial}{\partial v}\int_0^v{p(v')dv'} = p.$$ Now if we consider the curve in Figure 1 to be $v$ as a function of $p$ (rotate the graph around if that makes it clearer to you), we can make a similar reasoning. This time we integrate between $0$ and $p$ where $p$ has been chosen to correspond to our earlier $v$.$^2$ This integral is our second function; so in terms of our 1D classical example: $$H(p) = \int_0^p{v(p')dp'}.$$ You may have noticed that we've described a rectangle with the integrals (and therefore the two functions $L$ and $H$). This rectangle has a total surface of $p\cdot v$. But we've also calculated its surface in two parts: the green and the orange. The sum of both must therefore be equal to $pv$. This yields the Legendre transformation $$L(v) + H(p) = pv$$ or $$H(p) = pv - L(v)$$. **How does a Legendre transformation work in practice?** --- Here's a 3 step plan: 1. Start with your first function, e.g. $L(v)$. $\left[\right.$or $U(S)$ for a thermodynamical example$\left.\right]$ 2. Find the *conjugate variable* by differentiation: $$p = \frac{\partial L}{\partial v} \hspace{2cm} \left[T = \frac{\partial U}{\partial S}\right]$$ 3. Construct the second function $$H(p) = p\cdot v - L(v) \hspace{2cm} \left[\left(-F(T)\right) = T\cdot S - U(S)\right]$$ and insert the conjugate variable wherever you can, i.e. replace $v$ $[S]$ with the expression $v(p)$ $[S(T)]$ throughout the entire expression. Partly from Figure 1, it should now be clear that the two functions are not only generally different from each other, they describe things from a different perspective (we had to view the curve in Figure 1 once as a function $p(v)$ and once as a function $v(p)$). The functions are complementary and their close relation is governed by a Legendre transformation. --- $^1$ These are also functions of $q$, but that's not important. They could be functions of any number of distinct variables, though their list of variables will obviously be the same except for $v$ and $p$. Indeed, the Legendre transform doesn't change any of the other dependencies. If this is not clear now, it should become so throughout the rest of this explanation. $^2$ Note that this is where the single-valuedness of the relation between $v$ and $p$ is required. If $v(p)$ was a parabola for example, then there would be ambiguity about which $p$ corresponds to the $v$ we used. [1]: http://en.wikipedia.org/wiki/Monotone_function [2]: https://i.sstatic.net/geJtM.png [3]: http://en.wikipedia.org/wiki/Lagrangian [4]: http://en.wikipedia.org/wiki/Hamiltonian_mechanics