Prove that two matrices commute iff the square of the matrices commute In my textbook there is a task in which I have to prove the relation
\begin{equation}
AB=BA\Leftrightarrow A^2B^2=B^2A^2.
\end{equation}
For ($\Rightarrow$) it is easy
\begin{equation}
AB=BA\Rightarrow (AB)^2=(BA)^2\Rightarrow ABAB=BABA\Rightarrow BBAA=AABB.
\end{equation}
But how do I prove ($\Leftarrow$)?
 A: The equivalence is incorrect. Take for example
$$A = \begin{pmatrix} 1 & 0 \\ 0 & -1\end{pmatrix} \qquad B = \begin{pmatrix} 2 & 1 \\ 1 & 2\end{pmatrix}.$$
A: The implication '$\Leftarrow$' is so obviously false it surprises me that one should even ask this question. Though commutation of matrices can arise in many ways, one of the most simple ways is when one of the matrices is a scalar matrix (multiple of the identity). So if '$\Leftarrow$' were true, it would mean at least that whenever $A^2$ is a scalar matrix then $A$ commutes with every other matrix $B$; this clearly cannot be true.
There is a multitude of kinds of matrices whose square is scalar without any reason for the matrix itself to commute with all other matrices: the matrix of any reflection operation ($A^2=I$), that of a rotation by a quarter turn $(A^2=-I$), or a nilpotent matrix of index$~2$ (i.e., $A\neq0$ but $A^2=0$). These give many choices for a counterexample. (In fact the only way $A$ can commute with all other matrices is for $A$ to be scalar itself, but you don't need to know this fact to find counterexamples to '$\Leftarrow$'.)
A: If you're familiar with the quaternions, and the fact that they have matrix representations, one easy way to see that the reverse implication is false is to consider the fact that
$$i^2 = j^2 = k^2 = -1$$
(and thus the squares of the quaternion units commute) but that $i$, $j$, and $k$ themselves don't commute. These non-/commutativity relations will carry over to any matrix representation.
