Matrix multiplication as composition
How to think about matrix multiplication visually as successively applying two different linear transformations.
It is my experience that proofs involving matrices can be shortened by 50% if one throws the matrices out.
— Emil Artin
Recap
In the we showed how linear transformations are just functions with vectors as inputs and vectors as outputs. However it is often more convenient to think of linear transformations as moving space in a way that keeps gridlines parallel and evenly spaced.
We can determine the entirety of the transformation by where the basis vectors land after the transformation, which form the columns of a matrix. To find where any arbitrary vector lands after the transformation, there is an operation called matrix-vector multiplication. Here is the computation for a 2D matrix and vector:
Composition of Transformations
Oftentimes, you find yourself wanting to describe the effects of applying one linear transformation, then applying another. For example, maybe you want to describe what happens when you rotate the plane
Like any linear transformation, it can be described with a matrix all of its own by following
In this example, the ultimate landing spot for
Composition is Multiplication
Here's one way to think about that new matrix. If you were to take some vector and pump it through the rotation then the shear, the long way to compute where it lands by first multiplying on the left by the rotation matrix, then multiplying the result on the left by the shear matrix. This is, numerically speaking, what it means to apply a rotation then a shear to a given vector. But whatever you get should be the same as just multiplying this new composition matrix that we found by the vector, no matter what vector you chose, since this new matrix is supposed to capture the same overall effect as the rotation-then-shear action.
Based on how things are written down here, I think it's reasonable to call that new matrix the product of the two original matrices, don't you?
We can think about how to compute that product more generally in just a moment, but it's easy to get lost in the forest of numbers. Always remember that multiplying two matrices like this has the geometric meaning of applying one transformation after another.
One thing that's kind of weird is that this has us reading right to left. You first apply the transformation represented by the matrix on the right, then you apply the transformation represented by the matrix on the left. This stems from function notation, since we write functions on the left of the variable, so composition always has to be read right-to-left. Good news for Hebrew readers, bad news for the rest of us.
Computing the New Matrix
Let's look at another example. There are two matrices
The total effect of applying
But let's see if we can do it without any images, and instead just using the numerical entries in each matrix.
First we need to figure out where
Likewise, we can apply the same operation to find where
General Form
Let's go through that same process again, but this time the entries will be variables in each matrix, just to show that the same line of reasoning works for any matrices. This is more symbol heavy, and will require some more room, but it should be satisfying for anyone who has previously been taught matrix multiplication the traditional way.
To follow where
Similarly,
It's common to be taught this formula as something to memorize, along with a certain algorithmic process to remember it.
I really do believe that before memorizing that process, you should get in the habit of thinking about what matrix multiplication really represents: applying one transformation after another. Trust me, this will give you the conceptual framework that makes the properties of matrix multiplication easier to understand.
Noncommutativity
Here is an important question: Does it matter what order we put the two matrices in?
Well, let's think of a simple example like the one from earlier. Take a shear, which fixes
The overall effect is very different, so it would appear that order totally does matter! By thinking in terms of transformations, that's the kind of thing you can do in your head by visualizing, no matrix multiplication necessary!
Associativity
I remember when I first took linear algebra, there was a homework problem that asked to prove that matrix multiplication is associative. That means if you have three matrices, A, B and C, and multiply them all, it shouldn't matter if you first compute A times B, then multiply the result by C, or if you first multiply B times C, then multiply the result by the matrix A on the left. In other words, does it matter where you put the parentheses.
Now, if you try to work through this numerically, like I did back then, it's horrible! And unenlightening for that matter. But when you think of matrix multiplication as applying one transformation after another, this property is trivial, can you see why?
What it's saying is that if you first apply (C then B), then A, it's the same as applying C, (then B then A). I mean, there's nothing to prove! You're just applying three things one after the other, all in the same order!
This might feel like cheating, but it's not. It's an honest-to-goodness proof that matrix multiplication is associative. And even better than that, it's a good explanation for why that property should be true.