Let $ GL_2 (\mathbb {R}) $ be the set of matrices $ 2 $ x $ 2 $ invertible with real elements. Determine all positive integer pairs $ (m, n) $ with the following property: if $ A, B \in GL_2 (\mathbb {R}) $ are such that $ A \cdot B ^ m = B ^ m \cdot A $ and $ A \cdot B ^ n= B ^ n \cdot A $, then $ A $ and $ B $ switch, ie, $ AB = BA $
Attemp: Problem. Given an integer $k \ge 2,$ find all positive integer pairs $(m,n)$ with this property that if $A,B \in \text{GL}_k(\mathbb{R})$ are such that $AB^m=B^mA$ and $AB^n=B^nA,$ then $AB=BA.$
Answer. The set $\{(m,n) \in \mathbb{N} \times \mathbb{N}: \ \ \gcd(m,n)=1\}.$
Proof. Suppose first that $\gcd(m,n)=1.$ So there exist integers $r,s$ such that $rm+sn=1.$ Now let $C=ABA^{-1}.$ Then from $AB^m=B^mA$ and $AB^n=B^nA,$ we get $C^m=B^m$ and $C^n=B^n.$ Thus $C^{rm}=B^{rm}$ and $C^{sn}=B^{sn}$ and so $$ABA^{-1}=C=C^{rm+sn}=B^{rm+sn}=B,$$which gives $AB=BA.$
Now suppose that $\gcd(m,n)=d > 1.$ I show that there exist $A,B \in \text{GL}_k(\mathbb{R})$ such that $AB^m=B^mA$ and $AB^n=B^nA$ but $AB \ne BA.$ To do that, let $$P:=\begin{pmatrix}\cos(2\pi/d) & -\sin(2\pi/d) \\ \\ \sin(2\pi/d) & \cos(2\pi/d)\end{pmatrix}.$$If $d=2,$ we choose $B=\text{diag}(-1,1, \cdots , 1)$ and if $d > 2,$ we choose $B=\text{diag}(P,P, \cdots, P, u),$ where $u=P$ if $k$ is even and $u=1$ if $k$ is odd. So, in either case, $B^d=I_k,$ the identity matrix, and $B$ is not a scalar multiplication of $I_k.$ Thus $B$ is not in the center of $\text{GL}_k(\mathbb{R})$ and so there exists $A \in \text{GL}_k(\mathbb{R})$ such that $AB \ne BA$ and, clearly, $A=AB^d=B^dA.$ Hence, since $d$ divides both $m,n,$ we get that $AB^m=B^mA$ and $AB^n=B^nA,$
Am I right? Is there a better case to solve this? If you can, I would like ideas, or a better solution