# When is matrix multiplication commutative?

I know that matrix multiplication in general is not commutative. So, in general:

$A, B \in \mathbb{R}^{n \times n}: A \cdot B \neq B \cdot A$

But for some matrices, this equations holds, e.g. A = Identity or A = Null-matrix $\forall B \in \mathbb{R}^{n \times n}$.

I think I remember that a group of special matrices (was it $O(n)$, the group of orthogonal matrices?) exist, for which matrix multiplication is commutative.

For which matrices $A, B \in \mathbb{R}^{n \times n}$ is $A\cdot B = B \cdot A$?

-

4
A sufficient condition is that $A$ and $B$ are simultaneously diagonalizable. – Johannes Kloos Jul 13 '12 at 8:41
– J. M. Jul 13 '12 at 8:57

2
$SO(2)$ is commutative, but that is more of an accident than a general property of (special) orthogonal groups. – Henning Makholm Jul 13 '12 at 10:50
@JohannesKloos That was what I was looking for. If you post it as an answer, I'll accept it. – moose Jul 13 '12 at 13:58
I'm not aware of any general statement in this case. – Johannes Kloos Jul 13 '12 at 15:19
show 5 more comments

## 5 Answers

Two matrices that are simultaneously diagonalizable are always commutative.

Proof: Let $A$, $B$ be two such $n \times n$ matrices over a base field $\mathbb K$, $v_1, \ldots, v_n$ a basis of Eigenvectors for $A$. Since $A$ and $B$ are simultaneously diagonalizable, such a basis exists and is also a basis of Eigenvectors for $B$. Denote the corresponding Eigenvalues of $A$ by $\lambda_1,\ldots\lambda_n$ and those of $B$ by $\mu_1,\ldots,\mu_n$.

Then it is known that there is a matrix $T$ whose columns are $v_1,\ldots,v_n$ such that $T^{-1} A T =: D_A$ and $T^{-1} B T =: D_B$ are diagonal matrices. Since $D_A$ and $D_B$ trivially commute (explicit calculation shows this), we have $$AB = T D_A T^{-1} T D_B T^{-1} = T D_A D_B T^{-1} T D_B D_A = \cdots = BA.$$

-

Among the groups of orthogonal matrices $O(n,\mathbb R)$, only the case $n=0$ (the trivial group) and $n=1$ (the two element group) give commutative matrix groups. The group $O(2,\mathbb R)$ consists of plane rotations and reflections, of which the former form an index $2$ commutative subgroup, but reflections do not commute with rotations or among each other in general. The largest commutative subalgebras of square matrices are those which are diagonal on some fixed basis; these subalgebras only have dimension $n$, out of an available $n^2$, so commutation is really quite exceptional among $n\times n$ matrices (at least for $n\geq2$). Nothing very simple can be said that (non-tautologically) characterises all commuting pairs of matrices.

-

The orthogonal matrices don't commute, infact there's a subspace of the orthogonals that's non-commutative!

Check that a permutation matrix is an orthogonal matrix (In case you don't know what a permutation matrix is, it's just a matrix $(a_{ij})$ such that a permutation $\sigma$ exists for which $a_{i,\sigma(i)}=1$ and $a_{ij}=0$ for $j\ne\sigma(i)$

Applying to a column vector $x$ the action of the permutation matrices is just permutation of the co-ordinates of $x$. But as we know the symmetry group is non-abelian. So just choose two non-commuting permutations and their corresponding matrices clearly don't commute!

-

The only matrices that commutes with all other matrices are the multiples of the identity.

-

So there is no group of Matrix pairs that commute. It is $$AB = BA$$ if and only if there is a polynomial $$p \in \mathbb{R}[x]$$ such that $$p(A)=B.$$ This can be proven using Jordan Normalform or by simple computing.

-
What does "there is no group of matrix pairs that commute" mean? – user23211 Jul 13 '12 at 10:00

2
There is a small bit of truth here. IIRC, over an algebraically closed field, every matrix that commutes with $A$ is a polynomial in $A$ if and only if every eigenvalue of $A$ has geometric multiplicity $1$. – Robert Israel Jul 13 '12 at 15:38
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 47, "mathjax_display_tex": 4, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9267473220825195, "perplexity_flag": "head"}