Solution (source code)

= Solution

In the given <basis>, the <matrix> is $A=\begin{pmatrix}0&0&1\\1&0&0\\0&1&0\end{pmatrix}$. Let $\omega=e^{2\pi i/3}$, a primitive cube <root of unity>. For each $\xi\in\{1,\omega,\omega^2\}$,
$$
A\begin{pmatrix}1\\\xi\\\xi^2\end{pmatrix}
=\begin{pmatrix}\xi^2\\1\\\xi\end{pmatrix}
=\xi^2\begin{pmatrix}1\\\xi\\\xi^2\end{pmatrix}.
$$
Thus these are <eigenvectors> with distinct <eigenvalues> $1,\omega^2,\omega$, respectively, and form an eigenbasis. Set
$$
P=\begin{pmatrix}1&1&1\\1&\omega&\omega^2\\1&\omega^2&\omega\end{pmatrix}.
$$
The columns are mutually orthogonal with squared norm three, so $P^{-1}=P^*/3$. \b[The <diagonalization> and <characteristic polynomial> are]
$$
\boxed{P^{-1}AP=\operatorname{diag}(1,\omega^2,\omega),\qquad
\chi_A(t)=\det(tI-A)=(t-1)(t-\omega)(t-\omega^2)=t^3-1.}
$$
Scaling $P$ by $1/\sqrt3$ gives a unitary diagonalizing <matrix>.