Module 3: Systems of Equations
Every system of linear equations falls into one of exactly three categories. Understanding which one you're dealing with before you start solving saves enormous effort — and reveals something deep about the underlying transformation.
The coefficient matrix is invertible. The transformation it represents is a bijection — every output point came from exactly one input. You can always solve it: x=A−1b.
The matrix is singular. The transformation collapses the plane onto a line (or a point). The right-hand side b doesn't lie on that collapsed image, so no vector maps to it. Gaussian elimination will produce a row like 0=k where k=0.
The matrix is singular, but b does lie in the image. There's an entire line of solutions — the null space of Ashifted to one particular solution. Gaussian elimination produces a row of all zeros.
The rank of a matrix is the number of independent rows (or columns) it has. For a 2×2 matrix:
We'll explore rank properly in the Vector Spaces module. For now: rank = how much information the matrix carries.
import numpy as np
A = np.array([[1, 2], [2, 4]]) # rank 1
# Check rank
print(np.linalg.matrix_rank(A)) # 1 — singular
# np.linalg.solve will raise LinAlgError for singular A
# For least-squares (best approximate solution):
b = np.array([3, 7])
x, _, _, _ = np.linalg.lstsq(A, b, rcond=None)
print(x) # least-squares solutionThe two equations have different slopes, so the lines meet at exactly one point. There is a unique solution.