Independent spin-one-half two-level system (source code)

= Independent spin-one-half two-level system
{title2=$E_\uparrow=+\epsilon,\ E_\downarrow=-\epsilon$}

For $N$ distinguishable noninteracting spins, let a fraction $\alpha$ occupy the level $+\epsilon$ and the remainder occupy $-\epsilon$. The <Stirling formula> gives
$$
S=-Nk_B\bigl[\alpha\log\alpha+(1-\alpha)\log(1-\alpha)\bigr],
\qquad
E=N\epsilon(2\alpha-1).
$$
The relation $1/T=\partial S/\partial E$ yields
$$
\alpha=\frac1{1+e^{2\epsilon/(k_BT)}},
\qquad
E=-N\epsilon\tanh\left(\frac\epsilon{k_BT}\right).
$$
Positive temperature corresponds to $0\leq\alpha<1/2$; a population inversion $1/2<\alpha\leq1$ has <negative temperature>.