---
tag: 0P506SPZP2
kind: counterexample
name: Non-commutativity of matrix multiplication
msc: [15A27]
uses: [076JGP6R3T]
sources:
  - url: https://en.wikipedia.org/wiki/Commuting_matrices
    locator: lead section
---

## Counterexample

Let $A = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}$ and $B = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$, as real $2 \times 2$ matrices.
Then
$$AB = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}, \qquad BA = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}.$$
Thus $AB \ne BA$.
This shows that [[matrix multiplication|032Q9FB8MT]] of $n \times n$ matrices is not commutative for $n = 2$.

## Remarks

The same example, extended with zero rows and zero columns, shows that $M_n(R)$ is not commutative for each $n \ge 2$ and each nonzero ring $R$.
Two matrices $A$ and $B$ with $AB = BA$ are said to *commute*.
Some pairs commute, for example a matrix and the [[identity matrix|06DW9BAWB1]], or two [[diagonal matrices|044JNC7ZAA]].

## Explanations

### L1 human

For numbers, $2 \cdot 3 = 3 \cdot 2$, but for matrices the order of the factors matters.
Here $AB$ and $BA$ are different matrices.
A reason is that $AB$ means "first apply $B$, then $A$", and two actions done in a different order can give different results.
