2.2 Matrices
The question
Three related questions that came up around the end of §2.1 and the start of §2.2:
The questions (in substance):
- Why does the book talk about a “transformation” instead of just solving the system?
- Going back to the simple example, how do you decide what goes into which part of — what are the rows, the columns, and ?
- If you scale up production by 10×, does resource consumption scale by 10×? If you rotate your perspective, does the system look simpler?
All three are really the same question: what are the objects in , beyond being an array of numbers?
Answer
A matrix is a transformation, not just a table
A matrix is a function that takes a vector and returns a vector. Writing says “apply the map to and get ”. Solving is then inverting the map: given the output, recover the input. Both readings are the same equation — which is exactly why the same algebra models planning and prediction.
What makes it a linear map is two properties, and they are worth stating precisely because “linear” does not mean “a straight line”:
Homogeneity is what answers question 3’s first half: yes, scaling the plan by 10× scales every resource total by exactly 10×. That is the defining property, not a coincidence of the example. (Note with is not linear in this sense — it is affine, because . §2.7 returns to that distinction.)
What goes where
| Object | How to decide | In the factory |
|---|---|---|
| Rows of | every distinct thing that must be balanced or tracked | resources: plastic, wire, dye |
| Columns of | every distinct thing you control or every feature you have | products: blue, lavender |
| the relationship — how much of row one unit of column consumes | the BOM / recipe | |
| what you are solving for — the free decision | production plan | |
| the known side — outcome or constraint | inventory limits |
This is a modelling choice, not a mathematical one, and it is where the domain knowledge lives.
The same equation read in two directions
The knobs flip depending on which side is known:
| MRP / planning | Weather / prediction | |
|---|---|---|
| Input | unknown production plan | known current atmospheric state |
| Transformation | known recipe (BOM) | learned model weights |
| Output | known inventory limits | unknown predicted future state |
In MRP you know the limits and hunt for the plan, so is unknown. In weather prediction you know today’s state and apply a learned map to get tomorrow’s, so is the input and is what you predict. Identical algebra, and this is the sense in which §2.2’s “transformation” framing is the more general one: it survives the change of which side is known.
“Rotating your perspective” = choosing a different basis
This does not mean spinning the factory. It means asking whether a different set of variables makes the system easier to read — a change of basis. For the factory, the natural alternative coordinates are how much in total and in what ratio:
In practice
The basis question is not academic. Which coordinates you pick is often the difference between a model that works and one that does not, because it decides which structure is visible to the algebra. In the worked example below the change of basis does not change the answer — the same plan still consumes the same resources — but it separates two business questions that were tangled together:
- is the volume problem: how much do we make in total?
- is the mix problem: what ratio of blue to lavender?
Real planning systems make exactly this separation, because volume is driven by demand and capacity while mix is driven by margin and promotion. Principal component analysis (Chapter 10) is the machine-learning version of the same move: find the coordinates in which the data’s structure is simplest. This note stops at the mechanism; §2.7 gives the general language for linear maps.
Worked example
A four-resource, two-product factory. Rows are resources, columns are products:
Making 7 blue and 3 lavender consumes — 20 plastic, 10 wire, 21 blue dye, 12 lavender dye.
Now change to the volume/mix basis. Since and ,
The system becomes , i.e. the new matrix is :
Look at what happened to the mix column. Plastic and wire have a there: they depend only on total volume, so the “how much” question is fully decoupled from the “in what ratio” question. Only the dyes care about the mix. The same plan expressed in the new coordinates, blue and lavender , gives — identical to , as it must be.
The matrix is not diagonalised: it is , not square, so diagonalisation is not even defined. What the change of basis achieved is weaker and more useful — a column of structural zeros.
All numbers above are reproduced by scripts/explore_example_2_2.py.
References
- Deisenroth, Faisal & Ong, Mathematics for Machine Learning, Sections 2.1–2.2 (Systems of Linear Equations; Matrices). See References for the full citation and link.
- Reproducibility script:
scripts/explore_example_2_2.py. - Related notes: 2.1 Systems of Linear Equations, 2.3 Solving Systems of Linear Equations, 2.7 Linear Mappings.