Solution (source code)

= Solution

Use <completing the square> in the <Hermitian form> $x^*Ax$, rather than <unitary diagonalization of a normal matrix>. The first pivot is one, so
$$
x^*Ax=|x_1+ix_2+2ix_3|^2+2|x_2|^2+(-2-i)\overline{x_2}x_3+(-2+i)\overline{x_3}x_2+|x_3|^2.
$$
A second square completion gives
$$
x^*Ax=|x_1+ix_2+2ix_3|^2+2\left|x_2+\frac{-2-i}{2}x_3\right|^2-\frac32|x_3|^2.
$$
Therefore one answer is
$$
\boxed{D=\operatorname{diag}(1,2,-3/2),\qquad T=\begin{pmatrix}1&i&2i\\0&1&(-2-i)/2\\0&0&1\end{pmatrix}.}
$$
The diagonal entries of $D$ are rational, $\det T=1$, and the displayed identity for every $x$ proves $T^*DT=A$.

If $T$ were a <unitary matrix>, this <matrix congruence> would also be a <similarity transformation>, so the diagonal entries of $D$ would be the <eigenvalues> of $A$. Its <characteristic polynomial> is
$$
\det(tI-A)=t^3-9t^2+17t+3=(t-3)(t^2-6t-1).
$$
Thus its <eigenvalues> are $3,3+\sqrt{10},3-\sqrt{10}$, two of which are irrational. \b[A unitary factor cannot give a rational diagonal here.] Alternatively, the permitted <rational root theorem> implies that three rational eigenvalues would all be integers, whereas the quadratic factor has no integer roots.