Writing a System as Ax = b

Imagine trying to keep this straight in your head as one messy paragraph of algebra:

\begin{aligned} 2x + y &= 5 \\ x - y &= 1 \end{aligned}

That's only two equations. Real problems — balancing a chemical reaction, routing traffic through a city, ranking web pages — can have hundreds or thousands of equations in just as many unknowns. Writing each one out longhand, the way you would on paper, quickly becomes unthinkable; there simply isn't room, and no one could check it by eye. Linear algebra's answer is to repackage the whole system into a single line: every coefficient moves into a matrix A, every unknown into a vector \vec{x}, and every right-hand side into a vector \vec{b}:

\begin{aligned} 2x + y &= 5 \\ x - y &= 1 \end{aligned} \quad\Longleftrightarrow\quad \begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 5 \\ 1 \end{bmatrix}.

Check it: the matrix times the vector reproduces the two equations exactly. Solving the system now reads as one clean question — find the vector \vec{x} that A sends to \vec{b} — no matter whether there are 2 unknowns or 2 million.

The translation ritual

Turning a system into A\vec{x}=\vec{b} is a fixed, mechanical recipe — once you've done it a couple of times it stops feeling like algebra and starts feeling like filing paperwork into the right drawers:

Try it on a new pair of equations:

\begin{aligned} 3x + 2y &= 7 \\ x - 4y &= -1 \end{aligned}

Row 1 of A is the coefficients of the first equation, (3, 2); row 2 is (1, -4). The unknowns in order give \vec{x} = (x, y), and the right-hand sides give \vec{b} = (7, -1):

\begin{bmatrix} 3 & 2 \\ 1 & -4 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 7 \\ -1 \end{bmatrix}.

Multiply it back out to check: row 1 gives 3x+2y, row 2 gives x-4y — exactly the two original equations. The translation is reversible, which is exactly what makes it trustworthy.

The same recipe, with three unknowns

Nothing about the ritual changes when there are more unknowns — the matrix just grows another row and column for each one. Take:

\begin{aligned} 2x + y - z &= 4 \\ x - 3y + 2z &= -1 \\ -x + y + z &= 5 \end{aligned}

Fix the order (x, y, z). Each of the three equations becomes one row of a 3\times 3 matrix, read straight off the coefficients — and where a letter is missing, its coefficient is simply 0:

\begin{bmatrix} 2 & 1 & -1 \\ 1 & -3 & 2 \\ -1 & 1 & 1 \end{bmatrix}\begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 4 \\ -1 \\ 5 \end{bmatrix}.

The system has tripled in complexity, but the shape of the answer hasn't changed at all: a matrix of coefficients, a column of unknowns, a column of constants. This is exactly why the notation scales to a thousand equations without becoming a thousand times harder to write down — only harder to solve, which is a job we hand to a computer.

Nothing forces the number of equations to match the number of unknowns, either. Five equations in three unknowns gives a "tall" 5\times 3 matrix A — the overdetermined situation from the market-stall problem, where a third customer's sentence might not fit the other two at all. Two equations in five unknowns gives a "wide" 2\times 5 matrix instead — too few conditions to pin down a single answer. The shape of A is a direct fingerprint of how many conditions you have versus how many unknowns you're chasing.

Reading it the other way

The translation runs backwards just as cleanly: given a matrix equation, you can always recover the plain equations it represents. Take:

\begin{bmatrix} 0 & 3 \\ 2 & -1 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 6 \\ 4 \end{bmatrix}.

Read row 1 as a sentence: "0 lots of x, plus 3 lots of y, equals 6" — that is, 3y = 6. Row 2 reads 2x - y = 4. The zero in row 1 didn't delete x from the system; it just means x happens not to appear in that particular equation.

One more, with three unknowns, to make the zero-reading habit stick. The row \begin{bmatrix} 5 & 0 & -2 \end{bmatrix} (unknowns in order x, y, z) paired with right-hand side 7 reads as 5x + 0y - 2z = 7, i.e. 5x - 2z = 7 — a perfectly ordinary equation in x and z that simply has nothing to say about y.

From a word problem straight to a matrix

The coffee-blend problem from the previous page — mix m kg of mild coffee with s kg of strong coffee to make 10 kg costing £96 in total — gave two plain-English conditions:

\begin{aligned} m + s &= 10 \\ 8m + 12s &= 96 \end{aligned}

Run the same ritual: fix the order (m, s), read off each row's coefficients, and collect the right-hand sides:

\begin{bmatrix} 1 & 1 \\ 8 & 12 \end{bmatrix}\begin{bmatrix} m \\ s \end{bmatrix} = \begin{bmatrix} 10 \\ 96 \end{bmatrix}.

Nothing about coffee, kilograms, or pounds survives the translation — only numbers do. That's the whole point: once a real-world problem becomes A\vec{x}=\vec{b}, it looks identical to a problem about apples, bridges, or web traffic, and every tool built for solving matrix equations applies without modification.

Two mistakes account for almost every "the matrix is right but the answer is wrong" bug:

The column picture

Because A\vec{x} is a combination of A's columns, solving A\vec{x}=\vec{b} means: how much of each column do I add to reach \vec{b}? The two faint arrows are the columns; the star is \vec{b}. Dial x and y until the bold combination lands on the star — that's the solution.

This is a genuinely different way of reading the very same equation as the "translation ritual" above. Reading along the rows asks "does this point satisfy every equation?" — the row/line picture from the previous page. Reading down the columns asks a completely different question — "how do I mix these building blocks to build \vec{b} exactly?" Both questions have the same answer, precisely because they're two descriptions of the one matrix equation.

Two ways to see the same answer

The row picture (lines crossing) and the column picture (columns combining to reach \vec{b}) are two views of the identical solution. The row picture is friendlier in 2D; the column picture is the one that scales — and it makes the big truths obvious. If the columns are independent (so A is invertible), there's exactly one way to mix them — one unique solution.

Open a spreadsheet, a structural-engineering package, or a machine-learning library and, underneath the friendly interface, an astonishing amount of it eventually boils down to A\vec{x}=\vec{b}. An economist balancing supply and demand across a hundred linked industries, an engineer working out the forces in every beam of a bridge, a recommendation engine solving for millions of hidden preferences — all of them, underneath, are asking the exact same question: which \vec{x} does this A send to this \vec{b}? It's genuinely one of the most-solved equations on Earth, run trillions of times a day inside computers that never see it as anything other than rows and columns of numbers.

That's also why the translation ritual matters so much: software doesn't care whether your system came from coffee blends, bridges, or web pages — it only ever sees the matrix. Get the translation right, and every solving technique linear algebra has ever built — from elimination by hand to industrial-strength numerical solvers — becomes available for free.

The economist Wassily Leontief won a Nobel Prize partly for pushing this idea into the real world: his input-output model represented an entire national economy — dozens of interlinked industries, each buying from and selling to the others — as a single matrix equation, then solved it to predict how a change in one industry (say, steel) would ripple through all the rest. In the 1940s, solving that system by hand with mechanical calculators took a room full of assistants weeks. Today a laptop solves systems a thousand times larger before you've finished reading this sentence — a change in speed, not a change in the underlying idea, which is still exactly the same A\vec{x}=\vec{b} you built by hand above.