• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

When is matrix multiplication commutative?

Contents

  • When is 2x2 matrix multiplication commutative?
    • Case #1: a != d and e != h
    • Case #2.1: a == d
    • Case #2.2: e == h
  • Special Cases
  • Simultaneous diagonalization
  • See also

Matrix multiplication in general is not commutative. Here is an example:

\(A, B \in R^{2 \times 2}\)

$$A := \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$$
$$B := \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}$$
$$A \cdot B = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix} \neq \begin{pmatrix} 23 & 34 \\ 31 & 46 \end{pmatrix} = B \cdot A$$

When is 2x2 matrix multiplication commutative?

$$\begin{pmatrix} a & b \\ c & d \end{pmatrix} \cdot \begin{pmatrix} e & f \\ g & h \end{pmatrix} = \begin{pmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{pmatrix}$$
$$\begin{pmatrix} e & f \\ g & h \end{pmatrix} \cdot \begin{pmatrix} a & b \\ c & d \end{pmatrix} = \begin{pmatrix} ae + cf & be + df \\ ag + ch & bg + dh \end{pmatrix}$$

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 \neq d\) and \(e \neq h\) for commutative matrix multiplication of \(2 \times 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 \times 2$ rotation matrices. (basically case #2)
  • ... both matrices are Diagonal matrices.

Simultaneous diagonalization

Two matrices \(A, B \in R^{n \times n}\) are called simultaneous diagonalizable \(: \Leftrightarrow\) one matrix \(S \in R^{n \times n}\) exists, such that \(D_A = S^{-1} \cdot A \cdot S\) and \(D_B = S^{-1} \cdot B \cdot S\) with \(D_A\) and \(D_B\) are diagonal matrices.

Statement: \(A, B \in \mathbb{R}^{n \times n}\) are simultaneous diagonalizable \(\Rightarrow A \cdot B = B \cdot A\)

Proof: As A and B are simultaneous diagonalizable, a matrix \(T \in \mathbb{R}^{n \times n}\) exists, such that \(D_A = S^{-1} \cdot A \cdot S\) and \(D_B = S^{-1} \cdot B \cdot S\) with \(D_A\) and \(D_B\) are diagonal matrices.

\begin{align} \Rightarrow A \cdot B &= S \cdot D_A S^{-1} \cdot S \cdot D_B \cdot S^{-1} \\ &= S \cdot D_A \cdot D_B \cdot S^{-1} \\ &= S \cdot D_B \cdot D_A \cdot S^{-1} \\ &= S \cdot D_B \cdot S^{-1} \cdot S \cdot D_A \cdot S^{-1} \\ &= B \cdot A \blacksquare \end{align}

Statement: \(A \cdot B = B \cdot A \nRightarrow A, B \in \mathbb{R}^{n \times n}\) 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

Published

Jul 14, 2012
by Martin Thoma

Category

Mathematics

Tags

  • Linear algebra 18
  • mathematics 59

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor