# intuition for matrix multiplication not being commutative

I want to have an intuition for why AB in matrix multiplication is not same as BA. It's clear from definition that they are not and there are arguments here (Fast(est) and intuitive ways to look at matrix multiplication?) that explain that this is in order to maintain certain compositional properties. Example:

(column vector)

$A = \left( \begin{array}{c} 1\\ 2\\ 3 \end{array} \right)$

(row vector)

$B = \left(1, 5, 0\right)$

If we view a matrix as a linear combination of columns, then I read this from right to left as saying "take 1 times" of column 1 of left matrix, then "take 5 times" of column 2 of left matrix, then "take 0 times" of column 3 of left matrix. Intuitively this means the $B$ vector is the set of weights for the linear combination and the columns of $A$ are the ones being combined. This yields:

$AB = \left( \begin{array}{c} 1 & 5 & 0\\ 2 & 10 & 0\\ 3 & 15 & 0 \end{array} \right)$

1st question: is this a valid way to think of the operation? It gives the right answer here, but more generally is it correct?

2nd question: how can we apply this (or a better) intuition to the case of mutiplying $BA$? We have:

$BA = \left((1\times1) + (5\times2) + (3\times0)\right) = \left(11\right)$

not sure how to think of that intuitively.

one intuition that has been proposed is matrix multiplication as linear composition of functions. I'm open to that but usually I don't think of matrices like $A$ and $B$ as individually representing functions.

• I like to simply not have intuition on this, and take for granted that in general, composition of functions will not be commutative ; since matrices are essentially linear functions, we don't expect anything better from them either. That's just a comment though, I don't believe it answers your question. – Patrick Da Silva Feb 17 '14 at 2:44
• @user9576: note that your way to calculate BA is wrong, it should be $1\times1+5\times2+4\times0=11$. – Martin Argerami Feb 17 '14 at 2:46
• You should think of matrices as representing functions; a lot of properties become clearer that way. For example, function composition is associative, so matrix multiplication is associative; function composition is not commutative, so we shouldn't expect matrix multiplication to be commutative, either. – Ted Feb 17 '14 at 2:59
• @Ted: Can you point to a reference that elaborates on the connection, and makes it obvious that matrices are linear functions? – user9576 Feb 17 '14 at 3:06
• Any linear algebra textbook will do this. The entire reason for defining matrix multiplication in the way we do, is to make matrix multiplication correspond to composition of linear functions. – Ted Feb 17 '14 at 3:39

Regarding your first question, if you write $$A=\begin{bmatrix}\mathbf r_1\\\mathbf r_2\\\vdots\\\mathbf r_m\end{bmatrix}, \ \ B=[\mathbf c_1\ \mathbf c_2\ \cdots\ \mathbf c_n],$$ then $$AB=\begin{bmatrix} \mathbf r_1\cdot\mathbf c_1&\mathbf r_1\cdot\mathbf c_2&\cdots&\mathbf r_1\cdot\mathbf c_n\\\mathbf r_2\cdot\mathbf c_1&\mathbf r_2\cdot\mathbf c_2&\cdots&\mathbf r_2\cdot\mathbf c_n\\ \vdots&&\cdots&\vdots\\ \mathbf r_m\cdot\mathbf c_1&\mathbf r_m\cdot\mathbf c_2&\cdots&\mathbf r_m\cdot\mathbf c_n\\ \end{bmatrix}$$ so the idea works in general. You can also write this as $$AB=\begin{bmatrix}\mathbf r_1B\\\mathbf r_2B\\\vdots\\\mathbf r_mB\end{bmatrix}=[\mathbf Ac_1\ \mathbf Ac_2\ \cdots\ \mathbf Ac_n]$$
• thanks, but how does my formulation of linear combinations work when you have $row \times column$ instead of $column \times row$? – user9576 Feb 17 '14 at 3:00
• I don't think you can say a lot more. See the edit. In the end, you cannot avoid calculating dot products "row$\times$column" to calculate a product of matrix. You first example is the easiest because your dot products are just products of numbers; but that only happens that particular case. – Martin Argerami Feb 17 '14 at 3:15