Linear Mappings
§2.2 said a matrix has two faces — data and action. This section makes the second face precise, and delivers the payoff: once you fix a basis, every linear mapping between finite-dimensional spaces is a matrix. Not “can be represented by” in a loose sense — there is an exact correspondence, and the matrix depends on which basis you chose.
That dependence is the subtle part, and it is where most of the confusion in this section lives.
What you’ll learn
Section titled “What you’ll learn”- What makes a mapping linear, in one condition rather than two.
- Isomorphism, endomorphism, automorphism — and the theorem that says dimension is all that matters.
- Coordinates with respect to an ordered basis, and why the ordering is not pedantry.
- The transformation matrix, whose columns are the images of the basis vectors, in coordinates.
- Basis change: the same mapping, a different matrix, related by .
- Image and kernel, and the rank-nullity theorem tying their dimensions together.
Intuition: currency conversion
Section titled “Intuition: currency conversion”Converting pounds to euros is linear. Convert £10 and £20 separately, or convert £30 at once — same answer. Double the pounds and you double the euros. Two properties, and they are exactly the two the definition demands.
Now notice what is not linear: adding a £3 fixed fee. Convert £10 and £20 separately and you pay the fee twice; convert £30 once and you pay it once. The fee breaks additivity, and a mapping with a constant offset is affine, not linear — §2.8’s subject, and the reason a neural network layer with a bias term is affine rather than linear.
flowchart TD L["linear mapping Phi"] --> P1["Phi(x + y) = Phi(x) + Phi(y)"] L --> P2["Phi(lambda x) = lambda Phi(x)"] P1 --> C["combined into one condition:
Phi(lambda x + psi y) = lambda Phi(x) + psi Phi(y)"] P2 --> C C --> M["fix a basis in each space
and Phi IS a matrix"] M --> K["its COLUMNS are the coordinates
of the images of the basis vectors"] M --> B["change the basis and the matrix changes,
though the mapping does not"] C --> IK["two subspaces come free:
the KERNEL in V, the IMAGE in W"] IK --> RN["dim(ker) + dim(Im) = dim(V)"]
The math
Section titled “The math”Definition
Section titled “Definition”A mapping between real vector spaces is a linear mapping — equivalently a vector space homomorphism or linear transformation — when
This single condition packages the two separate ones — additivity and homogeneity — and they are equivalent: set to recover the first, and to recover the second.
An immediate consequence worth noting because it is the fastest disqualifier: . Every linear mapping sends zero to zero. If a candidate mapping does not, it is not linear, and you are done.
The four special cases
Section titled “The four special cases”| name | condition |
|---|---|
| Isomorphism | linear and bijective |
| Endomorphism | linear (same space both sides) |
| Automorphism | linear and bijective |
| Identity | , |
And the theorem that makes dimension the only thing that matters:
Read what that says. Two spaces of the same dimension “are kind of the same thing, as they can be transformed into each other without incurring any loss” — the book’s phrasing. It is why and can be used interchangeably, and why every -dimensional space is “really” once you pick a basis.
Three more closure facts: the composition of linear mappings is linear; the inverse of an isomorphism is an isomorphism; and and are linear. So linear mappings themselves form a vector space.
Coordinates, and why the order matters
Section titled “Coordinates, and why the order matters”Fix an ordered basis of — a tuple, not a set. Every then has a unique representation
and is the coordinate vector of with respect to . Uniqueness is §2.6’s characterisation 4 — this is what a basis was for.
The notation gets genuinely tricky here, and the book pauses to fix it:
| written | is |
|---|---|
| an ordered basis — a tuple | |
| an unordered basis — a set | |
| a matrix whose columns are those vectors |
Ordering matters because coordinates are a list. Swap and and the coordinate vector becomes — a different list describing the same point. A set cannot express that, which is why bases are tuples from here on.
A basis is a coordinate system, and the same vector has different coordinates in different ones. The book’s Example 2.20: in the standard basis means . With and , the same point has coordinates .
The transformation matrix
Section titled “The transformation matrix”Here is the construction. Let be an ordered basis of and one of . For each , expand the image of the -th basis vector in the basis:
The matrix with entries is the transformation matrix of with respect to and .
The -th column of is the coordinate vector of with respect to . That is the whole definition, and it is §2.2’s “the columns are the images of the basis vectors” — now stated properly, with the caveat that “images” means in coordinates, and which coordinates depends on .
Then, with the coordinate vector of in and that of in :
Matrix multiplication maps coordinates to coordinates. Not vectors to vectors — coordinates. The distinction is invisible when both bases are standard, which is why it is so easy to miss and so confusing when it finally matters.
Basis change
Section titled “Basis change”Same mapping, different bases, different matrix. How different?
where is the transformation matrix of mapping coordinates in the new basis onto coordinates in the old , and does the same for onto .
Read the formula right to left, which is the order it executes in: translates new-basis coordinates into old-basis ones, does the actual mapping in the old coordinates, and translates the result back into the new output coordinates. Three steps, and only the middle one is the mapping.
Two names for the resulting relation:
- are equivalent if for some regular .
- are similar if — the same matrix on both sides.
Similar matrices are always equivalent; equivalent ones need not be similar. Similarity is the one Chapter 4 cares about, because it is what “the same endomorphism in a different basis” means, and diagonalisation (§4.4) is the search for a basis making the matrix diagonal.
Image and kernel
Section titled “Image and kernel”Two subspaces come free with every linear mapping:
is the domain and the codomain. The kernel — also null space — is what gets crushed to zero. The image — also range — is what can be reached.
Four facts:
- always, so : the kernel is never empty.
- is a subspace of ; is a subspace of .
- is injective if and only if .
- For , the image is the span of the columns — the column space — so .
Note the asymmetry, which is easy to get backwards: the kernel lives in , the width of the matrix, and the image lives in , the height. The kernel is about relationships among the columns; the image is about what the columns reach.
Rank-nullity
Section titled “Rank-nullity”Also called the fundamental theorem of linear mappings. Every input dimension is accounted for exactly once: it either survives into the image or gets crushed into the kernel. Nothing is lost and nothing is double-counted.
Three consequences the book draws out:
- If then the kernel is non-trivial: .
- In that case has infinitely many solutions.
- If , then injective surjective bijective.
Consequence 3 is the one that saves work. For a square matrix you need check only one of the three properties; all of them follow. For a non-square one they can differ freely.
Worked example by hand
Section titled “Worked example by hand”Is it linear? Four candidates, checked against first because it is free:
| mapping | ? | linear? | why |
|---|---|---|---|
| yes | yes | both properties hold | |
| no, gives | no | affine, not linear | |
| yes | no | ||
| yes | yes | integration is linear | |
| no, gives | no | disqualified immediately |
The last row shows the value of the zero test: is settled without touching additivity.
Coordinates in two bases. Take written in the standard basis, and the alternative . Solve :
Adding: , so ; then . So the coordinates are — the book’s Example 2.20 exactly. Same point, different list.
Image and kernel of the book’s Example 2.25. For
The image is the span of the columns — four vectors in , which must be dependent, and they span all of . So .
For the kernel, reduce:
Non-pivot columns 3 and 4, so two kernel directions:
Check the first: ✓ and ✓.
Rank-nullity: ✓. Four input dimensions, two survive, two are crushed.
See it move
Section titled “See it move”A rank-1 map squashes the whole plane onto a line. The amber line is the image; the red dashed line is the kernel — every point on it lands on the origin.
Watch the probe. When the blue input crosses the red dashed line the amber output passes through the origin — that is what “the kernel maps to zero” looks like in motion. And no matter where the input goes, the output never leaves the amber line: the image is all the map can reach, and it is one-dimensional because the rank is 1.
Basis change, made concrete
Section titled “Basis change, made concrete”The book’s Example 2.23 in the lab: a matrix that looks like a shear in the standard basis and is a pure diagonal scaling in the right one.
Its eigenvectors are (1,1) and (1,-1) with eigenvalues 3 and 1 — so in that basis it is diag(3, 1). Watch the eigen-directions in the final frame.
The last frame draws the eigen-directions, and they are exactly and with eigenvalues and . Those numbers are the diagonal of . Basis change and eigendecomposition are the same operation seen from two sides — §4.4 makes it official.
From scratch
Section titled “From scratch”import numpy as np
rng = np.random.default_rng(0)
def is_linear(phi, dim, trials=500, tol=1e-9):
"""Test the single linearity condition on random inputs and scalars."""
for _ in range(trials):
x, y = rng.standard_normal(dim), rng.standard_normal(dim)
lam, psi = rng.normal(), rng.normal()
lhs = phi(lam * x + psi * y)
rhs = lam * np.asarray(phi(x)) + psi * np.asarray(phi(y))
if not np.allclose(lhs, rhs, atol=tol):
return False
return True
# ---- the zero test disqualifies fastest ------------------------------
cands = {
"3x ": lambda v: 3 * v,
"3x + 1 ": lambda v: 3 * v + 1,
"x squared ": lambda v: v ** 2,
"cos(x) ": lambda v: np.cos(v),
"A @ x ": lambda v: np.array([[1.0, 2.0], [3.0, 4.0]]) @ v,
}
for name, f in cands.items():
z = np.asarray(f(np.zeros(2)))
sends_zero = np.allclose(z, 0)
print(f"{name} Phi(0)=0: {str(sends_zero):5s} linear: {is_linear(f, 2)}")
# ---- coordinates with respect to an ordered basis --------------------
x = np.array([2.0, 3.0])
B = np.array([[1.0, 1.0], [-1.0, 1.0]]) # columns b1=(1,-1), b2=(1,1)
alpha = np.linalg.solve(B, x)
print("\ncoordinates of (2,3) in B:", alpha, " = 0.5 * ", 2 * alpha)
print("rebuild:", B @ alpha, " matches x:", np.allclose(B @ alpha, x))
# Ordering matters: swap the basis vectors and the coordinate list swaps.
B_swapped = B[:, ::-1]
print("with the basis vectors swapped:", np.linalg.solve(B_swapped, x))
# ---- the transformation matrix's columns ----------------------------
A = np.array([[1.0, 2.0], [3.0, 4.0]])
for j, e in enumerate(np.eye(2)):
print(f"\nPhi(e{j+1}) =", A @ e, " == column {}: {}".format(j, A[:, j]))
# ---- basis change: the book's Example 2.23 -------------------------
A23 = np.array([[2.0, 1.0], [1.0, 2.0]])
S = np.array([[1.0, 1.0], [1.0, -1.0]]) # new basis vectors as columns
A_tilde = np.linalg.inv(S) @ A23 @ S
print("\nExample 2.23:")
print("A in the canonical basis:\n", A23)
print("A in the basis ((1,1),(1,-1)):\n", np.round(A_tilde, 12))
print("diagonal?", np.allclose(A_tilde, np.diag(np.diag(A_tilde))))
vals, vecs = np.linalg.eigh(A23)
print("eigenvalues:", vals, " -> the diagonal entries, in the other order")
# ---- the book's Example 2.24, all the way through ------------------
A24 = np.array([[1.0, 2.0, 0.0],
[-1.0, 1.0, 3.0],
[3.0, 7.0, 1.0],
[-1.0, 2.0, 4.0]])
S24 = np.array([[1.0, 0.0, 1.0],
[1.0, 1.0, 0.0],
[0.0, 1.0, 1.0]])
T24 = np.array([[1.0, 1.0, 0.0, 1.0],
[1.0, 0.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])
A24_tilde = np.linalg.inv(T24) @ A24 @ S24
print("\nExample 2.24, T^-1 A S =\n", np.round(A24_tilde, 10))
# ---- image, kernel, rank-nullity: the book's Example 2.25 ---------
A25 = np.array([[1.0, 2.0, -1.0, 0.0],
[1.0, 0.0, 0.0, 1.0]])
r = np.linalg.matrix_rank(A25)
n = A25.shape[1]
k1 = np.array([0.0, 0.5, 1.0, 0.0])
k2 = np.array([-1.0, 0.5, 0.0, 1.0])
print("\nExample 2.25:")
print("rank = dim(Im) :", r, " (all of R^2)")
print("dim(ker) :", n - r)
print("k1 in kernel :", np.allclose(A25 @ k1, 0), " k2 in kernel:", np.allclose(A25 @ k2, 0))
print("rank-nullity :", (n - r), "+", r, "=", n, " == dim(V):", n)
# ---- injective iff surjective iff bijective, for SQUARE only ------
print("\nsquare, full rank -> all three:", end=" ")
Sq = np.array([[1.0, 2.0], [3.0, 4.0]])
rk = np.linalg.matrix_rank(Sq)
print(f"rank {rk} of 2, injective={rk==2}, surjective={rk==2}")
print("non-square, tall -> can be injective and NOT surjective:", end=" ")
Tall = np.array([[1.0], [2.0], [3.0]])
print(f"rank {np.linalg.matrix_rank(Tall)}, image is a line in R^3")
print("non-square, wide -> surjective and NOT injective:", end=" ")
print(f"rank {r} of R^2 reached, but kernel has dim {n - r}")3x Phi(0)=0: True linear: True
3x + 1 Phi(0)=0: False linear: False
x squared Phi(0)=0: True linear: False
cos(x) Phi(0)=0: False linear: False
A @ x Phi(0)=0: True linear: True
coordinates of (2,3) in B: [-0.5 2.5] = 0.5 * [-1. 5.]
rebuild: [2. 3.] matches x: True
with the basis vectors swapped: [ 2.5 -0.5]
Phi(e1) = [1. 3.] == column 0: [1. 3.]
Phi(e2) = [2. 4.] == column 1: [2. 4.]
Example 2.23:
A in the canonical basis:
[[2. 1.]
[1. 2.]]
A in the basis ((1,1),(1,-1)):
[[3. 0.]
[0. 1.]]
diagonal? True
eigenvalues: [1. 3.] -> the diagonal entries, in the other order
Example 2.24, T^-1 A S =
[[-4. -4. -2.]
[ 6. 0. 0.]
[ 4. 8. 4.]
[ 1. 6. 3.]]
Example 2.25:
rank = dim(Im) : 2 (all of R^2)
dim(ker) : 2
k1 in kernel : True k2 in kernel: True
rank-nullity : 2 + 2 = 4 == dim(V): 4
square, full rank -> all three: rank 2 of 2, injective=True, surjective=True
non-square, tall -> can be injective and NOT surjective: rank 1, image is a line in R^3
non-square, wide -> surjective and NOT injective: rank 2 of R^2 reached, but kernel has dim 2Four things confirmed against the book.
The zero test does real work. 3x + 1 and cos(x) are eliminated by one evaluation each, and
x squared survives the zero test and fails linearity — so the test is necessary but not sufficient,
exactly as expected.
Coordinates depend on the ordering. reproduces Example 2.20, and swapping the two basis vectors swaps the coordinate list to . Same point, same basis set, different basis tuple, different answer.
Example 2.23 comes out diagonal, , and the eigenvalues are and —
the same numbers, in the order eigh chose to return them. Basis change found the eigenbasis without
being asked.
Example 2.24 reproduces the book’s exactly, including the awkward first row.
On real data
Section titled “On real data”Reading the plot
Section titled “Reading the plot”The second figure is rank-nullity drawn as a conservation law, which is the most useful way to hold it. Each bar’s total height is — the number of columns — and the split between image and kernel varies with the rank. The total never does.
That framing makes the consequences immediate rather than something to derive. A wide matrix () cannot have a trivial kernel, because the image dimension is capped at and the rest of has to go somewhere. So a wide matrix is never injective — there are always distinct inputs colliding on the same output. That is precisely why an under-determined system has infinitely many solutions (§2.1), and why a compression step is inherently lossy (Chapter 10).
Conversely a tall matrix () can have a trivial kernel and still fail to be surjective, because the image is at most -dimensional inside an -dimensional codomain. That is why an overdetermined system usually has no solution.
The three-way equivalence — injective iff surjective iff bijective — needs , and the figure shows why: only when the bar height equals the codomain dimension can filling one force the other.
Pitfalls
Section titled “Pitfalls”Compare
Section titled “Compare”| shape | typical rank | kernel | injective? | surjective? |
|---|---|---|---|---|
| square, full rank | yes | yes — and bijective | ||
| square, deficient | non-trivial | no | no | |
| tall, , full rank | yes | no — image is -dim in | ||
| wide, , full rank | dimension | no | yes |
The two middle-column entries in the last two rows are the asymmetry the figure makes visible: a tall matrix loses nothing and reaches little; a wide one reaches everything and loses information.
-
What is the fastest way to show a mapping is not linear?
Linearity forces Phi(0) = 0, so any mapping with a constant offset is disqualified by one evaluation. It is necessary but not sufficient — x squared passes the zero test and is still not linear.
pch.quizShowAnswer
B — Check whether it sends the zero vector to the zero vector — Linearity forces Phi(0) = 0, so any mapping with a constant offset is disqualified by one evaluation. It is necessary but not sufficient — x squared passes the zero test and is still not linear.
-
What does the j-th column of a transformation matrix contain?
That is the definition. It is section 2.2's 'columns are the images of the basis vectors', made precise — with the important caveat that 'images' means in coordinates, and which coordinates depends on the codomain basis.
pch.quizShowAnswer
B — The coordinates of the image of the j-th domain basis vector, with respect to the codomain basis — That is the definition. It is section 2.2's 'columns are the images of the basis vectors', made precise — with the important caveat that 'images' means in coordinates, and which coordinates depends on the codomain basis.
-
A four-by-six matrix has full rank. What can you say?
Four rows and six columns means the image is at most four-dimensional and full rank makes it exactly four, so it covers the codomain. Rank-nullity then forces the kernel to have dimension six minus four, so distinct inputs collide.
pch.quizShowAnswer
B — It is surjective but not injective — the kernel has dimension two — Four rows and six columns means the image is at most four-dimensional and full rank makes it exactly four, so it covers the codomain. Rank-nullity then forces the kernel to have dimension six minus four, so distinct inputs collide.
-
Why does anyone bother changing basis?
The mapping does not change; the description does. A diagonal matrix raised to a high power is trivial, which is the entire motivation for Chapter 4's diagonalisation and for Chapter 10's choice of a basis in which data compresses.
pch.quizShowAnswer
B — Because the same mapping can have a far simpler matrix in the right basis — the book's example turns a shear-looking matrix into a diagonal one — The mapping does not change; the description does. A diagonal matrix raised to a high power is trivial, which is the entire motivation for Chapter 4's diagonalisation and for Chapter 10's choice of a basis in which data compresses.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – The zero test
Section titled “Exercise 1 – The zero test”Exercise 2 – Coordinates depend on the ordering
Section titled “Exercise 2 – Coordinates depend on the ordering”Exercise 3 – Basis change can diagonalise
Section titled “Exercise 3 – Basis change can diagonalise”Exercise 4 – Rank-nullity as a conservation law
Section titled “Exercise 4 – Rank-nullity as a conservation law”Exercise 5 – Verify a kernel basis
Section titled “Exercise 5 – Verify a kernel basis”Recall card
Section titled “Recall card”- Linearity is one condition — the mapping commutes with taking linear combinations — and it packages additivity and homogeneity together.
- Every linear mapping sends zero to zero, which is the cheapest disqualifier: any constant offset makes a mapping affine rather than linear.
- Isomorphism is linear plus bijective; endomorphism maps a space to itself; automorphism is both.
- Two finite-dimensional spaces are isomorphic exactly when their dimensions agree, which is why an m-by-n matrix space can be treated as a vector space of length mn.
- A basis must be ordered because coordinates are a list — swapping two basis vectors swaps the coordinates of every point.
- The j-th column of the transformation matrix is the coordinates of the image of the j-th basis vector, expressed in the codomain basis.
- Matrix multiplication maps coordinates, not vectors — the underlying vectors never touch a matrix.
- Basis change is T inverse times A times S, read right to left: translate in, map, translate out.
- Similar means the same matrix on both sides; equivalent allows different ones. Similar implies equivalent, not conversely.
- The kernel lives in the width and the image in the height — different spaces, which is why rank-nullity needs care.
- The kernel is never empty; it always contains the zero vector, and the mapping is injective exactly when that is all it contains.
- Rank-nullity is a conservation law: image dimension plus kernel dimension equals the number of input dimensions, always.
- A wide matrix is never injective and a tall one is rarely surjective, and injective-iff-surjective-iff-bijective needs the two dimensions to match.
Next: what happens when the offset is allowed back in — Affine Spaces.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading