# Finding a set of logarithms for a matrix in SO(n)

For any matrix $A$ in either $SO(2)$ or $SO(3)$, the expression $\frac{1}{\sqrt{2}}||\log A||_F$ gives the angle of the rotation represented by $A$, where $\log A$ is a matrix logarithm of $A$ and the norm is the Frobenius norm. From this result it follows that, for any given (skew-symmetric) matrix $X$ satisfying $\exp X = A$, every matrix $X'$ in the set $$L_X= \left\{tX \;\middle|\; t=\frac{||X||_F+k2\pi\sqrt{2}}{||X||_F} \;,\; k\in\mathbb{Z}\right\}$$ also satisfies $\exp X' = A$ .

I know from numerical tests that this is not necessarily true for other $SO(n)$ groups. So my question is: given a logarithm $X$ of a matrix $A\in SO(n)$, for arbitrary $n>3$, are there any known parameterisations of a set of logarithms of $A$ that includes (but is not limited to) $X$?

I have two objectives here:

1. I would ideally like to know how to parameterise all logarithms of $A$, or at least mathematically interesting subsets of them, out of a desire to improve my understanding of special orthogonal groups and algebras.
2. I am writing tests for functions that compute matrix exponentials and principal matrix logarithms. My test data consists of orthogonal matrices and their principal matrix logarithms. For each $(A,X)$ test pair, I am generating lots of additional test pairs of the form $(A^k,kX)$. For large $k$, $kX$ is not a principal logarithm of $A^k$, so I cannot compare $kX$ to the computed logarithm of $A^k$. I could compare $\log A^k$ to $\log \exp kX$, but the equality of these expressions doesn't imply that $\log A^k$ was computed correctly (e.g. if the $\log$ function erroneously mapped everything to a constant matrix $C$, these two expressions would be equal). So I would like to know how to map $kX$ to the principal logarithm without using $\log$ or $\exp$ .

The principal logarithm of a matrix $A\in SO(n)$ is the logarithm whose eigenvalues have imaginary components in the interval $(-i\pi,i\pi)$. As the Lie algebra $so(n)$ is the set of real skew-symmetric (and hence normal) $n\times n$ matrices, any logarithm* $X\in so(n)$ of $A$ has a complex eigendecomposition: \begin{align} X&=V\Lambda V^* \enspace,\\ \Lambda&=\mathrm{diag}(\lambda_1,-\lambda_1, \lambda_2, -\lambda_2, \ldots)\enspace, \end{align} with an extra zero eigenvalue if $n$ is odd, where the non-zero eigenvalues are purely imaginary. Since $V$ is unitary, we have $$A=e^X = e^{V\Lambda V^*} = Ve^\Lambda V^* \enspace,$$ where $$e^\Lambda=\mathrm{diag}\left(e^{\lambda_1},e^{-\lambda_1},e^{\lambda_2},\ldots\right)\enspace.$$ So if $\lambda_j$ and $-\lambda_j$ are eigenvalues of $X$, you can construct a set $L_j$ of logarithms of $A$ as follows: \begin{align} L_j &= \left\{V\Lambda^{(j)}_kV^* \;\middle|\; k\in\mathbb{Z} \right\} \\ \Lambda^{(j)}_k &= \mathrm{diag}\left(\ldots,-\lambda_{j-1},\;\lambda_j+2ik\pi, \;-(\lambda_j+2ik\pi), \;\lambda_{j+1},\ldots\right) \end{align} By adjusting all pairs of positive/negative imaginary eigenvalues like this, you can compute the principal logarithm that corresponds to $X$.
* Note: A matrix $A\in SO(n)$ has real logarithms that are not in $so(n)$ (e.g. see Is a real logarithm of a special orthogonal matrix necessarily skew-symmetric?). A real logarithm $X$ is in $so(n)$ if and only if $e^{tX}\in SO(n)$ for all real numbers $t$.