Prove that all the powers of these two matrices have the same trace 
Let $A, B \in M_{2}(\mathbb{R})$ be two square matrices such that $$AB
 \ne BA$$ and $$A^3 = B^3$$ Prove that $\mbox{Tr} (A^n) = \mbox{Tr} (B^n)$ for all $n \in \mathbb{N}$, where $\mbox{Tr} (\cdot)$ is the trace.


First, it's clear that $\det A = \det B$ and $A \ne B$. Also, using Cayley-Hamilton it is enough to prove it for $n=1$. I have played around with Cayley-Hamilton for both matrices, with no result. Any idea is welcome.
 A: It suffices to check that the characteristic polynomial of $A$ and $B$ coincide. To this end, we show that the given condition yields $\operatorname{tr}(A) = \operatorname{tr}(B)$ and $\det(A) = \det(B)$.
First, the latter equality is immediate from $\det(A)^3 = \det(A^3) = \det(B^3) = \det(B)^3$ together with $\det(A), \det(B) \in \mathbb{R}$.
Next, by the Cayley-Hamilton theorem we have $A^2 = \operatorname{tr}(A)A - \det(A)I_2$ and consequently
$$ A^3 = (\operatorname{tr}(A)^2 - \det(A))A - \det(A)\operatorname{tr}(A)I_2. \tag{*}$$
So if $\operatorname{tr}(A)^2 - \det(A) \neq 0$, then it follows that $A = pA^3 + qI_2$ for some $p, q \in \mathbb{R}$. Since $A^3 = B^3$, this forces that $AB = BA$, contradicting the assumption. Hence we have
$$\operatorname{tr}(A)^2 = \det(A).$$
We consider two cases separately:


*

*If $\det(A) = \det(B) = 0$, then this implies that $\operatorname{tr}(A) = \operatorname{tr}(B) = 0$.

*If $\det(A) = \det(B) \neq 0$, then taking trace to both sides of $\text{(*)}$ and using the identity above, we have
$$ \operatorname{tr}(A^3) = \operatorname{tr}(A)^3 - 3\det(A)\operatorname{tr}(A) = -2\det(A) \operatorname{tr}(A).$$
Dividing both sides by $-2\det(A)$, it follows that $\operatorname{tr}(A)$ is completely determined by $A^3$, hence again we have $\operatorname{tr}(A) = \operatorname{tr}(B)$.
Therefore in any cases we have $\operatorname{tr}(A) = \operatorname{tr}(B)$ as desired.

Remark. When the condition $AB \neq BA$ is dropped, we have an obvious counter-example $A = I_2$ and $B$ is the rotation matrix by angle $2\pi/3$. In this case, we have
$$A^3 = B^3 = I_2 \qquad \text{but} \qquad \operatorname{tr}(A) = 2 \neq -1 = \operatorname{tr}(B). $$
A: It is sufficiently to show that $|Ex-A|=|Ex-B|$.
If $A$ and $B$ are nilpotent matrices the proof is evident.
If $A$ and $B$ has different non-zero eigenvalues $\lambda_1,\lambda_2$ and $\mu_1,\mu_2$, respectively, then using the fact about eigenvalues of $A^3$ and $B^3$ we obtain $\{\lambda_1^3,\lambda_2^3\} = \{\mu_1^3,\mu_2^3\}$ and hence $\lambda_1\lambda_2=|A|= |B| = \mu_1\mu_2$ we obtain the required assertion.
So, It remains to consider the case, when $\lambda_1=\lambda_2$.
A: There are essentially two cases:


*

*Both spectra of $A$ and $B$ are real, or both of them are pairs of non-real eigenvalues. Then the condition $A^3=B^3$ implies that the two spectra are identical. Hence the assertion follows.

*$A$ has a conjugate pair of non-real eigenvalues and $B$ has a real spectrum. As the eigenvalues of $B$ are non-real, they are different from each other. Hence $B$ is diagonalisable over $\mathbb C$. Yet, $A^3=B^3$ and the spectrum of $A$ is real. Therefore $A^3=B^3$ must be a nonzero scalar matrix. Since real numbers have unique real cubic roots, $A$ has two repeated nonzero real eigenvalues. Hence $A$ is a scalar matrix too, or else $A^3=B^3$ is not diagonalisable. But this contradicts the assumption that $AB\ne BA$. So, this case is impossible.

