TITLE: Find $A,B\in\Bbb K^{2\times 2}$ such that $AB\neq BA$ but $e^{A+B}=e^Ae^B$
QUESTION [6 upvotes]: Find $A,B\in\Bbb K^{2\times 2}$ such that $AB\neq BA$ but $e^{A+B}=e^Ae^B$. Hint: $e^{2k\pi i}=1$ for all $k\in\Bbb Z$.

This is the exercise 10 in page 146 of Analysis II of Amann and Escher. I dont know exactly what to do here more than just try things blindly (trying to guess what is the hint about).
I know that
$$A:=\begin{bmatrix}a&b\\0&c\end{bmatrix}\implies e^A=\begin{cases}\begin{bmatrix}e^{a}&\frac{b}{c-a}(e^{c}-e^{a})\\0&e^{c}\end{bmatrix},& c\neq a\\\begin{bmatrix}e^{a}&be^{a}\\0&e^{a}\end{bmatrix},& c= a\end{cases}\tag1$$
$$A:=\begin{bmatrix}0&-\omega\\\omega&0\end{bmatrix}\implies e^{A}=\begin{bmatrix}\cos \omega&-\sin\omega \\\sin\omega &\cos\omega \end{bmatrix}\tag2$$
What I thought about the hint is setup some matrices as in $(1)$ such that $i(A+B)=i2\pi I$, by example
$$A:=\begin{bmatrix}a&b\\0&c\end{bmatrix},\quad B:=\begin{bmatrix}2\pi-a&-b\\0&2\pi-c\end{bmatrix}\implies e^{i(A+B)}=I$$
However we have that $AB=BA$, then I must find other way. Some help will be appreciated, thank you.

REPLY [3 votes]: E.g.
$$
A=\pmatrix{0&2\pi\\ -8\pi&0},
\ B=\pmatrix{0&8\pi\\ -2\pi&0}.
$$
The key is that, since $e^{2k\pi i}=1$, it suffices to generate two matrices $A$ and $B$ so that $A,B$ and $A+B$ are similar to integer multiples of $J=\pmatrix{0&2\pi\\ -2\pi&0}$. If $A$ and $B$ are chosen at random, they usually do not commute.
For instance, if we pick
$$
A=\pmatrix{0&2a\pi\\ -2b\pi&0},
\ B=\pmatrix{0&2c\pi\\ -2d\pi&0},
$$
for some $a,b,c,d\in\mathbb N$, then $A$ and $B$ are similar to $\sqrt{ab}J$ and $\sqrt{cd}J$ respectively, and hence $e^A=e^B=I$ when $ab$ and $cd$ are perfect squares. Similarly, if $(a+c)(b+d)$ is also a perfect square, then $e^{A+B}=I=e^Ae^B$. Finally, if $(a,b)$ and $(c,d)$ are linearly independent, then $AB\ne BA$. So, we can generate a bunch of desired examples using a simple Octave/Matlab script:
for a=1:10,for b=1:10,for c=1:10,for d=1:10,
  if det([a b;c d])~=0
    && abs(sqrt(a*b)-floor(sqrt(a*b)))<1e-6
    && abs(sqrt(c*d)-floor(sqrt(c*d)))<1e-6
    && abs(sqrt((a+c)*(b+d))-floor(sqrt((a+c)*(b+d))))<1e-6,
    sprintf("%d %d %d %d", a,b,c,d),
  end;
end;end;end;end