# Free Energy and Thermodynamic Potentials: Trading Variables You Cannot Fix for Ones You Can

> Legendre transformation replaces the natural variables (S,V,N) of internal energy by the controllable (T,p,μ), giving F, H, G, Ω, maximum work, and the Maxwell relations.
> https://rikai.mugen-giken.com/en/physics/thermodynamics/thermodynamic-potentials

## 0. Key points

- The internal energy $U$ is a *complete* thermodynamic function only when it is written as a function of $(S, V, N)$. But what a laboratory controls is not $S$ but the temperature $T$, and not $V$ but the pressure $p$. The operation that bridges this mismatch is the **Legendre transformation**.
- For a strictly convex function the Legendre transformation is a change of variables that **loses no information**, and it is involutive: performing it twice returns the original function. The essential point is not the algebraic act of subtracting $TS$ from $U$, but the expulsion of $S$ from the list of independent variables in favour of $T$.
- The functions obtained in this way — the Helmholtz free energy $F(T,V,N)$, the enthalpy $H(S,p,N)$, the Gibbs free energy $G(T,p,N)$ and the grand potential $\Omega(T,V,\mu)$ — are collectively called thermodynamic potentials.
- Each potential supplies a variational principle telling us which equilibrium state is realised when a given set of variables is held fixed. At constant temperature and volume $F$ decreases; at constant temperature and pressure $G$ decreases. The work extractable in an isothermal process is bounded above by $-\Delta F$.
- Because the differential of each potential is exact (mixed second partials commute), four **Maxwell relations** follow. They let us translate a quantity such as $(\partial S/\partial V)_T$, which is hard to measure, into $(\partial p/\partial T)_V$, which is easy.
- As applications we determine $(\partial U/\partial V)_T$ from the equation of state alone, prove $C_p - C_V = TV\alpha^2/\kappa_T$, and compute the inversion temperature of the Joule–Thomson coefficient, in each case carrying the calculation through to the end.

## 1. Motivation: why the internal energy alone is not enough

As we saw in [The laws of thermodynamics](/en/physics/thermodynamics/laws-of-thermodynamics), combining the internal energy guaranteed by the first law (<Ref to="physics/thermodynamics/laws-of-thermodynamics#thm-internal-energy" text="existence of the internal energy" />) with the entropy guaranteed by the second law (<Ref to="physics/thermodynamics/laws-of-thermodynamics#thm-entropy-exists" text="existence of the entropy" />) yields, for quasi-static processes, the relation

$$
dU = T\,dS - p\,dV + \mu\,dN .
$$

This is the **fundamental relation of thermodynamics**, also called the Gibbs relation. Here $U$ is the internal energy, $S$ the entropy, $V$ the volume, $N$ the particle number, $T$ the absolute temperature, $p$ the pressure and $\mu$ the chemical potential.

The equation has exactly the shape of the total differential of a function $U = U(S, V, N)$. That is,

$$
T = \left(\frac{\partial U}{\partial S}\right)_{V,N},\qquad
p = -\left(\frac{\partial U}{\partial V}\right)_{S,N},\qquad
\mu = \left(\frac{\partial U}{\partial N}\right)_{S,V},
$$

so that from the single function $U(S,V,N)$ the temperature, the pressure and the chemical potential all follow by differentiation. In this sense $U(S,V,N)$ contains the entire thermodynamics of the system.

For the experimenter, however, there is a serious inconvenience here. **Experiments at fixed entropy are, in most cases, impossible.** Placing a test tube in an adiabatic vessel so that it exchanges no heat with its surroundings does keep $S$ constant (if the process is reversible), but chemical and biological experiments are normally carried out in a thermostat, at atmospheric pressure. What is under control is $(T, p)$, not $(S, V)$.

A naive proposal suggests itself: "why not simply rewrite $U$ as a function of $(T,V,N)$?" This fails, and it is worth saying at once why. Given $U$ as a function of $(T,V,N)$, one cannot recover $S$ from it. Indeed, for a monatomic ideal gas $U = \tfrac{3}{2} N k_{\mathrm B} T$, an expression in which no volume dependence appears at all; the information contained in the equation of state $pV = N k_{\mathrm B} T$ has been thrown away. Mere substitution of variables destroys information.

The method that exchanges the independent variables while keeping the lost information is the **Legendre transformation**. It is mathematically identical to the operation of analytical mechanics that builds a Hamiltonian $H(q,p)$ out of a Lagrangian $L(q,\dot q)$ (see [Hamiltonian mechanics](/physics/mechanics/hamiltonian-mechanics) and <Ref to="physics/mechanics/hamiltonian-mechanics#def-hamiltonian" text="the definition of the Hamiltonian" />). That the same instrument appears in thermodynamics and in mechanics is no accident: in both cases one is re-encoding a function by using the slopes of its tangent lines as the new variable.

## 2. Preliminaries: complete thermodynamic functions and extensivity

We first fix the terminology.

<Definition id="def-complete-function" title="Complete thermodynamic function">
Let $\Phi$ be a state function of a thermodynamic system and let $(x_1,\dots,x_n)$ be a list of variables. If, once the functional form $\Phi = \Phi(x_1,\dots,x_n)$ is given, every thermodynamic quantity ($T, p, \mu, S, U$ and so on) is determined by differentiation alone, then $\Phi$ is called a **complete thermodynamic function** (or a fundamental relation) in the variables $(x_1,\dots,x_n)$, and $(x_1,\dots,x_n)$ are called its **natural variables**.
</Definition>

The fundamental relation $dU = T\,dS - p\,dV + \mu\,dN$ asserts that the natural variables of $U$ are $(S,V,N)$. By contrast, $U$ expressed in terms of $(T,V,N)$ is not a complete thermodynamic function, since, as we saw in $\S 1$, information is lost.

A second property we shall use is **extensivity**. Each of $U, S, V, N$ is an extensive variable: replacing the system by $\lambda$ copies of itself multiplies the quantity by $\lambda$. Hence

$$
U(\lambda S, \lambda V, \lambda N) = \lambda\, U(S,V,N) \qquad (\lambda > 0).
$$

Differentiating both sides with respect to $\lambda$ and then setting $\lambda = 1$, Euler's theorem on homogeneous functions gives

$$
U = T S - p V + \mu N .
$$

