Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Vectors and spaces

Kernel, Image and the Rank–Nullity Theorem

What a linear map destroys, what it can reach, and the beautiful law that balances the two. It explains when equations have solutions, why collinear features break regression, and how redundant robots do two jobs at once.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

The shadow machine

Hold a toy aeroplane under a lamp and look at its shadow on the floor. The shadow keeps the left–right and front–back information, but the height is gone. A plane high up and a plane low down make the same shadow.

  • The directions that vanish (here, “straight up”) are what mathematicians call the kernel.
  • Everything the shadow can look like (any spot on the floor) is called the image.

A fair trade

The air has 3 directions. The floor keeps 2 and the lamp destroys 1, and 2 + 1 = 3. Whatever a linear machine does, what it keeps plus what it destroys always adds up to what you started with. That’s the rank–nullity theorem, one of the most useful facts in all of linear algebra.

Try the “Project onto x” and “Rank 1” presets: the grid collapses onto a line, and the demo shows which direction gets squashed to zero.

Linear map visualiser: a matrix warps the grid
A = [[1.0, 1.0], [0.0, 1.0]]
det A = 1.00 (area scale) · rank = 2
Ae₁Ae₂
The first column of A is where e₁ = (1, 0) lands; the second column is where e₂ = (0, 1) lands. The orange square is the image of the unit square: its area is |det A|.
📝 Quick check (Level 0)
0/3 answered
  1. 1. A flagpole points straight up. How long is its shadow from a lamp directly above?
  2. 2. A 3D world is flattened onto a 2D floor. How many directions are lost?
  3. 3. Can two different planes cast the same shadow?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The two key sets

For a matrix AA (a linear map Rn→Rm\mathbb{R}^n\to\mathbb{R}^m):

  • Kernel (null space): ker⁡A={x:Ax=0}\ker A = \{\mathbf x : A\mathbf x = \mathbf 0\}, the inputs that get destroyed.
  • Image (column space): im⁡A={Ax}\operatorname{im}A = \{A\mathbf x\}, everything the map can output. It’s the span of the columns.

A worked example

A=(1224)A = \begin{pmatrix}1 & 2\\ 2 & 4\end{pmatrix}
  • Image. Both columns are multiples of (1,2)(1,2), so the image is the line span⁡{(1,2)}\operatorname{span}\{(1,2)\}.
  • Kernel. Ax=0A\mathbf x = \mathbf 0 means x+2y=0x + 2y = 0, so x=t(2,−1)\mathbf x = t(2,-1). The kernel is the line span⁡{(2,−1)}\operatorname{span}\{(2,-1)\}.
  • Rank (dimension of the image) = 1, nullity (dimension of the kernel) = 1, and 1+1=21 + 1 = 2 = the number of columns.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Projection onto the x-axis sends (3, 7) to…
  2. 2. The kernel of the x-axis projection is…
  3. 3. Rank of [[1, 2], [2, 4]]?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Rank, nullity and the theorem

Definition

rank⁡A=dim⁡im⁡A\operatorname{rank}A = \dim\operatorname{im}A (the number of independent columns), and nullity⁡A=dim⁡ker⁡A\operatorname{nullity}A = \dim\ker A.

Rank–nullity theorem

For A∈Rm×nA\in\mathbb{R}^{m\times n}: rank⁡A+nullity⁡A=n\operatorname{rank}A + \operatorname{nullity}A = n, the number of columns (inputs).

Computing them: row reduction

Reduce AA to reduced row echelon form (RREF). The columns with a leading 1 (pivots) count the rank. Every other column is a free variable, and each free variable gives one basis vector of the kernel. For example, A=(123456789)A = \begin{pmatrix}1&2&3\\4&5&6\\7&8&9\end{pmatrix} has RREF (10−1012000)\begin{pmatrix}1&0&-1\\0&1&2\\0&0&0\end{pmatrix}. That’s 2 pivots (rank 2) and 1 free variable (nullity 1), with kernel spanned by (1,−2,1)(1,-2,1).

🐍 Exercise 1: RREF and the null space
Implement exact row reduction, then build one null-space basis vector per free column.

What the kernel and image tell you

