# Macroscopic quantities (like isothermal compressibility) from fluctuations and the partition function

I'm trying to make sense of the following generalized expression from Wikipedia page on partition function:

$$\langle (\Delta X)^2\rangle=\frac{\partial \langle X\rangle}{\partial \beta Y}=\frac{\partial^2 \ln Z}{\partial (\beta Y)^2}$$

where $$X$$ and $$Y$$ are generalized conjugate pairs of extensive and intensive variables, respectively (e.g., $$X$$ could be volume and $$Y$$ could be pressure), and $$\beta = 1/k_B T$$.

I have figured out the second equality in the equation but I'm having difficulty relating L.H.S of the first equality with the rest of the equation.

I'm not able to find a derivation of this in the literature. Help would be highly appreciated. (That's the 'derivation' part of the question).

A related derivation, specific to pressure and volume, that I'm looking for is that of isothermal compressibility in the canonical ensemble (I haven't found it yet; I may have found something in the grand-canonical ensemble but I'm not sure if we really need to invoke grand-canonical in order to find a relation for isothermal compressibility in terms of the partition function; again help highly appreciated). The equation is as follows:

$$\beta_T = \frac{\langle (\Delta V)^2\rangle}{V k_B T}$$

where $$\beta_T$$ and $$\beta$$ have nothing to do with each other, and by definition,

$$\beta_T \equiv -\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{T,N}$$

In addition, for the 'validity' part of the question, it appears that this calculation is a standard procedure for any/most conjugate thermodynamic pairs. However, while looking for a derivation, I came across a caution in Reif, Fundamentals of Statistal and Thermal Physics, page 221, stating:

"Calculating the dispersion $$\langle (y - \langle y\rangle)^2\rangle$$ of some quantity $$y$$ is a much more delicate matter. There is no guarantee that the dispersion is the same when calculated under conditions where $$E$$ is precisely specified ... or under conditions where only the mean energy $$\langle E\rangle$$ is specified. As a matter of fact, one would expect the dispersion to be greater in the second case. In particular, if $$y$$ were the energy $$E$$ of the system, its dispersion would vanish in the first case where $$E$$ is precisely specified, but would not vanish in the second case where only the mean value $$E$$ is specified."

Therefore I'm a bit confused as to how valid this equation is (or maybe this passage is somewhat irrelevant, in which case this question is mainly about the derivation only).

edit 1: $$\langle (\Delta X)^2\rangle$$ is defined as:

$$\langle (\Delta X)^2\rangle \equiv \langle(X-\langle X\rangle)^2\rangle$$

edit 2: I guess I'm mainly interested in the canonical ensemble. Am I right in thinking, you need canonical (or grand-canonical) to have this equation, since this equation relies on having a $$\exp(-\beta E)$$ in the partition function? (But then I'm not looking for grand-canonical, so that leaves us with canonical ensemble. Does that make sense?)

Here's a formal derivation, ignoring any subtlety about different ensembles, etc. For brevity, I'm just going to write the partition function \begin{align} Z(Y) = \int dX \,e^{-XY} \end{align} Then \begin{align} \langle X \rangle(Y) = \frac{1}{Z(Y)}\int dX\,X e^{-XY}. \end{align} Differentiating with respect to $$Y$$, \begin{align} -\partial_Y \langle X \rangle &= -\partial_Y\left(\frac{1}{Z}\right)\int dX \,X e^{-XY} - \frac{1}{Z}\partial_Y\left(\int dX X \,e^{-XY}\right)\\ &= -\frac{1}{Z^2}\left(\int dX\,X e^{-XY}\right)^2 + \frac{1}{Z}\left(\int dX X^2 \,e^{-XY}\right)\\ &= \langle X^2\rangle - \langle X \rangle^2. \end{align}

• Your $Z$ is missing a $\beta$? Also why should $E$ equal $XY$? For isothermal compressibility, why should $E$ equal $pV$ (or $-pV$, whichever sign is correct)? If you ignore ensemble specification, why should $Z$ have an exponential in the integrand? (which mainly appears in canonical and grand-canonical $Z$, not in the microcanonical). Mar 27, 2019 at 4:22
• I was just trying to demonstrate in general how you get that identity for any two conjugate variables. I'm not saying $XY$ is the energy of anything. Just that if $X$ and $Y$ are conjugate they'll show up in the energy as $E = \pm XY + \ldots$ and then we can use this identity. And $\beta = 1$, if you like.
– d_b
Mar 27, 2019 at 4:35

Regarding the second part, the grand canonical ensemble is definitely helpful here since you can consider an arbitrary subvolume V of an extensive thermodynamic system, and then examine the fluctuations in total particle number N in that subvolume. The variance in N will be proportional to V. Such a proportionality means it is in fact fluctuations in density. The value $$\langle \delta N^2 \rangle / V$$ is then independent of the subvolume size, thus it's some kind of intensive quantity and indeed it turns out to be directly related to isothermal compressibility.

Now clearly, this trick only works because we allow N to vary, otherwise variance in N would be zero. But what if we want to use this trick to calculate the density fluctuations in another quantity? It's less obvious but we still have to pay attention about what ensemble we are using. To illustrate why, a couple of examples:

Let's look at trying to calculate fluctuations in energy, and consider the case where each particle carries a huge potential energy offset. Every time a particle jumps in and out of our subvolume, its total energy varies a great deal. If we used the canonical ensemble, this would have no impact on our energy variance. In the grand canonical ensemble it could dominate our energy variance. Both energy variances are nonzero and proportional to V, but have very different values, and the canonical one is wrong since it doesn't reflect the fact that particles can move in and out of the subvolume.

Alternatively let's say we are looking at fluctuations in magnetization in some gas of paramagnetic atoms, in a nonzero magnetic field. Each atom in our subvolume has some random (but biased) magnetic moment. Thus our fluctuations in total magnetization in a subvolume will be influenced by that per-atom variance, but will also have a contribution from the bias multiplied by the randomness in number of atoms that happen to find themselves in our subvolume. The canonical ensemble would only pick up the first term.

(On the other hand, if you know that you have placed exactly 85823135 atoms in a box and you want to calculate the variance in magnetization for the full box, then it would be a mistake to use the grand canonical ensemble in this calculation and you must use the canonical ensemble for N=85823135.)

For further reading, I suggest Landau & Lifshitz Volume 5 (Statistical Physics) section 112.