In this series on vectors we showed vector addition in this post, and then took a small excursion to show a surprising connection between some vector additions and the distributive property.
In this post, I will combine vectors with lookup tables and thus introduce an operation usually called inner product. For this, we will take as our starting point the driveup window order from a previous post:
coke  cheeseburger  hamburger  fries 
3  1  5  2 
The box above represents the order, and we have been assuming that this order is specific enough that the fast food folks can get you what you want. Specifically, that there is an understanding of what an order of “coke” is as compared to, say, “coke, small”, or “diet coke, large”.
Yet serving up your order is not the only concern of the fast food place. They need to get paid. They charge you for the items ordered, based on a price list. (And then, in the USA and some other countries, they compute taxes on top of the total; in yet other countries, the taxes would already be included in the prices shown on the price list. In this post, I’ll ignore taxes altogether.)
The price list can also be shown as a vector. It might look like this:
cheeseburger  $1.50 
chickenburger  $1.80 
coke  $1.20 
diet coke  $1.20 
fries  $1.50 
hamburger  $1.40 
ice cream treat  $1.90 
kid meal  $3.00 
The price list will typically contain many items that weren’t ordered. Typically, there is an entry in the price list for any item ordered.
To find the total amount (ignoring taxes), it is pretty clear what needs to be done: for each item ordered, you multiply the amount ordered by the price found from the price list vector, and then you add it all up.




The $15.10 comes from coke (3 times $1.20) plus cheeseburger (1 times $1.50) plus hamburger (5 times $1.40) plus fries (2 times 1.50).
The operation on the order vector and the price list vector that gives us the final price (ignoring taxes) is called inner product. I don’t want to go into the significance or the origin of the name (though you would correctly guess that there is also something called an outer product.) Inner product is also often called the dot product.
You may have noticed that the situation shown is not symmetric with respect to the two vectors. Yet there are ways to make the similarity between the two vectors more pronounced. One way to do that is to ignore the parts of the price list that aren’t being called upon. We can also reorder the entries to match those of the order. Doing so might give us something like this:
Alternatively, we could expand the order to match the price list, by explicitly marking zeros for those items on the menu that aren’t ordered. This is something we may show later.
For now, I will note that textbooks sometimes show this inner product as follows:




where the information that gives us the meaning of the 15.10 is left out, but at least the distinction between the two operands of the operation is maintained. But since the process of multiplying and adding is itself commutative, there are many textbooks that dispense with the different treatment of the two operands altogether and write the thing as (3,1,5,2) • (1.20,1.50,1.40,1.50) = 15.10 and treat it as a completely symmetric operation: (1.20,1.50,1.40,1.50) • (3,1,5,2) = 15.10. I will come back to these more subtle points in a later post. What I hope I have achieved in this post is that you see how the scenario of an order – written as a vector – combined with a price list – also written as a vector – naturally leads to a process that gives us a single number, and that this process matches what textbooks call inner product.
Pingback: Groupings, Shopping Lists, Vectors: part 7 « Learning and Unlearning Math
Pingback: Groupings, Shopping Lists, Vectors: part 10 « Learning and Unlearning Math
Pingback: Groupings, Shopping Lists, Vectors: part 19 « Learning and Unlearning Math
Pingback: Groupings, Shopping Lists, and Vectors: The Series « Learning and Unlearning Math