# Fair coin toss: Microcanonical vs Canonical ensemble

Suppose $N$ fair coin tosses. It is easy to represent this system in the micro-canonical ensemble as follows. There are 2^N possible results. Taking the entropy as the total number of micro state, we get

$S=N k_B \ln(2)$

$E=N k_B T \ln(2)$

and each bit contribute $k_B \ln(2)$ to the entropy.

I am trying to recover this results from the canonical ensemble, but it seems to fail. I try to obtain the partition function as follows: 1. Each bit (0 or 1) has the same energy level $E_0$. Hence the partition function is degenerate.

$Z=\sum_{i=0}^N{e^{-2\beta E_0}}=Ne^{-2\beta E_0}$

But when I take the energy using $\overline{E}=-\frac{\partial \ln{Z}}{\partial \beta}$

$\overline{E}=-\frac{1}{Ne^{-2\beta E_0}}(Ne^{-2\beta E_0})(-2 E_0)$

$\overline{E}=2E_0$

Why do I not recover the same results as the micro canonical case? Here, the average energy does not even depend on $T$.

Reverse engineering the process, to recover the micro canonical results, the partition function must be

$Z=\sum_{i=0}^N{e^{- E_0 \ln{\beta} \ln{2}}}$

then taking $\overline{E}=-\frac{\partial \ln{Z}}{\partial \beta}$ will give $\overline{E}=Nk_BT\ln{2}$. But a partition function with $\ln{\beta}$ instead of $\beta$ as a conjugate variable is hardly legit.

What am I doing wrong?

## 1 Answer

Let's start with the microcanonical case. Your expression for the entropy is correct. As far as the energy goes, in the microcanonical ensemble, the energy is a specified, not a derived, quantity, and by the description of the system you have given, $$E = N E_0$$ You seem to have assumed $S = \frac{\partial E}{\partial T}$, but this is not the case. You're looking for the formula $$T = \left( \frac{\partial S}{\partial E} \right)^{-1}$$ Then $dE = E_0 dN$, and so $$T = \left ( \frac{1}{E_0} \frac{\partial}{\partial N} \left [ k_B N \ln 2 \right ] \right )^{-1} = \frac{E_0}{k_B \ln 2}$$ although just what the "temperature" is in the MCE is a little fuzzy.

Next, let's look at the canonical ensemble. The exponents in the partition function are not correct; they should be $\beta$ times the energy of the whole microstate. Every microstate has the same energy $$E = \overline E = N E_0$$ This is the reason that the energy does not depend on the temperature. Then $$Z = \sum_{n=0}^{2^N} e^{-\beta N E_0} = 2^N e^{-\beta N E_0}$$ (Note that this correctly reproduces $\overline E$ via $E = -\frac{\partial \ln Z}{\partial \beta}$.) We can calculate the entropy via $$S = k_B \left ( \ln Z + \beta \overline E \right ) = k_B \left ( N \ln 2 - \beta N E_0 + \beta \overline E \right ) = k_B N \ln 2$$ and the temperature via $$T = \frac{\partial \overline E}{\partial S} = \frac{1}{k_B \ln 2}\frac{\partial N E_0}{\partial N} = \frac{E_0}{k_B \ln 2}$$

These results agree, but please note that the example is kind of janky. The microcanonical and canonical ensembles describe systems in different situations. In the microcanonical ensemble, $E$ is given and $T$ is derived (if ontologically dubious); in the canonical ensemble, $T$ is given by thermodynamic contact with a heat bath of infinite heat capacity, and $E$ is derived. There's an artificial character that arises in this case because you've specified a system with only one energetic macrostate. A much more interesting example is that in which the "heads" and "tails" states for individual coins have different energies; for the sake of simplicity, say "heads" is $0$ and "tails" is $E_0 > 0$. I encourage you to work it out.