Module 5: Vector Spaces
The Rank-Nullity theorem is one of the most fundamental results in linear algebra. It says that inputs to a matrix split cleanly into two complementary parts.
For any m×n matrix A:
where n is the number of columns (the dimension of the input space), rank(A) = dim(column space), and nullity(A) = dim(null space).
Every input vector splits into two perpendicular components:
Rank counts the surviving dimensions. Nullity counts the lost ones. Together they always add up to the total input dimension n.
For a square n×n matrix:
Drag the column vectors to change the rank. The bar shows how the two dimensions are split between column space (green) and null space (amber). When vectors are parallel, rank drops to 1 and nullity rises to 1 — they always sum to 2.
import numpy as np
from scipy.linalg import null_space
A = np.array([[1., 2.], [2., 4.]]) # rank 1
n = A.shape[1] # number of columns = 2
rank = np.linalg.matrix_rank(A) # 1
nullity = n - rank # 1
ns = null_space(A) # the null space vector(s)
print(f"rank={rank}, nullity={nullity}, sum={rank+nullity}") # 1 1 2rank + nullity = n → 2 + 0 = 2
Drag the column vectors until they're parallel. The rank drops to 1, nullity rises to 1 — they always sum to 2.