I have a question asking me why matrix multiplication isn't commutative. I'm not exactly sure what's the best way to explain this without simply saying "it's obvious".
$AB \not= BA$ because the steps to multiply the values are different going one way and the other way ways. Only in rare circumstances is it commutative.
$\endgroup$ 75 Answers
$\begingroup$Although matrix multiplication is not commutative, it is associative in the sense that $$A(BC)=(AB)C$$
for the correct dimensions.
To show matrix multiplication is not commutative we can consider an example. Take $$A=\begin{bmatrix} 1 & 1 \\ 0 & 0\end{bmatrix}$$
$$B=\begin{bmatrix}1 & 0 \\ 0 & 0\end{bmatrix}$$
Then $$AB=\begin{bmatrix} 1 & 1 \\ 0 & 0\end{bmatrix}\begin{bmatrix}1 & 0 \\ 0 & 0\end{bmatrix}=\begin{bmatrix} 1 & 0 \\ 0 & 0\end{bmatrix}$$ $$\text{and}$$ $$BA=\begin{bmatrix}1 & 0 \\ 0 & 0\end{bmatrix}\begin{bmatrix} 1 & 1 \\ 0 & 0\end{bmatrix}=\begin{bmatrix} 1 & 1 \\ 0 & 0\end{bmatrix}$$ Thus $AB\neq BA$.
See this for when is matrix multiplication commutative.
$\endgroup$ 1 $\begingroup$I think it always worth pointing out when introducing matrix multiplication that $AB$ and $BA$ are not necessarily even both defined. For example, if $A$ is a $5\times2$ matrix and $B$ is a $2\times 4$ matrix, then $AB$ is defined but $BA$ isn't.
Even when both products are defined, it can still be obvious that they are unequal. If $A$ is $1\times4$ and $B$ is $4\times1$ then $AB$ is $1\times1$ while $BA$ is $4\times4$.
This last example suggests an easy way to see that even for square matrices the two products are not necessarily the same. Let$$ A=\begin{bmatrix}1 & 2 & 3 & 6\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 \end{bmatrix}\quad\text{and}\quad B=\begin{bmatrix}4 & 0 & 0 & 0\\ 5 & 0 & 0 & 0\\ 1 & 0 & 0 & 0\\ 2 & 0 & 0 & 0 \end{bmatrix}. $$In this example, $AB$ has only a single nonzero element, whereas all $16$ elements of $BA$ are nonzero. The matrix $A$ can be thought of as a $1\times4$ matrix that has been padded with zero rows to make it square. Likewise, the matrix $B$ can be thought of as a $4\times1$ matrix that has been padded with zero columns to make it square. From this point of view, the structure of the resulting products is not surprising.
$\endgroup$ $\begingroup$Geometrically, you can realise both rotations and reflections by matrix multiplication. But, in general, the result of a reflection followed by a rotation is different from the rotation (same angle, same axis) followed by the reflection (same mirror). [The dihedral groups, for example, are non-abelian because they combine non-commuting rotations and reflections].
$\endgroup$ $\begingroup$Assuming one has to explain matrix multiplication to someone who has not seen much of linear algebra, a matrix is introduced as a collection of vectors. For example, for two $3\times3$ matrices $A$ and $B$,$$ A=\begin{bmatrix} \quad r_{A1} \quad \\ \quad r_{A2} \quad \\ \quad r_{A3} \quad \end{bmatrix} = \Biggl[ \begin{matrix} c_{A1} \quad & \quad c_{A2} \quad & \quad c_{A3} \end{matrix} \Biggr] $$
where $r_{Ai}$, $c_{Aj}$ are called row and column vectors respectively.
Similarly, $$ B=\begin{bmatrix} \quad r_{B1} \quad \\ \quad r_{B2} \quad \\ \quad r_{B3} \quad \end{bmatrix} = \Biggl[ \begin{matrix} c_{B1} \quad & \quad c_{B2} \quad & \quad c_{B3} \end{matrix} \Biggr] $$
By rules of matrix multiplication,$$ AB=\begin{bmatrix} r_{A1}\cdot c_{B1} & r_{A1}\cdot c_{B2} & r_{A1}\cdot c_{B3} \\ r_{A2}\cdot c_{B1} & r_{A2}\cdot c_{B2} & r_{A2}\cdot c_{B3} \\ r_{A3}\cdot c_{B1} & r_{A3}\cdot c_{B2} & r_{A3}\cdot c_{B3} \end{bmatrix} $$where $r_{A1}\cdot c_{B1}$ stands for dot product of vectors $r_{A1}$ and $c_{B1}$.
Similarly,$$ BA=\begin{bmatrix} r_{B1}\cdot c_{A1} & r_{B1}\cdot c_{A2} & r_{B1}\cdot c_{A3} \\ r_{B2}\cdot c_{A1} & r_{B2}\cdot c_{A2} & r_{B2}\cdot c_{A3} \\ r_{B3}\cdot c_{A1} & r_{B3}\cdot c_{A2} & r_{B3}\cdot c_{A3} \end{bmatrix} $$
Clearly, the two results are different.
$\endgroup$ $\begingroup$$$ \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}. $$
$$ \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}. $$
$$ \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix} \neq \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}. $$
$\endgroup$