Matrix $\log(\exp(M))\ne M$?

173 Views Asked by At

I have tested matrix $\log$ following matrix $\exp$ in many different math libraries (Eigen for C++, numpy for Python, and yet other less known implementations) and for most square matrices M we have $\log(\exp(M))=M$, which is expected.

Now it turns out that in some cases $\log(\exp(M))\ne M$.

e.g. for

$$ M= \begin{bmatrix} 0 & -6 & 5 & 1 \\ 6 & 0 & -4 & 2 \\ -5 & 4 & 0 & 3 \\ 0 & 0 & 0 & 0 \end{bmatrix} $$

all libraries return

$$ \log(\exp(M))= \begin{bmatrix} 0 & -1.70378748 & 1.4198229 & 1.47425723 \\ 1.70378748 & 0 & -1.1358583 & 2.05579497 \\ -1.4198229 & 1.13585832 & 0 & 2.6373327 \\ 0 & 0 & 0 & 0 \end{bmatrix} $$

Any idea of what is going on and why I am not getting $M$ as a result?

Note that in my case $M$ is an element of $\operatorname{se}(3)$, the special euclidean algebra (not sure whether this is important...).

------ EDIT ------

This behavior seems to be due to $\exp$ being many-to-one (modulo $2\pi$) though this is in contradiction with what is observed here:

Let $\overline M$ be the compact representation of $M$, hence

$$ \overline M= \begin{bmatrix} 1 & 2 & 3 & 4 & 5 &6 \end{bmatrix} $$

So $\left\|\overline M \right\|=9.53939201417$, and thus $\overline M$ is not the principal representation of the log. We obviously expect $\log(\exp(M))$ to be the principal representation, but it turns out it is not, because $$ \left\|\overline {\log(\exp(M))} \right\|=4.42314527494 \neq 9.53939201417 [2\pi] $$

and it also turns out that

$$ \frac{\overline M}{\left\|\overline M \right\|} \neq \frac{\overline {\log(\exp(M))}}{\left\|\overline {\log(\exp(M))} \right\|} $$

as

$$ \frac{\overline M}{\left\|\overline M \right\|} = \begin{bmatrix} 0.10482848 & 0.20965697 & 0.31448545 & 0.41931393 & 0.52414242 & 0.6289709 \end{bmatrix} $$

but

$$ \frac{\overline {\log(\exp(M))}}{\left\|\overline {\log(\exp(M))} \right\|} = \begin{bmatrix} 0.33330518 & 0.46478125 & 0.59625731 & 0.25679878 & 0.32099848 & 0.38519817 \end{bmatrix} $$

Any idea of what is going on?