Britannica Sources used in this answer

Why do diagonal matrices commute under multiplication?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

In general, matrix multiplication is not commutative, meaning that for two arbitrary matrices A and B, AB does not necessarily equal BA. However, diagonal matrices—square matrices where all elements aij are zero except when i=j—are a notable exception to this rule.1

Diagonal matrices commute because their multiplication effectively reduces to the independent multiplication of their corresponding diagonal elements. If A and B are diagonal matrices, the element in the ith row and jth column of their product AB is the product of the ith diagonal element of A and the jth diagonal element of B only when i=j; otherwise, the product is zero. Because the multiplication of these individual diagonal elements (which are ordinary numbers) is commutative, the resulting matrices AB and BA are identical.1