Combining this identity with the fundamental relation produces one further relation, which we shall need later.

<Proposition id="prop-gibbs-duhem" title="The Gibbs–Duhem relation">
If $U$ is homogeneous of degree $1$ in $(S,V,N)$ and satisfies the fundamental relation $dU = T\,dS - p\,dV + \mu\,dN$, then
$$
S\,dT - V\,dp + N\,d\mu = 0 .
$$
In other words the intensive variables $T, p, \mu$ are not independent: fixing two of them determines the third.
</Proposition>

<Proof of="prop-gibbs-duhem">
Taking the total differential of both sides of the Euler relation $U = TS - pV + \mu N$ gives

$$
dU = T\,dS + S\,dT - p\,dV - V\,dp + \mu\,dN + N\,d\mu .
$$

Subtracting the fundamental relation $dU = T\,dS - p\,dV + \mu\,dN$ term by term, the contributions $T\,dS$, $-p\,dV$ and $\mu\,dN$ cancel, and what remains is

$$
0 = S\,dT - V\,dp + N\,d\mu .
$$
</Proof>

## 3. The Legendre transformation

### 3.1. The geometric idea

Consider a strictly convex function $f(x)$ of one variable. Each point of its graph carries a tangent line, and since the slope $p = f'(x)$ is strictly increasing, slopes and points of tangency correspond one to one. We may therefore describe the curve as a family of tangent lines instead of a set of points. Specifying a tangent line requires its slope $p$ together with its $y$-intercept — and that $y$-intercept is precisely the value of the Legendre transform.

<Figure caption="The geometry of the Legendre transformation: to a tangent line of slope p, assign its y-intercept g(p)">
<svg viewBox="0 0 400 320" width="100%" role="img" aria-label="The graph of a convex function with a tangent line, and the Legendre transform as the y-intercept of that tangent">
  <g stroke="currentColor" fill="none" stroke-width="1">
    <line x1="40" y1="230" x2="360" y2="230" />
    <line x1="60" y1="40" x2="60" y2="300" />
  </g>
  <polyline points="60,230 105,225 150,210 195,185 240,150 285,105 330,50"
            fill="none" stroke="currentColor" stroke-width="2.5" />
  <line x1="48" y1="281" x2="345" y2="85"
        stroke="var(--sl-color-accent)" stroke-width="2" />
  <line x1="195" y1="185" x2="195" y2="230"
        stroke="currentColor" stroke-width="1" stroke-dasharray="4 3" />
  <circle cx="195" cy="185" r="4" fill="currentColor" />
  <circle cx="60" cy="275" r="4" fill="var(--sl-color-accent)" />
  <g fill="currentColor" font-size="13">
    <text x="336" y="46">f(x)</text>
    <text x="188" y="248">x</text>
    <text x="252" y="205" fill="var(--sl-color-accent)">slope p = f'(x)</text>
    <text x="72" y="279" fill="var(--sl-color-accent)">g(p) = f(x) - p x</text>
    <text x="30" y="34">y</text>
  </g>
</svg>
</Figure>

<Definition id="def-legendre" title="Legendre transformation">
Let $I \subset \mathbb{R}$ be an open interval and let $f: I \to \mathbb{R}$ be of class $C^2$ with $f''(x) > 0$ for every $x \in I$ (strict convexity). Put $J := f'(I)$. Since $f'$ is strictly increasing, $f' : I \to J$ is a bijection; write its inverse as $x(\cdot) : J \to I$. The function on $J$ defined by
$$
g(p) := f\bigl(x(p)\bigr) - p\, x(p)
$$
is called the **Legendre transform** of $f$.
</Definition>

<Aside type="note">
In mathematics (convex analysis) one calls $f^{*}(p) = \sup_x \bigl(px - f(x)\bigr)$ the convex conjugate. Under the hypotheses above the supremum is attained at $p = f'(x)$, so that $f^{*}(p) = p\,x(p) - f(x(p)) = -g(p)$. Physics conventionally works with $g$, that is, with the opposite sign. The sign in $F = U - TS$ reflects this convention.
</Aside>

### 3.2. No information is lost

The point of the Legendre transformation is that the content of the function survives the change of variables: the inverse transformation returns the original function.

<Theorem id="thm-legendre-involution" title="Involutivity of the Legendre transformation">
Under the hypotheses and notation of <Ref to="def-legendre" />, the following hold.

1. $g$ is of class $C^2$ on $J$, with $g'(p) = -x(p)$ and $g''(p) = -1/f''\bigl(x(p)\bigr) < 0$. In particular $g$ is strictly concave.
2. Form from $g$ the correspondence $p \mapsto x$ given by $x = -g'(p)$ (strictly monotone, hence bijective, because $g'' < 0$), write its inverse as $p(\cdot)$, and set $\tilde f(x) := g\bigl(p(x)\bigr) + p(x)\, x$. Then $\tilde f = f$ on $I$.
</Theorem>

<Proof of="thm-legendre-involution">
**(1)** Since $f'$ is of class $C^1$ with $(f')' = f'' > 0$, the inverse function theorem shows that $x(\cdot)$ is of class $C^1$ on $J$ with $x'(p) = 1/f''(x(p))$. Hence $g(p) = f(x(p)) - p\,x(p)$ is of class $C^1$, and the chain rule gives

$$
g'(p) = f'\bigl(x(p)\bigr)\,x'(p) - x(p) - p\,x'(p).
$$

By the definition of $x(p)$ we have $f'(x(p)) = p$, so the first and third terms cancel and

$$
g'(p) = -x(p)
$$

remains. This cancellation is the **envelope theorem**, and it is the core reason the Legendre transformation is easy to work with. Differentiating once more gives $g''(p) = -x'(p) = -1/f''(x(p))$, which is negative because $f'' > 0$. Since $f''$ is continuous, so is $g''$, and therefore $g$ is of class $C^2$.

**(2)** By (1) we have $-g'(p) = x(p)$, so the correspondence $x = -g'(p)$ is nothing but $x(\cdot)$, whose inverse is $f'$. That is, $p(x) = f'(x)$. Substituting,

