Originally Posted by
HallsofIvy For any invertible matrix P, define U by $\displaystyle U= P^{-1}XP$. Then $\displaystyle X= PUP^{-1}$ so $\displaystyle X^2= (PUP^{-1})(PUP^{-1})= PU^2P^{-1}$. Now if also $\displaystyle X^2= A$, $\displaystyle A= PU^2P^{-1}$ and $\displaystyle P^{-1}AP= U^2$.
If P is such that $\displaystyle P^{-1}AP= D$, a diagonal matrix, the $\displaystyle D= U^2$ and so U is also a diagonal matrix having entries equal to the square roots of the diagonal elements of D. That is, with $\displaystyle D= \begin{pmatrix}0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}$, U is also $\displaystyle \begin{pmatrix}0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}$ and, as before, $\displaystyle X= PUP^{-1}$.