Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

2.3 Solving Systems of Linear Equations

The question

Two things are being asked here: a complaint about how the book introduces the free variable, and two concrete questions about it.

The complaint, in substance:

The authors do that thing again — dropping a formula or concept when it will not be used until way later. Equation (2.7) appears with no explanation of why it looks like that.

The follow-up questions:

  1. Could any of the variables have been chosen as the free variable?
  2. Can there only ever be one free variable?

The complaint is fair, with a caveat worth stating precisely (see below): the book does define the free variable, but it does not say where the number of free variables comes from, nor that the choice of which one is free is arbitrary — and both are exactly what the two questions are about.

Screenshots

The passage under discussion — Equations (2.6)–(2.7) from §2.3, and the sentence that closes the example.

Answer

What the book actually does

Equation (2.6) is three equations in three unknowns:

Adding (1) and (2) gives , which is exactly (3). So (3) is redundant — it carries no information — and the system has only 2 independent constraints for 3 unknowns. The book then fixes and writes the solution set as

This is all correct. What it does not say is the reason the formula has one free parameter, or what would happen if you chose differently.

The reason: the count is

Write the system as . The number of free variables is the dimension of the null space of , and for an -column matrix that is

Here and the redundant third row leaves , so : exactly one free variable. That is the whole content of (2.7), and it is the fact the book defers — it is the language of §2.6 (basis and rank) and §2.7. The deferral is real, and it is why the formula looks unmotivated at this point.

This also gives a clean answer to both follow-up questions:

  • Could any variable have been the free one? Yes. The free variable is a choice of basis for the null space, not a property of any particular column. Parameterising by instead gives a different-looking formula for the same solution set.
  • Can there be only one? No — there are of them. Change the matrix and the count changes.

Why the choice is genuinely arbitrary

Solving with and with must describe the same set, because both are parameterisations of the same affine subspace. For (2.6):

They coincide whenever . At (so ) both give exactly . The factory does not care which variable you declare free — it is bookkeeping about which decision you make first.

In practice

This is the point where the book stops describing planning and starts needing optimisation, and the free variable is the hinge.

In MRP terms the free variable is “the one you decide first”: “I’ll decide how many red ones to make, then blue and lavender follow.” In the hairpin factory of 2.1 the same structure separates the volume decision from the mix decision. Real planning systems pick one of these and optimise around it, because an underdetermined system is not an answer — it is a family of answers, and something must break the tie.

That tie-breaker is where the whole optimisation half of the book comes from. The book’s own remark about finding “the solution with the smallest weights” is the same idea, and it splits into two well-known rules:

  • L2 / Ridge — minimise : shrink everything smoothly, no weight dominates. This is the minimum-norm solution of an underdetermined system.
  • L1 / Lasso — minimise : drive most weights to exactly zero, leaving a sparse, interpretable solution.

Choosing which free-variable combination to keep is therefore not a mathematical detail; it is the modelling decision, and it reappears throughout Chapters 7–12.

Worked example

The system (2.6) above, verified end to end:

  • Redundancy: row 3 = row 1 + row 2 exactly, and . So the third equation is discarded.
  • Rank: singular values give , hence .
  • Book’s parameterisation satisfies exactly for every — checked at , each with residual .
  • Alternative also satisfies it at every tested, and the two parameterisations agree as shown above.

The count generalises, and the script checks it against real matrices rather than asserting it:

SystemShapeRankFree variablesOutcome
5 unknowns, 2 constraints2infinitely many solutions
5 unknowns, 5 constraints5unique solution
6 constraints, one redundant5unique solution
6 constraints, one incompatible5no solution

The last two rows are the useful lesson: free variables are governed by rank, but whether a solution exists at all also depends on . Having more equations than unknowns does not by itself make a system inconsistent — it makes it likely to be.

All numbers are reproduced by scripts/explore_example_2_3.py.

References

  • Deisenroth, Faisal & Ong, Mathematics for Machine Learning, Section 2.3 (“Solving Systems of Linear Equations”), Equations (2.6)–(2.7). See References for the full citation and link.
  • Reproducibility script: scripts/explore_example_2_3.py.
  • Related notes: 2.1 Systems of Linear Equations, 2.2 Matrices.