$$
\tilde f(x) = g\bigl(f'(x)\bigr) + f'(x)\,x
= \Bigl[f(x) - f'(x)\,x\Bigr] + f'(x)\,x = f(x) ,
$$

where in the first equality we inserted $p = f'(x)$ and $x(p) = x$ into the definition of $g$.
</Proof>

<Example id="ex-legendre-quadratic" title="Legendre transform of a quadratic">
Take $f(x) = \tfrac{1}{2}k x^2$ with $k > 0$ and $I = \mathbb{R}$. Since $f'' = k > 0$, the hypotheses hold. From $p = f'(x) = kx$ we get $x(p) = p/k$ and $J = \mathbb{R}$. Substituting into the definition,

$$
g(p) = \frac{1}{2}k\left(\frac{p}{k}\right)^2 - p\cdot\frac{p}{k}
= \frac{p^2}{2k} - \frac{p^2}{k} = -\frac{p^2}{2k}.
$$

Indeed $g'' = -1/k = -1/f''$, in agreement with <Ref to="thm-legendre-involution" /> (1). Checking the inverse transformation, $-g'(p) = p/k = x$ and $\tilde f(x) = g(kx) + kx\cdot x = -\tfrac{1}{2}kx^2 + kx^2 = \tfrac{1}{2}kx^2 = f(x)$, so (2) holds as well.
</Example>

<Remark id="rem-convexity-physics">
Regarding $U$ in thermodynamics as a function of $S$, we have $\left(\partial^2 U/\partial S^2\right)_V = \left(\partial T/\partial S\right)_V = T/C_V$. For a stable system, whose heat capacity at constant volume satisfies $0 < C_V < \infty$, this is positive, so $U$ is strictly convex in $S$ and the hypotheses of <Ref to="def-legendre" /> are met. Convexity is not a mathematical convenience: it *is* thermodynamic stability (see the remark following <Ref to="prop-cp-cv" /> and the Appendix).
</Remark>

## 4. The four thermodynamic potentials

<Definition id="def-potentials" title="Thermodynamic potentials">
For the internal energy $U(S,V,N)$ define
$$
\begin{aligned}
F &:= U - TS &&\text{(Helmholtz free energy)}\\
H &:= U + pV &&\text{(enthalpy)}\\
G &:= U - TS + pV = F + pV = H - TS &&\text{(Gibbs free energy)}\\
\Omega &:= U - TS - \mu N = F - \mu N &&\text{(grand potential)}
\end{aligned}
$$
where $T = (\partial U/\partial S)_{V,N}$, $p = -(\partial U/\partial V)_{S,N}$ and $\mu = (\partial U/\partial N)_{S,V}$.
</Definition>

Here $F$ is the Legendre transform in $S \mapsto T$, and $H$ the Legendre transform in $V \mapsto -p$ (note that $U$ is convex in $V$ and that the conjugate variable is $-p$); $G$ performs both at once, and $\Omega$ transforms $N \mapsto \mu$ in addition.

<Figure caption="The thermodynamic potentials linked by Legendre transformations">
<Mermaid code={`flowchart LR
  U["U(S, V, N)"] -->|"S → T"| F["F(T, V, N)"]
  U -->|"V → -p"| H["H(S, p, N)"]
  F -->|"V → -p"| G["G(T, p, N)"]
  H -->|"S → T"| G
  F -->|"N → μ"| W["Ω(T, V, μ)"]`} />
</Figure>

<Proposition id="prop-differentials" title="Differentials and natural variables of the thermodynamic potentials">
Given the fundamental relation $dU = T\,dS - p\,dV + \mu\,dN$, the quantities of <Ref to="def-potentials" /> satisfy
$$
\begin{aligned}
dF &= -S\,dT - p\,dV + \mu\,dN, &\quad& F = F(T,V,N),\\
dH &= T\,dS + V\,dp + \mu\,dN, &\quad& H = H(S,p,N),\\
dG &= -S\,dT + V\,dp + \mu\,dN, &\quad& G = G(T,p,N),\\
d\Omega &= -S\,dT - p\,dV - N\,d\mu, &\quad& \Omega = \Omega(T,V,\mu).
\end{aligned}
$$
Moreover, extensivity gives $G = \mu N$ and $\Omega = -pV$.
</Proposition>

<Proof of="prop-differentials">
Taking the total differential of $F = U - TS$ gives $dF = dU - T\,dS - S\,dT$. Inserting the fundamental relation,

$$
dF = (T\,dS - p\,dV + \mu\,dN) - T\,dS - S\,dT = -S\,dT - p\,dV + \mu\,dN ,
$$

so that $T\,dS$ cancels. This cancellation is the same computation as $g' = -x$ in <Ref to="thm-legendre-involution" /> (1). Only the differentials $dT, dV, dN$ appear on the right-hand side, so the natural variables of $F$ are $(T,V,N)$.

For $H = U + pV$ we get $dH = dU + p\,dV + V\,dp = T\,dS + V\,dp + \mu\,dN$, with $p\,dV$ cancelling. Applying the same operation to $G = H - TS$ gives $dG = dH - T\,dS - S\,dT = -S\,dT + V\,dp + \mu\,dN$. For $\Omega = F - \mu N$ we get $d\Omega = dF - \mu\,dN - N\,d\mu = -S\,dT - p\,dV - N\,d\mu$.

Finally, using the Euler relation $U = TS - pV + \mu N$ from $\S 2$, we obtain at once $G = U - TS + pV = \mu N$ and $\Omega = U - TS - \mu N = -pV$.
</Proof>

The proposition supplies a rule for reading off derivatives. If, for instance, $F(T,V,N)$ is known, then

$$
S = -\left(\frac{\partial F}{\partial T}\right)_{V,N},\quad
p = -\left(\frac{\partial F}{\partial V}\right)_{T,N},\quad
\mu = \left(\frac{\partial F}{\partial N}\right)_{T,V},
$$

and the internal energy is recovered as $U = F + TS = F - T\left(\partial F/\partial T\right)_{V,N}$. This last identity can also be written $U = -T^2 \bigl[\partial (F/T)/\partial T\bigr]_{V,N}$, known as the **Gibbs–Helmholtz equation** (<Ref to="exr-gibbs-helmholtz" />). This is exactly what the claim of <Ref to="def-complete-function" /> means when we say that $F$ is a complete thermodynamic function.

<Example id="ex-ideal-gas-free-energy" title="Reconstructing everything from the free energy of an ideal gas">
Statistical mechanics ([the canonical ensemble](/physics/thermodynamics/canonical-ensemble)) gives, for the Helmholtz free energy of a monatomic ideal gas,
$$
F(T,V,N) = -N k_{\mathrm B} T\left[\ln\frac{V}{N\lambda(T)^3} + 1\right],
\qquad
\lambda(T) = \frac{h}{\sqrt{2\pi m k_{\mathrm B} T}}
$$
where $\lambda$ is the thermal de Broglie wavelength. Let us compute every other quantity from it.

**Pressure.** Since $\lambda$ does not depend on $V$,

$$
p = -\left(\frac{\partial F}{\partial V}\right)_{T,N}
= N k_{\mathrm B} T \frac{\partial}{\partial V}\ln V = \frac{N k_{\mathrm B} T}{V}.
$$

The equation of state has appeared.

**Entropy.** From $\lambda \propto T^{-1/2}$ we get $\ln \lambda^{3} = -\tfrac{3}{2}\ln T + \text{const}$, so writing the bracket as $A(T,V,N) := \ln\bigl(V/(N\lambda^3)\bigr) + 1$ we have $\partial A/\partial T = \tfrac{3}{2T}$. Hence

$$
S = -\left(\frac{\partial F}{\partial T}\right)_{V,N}
= N k_{\mathrm B} A + N k_{\mathrm B} T \cdot \frac{3}{2T}
= N k_{\mathrm B}\left[\ln\frac{V}{N\lambda^3} + \frac{5}{2}\right].
$$

This is the Sackur–Tetrode equation (<Ref to="physics/thermodynamics/microcanonical-ensemble#thm-sackur-tetrode" text="derived from the microcanonical ensemble" />).

**Internal energy.** $U = F + TS = -N k_{\mathrm B}T A + N k_{\mathrm B} T\bigl(A + \tfrac{3}{2}\bigr) = \tfrac{3}{2}N k_{\mathrm B} T$.

**Gibbs free energy and chemical potential.** $G = F + pV = -N k_{\mathrm B} T A + N k_{\mathrm B} T = -N k_{\mathrm B} T \ln\dfrac{V}{N\lambda^3}$, and from $G = \mu N$ in <Ref to="prop-differentials" />,

$$
\mu = -k_{\mathrm B}T \ln\frac{V}{N\lambda^{3}} = k_{\mathrm B} T \ln\bigl(n \lambda^{3}\bigr),
\qquad n := N/V .
$$

The chemical potential grows with the density and with decreasing temperature (larger $\lambda$). The classical approximation breaks down when $n\lambda^3 \sim 1$, and [quantum statistics](/physics/thermodynamics/quantum-statistics) becomes necessary.

Note that $p, S, U, G, \mu$ all came out of the single function $F$. That is the power of a complete thermodynamic function.
</Example>

## 5. Equilibrium conditions and maximum work

The other role of the thermodynamic potentials is to decide which state is realised as the equilibrium one. For an isolated system the criterion was maximum entropy ([The laws of thermodynamics](/en/physics/thermodynamics/laws-of-thermodynamics)). For a system in contact with a heat bath it is replaced by minimum free energy.

<Theorem id="thm-free-energy-min" title="Decrease of the free energy in an isothermal isochoric process">
Suppose a system exchanges heat only with a heat bath at temperature $T_0$, that its volume $V$ and particle number $N$ are fixed, and that it performs no work other than through volume change. If the system is in equilibrium at temperature $T_0$ both in the initial state $i$ and in the final state $f$, then $F := U - T_0 S$ satisfies
$$
F_f - F_i \le 0 ,
$$
with equality if and only if the process is reversible.
</Theorem>

<Proof of="thm-free-energy-min">
Since the volume is fixed and no other work is done, the work performed by the system is $W = 0$. The first law gives $\Delta U = Q$, where $Q$ is the heat received from the bath. On the other hand, the <Ref to="physics/thermodynamics/laws-of-thermodynamics#thm-clausius-inequality" text="Clausius inequality" /> applied to exchange with a bath at temperature $T_0$ gives

$$
\Delta S \ \ge\ \frac{Q}{T_0} ,
$$

with equality only for a reversible process. Therefore

$$
\Delta F = \Delta U - T_0 \Delta S = Q - T_0\Delta S \le Q - Q = 0 .
$$

The second equality used $\Delta U = Q$, and the inequality used the Clausius inequality.
</Proof>

Consequently, if a system is left alone with $T, V, N$ fixed, $F$ keeps decreasing and the system comes to rest at the state where $F$ is minimal. Running the same argument for a process at constant external pressure $p_0$, in which the system performs work $p_0\,\Delta V$ on its surroundings, we have $W = p_0 \Delta V$ and hence $\Delta U = Q - p_0\Delta V$, from which $\Delta G = \Delta U + p_0 \Delta V - T_0 \Delta S \le 0$ follows in the same way. Judging the spontaneity of a chemical reaction by the sign of $\Delta G$ is a direct consequence of this theorem.

<Corollary id="cor-max-work" title="Maximum work in an isothermal process">
Suppose a system is in contact with a heat bath at temperature $T_0$ and is in equilibrium at temperature $T_0$ both initially and finally. Then the work $W$ performed by the system on its surroundings during the process satisfies
$$
W \le -\Delta F ,
$$
with equality if and only if the process is reversible.
</Corollary>

<Proof of="cor-max-work">
The first law $\Delta U = Q - W$ gives $W = Q - \Delta U$. Substituting the Clausius inequality $Q \le T_0 \Delta S$,

$$
W \le T_0\Delta S - \Delta U = -\bigl(\Delta U - T_0 \Delta S\bigr) = -\Delta F .
$$

The condition for equality is that of the Clausius inequality, namely reversibility.
</Proof>

This is where the name "free energy" comes from. Of the change $-\Delta U$ in internal energy, the part that can be freely extracted as work is bounded by $-\Delta F = -\Delta U + T_0\Delta S$; the difference $T_0 \Delta S$ is the "bound" part that must be surrendered to the bath as heat.

<Aside type="tip">
In statistical mechanics the potentials appear directly as logarithms of partition functions: $F = -k_{\mathrm B}T\ln Z$ ([the canonical ensemble](/physics/thermodynamics/canonical-ensemble), <Ref to="physics/thermodynamics/canonical-ensemble#thm-free-energy" text="partition function and Helmholtz free energy" />) and $\Omega = -k_{\mathrm B}T \ln \Xi$ ([the grand canonical ensemble](/physics/thermodynamics/grand-canonical-ensemble), <Ref to="physics/thermodynamics/grand-canonical-ensemble#def-grand-potential" text="definition of the grand potential" />). Which potential one uses corresponds one to one with which ensemble one uses. The picture becomes clearer if one regards [the microcanonical ensemble](/physics/thermodynamics/microcanonical-ensemble), whose starting point is $S = k_{\mathrm B}\ln W$ (<Ref to="physics/thermodynamics/microcanonical-ensemble#def-boltzmann-entropy" text="the Boltzmann entropy" />), as the counterpart of $U(S,V,N)$.
</Aside>

## 6. The Maxwell relations

<Theorem id="thm-maxwell" title="Maxwell relations">
Consider a simple system with fixed particle number $N$, and suppose that on the region under consideration $U, H, F, G$ are of class $C^2$ in their respective natural variables. Then
$$
\begin{aligned}
\left(\frac{\partial T}{\partial V}\right)_{S} &= -\left(\frac{\partial p}{\partial S}\right)_{V}
&\quad&(\text{from}\ U),\\
\left(\frac{\partial T}{\partial p}\right)_{S} &= \phantom{-}\left(\frac{\partial V}{\partial S}\right)_{p}
&\quad&(\text{from}\ H),\\
\left(\frac{\partial S}{\partial V}\right)_{T} &= \phantom{-}\left(\frac{\partial p}{\partial T}\right)_{V}
&\quad&(\text{from}\ F),\\
\left(\frac{\partial S}{\partial p}\right)_{T} &= -\left(\frac{\partial V}{\partial T}\right)_{p}
&\quad&(\text{from}\ G).
\end{aligned}
$$
</Theorem>

<Proof of="thm-maxwell">
All four work in the same way, so we write out in detail the one coming from $F$. By <Ref to="prop-differentials" /> we have $F = F(T,V)$ (suppressing the fixed $N$) with

$$
S = -\left(\frac{\partial F}{\partial T}\right)_{V},
\qquad
p = -\left(\frac{\partial F}{\partial V}\right)_{T}.
$$

Since $F$ is of class $C^2$ by hypothesis, Schwarz's theorem on the commutation of second partial derivatives applies:

$$
\frac{\partial^2 F}{\partial V \partial T} = \frac{\partial^2 F}{\partial T \partial V}.
$$

The left-hand side is $\dfrac{\partial}{\partial V}\left(\dfrac{\partial F}{\partial T}\right)_V = -\left(\dfrac{\partial S}{\partial V}\right)_T$ and the right-hand side is $\dfrac{\partial}{\partial T}\left(\dfrac{\partial F}{\partial V}\right)_T = -\left(\dfrac{\partial p}{\partial T}\right)_V$. Cancelling the factor $-1$ on both sides gives $\left(\partial S/\partial V\right)_T = \left(\partial p/\partial T\right)_V$.

For $G(T,p)$ we have $S = -\left(\partial G/\partial T\right)_p$ and $V = \left(\partial G/\partial p\right)_T$, so Schwarz's theorem gives $-\left(\partial S/\partial p\right)_T = \left(\partial V/\partial T\right)_p$, which is the fourth identity.

For $U(S,V)$ we have $T = \left(\partial U/\partial S\right)_V$ and $-p = \left(\partial U/\partial V\right)_S$, whence $\left(\partial T/\partial V\right)_S = -\left(\partial p/\partial S\right)_V$; for $H(S,p)$ we have $T = \left(\partial H/\partial S\right)_p$ and $V = \left(\partial H/\partial p\right)_S$, whence $\left(\partial T/\partial p\right)_S = \left(\partial V/\partial S\right)_p$.
</Proof>

<Remark id="rem-maxwell-mnemonic">
There is no need to memorise the signs. Redo, each time, the procedure "write down the differential of the potential and cross-differentiate its coefficients", using the table in <Ref to="prop-differentials" />; the correct sign always comes out. Put the other way round, the Maxwell relations are nothing but a restatement of the fact that $dF$ and its companions are **exact** differentials, that is, that $F$ is a state function.
</Remark>

What makes the Maxwell relations useful in practice is that a derivative of the entropy, which cannot be measured directly, stands on the left, while a quantity readable off the equation of state stands on the right. The next proposition is the typical case.

<Proposition id="prop-energy-equation" title="The energy equation">
For a simple system with fixed particle number, on any region where $F$ is of class $C^2$,
$$
\left(\frac{\partial U}{\partial V}\right)_{T} = T\left(\frac{\partial p}{\partial T}\right)_{V} - p .
$$
That is, the volume dependence of the internal energy is fixed by the equation of state $p = p(T,V)$ alone.
</Proposition>

<Proof of="prop-energy-equation">
Differentiating $U = F + TS$ with respect to $V$ at constant $T$,

$$
\left(\frac{\partial U}{\partial V}\right)_T
= \left(\frac{\partial F}{\partial V}\right)_T + T\left(\frac{\partial S}{\partial V}\right)_T .
$$

The first term equals $-p$ by <Ref to="prop-differentials" />. To the second term we apply the third identity of <Ref to="thm-maxwell" />, $\left(\partial S/\partial V\right)_T = \left(\partial p/\partial T\right)_V$. Together these give the stated formula.
</Proof>

<Example id="ex-vdw-energy" title="Internal energy of a van der Waals gas">
For $n$ moles of a van der Waals gas the equation of state is
$$
\left(p + \frac{a n^2}{V^2}\right)(V - nb) = nRT,
\qquad\text{that is}\qquad
p = \frac{nRT}{V - nb} - \frac{an^2}{V^2}.
$$
The second term on the right does not depend on $T$, so

$$
\left(\frac{\partial p}{\partial T}\right)_V = \frac{nR}{V-nb},
\qquad
T\left(\frac{\partial p}{\partial T}\right)_V - p
= \frac{nRT}{V-nb} - \left(\frac{nRT}{V-nb} - \frac{an^2}{V^2}\right)
= \frac{an^2}{V^2}.
$$

By <Ref to="prop-energy-equation" /> we have $\left(\partial U/\partial V\right)_T = an^2/V^2$, so integrating in $V$ at fixed $T$ gives

$$
U(T,V) = -\frac{a n^2}{V} + \phi(T)
$$

where $\phi$ is a function of $T$ alone, namely the internal energy of the ideal gas reached in the dilute limit $V \to \infty$ (for instance $\tfrac{3}{2}nRT$ for a monatomic gas). When an intermolecular attraction $a$ is present, merely enlarging the volume increases the internal energy. For an ideal gas ($a=0$) we get $\left(\partial U/\partial V\right)_T = 0$, so Joule's law — that $U$ is a function of temperature alone — follows from the equation of state by itself.
</Example>

## 7. Relations among the response functions

The quantities normally measured in experiments are the following three kinds of response function.

<Definition id="def-response" title="Response functions">
For a system with fixed particle number, the quantities
$$
C_V := T\left(\frac{\partial S}{\partial T}\right)_{V},\qquad
C_p := T\left(\frac{\partial S}{\partial T}\right)_{p},\qquad
\alpha := \frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{p},\qquad
\kappa_T := -\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{T}
$$
are called respectively the heat capacity at constant volume, the heat capacity at constant pressure, the coefficient of thermal expansion and the isothermal compressibility.
</Definition>

<Proposition id="prop-cp-cv" title="Difference of the heat capacities at constant pressure and constant volume">
On any region where $\left(\partial V/\partial p\right)_T \ne 0$,
$$
C_p - C_V = T\left(\frac{\partial p}{\partial T}\right)_V\left(\frac{\partial V}{\partial T}\right)_p
= \frac{T V \alpha^2}{\kappa_T} .
$$
In particular, if $\kappa_T > 0$ then $C_p \ge C_V$.
</Proposition>

<Proof of="prop-cp-cv">
Regard $S$ as a function of $(T,V)$. Moving $T$ at constant $p$ moves $V$ as well, so the chain rule gives

$$
\left(\frac{\partial S}{\partial T}\right)_p
= \left(\frac{\partial S}{\partial T}\right)_V
+ \left(\frac{\partial S}{\partial V}\right)_T\left(\frac{\partial V}{\partial T}\right)_p .
$$

Multiplying both sides by $T$ and using the definitions in <Ref to="def-response" />,

$$
C_p = C_V + T\left(\frac{\partial S}{\partial V}\right)_T\left(\frac{\partial V}{\partial T}\right)_p .
$$

Replacing $\left(\partial S/\partial V\right)_T$ by $\left(\partial p/\partial T\right)_V$ using the third identity of <Ref to="thm-maxwell" /> yields the first equality.

Next we convert $\left(\partial p/\partial T\right)_V$ into measurable quantities. Setting $dV = 0$ in the total differential $dV = \left(\partial V/\partial T\right)_p dT + \left(\partial V/\partial p\right)_T dp$ of $V = V(T,p)$ gives

$$
\left(\frac{\partial p}{\partial T}\right)_V
= -\frac{\left(\partial V/\partial T\right)_p}{\left(\partial V/\partial p\right)_T}
= -\frac{V\alpha}{-V\kappa_T} = \frac{\alpha}{\kappa_T}
$$

(the triple product rule). Substituting this together with $\left(\partial V/\partial T\right)_p = V\alpha$,

$$
C_p - C_V = T\cdot\frac{\alpha}{\kappa_T}\cdot V\alpha = \frac{TV\alpha^2}{\kappa_T} .
$$

Since $T > 0$, $V > 0$ and $\alpha^2 \ge 0$, the right-hand side is non-negative whenever $\kappa_T > 0$.
</Proof>

The condition $\kappa_T > 0$ is the mechanical stability requirement that a body contracts when pushed; if it fails, the system undergoes phase separation (see the Appendix). Hence for any stable substance $C_p \ge C_V$. At a point where $\alpha = 0$ — near $4\,^\circ\mathrm{C}$ for water — the two coincide.

<Example id="ex-cp-cv-ideal" title="Checking the ideal gas">
For an ideal gas $pV = nRT$ we have $\left(\partial V/\partial T\right)_p = nR/p$, hence $\alpha = nR/(pV) = 1/T$, and $\left(\partial V/\partial p\right)_T = -nRT/p^2$, hence $\kappa_T = nRT/(p^2 V) = 1/p$. Substituting into <Ref to="prop-cp-cv" />,

$$
C_p - C_V = \frac{TV\alpha^2}{\kappa_T} = \frac{T V \cdot T^{-2}}{p^{-1}} = \frac{pV}{T} = nR ,
$$

which reproduces <Ref to="physics/thermodynamics/laws-of-thermodynamics#ex-mayer" text="Mayer's relation" />.
</Example>

<Example id="ex-joule-thomson" title="The Joule–Thomson effect and the inversion temperature">
When a gas is passed slowly through a porous plug from the high-pressure side to the low-pressure side, the enthalpy is conserved. The associated rate of temperature change,
$$
\mu_{\mathrm{JT}} := \left(\frac{\partial T}{\partial p}\right)_H ,
$$
is called the Joule–Thomson coefficient. The triple product rule gives first

$$
\mu_{\mathrm{JT}} = -\frac{\left(\partial H/\partial p\right)_T}{\left(\partial H/\partial T\right)_p}
= -\frac{1}{C_p}\left(\frac{\partial H}{\partial p}\right)_T
$$

(here $\left(\partial H/\partial T\right)_p = T\left(\partial S/\partial T\right)_p = C_p$ follows from $dH = T\,dS + V\,dp$ in <Ref to="prop-differentials" />). Dividing the same differential by $dp$ at constant $T$,

$$
\left(\frac{\partial H}{\partial p}\right)_T = T\left(\frac{\partial S}{\partial p}\right)_T + V
= -T\left(\frac{\partial V}{\partial T}\right)_p + V ,
$$

where the second equality used the fourth identity of <Ref to="thm-maxwell" />. Therefore

$$
\mu_{\mathrm{JT}} = \frac{1}{C_p}\left[T\left(\frac{\partial V}{\partial T}\right)_p - V\right]
= \frac{V}{C_p}\left(T\alpha - 1\right).
$$

For an ideal gas $\alpha = 1/T$, so $\mu_{\mathrm{JT}} = 0$ and the temperature does not change.

Let us evaluate the coefficient for a van der Waals gas (one mole, molar volume $v$) to first order in $a$ and $b$. Expanding the equation of state $\left(p + a/v^2\right)(v-b) = RT$, dropping the term $ab/v^2$, and substituting $v \simeq RT/p$ into the small terms on the right,

$$
pv = RT + pb - \frac{a}{v} \simeq RT + pb - \frac{ap}{RT}
\quad\Longrightarrow\quad
v \simeq \frac{RT}{p} + b - \frac{a}{RT}.
$$

Differentiating with respect to $T$ gives $T\left(\partial v/\partial T\right)_p = RT/p + a/(RT)$, so

$$
T\left(\frac{\partial v}{\partial T}\right)_p - v
\simeq \left(\frac{RT}{p} + \frac{a}{RT}\right) - \left(\frac{RT}{p} + b - \frac{a}{RT}\right)
= \frac{2a}{RT} - b .
$$

Hence $\mu_{\mathrm{JT}} > 0$ — cooling upon expansion — holds when $T < T_{\mathrm{inv}} := 2a/(Rb)$. This $T_{\mathrm{inv}}$ is called the inversion temperature. Nitrogen at room temperature lies below its inversion temperature, so throttling cools it and it can be liquefied. Hydrogen and helium have inversion temperatures far below room temperature, so throttling them directly warms them instead, and they must be pre-cooled. The formula displays the structure clearly: the intermolecular attraction $a$ produces cooling, the excluded volume $b$ produces heating.
</Example>

## 8. Exercises

<Exercise id="exr-maxwell-ideal" difficulty="Easy">
For an ideal gas $pV = nRT$, compute $\left(\partial S/\partial p\right)_T$. Then find the entropy change when the pressure is changed from $p_1$ to $p_2$ at constant temperature.
<Solution>
By the fourth identity of <Ref to="thm-maxwell" />, $\left(\partial S/\partial p\right)_T = -\left(\partial V/\partial T\right)_p$. Differentiating $V = nRT/p$ with respect to $T$ at constant $p$ gives $\left(\partial V/\partial T\right)_p = nR/p$, so

$$
\left(\frac{\partial S}{\partial p}\right)_T = -\frac{nR}{p}.
$$

Integrating this from $p_1$ to $p_2$ at constant $T$,

$$
\Delta S = -nR\int_{p_1}^{p_2}\frac{dp}{p} = -nR\ln\frac{p_2}{p_1}
= nR \ln\frac{p_1}{p_2}.
$$

Under compression ($p_2 > p_1$) the entropy decreases. The process is isothermal, so $\Delta U = 0$, and the system therefore discards to the bath a quantity of heat equal to $-T\Delta S\ (>0)$.
</Solution>
</Exercise>

<Exercise id="exr-gibbs-helmholtz" difficulty="Standard">
Given $F(T,V,N)$, show that
$$
U = -T^2\left[\frac{\partial}{\partial T}\left(\frac{F}{T}\right)\right]_{V,N}
$$
(the Gibbs–Helmholtz equation). Then apply it to the $F$ of <Ref to="ex-ideal-gas-free-energy" /> and verify that $U = \tfrac{3}{2}Nk_{\mathrm B}T$.
<Solution>
By the quotient rule,

$$
\left[\frac{\partial}{\partial T}\left(\frac{F}{T}\right)\right]_{V,N}
= \frac{1}{T}\left(\frac{\partial F}{\partial T}\right)_{V,N} - \frac{F}{T^2}
= \frac{1}{T^2}\left[T\left(\frac{\partial F}{\partial T}\right)_{V,N} - F\right].
$$

Multiplying both sides by $-T^2$ gives $-T\left(\partial F/\partial T\right)_{V,N} + F$. Since $\left(\partial F/\partial T\right)_{V,N} = -S$ by <Ref to="prop-differentials" />, this equals $TS + F = U$, which proves the claim.

For the ideal gas, $F/T = -Nk_{\mathrm B}\bigl[\ln\bigl(V/(N\lambda^3)\bigr)+1\bigr]$, whose only $T$ dependence sits in $-3\ln\lambda = \tfrac{3}{2}\ln T + \text{const}$. Hence

$$
\left[\frac{\partial}{\partial T}\left(\frac{F}{T}\right)\right]_{V,N}
= -Nk_{\mathrm B}\cdot\frac{3}{2T},
\qquad
U = -T^2\cdot\left(-\frac{3Nk_{\mathrm B}}{2T}\right) = \frac{3}{2}Nk_{\mathrm B}T ,
$$

in agreement with the result of <Ref to="ex-ideal-gas-free-energy" />.
</Solution>
</Exercise>

<Exercise id="exr-vdw-adiabatic" difficulty="Standard">
A van der Waals gas of $n$ moles, with $\phi(T) = nc_V T$ for a constant $c_V$, expands adiabatically and freely into vacuum from volume $V_1$ to volume $V_2$. Find the change in temperature.
<Solution>
In a free expansion the system does no work on its surroundings ($W=0$), and the expansion is adiabatic ($Q=0$), so the first law gives $\Delta U = 0$. By <Ref to="ex-vdw-energy" />,

$$
U = -\frac{an^2}{V} + n c_V T ,
$$

so the condition that $U$ be unchanged reads

$$
-\frac{an^2}{V_1} + nc_V T_1 = -\frac{an^2}{V_2} + n c_V T_2 .
$$

Solving for $T_2$,

$$
T_2 - T_1 = -\frac{a n}{c_V}\left(\frac{1}{V_1} - \frac{1}{V_2}\right) < 0
\qquad (V_2 > V_1,\ a > 0).
$$

The gas cools upon expansion: work must be done against the attraction to pull the molecules apart, and the corresponding kinetic energy is lost. If $a = 0$ (ideal gas) the temperature does not change, in agreement with the result of Joule's experiment.
</Solution>
</Exercise>

<Exercise id="exr-surface-tension" difficulty="Hard">
For a liquid film of surface area $A$, the quasi-static work is $\bar{d}W = -\sigma\,dA$ (where $\sigma$ is the surface tension, so that the work done *on* the system is $\sigma\,dA$), and the fundamental relation becomes $dU = T\,dS + \sigma\,dA$.

1. Write the differential of the potential $F = U - TS$ appropriate to this system, and derive the corresponding Maxwell relation.
2. Suppose the surface tension is measured to be $\sigma(T) = \sigma_0\bigl(1 - T/T_c\bigr)$ with $\sigma_0 > 0$ and $T_c$ constant. Find the heat $Q$ absorbed from the bath and the increase $\Delta U$ in internal energy when the area is increased by $A$ isothermally.
<Solution>
**1.** From $F = U - TS$ we get $dF = dU - T\,dS - S\,dT = -S\,dT + \sigma\,dA$. The natural variables are therefore $(T,A)$, with $S = -\left(\partial F/\partial T\right)_A$ and $\sigma = \left(\partial F/\partial A\right)_T$. If $F$ is of class $C^2$, Schwarz's theorem gives $\partial^2 F/\partial A\,\partial T = \partial^2 F/\partial T\,\partial A$, that is,

$$
-\left(\frac{\partial S}{\partial A}\right)_T = \left(\frac{\partial \sigma}{\partial T}\right)_A
\qquad\Longleftrightarrow\qquad
\left(\frac{\partial S}{\partial A}\right)_T = -\frac{d\sigma}{dT}.
$$

This is the third identity of <Ref to="thm-maxwell" /> read with the replacement $(-p, V) \to (\sigma, A)$.

**2.** Since $d\sigma/dT = -\sigma_0/T_c$, we have $\left(\partial S/\partial A\right)_T = \sigma_0/T_c > 0$. For an isothermal reversible process $Q = T\Delta S$, and $\Delta S = (\sigma_0/T_c)A$, so

$$
Q = \frac{\sigma_0 T}{T_c}A .
$$

Stretching the film absorbs heat. For the internal energy, the same computation as in <Ref to="prop-energy-equation" /> (with the replacements $-p \to \sigma$ and $V \to A$) gives

$$
\left(\frac{\partial U}{\partial A}\right)_T = T\left(\frac{\partial S}{\partial A}\right)_T + \sigma
= \frac{\sigma_0 T}{T_c} + \sigma_0\left(1 - \frac{T}{T_c}\right) = \sigma_0 ,
$$

which is independent of $T$. Hence $\Delta U = \sigma_0 A$. The work done on the system, $\sigma A = \sigma_0(1 - T/T_c)A$, plus the absorbed heat $Q = \sigma_0 T A/T_c$, is exactly $\sigma_0 A$, consistent with the first law.
</Solution>
</Exercise>

## References

- H. B. Callen, *Thermodynamics and an Introduction to Thermostatistics*, 2nd ed., Wiley, 1985 — Chapter 5 (Legendre transformations and the several potentials), Chapter 7 (Maxwell relations), Chapter 8 (stability). The organisation of this article is closest to the style of this book.
- Tasaki Hal, *Netsurikigaku — Gendaiteki na Shiten kara* (Thermodynamics: From a Modern Point of View), Baifukan, 2000 (in Japanese) — Chapter 8 (free energy). An axiomatic and lucid treatment that defines the free energy from the maximum work of an isothermal process.
- Kubo Ryogo (ed.), *Daigaku Enshū: Netsugaku・Tōkei Rikigaku* (University Exercises: Heat and Statistical Mechanics), Shokabo, 1961 (in Japanese) — Chapter 2. Rich in exercises on the Maxwell relations and the response functions.
- L. D. Landau and E. M. Lifshitz, *Statistical Physics, Part 1*, 3rd ed., Pergamon Press, 1980 — Chapter II (thermodynamic quantities). A concise treatment of the Joule–Thomson effect and of the relations among heat capacities.
- R. T. Rockafellar, *Convex Analysis*, Princeton University Press, 1970 — Chapter 12. The general theory of the Legendre transformation (convex conjugation); the standard reference when differentiability cannot be assumed.

## Appendix: Convexity, concavity and thermodynamic stability

**The convexity type of each potential.** Part (1) of <Ref to="thm-legendre-involution" /> asserted that the Legendre transform of a strictly convex function is strictly concave. Translated into thermodynamics, this yields the rule: concave in the transformed variables, convex in the untransformed ones. Organised into a table:

| Potential | Convex in | Concave in |
|---|---|---|
| $U(S,V)$ | $S$, $V$ | — |
| $F(T,V)$ | $V$ | $T$ |
| $H(S,p)$ | $S$ | $p$ |
| $G(T,p)$ | — | $T$, $p$ |

**Why this is stability.** That $F$ is concave in $T$ says

$$
\left(\frac{\partial^2 F}{\partial T^2}\right)_V = -\left(\frac{\partial S}{\partial T}\right)_V = -\frac{C_V}{T} \le 0,
$$

which is equivalent to $C_V \ge 0$. Were $C_V < 0$, a region that received heat would drop in temperature, drawing in still more heat, and an infinitesimal temperature fluctuation would grow without bound. Likewise, that $F$ is convex in $V$ says

$$
\left(\frac{\partial^2 F}{\partial V^2}\right)_T = -\left(\frac{\partial p}{\partial V}\right)_T = \frac{1}{V\kappa_T} \ge 0,
$$

which is equivalent to $\kappa_T \ge 0$. If this fails, a slightly compressed region drops in pressure and is compressed further, and the system cannot remain uniform. The isotherms of a van der Waals gas do in fact contain intervals on which $\left(\partial p/\partial V\right)_T > 0$. Such an interval is not physically realised; it is replaced by liquid–gas coexistence (phase separation) according to Maxwell's equal-area rule. The thermodynamic view of a phase transition is that the concavity of $G(T,p)$ expresses this replacement as the operation of taking a concave hull.

**Relation to the variational principle.** <Ref to="thm-free-energy-min" /> stated that $F$ decreases at constant $T, V, N$. What guarantees that a stationary point is a minimum is precisely the convexity just discussed. Conversely, in a region where convexity fails, the stationary point ceases to be a minimum and the system settles into a different state, namely a phase-separated one. It is worth remembering that the first derivatives of the potentials govern the Maxwell relations, while the second derivatives govern stability and phase transitions.
