# Why is matrix multiplication defined a certain way? [duplicate]

Why is it that when multiplying a (1x3) by (3x1) matrix, you get a (1x1) matrix, but when multiplying a (3x1) matrix by a (1x3) matrix, you get a (3x3) matrix? Why is matrix multiplication defined this way?

Why can't a (1x3) by (3x1) yield a (3x3), or a (3x1) by (1x3) yield a (1x1)? I really would like to get to the root of this problem or 'axiomatization'. Thanks.

• I read the related posts as mentioned above, but I'm still unable to understand why. – user85362 Jul 7 '13 at 20:46
• @AbhishekMallela Have you learned about linear maps and their relation to matrices? – Git Gud Jul 7 '13 at 20:48

The idea is that a matrix represents a linear map of finite-dimensional vector spaces. A (3x1) matrix "is" a linear map $\Bbb{R} \to \Bbb{R}^3$, and so on...

Multiplying matrices amounts to composing these functions. The rules of matrix multiplication you ask about are tha classical rules of function composition. (if $f:E \to F$ and $g:F\to G$ then $g\circ f : E \to G$.)

Long story short, you need to study the relationship between matrices and linear maps.

• Thank you, it makes sense now – user85362 Jul 7 '13 at 20:53
• @AbhishekMallela How does this answer make sense, but the other answers in the duplicate question which you claim to have read and said didn't understand do not? – Git Gud Jul 7 '13 at 20:55
• However, if one defines the composition of (linear) functions from left to right instead of the usual backwards way, then matrix multiplication would end up the other way around, exactly as you suggested in the question. – Berci Jul 7 '13 at 22:26
• You're right, and it would be actually less confusing ! – justt Jul 8 '13 at 7:45

Suppose \begin{align} p & = 2x + 3y \\ q & = 3x - 7y \\ r & = -8x+9y \end{align} Represent this way from transforming $\begin{bmatrix} x \\ y \end{bmatrix}$ to $\begin{bmatrix} p \\ q \\ r \end{bmatrix}$ by the matrix $$\left[\begin{array}{rr} 2 & 3 \\ 3 & -7 \\ -8 & 9 \end{array}\right].$$ Now let's transform $\begin{bmatrix} p \\ q \\ r \end{bmatrix}$ to $\begin{bmatrix} a \\ b \end{bmatrix}$: \begin{align} a & = 22p-38q+17r \\ b & = 13p+10q+9r \end{align} represent that by the matrix $$\left[\begin{array}{rr} 22 & -38 & 17 \\ 13 & 10 & 9 \end{array}\right].$$ So how do we transform $\begin{bmatrix} x \\ y \end{bmatrix}$ directly to $\begin{bmatrix} a \\ b \end{bmatrix}$?

Do a bit of algebra and you get \begin{align} a & = \bullet x + \bullet y \\ b & = \bullet x + \bullet y \end{align} and you should be able to figure out what numbers the four $\bullet$s are. That matrix of four $\bullet$s is what you get when you multiply those earlier matrices. That's why matrix multiplication is defined the way it is.

• Just to make sure: The first transformation (x,y)=>(p,q,r) would be a function from $R^2 => R^3$ right? so $\begin{bmatrix}2&3\\3&-7\\-8&9\end{bmatrix}$ would represent the vectors in $R^3$ $(2,3,-8)$ and $(3,-7,9)$ to wich my original $R^2$ vectors transformed into. Then the second transformation would be a function $R^3 => R^2$ and the black dots would be two vectors in $R^2$ to wich my $R^3$ vectors will transform into. – Joaquin Brandan Apr 12 '17 at 15:15
• @JoaquinBrandan : No. Figure out what $a$ and $b$ are as functions of $x$ and $y$, just by algebra with no matrices, and you'll see what numbers the black dots represent. But the four black dots correspond to a function from $\mathbb R^2$ to $\mathbb R^2$, which is a composition of two functions: $\mathbb R^2 \to\mathbb R^3 \to \mathbb R^2. \qquad$ – Michael Hardy Apr 12 '17 at 17:15