## Groupings, Shopping Lists, Vectors: part 10

I’d like to revisit the price list from part 6 of this series for the fast food place, and revisit how the price list can be combined with an order to arrive at the total cost (ignoring taxes).

As you can see, the picture doesn’t just show the price of each item, but includes calorie information and sodium content as well.  The picture also includes, on the left, an order: a cheeseburger and fries.  This order, Jerry’s order, can be priced out, giving a total of \$3.00.   The very same way you price out the order, but with different numbers, will give you to the total calories of that order.  Also, the same way you price out the order, but with the numbers in the sodium column, will give you the total sodium content of the order.  Isn’t this interesting?  Even though one column has numbers in dollars, and the other in (kilo)calories, and the third in milligrams, and even though each addresses a very different concern (wallet, weight, and heart) – the relationship between the numbers is the same in each of the three column.

And what is that relationship?  In this particular example, if I had to price out the order on my calculator, I’m quite sure I wouldn’t bother to multiply the price of a cheeseburger by 1, since I can see straight away that there is no need to multiply anything: I would just add up the price for a single cheeseburger and the price for a single order of fries, and adding \$1.50 and \$1.50 gives me \$3.00, with or without a calculator.  When the cash register prices out the order, on the other hand, it may not bother to treat the case of ordering a single cheeseburger any differently from ordering 2, 3, or 11 cheeseburgers.  It may simply multiply the number of cheeseburgers ordered with the price of a single cheeseburger in all cases.
Yet the question of what the relationship is between the numbers is distinct from the question of how best to perform the computation in a particular case.  The relationship is a static thing.  It is something like: the product of corresponding numbers in the order vector and the column vector (regardless of whether we are talking about the price column or the calorie column or the sodium column), summed up, matches the number in the totals vector.  In other words, they all fit the idea of an inner product: the number in the totals vector is the inner product of the order vector with the corresponding column vector.

A natural extension of what we just showed is to include another order in the same picture:

where you may recognize the order as the one for Joe and his roommates, which we encountered in part 6.

If this three-dimensional representation you can see three kinds of slices.  Horizontal slices represent a single product.  For example, the second horizontal slice from the top represents all the information about chicken burgers, and conversely, there is nothing in that horizontal slice that doesn’t refer to chicken burgers.
Jerry’s order is a particular kind of vertical slice, and Joe’s order is another one of those vertical slices.  In the slice for Jerry’s order, there’s nothing about Joe and vice versa.
The calorie slice is another kind of vertical slice, cut from front to back, and the information contained in that slice is precisely all the information about calories, and nothing about price nor sodium.

In addition to slices, we can look at faces.  The front face of the box is independent of orders.  It may await orders, but it does not itself contain any order information.  The front face contains the kind of stuff that the fast food place may post on the window, or on its website, and update only when their product line or their pricing strategy changes.  The left face of the box is strictly order information.  It tells us how much of each product was order by Jerry, or by Joe, but the left face tells nothing about prices or calories or totals.
The bottom face gives all the totals, but nothing about how these totals came about.  For Joe’s order we know that the total price is \$15.10, and that the order contains a total of 5410 milligrams of sodium.  To find out where the sodium came from, we need information that’s not in the bottom face.

Each of the three faces is a matrix: a rectangular arrangement where each row or column is a vector.

The left face is the order matrix, the front face is the menu information matrix, and the bottom face is the order totals matrix.  If we look at the menu information matrix separately, we could show it in at least these two ways:

and the order matrix can be shown in at least these ways:

and finally, the totals matrix can be shown like this:

We now have all the ingredients together to make matrix multiplication soup, and we have it in a way that is independent of the details of the representation that we prefer.

The totals matrix is the product of the order matrix and the menu information matrix.  Here we have the key idea of what matrix multiplication is, even though what you’ve learned in math class about matrix multiplication may not have looked exactly like this.

In a next post we will look at some of the consequences of this idea.