# Calculating the heat capacity of a system

I have started reading Statistical Physics by F. Mandl and I would appreciate some help with the following exercise

A system consists of $N$ weakly interacting subsystems. Each subsystem possesses only two energy levels $E_1$ and $E_2$, each of them non-degenerate.

Obtain an exact expression for the heat capacity of the system.

The heat capacity is given by $$C = \frac{\partial E}{\partial T}$$ with $E$ the mean energy, $T$ the temperature. Then we also have $$\frac1T = \frac{\partial S}{\partial E}$$ with the entropy $S = k\ \ln \Omega(E)$.

Now, for a given energy $E$, there is a (unique) number $n \le N$ with $E=n E_1 + (N-n)E_2$. And with this $n$ we get

$$\Omega(E) = {N \choose n} = \frac{N!}{(N-n)!n!}$$

And then I thought about writing the heat capacity as $\frac{\partial E}{\partial n} \frac{\partial n}{\partial S} \frac{\partial S}{\partial T}$ or something like that. But in everything I have tried, I'm having trouble to differentiate with respect to $T$. I don't really get a grip on how the other things depend on $T$.

Hint: Analyze each subsystem separately. Occupation probabilities will follow Boltzman distribution: $P(1) = exp(-E_1/kT)/(exp(-E_1/kt)+exp(-E_2/kt))$ etc.
$<E(T)> = P_1 * E_1 + P_2*E_2$
Expected energy for whole system is just $N$ times that per subsystem. Differentiate to get heat capacity.