When are two matrices A and B: AB = BA? 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
$$
 A: 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.
