16. Kernel and image
§17.4 attached a null space and column space to every matrix. This lesson attaches the same two ideas to every linear transformation — under new names, kernel and image — valid even for transformations between abstract vector spaces where §18.1's standard matrix doesn't directly apply (transformations on P_n or M_{m\times n}, for instance).
Kernel
The kernel of T:V\to W is
\ker T=\{\vec v\in V:T(\vec v)=\vec0\}
\ker T is always a subspace of V: \vec0\in\ker T (§18.0's T(\vec0)=\vec0), and if T(\vec u)=\vec0,T(\vec v)=\vec0 then T(\vec u+\vec v)=T(\vec u)+T(\vec v)=\vec0 and T(c\vec u)=cT(\vec u)=\vec0, using linearity directly. For T(\vec x)=A\vec x, \ker T=\operatorname{Null}(A) exactly — §18.1's matrix representation makes kernel and null space the same computation, just named for the function rather than the matrix.
The kernel measures failure of injectivity. T is one-to-one (injective — distinct inputs give distinct outputs) if and only if \ker T=\{\vec0\}: if T(\vec u)=T(\vec v) then T(\vec u-\vec v)=\vec0 by linearity, so \vec u-\vec v\in\ker T; this is \vec0 (forcing \vec u=\vec v, injective) exactly when the kernel is trivial. A nontrivial kernel means some nonzero vector maps to \vec0 — the same output \vec0 hit by two different inputs (\vec0 itself and that nonzero vector) — so injectivity fails immediately.
Image
The image (or range) of T:V\to W is
\operatorname{im}T=\{T(\vec v):\vec v\in V\}\subseteq W
Always a subspace of W: \vec0=T(\vec0)\in\operatorname{im}T, and closure under addition/scaling follows from linearity exactly as for the kernel. For T(\vec x)=A\vec x, \operatorname{im}T=\operatorname{Col}(A) — every output is some linear combination of A's columns (§16.2), and every column combination is achievable by some input.
The image measures surjectivity. T:V\to W is onto (surjective — every element of W is hit) exactly when \operatorname{im}T=W, i.e. \dim\operatorname{im}T=\dim W.
Rank-nullity, restated for transformations
§17.5's Rank-Nullity Theorem, translated directly:
\dim\ker T+\dim\operatorname{im}T=\dim V
\dim\ker T is called the nullity of T; \dim\operatorname{im}T is called the rank of T — the same words as §17.4/§17.5, now attached to the function rather than to a matrix, and equal to those matrix quantities whenever T(\vec x)=A\vec x.
Doing it in Python
import sympy as sp
# T(x, y, z) = (x + 2y - z, 2x + 4y - 2z) -- note row 2 = 2 * row 1
A = sp.Matrix([
[1, 2, -1],
[2, 4, -2],
])
ker_basis = A.nullspace()
print(f"dim(ker T) = {len(ker_basis)}")
for v in ker_basis:
print(" ", list(v))
rref, pivots = A.rref()
img_basis = [A.col(i) for i in pivots]
print(f"dim(im T) = {len(img_basis)}")
for v in img_basis:
print(" ", list(v))
print(f"\nrank-nullity: {len(ker_basis)} + {len(img_basis)} = {len(ker_basis) + len(img_basis)} (should equal {A.cols})")
dim(ker T) = 2
[-2, 1, 0]
[1, 0, 1]
dim(im T) = 1
[1, 2]
rank-nullity: 2 + 1 = 3 (should equal 3)
Checking injectivity/surjectivity directly:
import numpy as np
A = np.array([[1., 2.], [3., 4.], [5., 6.]]) # T: R^2 -> R^3
rank = np.linalg.matrix_rank(A)
n_in, n_out = A.shape[1], A.shape[0]
nullity = n_in - rank
print(f"T: R^{n_in} -> R^{n_out}, rank = {rank}, nullity = {nullity}")
print("injective (nullity == 0)?", nullity == 0)
print("surjective (rank == output dim)?", rank == n_out)
T: R^2 -> R^3, rank = 2, nullity = 0
injective (nullity == 0)? True
surjective (rank == output dim)? False
Worked example
Find \ker T and \operatorname{im}T for T(x,y,z)=(x+y,\,y+z,\,x-z), and determine whether T is injective and/or surjective.
Standard matrix: A=\begin{pmatrix}1&1&0\\0&1&1\\1&0&-1\end{pmatrix}. Row-reduce: R_3\leftarrow R_3-R_1 gives \begin{pmatrix}1&1&0\\0&1&1\\0&-1&-1\end{pmatrix}; R_3\leftarrow R_3+R_2 gives \begin{pmatrix}1&1&0\\0&1&1\\0&0&0\end{pmatrix}. Pivots in columns 1,2 only — rank 2, nullity 3-2=1.
Kernel: free variable z; x+y=0,\,y+z=0\Rightarrow y=-z,\,x=z. \boxed{\ker T=\operatorname{span}\{(1,-1,1)\}}.
Image: pivot columns of the original A: \boxed{\operatorname{im}T=\operatorname{span}\{(1,0,1),(1,1,0)\}}, a plane in \mathbb{R}^3.
Injective? \ker T\neq\{\vec0\}, so no. Surjective? \dim\operatorname{im}T=2<3=\dim\mathbb{R}^3, so no.
Sanity check. T(1,-1,1)=(1-1,\,-1+1,\,1-1)=(0,0,0) ✓ — the kernel vector genuinely maps to zero — and 2+1=3=\dim\mathbb{R}^3 ✓, confirming rank-nullity holds exactly.
Your turn
1. For T(x,y)=(x,x) (from \mathbb{R}^2\to\mathbb{R}^2), find \ker T and \operatorname{im}T.
2. Can a linear T:\mathbb{R}^3\to\mathbb{R}^2 ever be injective? Justify using rank-nullity.
3. True or false: if \dim V=\dim W and T:V\to W is injective, then T is automatically surjective too.
Solutions
1. T(x,y)=\vec0\iff x=0 (and y free) — \ker T=\operatorname{span}\{(0,1)\}. Every output has the form (x,x) — \operatorname{im}T=\operatorname{span}\{(1,1)\}, a line, not all of \mathbb{R}^2.
2. No, never. By rank-nullity, \dim\ker T=\dim V-\dim\operatorname{im}T=3-\dim\operatorname{im}T. Since \operatorname{im}T\subseteq\mathbb{R}^2, \dim\operatorname{im}T\le2, forcing \dim\ker T\ge3-2=1>0 — the kernel can never be trivial when the domain has strictly larger dimension than the codomain. (This is the transformation-level version of §17.5's "a wide matrix always has a nontrivial null space.")
3. True. Injective means \dim\ker T=0, so by rank-nullity \dim\operatorname{im}T=\dim V=\dim W. Since \operatorname{im}T is a subspace of W with the same dimension as W itself, it must equal W (a proper subspace always has strictly smaller dimension) — so T is surjective too. This equivalence (injective \iff surjective, only when domain and codomain have equal dimension) is exactly what makes §18.4's isomorphism test a single rank check instead of two separate ones.
Check yourself in code
For T(x,y,z)=(x-y,\,y-z,\,x-z), find the dimensions of \ker T and \operatorname{im}T, and confirm rank-nullity.
Print exactly this:
dim(ker T) = 1
dim(im T) = 2
rank-nullity holds: True
import sympy as sp
A = sp.Matrix([
[1, -1, 0],
[0, 1, -1],
[1, 0, -1],
])
ker_basis = A.nullspace()
print("dim(ker T) =", len(ker_basis))
# print dim(im T) (rank, via A.rank()) and whether rank + nullity == A.cols
import sympy as sp
A = sp.Matrix([
[1, -1, 0],
[0, 1, -1],
[1, 0, -1],
])
ker_basis = A.nullspace()
rank = A.rank()
print("dim(ker T) =", len(ker_basis))
print("dim(im T) =", rank)
print("rank-nullity holds:", rank + len(ker_basis) == A.cols)
Kernel and image are §17.4's null space and column space, restated for functions rather than matrices — \ker T is trivial exactly when T is injective, \operatorname{im}T=W exactly when T is surjective, and rank-nullity, \dim\ker T+\dim\operatorname{im}T=\dim V, still holds without exception. When \dim V=\dim W, injective and surjective become the same condition.
Next: transformations that are both injective and surjective at once — isomorphisms — which turn out to mean two vector spaces are, for every algebraic purpose, indistinguishable.