Why is matrix multiplication (linear transformations) done per row

linear algebralinear-transformations

I have a basic 2D vector:
$
\begin{pmatrix}
2 \\
2 \\
\end{pmatrix}
$

In order to perform a 90 degree clockwise rotation, I am using the following transformation matrix:

$
\begin{pmatrix}
0 & 1 \\
-1 & 0 \\
\end{pmatrix}
$

Here is a visualisation:

(2,2) vector with normal basis vectors

(2,2) transformed vector (2,-2)

I have learnt that the basis vectors make up the columns of the transformation matrix e.g. the basis vectors of the transformation matrix which rotates by 90 degrees would be:

$
\begin{pmatrix}
0 \\
-1 \\
\end{pmatrix}
$

and
$
\begin{pmatrix}
1 \\
0 \\
\end{pmatrix}
$

In order to perform the transformation, I have to multiply the transformation matrix with the vector. Why does the matrix multiplication work when we do it per row, since that is really the transposed matrix?

This visual should explain my confusion better.
The matrix multiplication essentially performs 2 dot products and projects each component of the vector onto the basis vectors of the transposed transformation matrix.

Applying the transformation

$
\begin{pmatrix}
0x & 1x \\
\end{pmatrix}
\begin{pmatrix}
2x \\
2y \\
\end{pmatrix}
= 2
$

$
\begin{pmatrix}
-1y & 0y \\
\end{pmatrix}
\begin{pmatrix}
2x \\
2y \\
\end{pmatrix}
= -2
$

Finally we get to the correct transformed vector

$
\begin{pmatrix}
2 \\
-2 \\
\end{pmatrix}
$

Why does this way make sense?

Best Answer

Matrix-vector multiplication really means:

The columns of the matrix are vectors. Multiplying the matrix with a vector means, use the numbers in the vector to form a linear combination with the vectors in the matrix. Basically, you are answering, what does the vector with the coefficients $v_1,\dots,v_n$ look like in the coordinate system $b_1,\dots,b_n$, which is $v_1\cdot b_1+\dots+v_n\cdot b_n$ which looks like a dot product, right? But it isn't because $v_1,\dots,v_n$ are numbers and $b_1,\dots,b_n$ are vectors. But if you look at the first component of $v_1\cdot b_1+\dots+v_n\cdot b_n$ you notice, that it is a dot product between $v_1,\dots,v_n$ and the first components of the vectors $b_1,\dots,b_n$. And that is true for any component you look at in the result.

So what you are basically doing is taking a horizontal slice through the coordinate system vectors and doing a dot product with the coefficients. And the horizontal slice is exactly what the row in the matrix is.

So in your case, you are asking, what does the vector with coefficents $\begin{bmatrix}2\\2\end{bmatrix}$ look like in the coordinate system $\begin{bmatrix}0&1\\-1&0\end{bmatrix}$.

It looks like $2\begin{bmatrix}0\\-1\end{bmatrix}+2\begin{bmatrix}1\\0\end{bmatrix}$. Which is the same as doing a dot product between the coeffiecients and the rows of the matrix.

Related Question