Solution (source code)

= Solution

Take $\sigma_z|e\rangle=|e\rangle$ and $\sigma_z|g\rangle=-|g\rangle$. In the resonant <Jaynes-Cummings model>, the interaction connects only $|e,n\rangle$ and $|g,n+1\rangle$. Both have free <energy> $\hbar\omega(n+1/2)$, and their interaction <matrix> is $\hbar g\sqrt{n+1}\,\sigma_x$. Therefore
$$
H_n=\hbar\omega(n+1/2)I+\hbar g\sqrt{n+1}\begin{pmatrix}0&1\\1&0\end{pmatrix}.
$$
Exponentiating this two-state block and applying it to $|e,n\rangle$ yields
$$
\boxed{|\psi_n(t)\rangle=e^{-i\omega(n+1/2)t}\left[\cos(g\sqrt{n+1}\,t)|e,n\rangle-i\sin(g\sqrt{n+1}\,t)|g,n+1\rangle\right].}
$$
The populations undergo <Rabi oscillations> at <angular frequency> $2g\sqrt{n+1}$. The common <phase> in this fixed-$n$ block does not affect its <probabilities>, but it must be retained when blocks with different <photon numbers> are superposed.