Why is dot product commutative but matrix multiplication is not?

2.5k Views Asked by At

I have been told $a \cdot b = a^Tb$

If dot product is commutative, then $a \cdot b = a^Tb = b \cdot a = b^Ta$

So we get $a^Tb = b^Ta$. A contradiction to matrix multiplication not being commutative.

2

There are 2 best solutions below

4
On BEST ANSWER

Matrix multiplication is not commutative in general. In Mathematics, "in general it is not..." means: "there are cases in which it is not..."; it does not mean "in all cases it is not...". Sure, there are pair of matrices whose product is the same whatever is the order in the product.

However, your case is different: you are not providing an example of two matrices whose product commutes. The product does not commute in your example: $$ [a_1,\ldots,a_n] \begin{bmatrix} b_1\\ \vdots\\ b_n \end{bmatrix}= a_1b_1+\ldots+a_nb_n\in \mathbb R $$ while $$ \begin{bmatrix} b_1\\ \vdots\\ b_n \end{bmatrix} [a_1,\ldots,a_n]= \begin{bmatrix} b_1 a_1 &\ldots &b_1 a_n\\ \vdots & & \vdots \\ b_n a_1& \ldots & b_n a_n \end{bmatrix}\in \mathbb R^{n\times n} $$ Commutativity is out of question for pair of matrices which are not square matrices (of the same order). For square matrices of the same order, commutativity occurs in particular cases.

2
On

Notice that you can't multiply two vectors when they are regarded as matrices. Hence the "$\cdot$" in $a\cdot b$ doesn't refer to the product of two matrices.

But for any two matrices $A$ and $B$ of the same dimension you may define $$A\ast B=\operatorname{trace}(A^TB).$$ For this product we have that $A\ast B=B\ast A$.