Dimension
- Explain why any two bases of the same finite-dimensional space have the same number of vectors (Dimension Theorem)
- Compute the rank and nullity of a matrix and verify that they sum to the number of columns
- Use dimension counting as a shortcut to confirm that a set spans or is independent without row reduction
- Interpret rank as the number of independent directions in a matrix and relate it to information capacity in ML models
All Bases Have the Same Size
The most surprising and important fact about bases is:
Theorem (Invariance of Dimension): any two bases for the same vector space have the same number of elements.
This number is the dimension of , written . It is well-defined regardless of which basis you choose.
Proof sketch: if has vectors and has vectors and both are bases, then expressing each vector in terms of and using a linear-algebra counting argument shows . Repeating with the roles swapped gives , so .
Dimensions of Common Spaces
| Space | Dimension | Natural basis |
|---|---|---|
| matrix units | ||
| (deg ) | ||
| empty set | ||
| (sequences) | — |
Using Dimension to Identify Bases
In a space of dimension , any set of exactly vectors that satisfies one of the following automatically satisfies both:
- independent vectors → automatically span → basis
- spanning vectors → automatically independent → basis
This is immensely practical: to show a set of vectors is a basis for , you only need to check independence (or spanning) — the other condition is free.
The Rank-Nullity Theorem
For any matrix , define:
- = dimension of the column space = number of pivots in echelon form
- = dimension of the null space = number of free variables
Then:
Every column of is either a pivot column (contributing to rank) or a free column (contributing to nullity). The two types partition all columns.
Equivalences for an matrix :
All of the following are equivalent:
- , i.e.,
- The columns of are linearly independent
- The columns of span
- is invertible
- has a unique solution for every
This list of equivalences is sometimes called the Invertible Matrix Theorem. Knowing any one of them gives all the others for free.
Dimension of Subspaces
If is a subspace of with :
- (the only -dimensional subspace of is itself)
Combining Subspaces
If (every vector in is a sum of a vector from and one from ), the dimension formula is:
If the intersection is only , the sum is direct: and . The direct sum decomposes into orthogonal (or at least non-overlapping) pieces — the matrix analogue is block-diagonal decomposition.
Computing Rank and Nullity
import numpy as np
# 2 × 4 matrix — rank 2, nullity 2
A = np.array([[1., 2., 0., 1.],
[2., 4., 1., 1.]])
# Rank and nullity via SVD
_, S, Vh = np.linalg.svd(A, full_matrices=True)
rank = int(np.sum(S > 1e-9))
nullity = A.shape[1] - rank
print(f'rank = {rank}') # 2
print(f'nullity = {nullity}') # 2
print(f'rank + nullity = {rank + nullity} = n = {A.shape[1]}') # 2 + 2 = 4
# Null space basis: rows of Vh beyond rank index
null_basis = Vh[rank:]
print('null space basis (rows):')
print(np.round(null_basis, 4))
# Verify A @ null_vec = 0 for every null vector
for i, h in enumerate(null_basis):
resid = np.einsum('ij,j->i', A, h)
print(f'A @ null_basis[{i}] = {np.round(resid, 4)}') # [0. 0.]
The row dimension of Vh[rank:] always equals the nullity — that is the Rank-Nullity Theorem made concrete. For a square invertible matrix, rank == n, so Vh[rank:] is empty and nullity == 0.