Solution (source code)

= Solution

By the <spectral theorem>, a <Hermitian matrix> has real <eigenvalues> and an orthonormal eigenbasis. Choose column vectors $u_j$ with $Hu_j=\lambda_ju_j$ and $u_i^\dagger u_j=\delta_{ij}$, and form $U=(u_1\ \cdots\ u_n)$. Then $U^\dagger U=I$, so $U$ is unitary, and $HU=U\Lambda$ gives
$$
\boxed{U^\dagger HU=\Lambda=\operatorname{diag}(\lambda_1,\ldots,\lambda_n).}
$$
The entries of $\Lambda$ are the real <eigenvalues>, repeated according to their multiplicities. Within a degenerate <eigenspace>, any <orthonormal basis> may be used. Equivalently $H=U\Lambda U^\dagger$.