Matrices for coffee lovers. (Part 1)

Joshua Fitzgerald
3 min readNov 28, 2018

--

Big deal. It’s a box with numbers in it. Who cares?

This is what I thought when I first saw a matrix in 8th grade algebra. We learned to add and subtract matrices. I was still unimpressed. You just add or subtract the corresponding entries! They were just making me do addition and subtraction again except this time the numbers were written in a rectangle with brackets on either side. Why don’t I just write numbers in a circle and call it a new thing, too?

No one told me what a matrix really was. I wish someone had. They are a lot more than numbers written in a rectangle.

I hope to show you exactly what a matrix is, using coffee.

Suppose you own a coffee shop. Your minimalist coffee shop sells two different coffee beverages. To keep things simple we’ll assume each coffee drink sold is made from a double shot of espresso and various amounts of milk. (I’m aware that some coffee-lovers are cringing at my over-simplified model. If I’m describing you, leave a comment or send me an email with your favorite coffee beverage!)

Menu

Latte: 15 g coffee, 6 oz milk

Cappuccino: 15 g coffee, 4 oz milk

Suppose we want to express our menu mathematically and concisely. We’ll use some variables to express our units of coffee and milk.

Now we can write our recipes compactly as a system of linear equations.

We can write this even more compactly! If we understand that the equal sign below means that corresponding entries are equal, we could write this instead.

We have a column of variables on the left side. On the right side, our variables e and k are inside the equations. If we want to write our right-side variables as a nice column, just like on the left side, we’ll need to make a rule:

If this is true, we can write our recipes even more concisely. Extending this we get the definition of matrix multiplication.

Finally we will use the rule above to write our recipe list as compactly as possible.

This notation allows us to put all the juicy details (the coefficients of the system) together in their own little object, while the variables are separated out. Also we get an idea of what is happening. We are translating from the “espresso, milk” world on the right side into the “latte, cappuccino” world on the left side. The 2 x 2 matrix translates between the two.

So I like to think of a matrix as a translator between two sets of variables. The relationship could be written as a system of equations, but if we use a matrix we can refer to the good stuff (the coefficients of the system) in a tidy object of its own.

Translating from 2 variables in one world to 2 variables in a another requires a 2 x 2 matrix. Getting to 5 variables from 3 variables requires a 5 x 3 matrix of coefficients.

If this helped you, tune in to Part 2 where we’ll use matrices to translate lattes and cappuccinos into two new coffee drinks.

--

--

Joshua Fitzgerald

Joshua is a mathematician, educator, cryptographer, and developer. He is a developer at Heliax working on the @anoma protocol.