I was reading this post and it got me thinking about square roots. Recall the Pauli $ X $ gate $$ X=\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}; $$
How many unitary matrices $ U $ are there such that $$ U^2=X $$ In other words, how many unitary square roots does $ X $ have? I would expect that there are $ 4 $ square roots because each eigenvalue has 2 square roots.
However, this naïve approach fails for some matrices, for example the identity $ I $. Not only does $ \pm I $ square to $ I $ but also every matrix of the form $ VZV^{-1} $ for $ V $ unitary is a unitary square root of $ I $. For example $ \pm I, \pm X, \pm Z , \pm Y $ are all unitary matrices that square to $ I $. As are all matrices of the form $$ \begin{bmatrix} 0 & e^{i \theta} \\ e^{-i \theta} & 0 \end{bmatrix} $$
Edit: The relevant distinction here between $ X $ having finitely many roots and $ I $ having infinitely many roots is that $ X $ has all distinct eigenvalues while $ I $ has repeated eigenvalues.