Systems of Linear Equations & Gaussian Elimination

Linear Algebra Fundamentals

Chapter 6 · Systems of Linear Equations & Gaussian Elimination

A system of linear equations is just several linear equations sharing the same unknowns, all required to hold at once. Chapters 4 and 5 already built the exact notation for this: a system is A x = b, where A is a matrix of coefficients, x is the vector of unknowns being solved for, and b is the vector of right-hand-side values.

From Equations to a Matrix

Consider the system:

A worked system
x + y = 5
2x − y = 1

This is A x = b with:

A = [[1, 1], [2, -1]] x = [x, y] # the unknowns b = [5, 1]

Gaussian Elimination — Systematic Row Reduction

Rather than guessing or using substitution tricks, Gaussian elimination works on the augmented matrixA with b tacked on as an extra column — using three row operations that are guaranteed never to change the solution set:

  • Swap two rows
  • Multiply a row by a nonzero scalar
  • Add a multiple of one row to another row

The goal is to use these operations to eliminate variables from rows, one at a time, until the system is easy to solve by simple substitution.

StepAugmented matrix [A | b]
Start[1, 1 | 5]
[2, −1 | 1]
R2 → R2 − 2·R1[1, 1 | 5]
[0, −3 | −9]

The second row now reads 0x − 3y = −9, which only involves y — the x term has been eliminated. This is called row echelon form: each row's leading (leftmost nonzero) entry sits strictly to the right of the row above it.

Back-Substitution

Once the system is in echelon form, solve from the bottom row upward, substituting each known value into the row above it:

StepWorking
Solve row 2 for y−3y = −9 → y = 3
Substitute into row 1x + 3 = 5 → x = 2

So x = 2, y = 3. Checking against the original second equation: 2(2) − 3 = 4 − 3 = 1 ✓.

def gaussian_eliminate_2x2(A, b): # Eliminate x from row 1 using row 0 factor = A[1][0] / A[0][0] A[1] = [A[1][i] - factor * A[0][i] for i in range(2)] b[1] = b[1] - factor * b[0] # Back-substitute y = b[1] / A[1][1] x = (b[0] - A[0][1] * y) / A[0][0] return x, y print(gaussian_eliminate_2x2([[1, 1], [2, -1]], [5, 1])) # (2.0, 3.0)

When There's No Solution

Consider instead:

An inconsistent system
2x + 2y = 4
x + y = 5

Eliminating: R1 → R1 − 2·R2 gives [0, 0 | −6] — the row 0x + 0y = −6, which is never true for any x or y. Geometrically, these are two parallel lines (both have the same slope, x + y = k for different k) that never intersect. Whenever elimination produces a row that's all zeros on the left but nonzero on the right, the system has no solution.

When There Are Infinitely Many Solutions

Now consider:

A dependent system
x + y = 3
2x + 2y = 6

Eliminating: R2 → R2 − 2·R1 gives [0, 0 | 0] — the row 0x + 0y = 0, which is always true, for any x and y. The second equation was never independent information at all — it's exactly the first equation multiplied by 2. Whenever elimination produces a row that's entirely zero on both sides, that equation contributed nothing new, and there's a free variable: letting x = t for any value t, y = 3 − t — every point on the line x + y = 3 is a valid solution.

Forward reference — the determinant will explain this instantly
Computing det(A) = a₁₁a₂₂ − a₁₂a₂₁ (Chapter 7's own subject) for each of the three systems above: the first system's matrix has determinant 1(−1) − 1(2) = −3 (nonzero — unique solution). Both the no-solution and infinite-solution systems have coefficient matrices with determinant 0. A zero determinant is exactly the signal that a system won't have a single unique solution — Chapter 7 explains precisely why.

Systems in Code — NumPy

import numpy as np A = np.array([[1, 1], [2, -1]]) b = np.array([5, 1]) x = np.linalg.solve(A, b) print(x) # [2. 3.] # np.linalg.solve raises LinAlgError for a singular (zero-determinant) A — # it does NOT silently return a wrong answer for the no-solution / infinite cases

Hands-On Exercises

Exercise 1

Solve the system 3x + y = 11, x − y = 1 using Gaussian elimination on the augmented matrix. Show the row operation you use to eliminate x from the second row, the resulting echelon form, and the back-substitution steps. Check your final answer against both original equations.

📄 View solution
Exercise 2

Apply Gaussian elimination to 4x + 6y = 10, 2x + 3y = 8. What does the resulting row tell you about this system? Name which of this chapter's two "no unique solution" cases it falls into, and explain geometrically what's true about the two lines these equations represent.

📄 View solution
Exercise 3

A teammate's code calls np.linalg.solve(A, b) inside a loop that processes many different systems, and it occasionally crashes with a LinAlgError. Explain, using this chapter's own material, what property of a particular A matrix would cause that crash, and why that crash is actually more useful behavior than the function silently returning some plausible-looking numbers instead.

📄 View solution

Chapter 6 Quick Reference

  • A system of linear equations is A x = b — a matrix of coefficients, a vector of unknowns, a vector of results
  • Row operations (swap, scale, add a multiple of one row to another) never change a system's solution set
  • Gaussian elimination: use row operations to reach echelon form, then solve via back-substitution from the bottom row up
  • A row of all zeros on the left but nonzero on the right (0 = k, k ≠ 0) means no solution — geometrically, parallel lines that never meet
  • A row of all zeros on both sides (0 = 0) means a free variable and infinitely many solutions — one equation added no new information
  • A zero determinant (Chapter 7 forward reference) is the single-number signal that a system won't have a unique solution
  • Next chapter: The determinant and matrix inverse