## The Legendre transformation in physics

In both classical mechanics and in statistical mechanics, at some point while you’re following the derivations, suddenly an expression like “and this is the Legendre transformation” will pop up. Now, in my experience that was it. I was so confused: “Wait what was the transformation? We were just messing around with differentials.” It’s possible my experience was an outlier, but in case it isn’t (and because the transformation itself is kind of cool), here are some notes describing what it actually is.

Say we have a function $\displaystyle f(x,y)$. We define the exact differential of the function as

$\displaystyle df = \frac{\partial f}{\partial x}dx + \frac{\partial f}{\partial y}dy$

and we can further introduce the variables $\displaystyle u=\partial f/\partial x$ and $\displaystyle v = \partial f/\partial y$ such that

$\displaystyle df = udx + vdy$.

We call $\displaystyle u$ and $\displaystyle x$ conjugate variables; likewise $\displaystyle v$ and $\displaystyle y$. We now define the Legendre transformation as the addition or subtraction of a conjugate variable pair to the original function, with the goal “swapping differentials.” An example to illustrate: we introduce a new function

$\displaystyle g = f - ux$.

Let’s take the total derivative of this expression to give

$\displaystyle dg = d(f - ux) = df - xdu - udx = {udx} + vdy - xdu - udx$.

We see that the $\displaystyle udx$ terms cancel out leaving

$\displaystyle dg = -xdu + vdy$.

So the transformation has swapped the first conjugate variable pair, with the differential now on the $\displaystyle u$ rather than the $\displaystyle x$. We can even write $\displaystyle g=g(u,y)$ by analogy with how we started out. Try out the transformation

$\displaystyle h = f - vy$

for yourself.

In classical mechanics, the time-independent Lagrangian $\displaystyle L=L(q,\dot{q})$ can be turned into another function $\displaystyle H=H(q,p)$ where $\displaystyle \dot{q}$ (the canonical velocity) and $\displaystyle p$ (the canonical momentum) are conjugate variables. Those familiar can now recognize the Legendre transformation definition of this Hamiltonian (with an unimportant total minus sign)

$\displaystyle H = \dot{q}p - L$.

In statistical mechanics, the First Law of thermodynamics is typically written as

$\displaystyle dU = TdS - PdV + \mu dN$.

That is, the change in internal energy $\displaystyle dU$ is related to the temperature times the change in entropy $\displaystyle TdS$, the negative of the pressure times the change in volume $\displaystyle -PdV$, and the so-called chemical potential times the change in the number of particles $\displaystyle \mu dN$ (in general for many particle types this last term will be a sum). Notably, the conjugate variables come in pairs of one intensive and one extensive variable.

Now, via Legendre transformations, we can introduce a whole family of thermodynamic potentials:

• The enthalpy $\displaystyle H = U + PV$.
• The Helmholtz free energy $\displaystyle F=U - TS$.
• The Gibbs free energy $\displaystyle G=U-TS+PV=H-TS=F+PV$.
• The grand potential $\displaystyle \Omega=U - TS - \mu N$.
• Another useful one that I’m not sure has a name is $\displaystyle \phi=U - TS +PV - \mu N = 0$.

Now, since $\displaystyle U=U(S,V,N)$, the reader can now try, using the transformations above, to write similar expressions for the other potentials. For example, $\displaystyle H=H(S,P,N)$.

To reiterate: the Legendre transformation are when we add or subtract a conjugate variable pair to a function in order to swap which of the two variables is “under the differential operator”.  This becomes really useful for deriving things like the Maxwell relations.