Let’s look some more at matrix multiplication, which we introduced in part 10 of this series. We showed three rectangular arrangements, and called each a matrix, and called one the product of the other two. (The accepted plural of matrix happens to be ‘matrices’.) Here they are again, in a slightly different form:
Each matrix is a rectangular arrangement of numbers, where the labels for rows and columns indicate what these numbers stand for. The matrix for the left is the order matrix, and it shows that Joe ordered 5 hamburgers. Jerry order 1 fries and no hamburgers. The matrix in the middle is the menu information matrix and it shows that one order of coke contains 10 mg of sodium, and one order of diet coke contains 20 mg of sodium. The matrix on the right is the totals matrix, and it shows that Joe’s order came to $15.10 (ignoring taxes) and Jerry’s order contained 1460 mg of sodium altogether. Matrix multiplication is the thing that gives us the matrix on the right from the two matrices on the left.
It is now time to stand back a bit and look at what is going on in a way that depends less on the particular situation of pricing out an order. The two matrices that are being multiplied have different shapes, but they aren’t wholly independent. They share an edge, so to speak, an edge that allows them to be folded into part of a box. In our example above, the shared edge is the list of products on the menu, cheeseburger, chickenburger, etc. Both matrices have exactly that edge as one of their dimensions (whether row or column). The resulting (product) matrix shares one edge with the left matrix, and one edge with the middle matrix, and all three matrices would fold together to make a 3-dimensional box. Each entry in the resulting matrix is obtained from an inner product of two vectors, one in each of the original matrices. In our example, the total price for Joe is obtained from the inner product of the Joe order vector with the menu price vector. In our picture, the Joe order vector is the top row of the order matrix, and the menu price vector is the left column of the menu information matrix.
If you have taught matrix multiplication before, you may be interest to notice that in the setup we’ve shown here, matrix multiplication is entirely commutative. This may be counterintuitive, since the normal way of introducing matrix multiplication has it be non-commutative. The difference, as you can see, is that the way each row and column is labeled allows you to keep track of what number means what.
If you have never before seen matrix multiplication, you may wonder what the big deal is. What we’ve done seems pretty straightforward, right? You can simply look at the labels and track what is going on. The totals price for Joe’s order ($15.10) clearly comes from what he pays for cheeseburgers (1 × $1.50) plus what he pays for coke (3 × $1.20) plus what he pays for fries (3 × $1.50), etc. For you, I recommend you pay particular attention to the fact that the pattern of numerical relationships is the same for each of the positions in the totals matrix: each derives from the inner product of a row of the order matrix and a column of the menu information matrix, and this pattern itself is independent of the label shown above the column or left of the row. It is because this numerical pattern (sum of products) shows up so often in real-life situations that it is worthwhile giving it a special name (innerproduct) and worth it to pay particular attention to all the various places that it shows up. We’ll do more of that – in a next post.