Counting unitary square roots Let $ g $ be an $ n \times n $ unitary matrix. How many unitary matrices $ U $ are there such that
$$
U^2=g
$$
My first guess was that there are $ 2^n $ such unitary matrices since each of the $ n $ eigenvalues has 2 square roots. However that already fails for the identity matrix
$$
I=\begin{bmatrix}
1 & 0 \\
0 & 1 
\end{bmatrix}
$$
since there are infinitely many unitary matrices that square to $ I $. For example all unitary matrices of the form
$$
\begin{bmatrix} 
0 & e^{i \theta} \\
e^{-i \theta} & 0
\end{bmatrix}
$$
If there are infinitely many $ \sqrt{g} $ then what can we say about the geometry of the real algebraic variety $ U^2=g $? What is the dimension? Number of connected components? For connected components that aren't just points what kind of manifold are they?
If these questions are too difficult with a generic unitary $ g $ what about just describing the structure of the variety $ U^2=I $?
 A: It is simpler to view $g$ as a unitary endomorphism of some hermitian space. Since $g$ is unitary, it is diagonalisable and the eigenvalues have modulus $1$. Eigenspaces of $g$ are stable under every endomorphism which commutes with $g$. Therefore, every endomorphism which commutes with $g$ (including all square roots of $g$) is completely determined by the endomorphisms it induces on the eigenspaces of $g$.
In particular, the choice of a square root of $g$ is given by the choice of a square root on each eigenspace of $g$, equivalently by the choice of a symmetry on each eigenspace of $g$ (which has to be multiplied by a fixed square root of the the corresponding eigenvalue). Calling $m_1,\ldots,m_r$ the multiplicities of the eigenvalues of $g$, we get a variety isometric to $\Sigma_{m_1} \times \ldots \times \Sigma_{m_r}$, where $\Sigma_m$ denotes the set of all $\mathbb{C}$-linear symmetries on $\mathbb{C}^m$.
The global number of connected components is $(m_1+1)\cdots(m_r+1)$. Indeed, each $\Sigma_m$ has $m+1$ connected components given by the dimension of the invariant subspace which may be any integer between $0$ and $m$, and $\Sigma_m$ can be viewed as a disjoint union of Grassmanian manifolds.
