# When are two matrices A and B: AB = BA? [duplicate]

Matrix multiplication is not commutative. If however $$AB = BA$$for the matrices A and B with $$A, B \in M_{nn}(\mathbb{K})$$

Can I conclude that A has to be of the form $$A = B^{Ad} = det(B)B^{-1}$$? Or when is $$AB = BA$$

• Certainly not. $A = 0$ already gives a counterexample, as does $A = I$. – user296602 Mar 20 '18 at 1:31

Here are some choices for $A$ that commutes with $B$ in order of increasing complexity.
• $A=I$ then $AB=BA$,
• $A=B$ then $AB=BA$
• $A=B^n$ then $AB=BA$
• $A=\mathrm{polynomial}(B)$ then $AB=BA$
• If $B$ is invertible and $A=B^{-n}$ then $AB=BA$
• If $B$ is invertible and $A=\mathrm{polynomial}(B,B^{-1})$ then $AB=BA$
It was noted in the comments that the problem on when two matrices $A$ and $B$ commutes has been answered before, but I decided to give the short answer anyway. The version of this problem that I am familiar is when $A$ and $B$ are symmetric, diagonalizable matrices. The diagonalizable case was discussed in the other problem and gives a superset of the examples I gave. When the two matrices are simultaneously diagonalizable then the matrices commute. i.e. if $A=P\Lambda P^\top$, $B=P\Sigma P^\top$ with $P$ an orthogonal matrix and $\Sigma$, $\Lambda$ diagonal matrices then $AB=BA$. The examples in the list above are in fact valid even when the matrices are not diagonalizable.
• In case of interest: if the minimal polynomial of $B$ is the same as the characteristic polynomial of $B,$ and $AB=BA,$ then $A$ must be a polynomial in $B.$ – Will Jagy Mar 20 '18 at 3:51