Systems of equations and row reduction
Solving equations by row operations — and why those operations can never move the solution.
- Write a system of equations as Ax = b
- Apply the three row operations and know why they are safe
- Read the solution straight off the reduced row echelon form
Two linear equations in two unknowns are two lines in the plane, and solving them means finding where the lines cross. The notebook’s example:
\[y = 2x + 1, \qquad 2y = x + 3\]Collect the unknowns on the left and this becomes \(A\mathbf{x} = \mathbf{b}\):
\[\begin{bmatrix} -2 & 1 \\ -1 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 1 \\ 3 \end{bmatrix}\]Row operations
Three operations change a system without changing its solution:
- Swap two rows.
- Scale a row by a non-zero number.
- Add a multiple of one row to another.
The first two are obviously harmless. The third is the workhorse, and the reason it is safe is geometric: a combination of two equations that both hold at a point also holds at that point. The new line still passes through the solution — it just pivots around it.
Echelon forms
Row echelon form is the staircase you get by eliminating below each pivot. Reduced row echelon form (RREF) goes further: every pivot is 1 and is the only non-zero entry in its column. At that point the system is its own solution.
The notebook writes RREF from scratch, and also uses SymPy to check it:
from sympy import Matrix
A = Matrix(np.random.randn(4, 4))
rrefA = A.rref() # (reduced matrix, pivot columns)
A = array([[2, 2, 4, 4],
[3, 1, 6, 2],
[5, 3, 10, 6]])
R = rref(A, precision=2)
That second example is a good one to study. The third column is exactly twice the first, so RREF finds only two pivots in a 3×4 matrix: the rank is 2, and the system has free variables — infinitely many solutions.
What RREF tells you
| What you see in the RREF | What it means |
|---|---|
| A pivot in every column of \(A\) | exactly one solution |
| A column without a pivot | a free variable: infinitely many solutions |
| A row \([0 \; 0 \; \cdots \; 0 \mid c]\) with \(c \ne 0\) | a contradiction: no solution |
The number of pivots is the rank — the same rank as in the previous lesson, now counted by elimination instead of by geometry.
Try it yourself. Change the second equation to \(4y = 8x + 4\) — the same line as the first, multiplied through by 4. Predict what RREF will show before running it. Then make it \(4y = 8x + 5\), a parallel line, and find the contradiction row.