# Under what conditions does matrix multiplication commute?

This is just a check on my reasoning, I guess.

So for two matrices $A, B$ to commute, the following must hold:

$$(AB)_{ij} = \sum_{k=1}^{n}a_{ik}b_{kj} = \sum_{k=1}^{n}b_{ik}a_{kj} = (BA)_{ij}$$

This can happen if for all $i, j, k$:

a. $a_{ik}=a_{kj}$ and $b_{ik}=b_{kj}$, or

b. $a_{ik}=b_{ik}$ and $a_{kj}=b_{kj}$, i.e. $A=B$, or

c. $a_{ik} = 0$ or $b_{ik} = 0$, i.e. either matrix is null.

Are there more possibilities?

Edit: I originally had (a) as "Both matrices are symmetric", but as @user1551 points out, this is not true. After fixing the summations, I see where I was mistaken. I'm not sure how to characterize (a) now.

• Certainly any power of $A$ commutes with $A$ for any matrix $A$. – André 3000 Sep 28 '15 at 16:17
• Your case (a) is not true. $A,B$ may not commute if they are symmetric. Consider, e.g., $A$ is the matrix whose only nonzero entry is the $(1,1)$-th one and $B$ is the all-one matrix. By the way, I don't understand what the symbol $\sum_k^j$ means. – user1551 Sep 28 '15 at 16:25
• @user1551 Hm. The summation is supposed to capture that each entry is the inner product of a row of A and a column of B (or the other way around). – Nathan Sep 28 '15 at 16:43
• Then it should be $\sum\limits_{k=1}^na_{ik}b_{kj}$, not $...a_{ik}b_{ki}$ – Ivan Neretin Sep 28 '15 at 16:44
• @IvanNeretin Oh ok. I see where I messed up then. Thanks! I didn't know about \limit. I've always just written it the other way. – Nathan Sep 28 '15 at 16:46

This property has really nothing to do with A and B being symmetric. Indeed, there are examples of matrices which are symmetric and don't commute... $$A=\left(\begin{matrix}2& 1\\1 & 3 \end{matrix}\right),\; B=\left(\begin{matrix}3& 1\\1 & 2 \end{matrix}\right),$$ ...and those which are not symmetric but do commute: $$A=\left(\begin{matrix}1& 1\\0 & 1 \end{matrix}\right),\; B=\left(\begin{matrix}1& 2\\0 & 1 \end{matrix}\right).$$
• Can I ask what are the degenerate cases? Specifically, is it true that any two matrices commute iff they have the same eigenspaces (excluding with eigenvalue $1$)? The backward implication is clear, but what about the forward implication? – user21820 Nov 29 '16 at 17:40
• The reason I singled out the eigenvalue $1$ is because a rotation about an axis commutes with a stretch along the same axis but their eigenspaces differ by those for eigenvalue $1$, and I had forgotten where I saw some Math SE post about this phenomenon. Now I recall I saw it at math.stackexchange.com/a/2019710, which makes a lot more sense. – user21820 Nov 30 '16 at 2:35