Solution (source code)

= Solution

For $\mathbf B=B\mathbf e_z$, the <quantum Gibbs state> is diagonal in the $S_z$ basis. Its two <probabilities> are proportional to $e^{\pm\beta\gamma\hbar B/2}$. Thus
$$
\boxed{\langle S_z\rangle=\frac\hbar2\tanh\left(\frac{\gamma\hbar B}{2k_BT}\right).}
$$
At small <inverse temperature>, $\langle S_z\rangle\simeq\beta\gamma\hbar^2B/4$. As a function of $u=\beta\gamma\hbar B/2$, the normalized <spin> component is the smooth odd curve $\tanh u$: it crosses zero at $u=0$ and saturates at $\pm1$. As a function of $\beta$ its direction is reversed if $\gamma B<0$. For $\gamma B>0$, positive <temperature> favors $S_z=+\hbar/2$, while negative <temperature> gives the inverted population.

\Image[/past-exam-of-the-theoretical-physics-ii-course-of-the-university-of-cambridge/2017-spin-polarization.png]
{title=Thermal <spin one-half> polarization versus dimensionless <inverse temperature>}
{description=Original plot of $2\langle S_z\rangle/\hbar=\tanh u$, with $u=\beta\gamma\hbar B/2$. For $\gamma B>0$, the negative-$u$ half corresponds to <negative temperature>. Dashed lines mark the fully polarized limits.}