# Can AB be anything other than the Identity matrix?

Say we have two square, non-singular matrices A and B, which are not equal to each other. And such that both AB and BA is defined. So will the only solutions to the equation AB = BA be that either one of them is the Identity matrix or A is the inverse of B or B is the inverse of A. But my teacher had said that the last two are true only when AB = BA = I (Identity matrix). But how can AB = BA be equal to something other than the Identity matrix ? Is it possible that : $$AB = BA \neq I$$

• Simplest case for instance: $3 \times 2 = 2 \times 3 = 6$. Extend it to diagonal matrices when $n > 1$. Nov 9, 2020 at 16:02
• For, say, $B=A^3+17A^2+\frac12A+9I$ we have $BA=AB$ (and $A^3+17A^2+\frac12A+9I\notin\{ A^{-1}, I, A\}$ more often than not).
– user239203
Nov 9, 2020 at 16:07
• In general, if $B$ is any polynomial in $A$ with real coefficients, then $AB=BA$. Also, if both $A$ and $B$ are any diagonal matrices, then $AB=BA$. Nov 9, 2020 at 16:08
• Let $A=B=\pmatrix{1&0\\ 0&0}$. Then $AB=BA$ and none of $A,B,AB$ or $BA$ is equal to any scalar multiple of $I$. Nov 9, 2020 at 17:48

• it means that if there exist a matrix $P$ such that $PAP^{-1}$ and $PBP^{-1}$ are diagonal matrices
• @KoustubhJain So for example, $AB = BA$ will always work if $$A = \pmatrix{p&0\\0&q}, \quad B = \pmatrix{s & 0 \\ 0 & t}$$ for numbers $p,q,s,t$. Nov 9, 2020 at 18:37