Matrix multiplication in general is not commutative. Here is an example:
A,B∈R2×2
A:=(12 34) B:=(56 78)
A⋅B=(1922 4350)≠(2334 3146)=B⋅A
When is 2x2 matrix multiplication commutative? ¶
(ab cd)⋅(ef gh)=(ae+bgaf+bh ce+dgcf+dh)
(ef gh)⋅(ab cd)=(ae+cfbe+df ag+chbg+dh)
So you get four equations: $$\begin{eqnarray} I) & ae + bg &= ae + cf &\Leftrightarrow bg = cf \ II) & af + bh &= be + df\ III) & ce + dg &= ag + ch\ IV) & cf + dh &= bg + dh &\Leftrightarrow cf = bg \end{eqnarray}$$
You might note that (I) is the same as (IV). So you have those equations: $$\begin{eqnarray} I) & bg = cf \ II) & af + bh &= be + df & \Leftrightarrow f (a - d) = b (e - h)\ III) & ce + dg &= ag + ch & \Leftrightarrow g (a - d) = c (e - h) \end{eqnarray}$$
Case #1: a != d and e != h ¶
$$\begin{eqnarray} I) & bg &= cf \ II) & \frac{f}{g} &= \frac{b}{c} \Leftrightarrow cf = bg \end{eqnarray}$$
Now (I) and (II) are essentially the same. So we only demand that bg=cf and a≠d and e≠h for commutative matrix multiplication of 2×2 matrices.
Case #2.1: a == d ¶
\begin{eqnarray} I) & bg &= cf \ II) & 0 &= b (e - h)\ III) & 0 &= c (e - h) \end{eqnarray}
So you end up with: (e=h and bg=cf) or (b=c=0)
Case #2.2: e == h ¶
\begin{eqnarray} I) & bg &= cf \ II) & f (a - d) &= 0\ III) & g (a - d) &= 0 \end{eqnarray}
So you end up with: (a=d and bg=cf) or (f=g=0)
Special Cases ¶
Matrix multiplication is always commutative if ...
- ... one matrix is the Identity matrix.
- ... one matrix is the Zero matrix.
- ... both matrices are 2×2 rotation matrices. (basically case #2)
- ... both matrices are Diagonal matrices.
Simultaneous diagonalization ¶
Two matrices A,B∈Rn×n are called simultaneous diagonalizable :⇔ one matrix S∈Rn×n exists, such that DA=S−1⋅A⋅S and DB=S−1⋅B⋅S with DA and DB are diagonal matrices.
Statement: A,B∈Rn×n are simultaneous diagonalizable ⇒A⋅B=B⋅A
Proof: As A and B are simultaneous diagonalizable, a matrix T∈Rn×n exists, such that DA=S−1⋅A⋅S and DB=S−1⋅B⋅S with DA and DB are diagonal matrices.
⇒A⋅B=S⋅DAS−1⋅S⋅DB⋅S−1 =S⋅DA⋅DB⋅S−1 =S⋅DB⋅DA⋅S−1 =S⋅DB⋅S−1⋅S⋅DA⋅S−1 =B⋅A◼
Statement: A⋅B=B⋅A⇏ are simultaneous diagonalizable.
Proof: by Counter-Example \begin{pmatrix}0 & 1 \ 0 & 0\end{pmatrix} \cdot \begin{pmatrix}1 & 0 \ 0 & 1\end{pmatrix} = \begin{pmatrix}1 & 0 \ 0 & 1\end{pmatrix} \cdot \begin{pmatrix}0 & 1 \ 0 & 0\end{pmatrix} but \begin{pmatrix}0 & 1 \ 0 & 0\end{pmatrix} is not diagonalizable. \blacksquare
See also ¶
- When is matrix multiplication commutative? on math.stackexchange.com