Row Operations

Every method for solving a system of equations — most of all Gaussian elimination — really boils down to one trick: rewrite the system, over and over, into a simpler-looking system with the exact same solution, until the answer is sitting there in plain sight. But that trick only works if every single rewrite is provably safe — if it can never quietly change what x and y actually are.

This page is the rulebook. There are exactly three moves you're ever allowed to make to a system's rows, and for each one there's a rock-solid reason it can never smuggle in a wrong answer, or lose a right one. Learn these three moves cold, and every later algorithm — row reduction, elimination, computing an inverse — is just these same three moves, applied with a plan.

The three legal moves — and why each is safe

We usually work on the augmented matrix: the system's coefficients with the right-hand side tacked on as one final column, so each row of the matrix is just one equation written as a row of bare numbers. The three elementary row operations are:

Each operation is reversible, and applying any sequence of them never changes a system's solution set.

Pick an operation below and watch it act on a small augmented matrix — the row that changes is rebuilt from the original rows using exactly the reasoning above.

Worked example: the solution survives every single move

Take the system x + y = 5 \qquad 2x - y = 1 A quick check shows its solution is x = 2,\ y = 3: indeed 2 + 3 = 5 and 2(2) - 3 = 1. Now apply each operation on its own, and re-check that (2, 3) still fits — that's the whole promise of a "legal" move.

Worked example: two moves in sequence solve the whole system

Elimination is nothing more than this combine move, aimed deliberately at one variable at a time. Take x + 2y = 4 \qquad 3x - y = 5 To knock x out of row 2, replace row 2 with \text{row 2} - 3 \cdot \text{row 1}:

(3x - y) - 3(x + 2y) = 5 - 3(4) \ \Longrightarrow\ -7y = -7 \ \Longrightarrow\ y = 1

Back-substituting into row 1 gives x + 2(1) = 4, so x = 2. One combine operation, aimed at the right target, turned a two-variable puzzle into a one-line answer. Chaining moves like this — always eliminating one more variable, one row at a time — is exactly what Gaussian elimination automates for systems far too big to eyeball.

Worked example: reversibility, checked directly

"Reversible" isn't a hand-wave — you can watch it happen. Go back to the combine step from the previous example: we replaced row 2 of x + 2y = 4,\ 3x - y = 5 with \text{row 2} - 3 \cdot \text{row 1}, landing on -7y = -7. To undo it, apply the opposite combine: add 3 \cdot \text{row 1} back onto the new row 2.

-7y + 3(x + 2y) = -7 + 3(4) \ \Longrightarrow\ 3x - y = 5

Row 2 is exactly back where it started. The same pattern works for the other two moves: swapping twice returns every row to its original slot, and scaling by k then by 1/k multiplies a row by k \cdot \tfrac{1}{k} = 1 — unchanged. Every legal move has a matching "undo" move of the very same kind, which is exactly why none of them can ever lose or invent a solution.

From equations to matrices, and back

Every row operation can be written as a matrix multiplying the system from the left. Take A = \begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} (the coefficients from the very first worked example). Swapping its two rows is the same as multiplying by the swap matrix E = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}:

EA = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} = \begin{bmatrix} 1 & -1 \\ 2 & 1 \end{bmatrix}

Row 1 of the answer is row 2 of A, and row 2 of the answer is row 1 of A — precisely a swap, produced by ordinary matrix multiplication. E is called an elementary matrix: the identity matrix with one tiny edit, engineered so that multiplying by it performs exactly one row operation and nothing else.

The other two moves work the same way. Scaling row 1 by 3 is multiplying by \begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix} — the identity matrix with a 3 where a 1 used to be. Adding -2 times row 1 onto row 2 is multiplying by \begin{bmatrix} 1 & 0 \\ -2 & 1 \end{bmatrix} — the identity matrix with a single off-diagonal entry filled in. In every case, the "edit" made to the identity matrix is a direct picture of the operation: a swapped pair of rows, a changed diagonal entry, or a filled-in off-diagonal slot. Chain several elementary matrices together and you've written an entire elimination as one matrix product — the exact bridge between "solving equations by hand, row by row" and "multiplying matrices."

Why only these three?

Each operation is reversible — you can always undo it with another operation of the same kind: undo a swap with the same swap, undo scaling by k by scaling by 1/k, undo adding k times row 1 to row 2 by subtracting it back off again. Because nothing is ever thrown away — only rearranged — no information is lost and no false solutions can sneak in. Strung together cleverly, the three moves drive a system toward a form you can read the answer straight off of. That deliberate, repeated sequence is Gaussian elimination, the workhorse algorithm built next.

Scaling a row by zero is not allowed. It might look like just another special case of "scale by a constant," but it's actually catastrophic: multiplying a whole equation by 0 turns it into 0 = 0 — a statement that's always true and says nothing at all about x or y. You've thrown an entire equation's worth of information straight in the bin.

That's exactly why the rule insists on a non-zero constant. Every legal operation must be reversible, and there is no way to undo a multiplication by zero — once the original numbers are gone, no amount of further scaling can bring them back. Compare that with swapping (undo with the same swap) or combining (undo by subtracting back what you added): scaling by zero is the one move on this page with no "undo" button, which is precisely why it's banned.

Yes — and it's the single easiest thing to forget about row operations. They guarantee the solution set stays identical, but they make no promise whatsoever about the equations looking similar. Run a 3×3 system all the way through elimination and the bottom row might end up reading 0x + 0y + 5z = 10 — nothing like any of the three equations you started with, and missing two of the original three letters entirely.

That's not a bug — it's the entire strategy. The whole point is to keep trading the system for stranger and stranger-looking, but progressively easier-to-solve, equivalents, right up until one of them can be read off directly (here, instantly, z = 2). Never expect the "simplified" system to resemble the original system — expect it to have the exact same answer.

These three moves aren't just a textbook convention — they're the literal instruction set. Every spreadsheet's built-in solver, every engineering package, every computer algebra system solves linear systems by executing nothing but swaps, scales, and combines, sometimes millions of times a second, on matrices with thousands of rows that no human could ever touch by hand.

There's a reason it's this fast: as the next card shows, every row operation is secretly a matrix multiplication, so an entire elimination run is really one big product of small, cheap matrices. Record only the "combine" and "scale" steps used to march a matrix down to a triangular shape, and you've built its LU decomposition — a pre-digested form that lets a computer re-solve the same system for a hundred different right-hand sides without ever repeating the row operations. That single trick is why simulations that would take a supercomputer days can instead take seconds.