# How do I find if two matrices are unitarily equivalent and the corresponding unitary matrix?

I'm trying to solve some exercises on linear operators and I came acroos the notion of unitary equivalence recently. I'm having problems solving the following exercise. I have two matrices-

$A=\begin{bmatrix} 0&0&1\\0&0&0\\1&0&0 \end{bmatrix}$

and

$B=\begin{bmatrix} 0.5&0.5&0\\0.5&0.5&0\\0&0&-1 \end{bmatrix}$. The question is to check if the matrices are unitarily similar and if so, to find the unitary matrix $C$ such that $B=C^{-1}AC$.

I have calculated the eigenvalues and both have the same set of eigenvalues-$0,1,-1$. Since the eigenvalues are distinct and the same, the matrices are similar. But how do I check if they are unitarily similar? And if so, what will be my matrix $C$? I have a feeling that I need to do something with an orthonormal basis of eigenvectors of one of the matrices, but here I'm not sure. I would appreciate some help. Thanks.

First you have to find an orthonormal basis of eigenvectors of $A$. Just find any eigevectors, they are necessarily orthogonal because you have three eigenspaces, and distinct eigenspaces are always orthogonal to each other. Then normalize your vectors to get an orthonormal basis $v_1,v_2,v_3$ for eigenvalues $0,1,-1$. Let $V=(v_1|v_2|v_3)$ be the orthogonal matrix with columns $v_1,v_2,v_3$. Then $D:=V^*AV$ is the diagonal matrix with diagonal values $0,1,-1$. Do the same for $B$ to get $u_1,u_2,u_3$, and $D=U^*BU$. Then $A=VU^*BUV^*=(UV^*)^*B(UV^*)$ with orthogonal and therefore unitary $UV^*$.
We have $v_1,v_2,v_3=(0,1,0),(1,0,1)/\sqrt{2}, (1,0,-1)/\sqrt{2}$ and $u_1,u_2,u_3=(1,-1,0)/\sqrt{2}, (1,1,0)/\sqrt{2}, (0,0,1)$.