Property Test
AA is injective (one-to-one) ker⁡A={0}\ker A = \{\mathbf 0\}, i.e. rank = nn
AA is surjective (onto Rm\mathbb{R}^m) rank = mm
Ax=bA\mathbf x = \mathbf b has a solution b∈im⁡A\mathbf b\in\operatorname{im}A
The solution is unique ker⁡A={0}\ker A = \{\mathbf 0\}
All solutions x=xp+n\mathbf x = \mathbf x_p + \mathbf n with n∈ker⁡A\mathbf n\in\ker A

The last row is important: if one solution exists, adding anything from the kernel gives another one.

In data science and ML: identifiability

In linear regression Xw≈yX\mathbf w \approx \mathbf y, if a feature is a combination of others (for example, total = a + b), then XX has a non-trivial kernel. Adding any kernel vector to the weights gives identical predictions, so the “true” weights can’t be identified. Feature importances become meaningless. Remedies: remove redundant features, or use ridge regression, which picks one solution (Practice Code 5).

In robotics: singularities and redundancy

The Jacobian JJ maps joint speeds to hand velocity. Its image is the set of hand velocities that are possible right now. At a singular pose, the rank drops and some directions become impossible. Its kernel is the set of joint motions that don’t move the hand, the “self-motion” of redundant arms (A2.1-3).

📝 Quick check (Level 2)
0/3 answered
  1. 1. A is 3 × 5 with rank 3. Nullity?
  2. 2. A 4 × 4 matrix has rank 4. Is it injective?
  3. 3. A 5 × 3 matrix can be surjective onto ℝ⁵?

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Kernel and image are subspaces

Theorem

ker⁡A\ker A is a subspace of Rn\mathbb{R}^n, and im⁡A\operatorname{im}A is a subspace of Rm\mathbb{R}^m.

Proof. If Au=Av=0A\mathbf u = A\mathbf v = \mathbf 0, then A(au+bv)=0A(a\mathbf u + b\mathbf v) = \mathbf 0. And aAx+bAy=A(ax+by)aA\mathbf x + bA\mathbf y = A(a\mathbf x + b\mathbf y) is in the image. ∎

Proof of rank–nullity

Rank–nullity theorem

dim⁡ker⁡A+dim⁡im⁡A=n\dim\ker A + \dim\operatorname{im}A = n.

Proof. Let k1,…,kp\mathbf k_1,\dots,\mathbf k_p be a basis of ker⁡A\ker A, and extend it to a basis k1,…,kp,u1,…,uq\mathbf k_1,\dots,\mathbf k_p,\mathbf u_1,\dots,\mathbf u_q of Rn\mathbb{R}^n (A2.1-4), so p+q=np + q = n. We claim Au1,…,AuqA\mathbf u_1,\dots,A\mathbf u_q is a basis of the image.

  • Spanning: any x=∑aiki+∑bjuj\mathbf x = \sum a_i\mathbf k_i + \sum b_j\mathbf u_j has Ax=∑bjAujA\mathbf x = \sum b_jA\mathbf u_j.
  • Independent: if ∑bjAuj=0\sum b_jA\mathbf u_j = \mathbf 0, then ∑bjuj∈ker⁡A\sum b_j\mathbf u_j\in\ker A, so it equals some ∑aiki\sum a_i\mathbf k_i. Independence of the whole basis forces all bj=0b_j = 0.

So dim⁡im⁡A=q=n−p\dim\operatorname{im}A = q = n - p. ∎

Consequences

  • Square matrices: for A∈Rn×nA\in\mathbb{R}^{n\times n}, injective ⟺ surjective ⟺ invertible ⟺ rank nn. One condition gives all of them for free.
  • Row rank = column rank. The number of independent rows equals the number of independent columns. So rank⁡A=rank⁡A⊤\operatorname{rank}A = \operatorname{rank}A^\top.
  • Wide matrices always have kernels: if n>mn > m, then nullity ≥ n−m>0n - m > 0. More unknowns than equations means infinitely many solutions (if any).

The four fundamental subspaces

Strang (1993) organised everything into four subspaces of A∈Rm×nA\in\mathbb{R}^{m\times n} with rank rr:

