Solution (source code)

= Solution

The <characteristic polynomial> is $\lambda^2-2\lambda\cos\theta+1$, with <eigenvalues> $\cos\theta\pm i\sin\theta$. A real diagonal form can have only real <eigenvalues>, so it requires $\sin\theta=0$. Conversely, when $\theta=k\pi$, the <rotation matrix> is already $(-1)^kI$. Thus
$$
\boxed{\text{real diagonalization is possible exactly when }\theta\in\pi\mathbb Z}.
$$