The Lie algebra $\mathfrak{so}(n)$ of the Lie group $SO(n)$ is the space of real skew-symmetric matrices.
Given an element $U \in SO(n)$, how can I get back the element $\mathfrak{u} \in \mathfrak{so}(n)$ such that $\exp(\mathfrak{u}) = U$.
I tried matrix logarithm,
$$\log(U) = P\log(D)P^{-1}$$
but it doesn't work for the example below:
$$U = \begin{pmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0\end{pmatrix}$$
By diagonalization, I computed
$$P = \frac{1}{\sqrt2}\begin{pmatrix} 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & -1 \\ 0 & 0 & 1 & 1 \\ 1 & -1 & 0 & 0 \end{pmatrix} ; \quad D = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1\end{pmatrix}$$
Then I take the $\log$ of the diagonal matrix.
$$\log(D) = \begin{pmatrix} \mathbf{0} & 0 & 0 & 0 \\ 0 & \mathbf{i\pi} & 0 & 0 \\ 0 & 0 & \mathbf{0} & 0 \\ 0 & 0 & 0 & \mathbf{i\pi} \end{pmatrix} $$
Finally, using the formula above $\log(U) = P \log(D)P^{-1}$,
$$\log(U) = \frac{1}{\sqrt2}\begin{pmatrix} 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & -1 \\ 0 & 0 & 1 & 1 \\ 1 & -1 & 0 & 0 \end{pmatrix}\begin{pmatrix} \mathbf{0} & 0 & 0 & 0 \\ 0 & \mathbf{i\pi} & 0 & 0 \\ 0 & 0 & \mathbf{0} & 0 \\ 0 & 0 & 0 & \mathbf{i\pi} \end{pmatrix}\frac{1}{\sqrt2} \begin{pmatrix} 1 & 0 & 0 & 1 \\ 1 & 0 & 0 & -1 \\ 0 & 1 & 1 & 0 \\ 0 & -1 & 1 & 0 \end{pmatrix}$$
which gives
$$\log(U) = \frac{i\pi}{2}\begin{pmatrix} 1 & 0 & 0 & -1 \\ 0 & 1 & -1 & 0 \\ 0 & -1 & 1 & 0 \\ -1 & 0 & 0 & 1\end{pmatrix}$$
But this matrix is neither real nor skew-symmetric, so how can it be can element of $\mathfrak{so}(n)$