# Changing Between Thermodynamic Ensembles

Given a two-variable function $f(x,y)$ and its Legendre transform $g(x,f_y) = f - yf_y$ , there exists a simple identity between second-order partial derivatives of $f$ and $g$:

\begin{equation} g_{xx} - f_{xx} = - \frac{f_{xy}^2}{f_{yy}} = \frac{g_{x f_y}^2}{g_{f_y f_y}}. \end{equation}

Taking $f$ to be the Helmholtz free energy $F(T, V, N)$, and $g$ to be the Landau free energy $\Omega(T, V, \mu) = F - \mu N$ (Legendre transform of $F$ w.r.t. $N$), one obtains \begin{equation} \Omega_{VV} - F_{VV} = - \frac{F_{VN}^2}{F_{NN}} = \frac{\Omega_{V\mu}^2}{\Omega_{\mu\mu}}, \end{equation} from which an expression for the difference of the following two quantities can be derived: \begin{equation} \kappa_{NVT}^{-1} := -V \left(\frac{\partial P}{\partial V}\right)_{N,T} = V F_{VV}, \end{equation} \begin{equation} \kappa_{\mu VT}^{-1} := -V \left(\frac{\partial P}{\partial V}\right)_{\mu,T} = V \Omega_{VV}. \end{equation}

(Although OP considered $\kappa$ in the $NPT$ ensemble, the $NVT$ ensemble leads to the same quantity as well.)

Also, by setting $f = F(T,V,N)$, $g = G(T,P,N)$ (i.e., Gibbs free energy), $x = T$, $y = V$, and $f_y = -P$, one can derive the relation \begin{equation} C_P - C_V = T(-G_{TT} + F_{TT}) = \frac{VT\alpha^2}{\kappa}, \end{equation} where $\alpha = \frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P,N} = G_{PT}/V$ and $\kappa = - \frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T,N} = - G_{PP}/V$.

**Proof of the identity:**

Consider a twice-differentiable function $f(x,y)$ and its Legendre transform w.r.t. $y$:^{1}
\begin{equation}
g(x,f_y) := f(x,y) - f_yy.
\end{equation}
(Here, it is implicitly assumed that $y$ is expressed as a function of $x$ and $f_y$.) Notice that
\begin{equation}
\tag{1}
\label{a}
\frac{\partial f}{\partial x} \bigg|_{f_y} = f_x + f_y \frac{\partial y}{\partial x}\bigg|_{f_y} = f_x - f_y \frac{f_{xy}}{f_{yy}},
\end{equation}
where the last equality holds due to the triple product rule. We then have
\begin{equation}
g_x = \frac{\partial f}{\partial x} \bigg|_{f_y} - f_y \frac{\partial y}{\partial x}\bigg|_{f_y} = f_x,
\end{equation}
from which it follows that
\begin{equation}
g_{xx} = \frac{\partial f_x}{\partial x} \bigg|_{f_y} = f_{xx} - \frac{f_{xy}^2}{f_{yy}}.
\end{equation}
Here, the last equality is simply Eq. (\ref{a}) with $f$ replaced by $f_x$.
Noting that Legendre transformation of $g$ w.r.t. $f_y$ gives $f$, one can exchange the role of $f$ and $g$ on the above, which leads to
\begin{equation}
f_{xx} = g_{xx} - \frac{g_{xf_y}^2}{g_{f_yf_y}}.
\end{equation}

^{1} $f$ must be either a convex or a concave function of $y$ for the Legendre transformation to be well-defined.