Taylor expansion using stirling's approximation

Let us define the following two configurations:

  • An "optimal" configuration: $\mathbf n_1 := [n_0, \cdots, n_0]$ .
  • The perturbed configuration: $\mathbf n_2 := [n_0 - \delta n, n_0 + \delta n, n_0, \cdots, n_0]$ .

Statistical weights of the two configurations are: $$ \Omega_0 := \Omega_{\{\mathbf n_1\}} = \frac{N!}{(n_0!)^M}\,, \qquad \Omega_{\{\mathbf n_2\}} = \frac{N!}{(n_0-\delta n)!(n_0 + \delta n)! (n_0!)^{M-2}} \,. $$ Taking log of these two weights we get: \begin{align} \ln \Omega_0 =&\; \ln N! - M \ln n_0!\,, \\ \qquad \ln \Omega_{\{\mathbf n_2\}} =&\; \ln N! - \ln (n_0-\delta n)! - \ln(n_0+\delta n)! - (M-2) \ln n_0!\,. \end{align} Log of the number of microstates is proportional to entropy, so let's call these two quantities the entropies of the two configurations (ignoring the proportionality constant, which is called the Boltzmann constant). Change in entropy due to perturbation is: $$\ln \Omega_{\{\mathbf n_2\}} - \ln \Omega_0 = - \ln(n_0-\delta n)! - \ln(n_0 + \delta n)! + 2\ln n_0!\,. \tag{1}$$

Assuming $n_0$ and $n_0-\delta n$ are both fairly large we use Stirling's approximation, nameley $\ln m! \approx m \ln m - m$ for large $m$, to approximate (1): $$ \ln \Omega_{\{\mathbf n_2\}} - \ln \Omega_0 \approx -(n_0 - \delta n) \ln (n_0 - \delta n)-(n_0 + \delta n) \ln (n_0 + \delta n) + 2 n_0 \ln n_0\,. \tag{2}$$ Now we use Taylor expansion to expand $\ln(n_0 \pm \delta n)$ by treating $\delta n$ as small compared to $n_0$. The expansion of $\ln(x+\epsilon)$ around $x$ is given by: $$ \ln(x + \epsilon) = \ln x + \frac{\epsilon}{x} - \frac{\epsilon^2}{2x^2} + \mathcal O\left(\left(\frac{\epsilon}{x}\right)^3\right)\,.$$ Using this in (2), and keeping terms upto quadratic order in $\delta n$ we find: $$ \ln \Omega_{\{\mathbf n_2\}} - \ln \Omega_0 \approx -\frac{(\delta n)^2}{n_0}\,.$$ So the entropy of the perturbed system is given by: $$ \ln \Omega_{\{\mathbf n_2\}} \approx \ln\Omega_0 -\frac{(\delta n)^2}{n_0} \,. \tag{3}$$

The reason why in (3) there is no term linear in $\delta n$ is very physical, an optimal configuration has the highest entropy, therefore change in entropy as you perturb from an optimal configuration must begin at least at the quadratic order.


We assume the Stirling approximation (first order) $$\log(n!)\approx n \log(n) - n = g(n) \tag{1}$$

And the Taylor expansion:

$$g(x)\approx g(x_0)+g'(x_0)(x-x_0)+g''(x_0)\frac{(x-x_0)^2}{2}=\\ =x_0\log(x_0)-x_0 + \log(x_0)\delta+\frac{\delta^2}{2 x_0} \tag{2}$$

where $\delta = x-x_0$ (increment).

Then the change in the box that decrements its counting (box 1) by $\delta$ is

$$\Delta_1(\ln\Omega_{\{n\}})=-\ln((n_0-\delta)!)+\ln(n_0!)=\\= \log(n_0)\delta-\frac{\delta^2}{2 n_0} \tag{3}$$

The change in the other box that increments its counting (box 2) by $\delta$ is

$$\Delta_2(\ln\Omega_{\{n\}})=-\ln((n_0+\delta)!)+\ln(n_0!)=\\ =-\log(n_0)\delta-\frac{\delta^2}{2 n_0} \tag{4}$$

The total change is then $$\Delta(\ln\Omega_{\{n\}})= \Delta_1(\ln\Omega_{\{n\}})+\Delta_2(\ln\Omega_{\{n\}})=-\frac{\delta^2}{n_0} \tag{5}$$

(that's why we need to take a second-order Taylor expansion: because the linear terms cancel - not because "we are at a local maximum" - actually the result is valid for any $n_0$, not only for $n_0=N/M$)

The original statement $$\delta\left(\ln\Omega_{\{n\}}\right)\approx \ln\Omega_0-\frac{\delta n^2}{2 n_0}$$ seems to have two errors: First, if mixes the value of the statistical weight with its change. If we are speaking of the change, then the first "$\delta$" is right, but the initial term $\ln\Omega_0$ is wrong - sanity check: if $\delta n=0$ the change should be zero). Furthermore, the result seems to have a missing two factor (indeed, the copied derivation emphasizes that the first variation is due to one box, but then it seems ot forget about the other one).

Edit: Regarding your edit: your "equation in blue" is only correct if it's understood to be the change in one box (see eq $3$). If it's understood (as it seems) as the total change, then it's wrong. The net change is given by eq. $(5)$