Subspace Lives in Dimension
Column space im⁡A\operatorname{im}A Rm\mathbb{R}^m rr
Left null space ker⁡A⊤\ker A^\top Rm\mathbb{R}^m m−rm - r
Row space im⁡A⊤\operatorname{im}A^\top Rn\mathbb{R}^n rr
Null space ker⁡A\ker A Rn\mathbb{R}^n n−rn - r

Each pair is orthogonal: the null space is perpendicular to the row space, because Ax=0A\mathbf x = \mathbf 0 says x\mathbf x is perpendicular to every row. Likewise the left null space is perpendicular to the column space. This picture is the geometric heart of least squares (A2.4) and the SVD (A2.3).

Exercise 3.1: Prove that A is injective if and only if ker A = 0

(⇒) If Ax=0=A0A\mathbf x = \mathbf 0 = A\mathbf 0, injectivity gives x=0\mathbf x = \mathbf 0. (⇐) If Ax=AyA\mathbf x = A\mathbf y, then A(x−y)=0A(\mathbf x - \mathbf y) = \mathbf 0, so x−y∈ker⁡A={0}\mathbf x - \mathbf y \in \ker A = \{\mathbf 0\}. ∎

📝 Quick check (Level 3)
0/3 answered
  1. 1. A is 6 × 4 with rank 3. Dimension of the left null space ker Aᵀ?
  2. 2. A 4 × 7 matrix has nullity at least…
  3. 3. ker A is orthogonal to…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Null-space control: two jobs at once

A redundant robot can follow a hand trajectory and pursue a secondary goal, such as avoiding a joint limit or an obstacle. The secondary motion is projected into the Jacobian’s kernel, so it can’t disturb the hand:

q˙=J+x˙task+(I−J+J) z\dot{\mathbf q} = J^{+}\dot{\mathbf x}_{\text{task}} + (I - J^{+}J)\,\mathbf z

Here J+J^+ is the pseudo-inverse (A2.4), and I−J+JI - J^+J projects any vector onto ker⁡J\ker J. This structure, from Liégeois (1977) and generalized in Khatib’s operational-space framework (1987), is how humanoids balance while reaching, and how space station arms avoid collisions while holding a payload (S5).

🐍 Exercise 2 (research): null-space control of a 3-link arm
Command a hand velocity while a secondary task straightens joint 2. Check that the hand still moves exactly as commanded.

Huge kernels and sparse solutions: compressed sensing

If A∈Rm×nA\in\mathbb{R}^{m\times n} with m≪nm \ll n (few measurements, many unknowns), the kernel has dimension at least n−mn - m, so infinitely many signals explain the data. Candès, Romberg and Tao (2006) and Donoho (2006) showed that if the true signal is sparse, and AA’s kernel contains no sparse vectors (a condition random matrices satisfy with high probability), then the sparsest solution is unique and can be found by L1 minimization. This changed MRI (faster scans) and single-pixel cameras, and it’s used in spacecraft imaging with limited bandwidth.

Kernels in deep learning

Over-parameterized networks have far more weights than data constraints. Locally, the map from weights to predictions on the training set has a large kernel: many weight changes don’t change any prediction. Which solution gradient descent picks out of this huge set (“implicit bias”, B4) is a central question in deep-learning theory. For linear models trained from zero, gradient descent finds exactly the minimum-norm solution, the one orthogonal to the kernel.

References

  1. A. Liégeois (1977). “Automatic supervisory control of the configuration and behavior of multibody mechanisms.” IEEE Transactions on Systems, Man, and Cybernetics, 7(12).
  2. O. Khatib (1987). “A unified approach for motion and force control of robot manipulators: The operational space formulation.” IEEE Journal on Robotics and Automation, 3(1).
  3. G. Strang (1993). “The fundamental theorem of linear algebra.” American Mathematical Monthly, 100(9).
  4. E. Candès, J. Romberg, T. Tao (2006). “Robust uncertainty principles: exact signal reconstruction from highly incomplete frequency information.” IEEE Transactions on Information Theory, 52(2).
  5. D. Donoho (2006). “Compressed sensing.” IEEE Transactions on Information Theory, 52(4).
  6. G. Strang (2016). Introduction to Linear Algebra, 5th ed. Chapter 3.