The dot product takes two vectors and returns a single number. It is zero exactly when the vectors are perpendicular, and it lurks inside every matrix-vector multiplication: each entry of is the dot product of a row of with .
Transpose of a matrix is another matrix, denoted by or , such that the rows of are the columns of :
Note that a vector can also be seen as a matrix with only one column. Thus we can define the transpose for a vector as well:
When you see a matrix, there are two ways you can look at it: an array of columns and an array of rows. So far we have been treating it as an array of columns only.
Each of these perspectives provides a way to interpret matrix-vector multiplication. From the first perspective, you can imagine the columns of a matrix being scaled and added up:
From the second perspective, you can think of the rows of the matrix being fed to the dot product function along with the input vector:
Note that the same matrix is colored by columns in the first equation and by rows in the second, the colors are there to visualize the two perspectives.
Consider the matrix-matrix multiplication where and is a 3-by-3 matrix. The first matrix is 1-by-3 and the second matrix is 3-by-3.
M:
M, where the weights come from the vector v:
We started out with taking weighted sums of only the columns of a matrix. The property of weighted sums of the rows of a matrix emerges simply out of weighted sums of columns.
This duality between a sum of weighted columns and a sum of weighted rows can be expressed in a very elegant identity:
It is obvious that both lead to the same result. We can also extend this identity to matrix-matrix multiplication (since a matrix-matrix multiplication is just many matrix-vector multiplications):
It is useful to be able to switch between these three points of view when looking at a matrix-matrix multiplication . Let the row vectors of be and let the column vectors of be .
AB = a matrix of weighted sums of columns of A:
AB = a matrix of weighted sums of rows of B:
AB = a matrix of dot products of rows of A with columns of B:
Let's visualize some transformations by a 2-by-2 matrix M again. This time, we want to focus on what the rows of M tell us about the transformation.
If we want to see how a vector is transformed by a matrix, it is sufficient to see how the unit vector is transformed. This is because we can simply scale the output of by the norm of :
Next, to fully understand the transformation by a matrix, we don't want just one unit vector. We would ideally like to view how all the unit vectors are transformed. But the unit vectors are exactly the points on a unit circle. Thus, by understanding how the points on a circle are transformed by a matrix, we get a good idea of what that matrix is doing.
We are given the matrix
whose first row is colored and second row .
The matrix - each colored segment joins an input point to its output point. This is nothing new. What's interesting here is the relationship between the shape of the ellipse and the row vectors.
M as arrows.
Now pick .
Note that each output coordinate is a dot product with a row of M:
To visualize this, let's .
We want to show that the (signed) projection of on the is equal to the x-coordinate of .
You can try and see this setup changes according.
To reiterate, the of the first row vector is equal to the of the output vector.
We can show the same thing for the second row vector. Let's .
You can try and see this setup changes accordingly.
To reiterate, the of the second row vector is equal to the of the output vector.
Let's look at the matrix multiplication again:
One can ask - what are the largest (or smallest) x- and y- coordinate values for the output vector? Since these values are the dot products of the row vectors with the input vector, coordinate is maximized when the input vector aligns with the row vector .
One can indeed see this by the input vector with the first row vector. Note how the has the largest x-coordinate on the entire ellipse.
Similarly, by aligning the input vector with the , one gets the output vector whose y-coordinate is the largest on the entire ellipse.
The same reasoning can be applied to get the smallest coordinates of the output vectors. This happens when the dot product is minimized - which happens when the two vectors point in exactly opposite directions.
This entire reasoning is applicable to matrix multiplication of any dimension, not just two.
In other words,
the output ellipse is bounded by whose x-coordinates are
± norm of the first rowand whose y-coordinates are± norm of the second row.
This is because the projection of a row on can never exceed the row's own length.
To confirm, let's change the rows and watch the rectangle follow:
So the columns of a matrix tell us where the basis vectors land, but the rows tell us how the output coordinates are extracted.
In the next chapter we will study rotations, the matrices whose rows and columns are unit vectors perpendicular to each other, for which the transpose plays an especially beautiful role.