When will $AB=BA$?

Solution 1:

If $A,B$ are diagonalizable, they commute if and only if they are simultaneously diagonalizable. For a proof, see here. This, of course, means that they have a common set of eigenvectors.

If $A,B$ are normal (i.e., unitarily diagonalizable), they commute if and only if they are simultaneously unitarily diagonalizable. A proof can be done by using the Schur decomposition of a commuting family. This, of course, means that they have a common set of orthonormal eigenvectors.

Solution 2:

This is too long for a comment, so I posted it as an answer.

I think it really depends on what $A$ or $B$ is. For example, if $A=cI$ where $I$ is the identity matrix, then $AB=BA$ for all matrices $B$. In fact, the converse is true:

If $A$ is an $n\times n$ matrix such that $AB=BA$ for all $n\times n$ matrices $B$, then $A=c I$ for some constant $c$.

Therefore, if $A$ is not in the form of $c I$, there must be some matrix $B$ such that $AB\neq BA$.

Solution 3:

Here are some different cases I can think of:

  1. $A=B$.
  2. Either $A=cI$ or $B=cI$, as already stated by Paul.
  3. $A$ and $B$ are both diagonal matrices.
  4. There exists an invertible matrix $P$ such that $P^{-1}AP$ and $P^{-1}BP$ are both diagonal.