Vector Spaces
So far vectors have been “things you can add and scale”. This section makes that precise, and the payoff is larger than it first appears: because the definition demands only addition and scaling, it admits objects that look nothing like arrows. Polynomials are vectors. Audio signals are vectors. Functions are vectors. Every theorem proved from the axioms applies to all of them at once.
The book builds up in two stages — first a group, then a vector space — and the intermediate stop is worth taking, because it isolates exactly which properties do which work.
What you’ll learn
Section titled “What you’ll learn”- What a group is, in four axioms, and which familiar sets fail which axiom.
- The vector-space axioms, and what breaks if you drop each one.
- Why “multiplying two vectors” is not defined, and what is defined instead.
- What a subspace is, and the three-part test for one.
- Why the solution set of is always a subspace and the solution set of never is.
Intuition: RGB colour space
Section titled “Intuition: RGB colour space”A colour on a screen is three numbers — red, green, blue. Add two colours and you get a colour. Scale a colour by and you get a dimmer colour. The set of colours is closed under these two operations, and that closure is what makes it a vector space rather than just a set of triples.
Now try the same with the set of colours that are “at least half red”, . Add two of them and you get — outside the set. Closure fails, so it is not a subspace, even though it is a perfectly reasonable set of colours.
That is the whole idea of this page: which sets survive their own operations.
flowchart TD
S["a set with an operation"] --> G{"closure? associativity?
neutral element? inverses?"}
G -->|"all four"| GR["GROUP"]
G -->|"any missing"| NOT["not a group"]
GR -->|"+ commutative"| AB["ABELIAN GROUP"]
AB -->|"+ a scaling operation
with distributivity"| VS["VECTOR SPACE"]
VS --> SUB["SUBSPACE:
a subset that is
itself a vector space"]
SUB --> T["test: nonempty (so 0 is in it),
closed under +, closed under scaling"]
The math
Section titled “The math”Groups: four axioms
Section titled “Groups: four axioms”A group is a set with an operation satisfying:
| # | axiom | in symbols |
|---|---|---|
| 1 | Closure | |
| 2 | Associativity | |
| 3 | Neutral element | and |
| 4 | Inverse element | and |
If additionally for all , the group is Abelian (commutative).
The book’s own catalogue of near-misses is the fastest way to see what each axiom rules out:
| set and operation | group? | what fails |
|---|---|---|
| yes | — | |
| no | inverses — there is a neutral element , but no | |
| no | inverses — neutral exists, but | |
| no | inverses — has none | |
| yes, Abelian | — | |
| componentwise | yes, Abelian | inverse is , neutral is |
| yes, Abelian | — | |
| no | inverses — singular matrices have none |
That last row is the interesting one. Closure and associativity come free from the definition of matrix multiplication, and is a perfectly good neutral element. Only invertibility fails. Throw out the singular matrices and what remains is a group — the general linear group — and because matrix multiplication does not commute, it is not Abelian.
So the four axioms are not a checklist to memorise. They are four independent ways a set can fail to be well behaved, and matrices fail exactly one of them.
Vector spaces
Section titled “Vector spaces”A real vector space is a set with two operations,
satisfying:
- is an Abelian group.
- Distributivity: and .
- Associativity of the outer operation: .
- Neutral element for the outer operation: .
The elements of are vectors; the neutral element of is the zero vector ; the are scalars.
Notice the two operations have different signatures. The inner one takes two vectors and returns a vector. The outer one takes a scalar and a vector. They are not two flavours of the same thing, and the axioms above are precisely the compatibility conditions between them.
Why axiom 4 is not redundant. It looks like it should follow from the others, and it does not. Take with the perverse scaling for every . Distributivity holds (), outer associativity holds, and is still an Abelian group. Only axiom 4 fails — and it must, or scaling could collapse everything and the structure would be useless. Each axiom is load-bearing.
Three vector spaces the book names: with componentwise operations, with entry-wise operations, and with the standard complex addition.
Subspaces
Section titled “Subspaces”is a vector subspace of when , , and is itself a vector space under the operations of restricted to . Written .
The good news is that almost everything is inherited. Associativity, distributivity, the neutral element — all hold for every element of , hence for every element of any subset. So to check a subspace you need only:
- , and in particular ;
- closure under scaling: ;
- closure under addition: .
Three tests, and the book’s Figure 2.6 shows a subset of failing each of them: two sets where closure is violated, one that does not contain , and only one genuine subspace.
Four facts worth having:
- The trivial subspaces of any are itself and .
- The solution set of a homogeneous system is a subspace of .
- The solution set of an inhomogeneous system with is not.
- The intersection of arbitrarily many subspaces is a subspace.
The homogeneous/inhomogeneous split is the one to keep. Homogeneous solutions are closed: if and then . Inhomogeneous ones are not: adding two solutions gives , and is not a solution at all. The inhomogeneous set is a subspace shifted off the origin — §2.3’s particular-plus-general shape, and §2.8’s affine subspace.
And the converse, which the book states as a closing remark: every subspace of is the solution space of some homogeneous system. Subspaces and homogeneous systems are two descriptions of one thing.
Worked example by hand
Section titled “Worked example by hand”Test three subsets of against all three conditions.
— the line .
| test | check | verdict |
|---|---|---|
| contains | ✓ | pass |
| closed under scaling | , still of the form | pass |
| closed under addition | pass |
A subspace. Dimension 1 — a line through the origin.
— the same line, shifted up.
| test | check | verdict |
|---|---|---|
| contains | fail |
Not a subspace, and one failed test is enough. It is an affine subspace (§2.8).
— the first and third quadrants.
| test | check | verdict |
|---|---|---|
| contains | ✓ | pass |
| closed under scaling | ✓ | pass |
| closed under addition | , and ✓… but with | fail |
Not a subspace. Note it passed two of three, which is why all three must be checked — and this is the shape of the book’s Figure 2.6 counterexamples.
Now the homogeneous versus inhomogeneous claim, concretely. For :
- has solutions . Contains ✓; sum of and is ✓. Subspace.
- has solutions . Contains ? ✗. Sum of and is , and ✗. Not a subspace — and it fails on both counts.
See it move
Section titled “See it move”Two lines, both perfectly good sets of vectors. On the left the line passes through the origin, so the sum of two of its points stays on it. On the right the line is shifted up, and the sum leaves.
The white dot is the sum. On the left it never leaves the green line, however and move. On the right it is almost never on the red line — and “almost never” is enough: one violation disqualifies the set. Closure is a universally quantified statement, so a single counterexample settles it.
From scratch
Section titled “From scratch”import numpy as np
import itertools
rng = np.random.default_rng(0)
def is_subspace(sample, contains, trials=2000):
"""Empirically test the three subspace conditions on a candidate set.
A pass here is evidence, not proof — closure is a statement about ALL
elements. But a failure IS proof, because one counterexample is enough.
"""
if not contains(np.zeros_like(sample[0])):
return False, "does not contain the zero vector"
for _ in range(trials):
x, y = sample[rng.integers(len(sample))], sample[rng.integers(len(sample))]
lam = float(rng.normal() * 3)
if not contains(lam * x):
return False, f"not closed under scaling: {lam:.3f} * {x} = {lam * x}"
if not contains(x + y):
return False, f"not closed under addition: {x} + {y} = {x + y}"
return True, "passed every trial"
# Sample points of each candidate set, and a membership test for each.
t = rng.normal(size=400) * 3
sets = {
"line x2 = 2*x1 ": (np.c_[t, 2 * t],
lambda v: np.isclose(v[1], 2 * v[0])),
"line x2 = 2*x1 + 1 ": (np.c_[t, 2 * t + 1],
lambda v: np.isclose(v[1], 2 * v[0] + 1)),
"quadrants x1*x2 >= 0 ": (np.array([[a, b] for a, b in
zip(abs(t), abs(t) * rng.choice([1, 1]))]),
lambda v: v[0] * v[1] >= -1e-12),
"solutions of x1+x2 = 0": (np.c_[t, -t],
lambda v: np.isclose(v[0] + v[1], 0)),
"solutions of x1+x2 = 3": (np.c_[t, 3 - t],
lambda v: np.isclose(v[0] + v[1], 3)),
}
for name, (sample, member) in sets.items():
ok, why = is_subspace(sample, member)
print(f"{name} subspace: {str(ok):5s} ({why})")
# ---- the general linear group: matrices fail exactly one group axiom ----
A = np.array([[1.0, 2.0], [3.0, 4.0]]) # invertible
B = np.array([[1.0, 2.0], [2.0, 4.0]]) # singular
print("\nclosure : A@B is still 2x2 ->", (A @ B).shape == (2, 2))
print("assoc : (AB)C == A(BC) ->",
np.allclose((A @ B) @ A, A @ (B @ A)))
print("neutral : A @ I == A ->", np.allclose(A @ np.eye(2), A))
print("inverse : det(A) =", np.linalg.det(A), "-> invertible")
print("inverse : det(B) =", np.linalg.det(B), "-> NO inverse, so not a group")
# ---- there is no vector multiplication --------------------------------
a = np.array([1.0, 2.0, 3.0])
b = np.array([4.0, 5.0, 6.0])
print("\nouter product a b^T shape:", np.outer(a, b).shape, "-> a MATRIX")
print("inner product a^T b :", a @ b, "-> a SCALAR")
print("NumPy's a * b :", a * b, "-> an operation the axioms do not define")
# ---- axiom 4 is not redundant -----------------------------------------
# Perverse scaling: lam . x := 0 for all lam. Check which axioms survive.
def bad_scale(lam, x):
return np.zeros_like(x)
x, y = np.array([1.0, 2.0]), np.array([3.0, -1.0])
lam, psi = 2.0, 5.0
print("\nwith the perverse scaling lam.x := 0 :")
print(" distributive over vectors :", np.allclose(bad_scale(lam, x + y),
bad_scale(lam, x) + bad_scale(lam, y)))
print(" distributive over scalars :", np.allclose(bad_scale(lam + psi, x),
bad_scale(lam, x) + bad_scale(psi, x)))
print(" outer associativity :", np.allclose(bad_scale(lam, bad_scale(psi, x)),
bad_scale(lam * psi, x)))
print(" 1 . x == x (axiom 4) :", np.allclose(bad_scale(1.0, x), x), " <- the only failure")
# ---- intersection of subspaces is a subspace --------------------------
# Two planes through the origin in R^3 meet in a line through the origin.
P1 = np.array([[1.0, 1.0, 1.0]]) # x1+x2+x3 = 0
P2 = np.array([[1.0, -1.0, 0.0]]) # x1-x2 = 0
both = np.vstack([P1, P2])
print("\ndim of plane 1 :", 3 - np.linalg.matrix_rank(P1))
print("dim of plane 2 :", 3 - np.linalg.matrix_rank(P2))
print("dim of the meet :", 3 - np.linalg.matrix_rank(both), "-> a line, still through 0")line x2 = 2*x1 subspace: True (passed every trial)
line x2 = 2*x1 + 1 subspace: False (does not contain the zero vector)
quadrants x1*x2 >= 0 subspace: True (passed every trial)
solutions of x1+x2 = 0 subspace: True (passed every trial)
solutions of x1+x2 = 3 subspace: False (does not contain the zero vector)
closure : A@B is still 2x2 -> True
assoc : (AB)C == A(BC) -> True
neutral : A @ I == A -> True
inverse : det(A) = -2.0000000000000004 -> invertible
inverse : det(B) = 0.0 -> NO inverse, so not a group
outer product a b^T shape: (3, 3) -> a MATRIX
inner product a^T b : 32.0 -> a SCALAR
NumPy's a * b : [ 4. 10. 18.] -> an operation the axioms do not define
with the perverse scaling lam.x := 0 :
distributive over vectors : True
distributive over scalars : True
outer associativity : True
1 . x == x (axiom 4) : False <- the only failure
dim of plane 1 : 2
dim of plane 2 : 2
dim of the meet : 1 -> a line, still through 0On real data
Section titled “On real data”Reading the plot
Section titled “Reading the plot”Each failing panel carries the actual counterexample, and that is the point. “Not a subspace” is never a judgement call — it is a specific pair of vectors, or a specific scalar, that escapes. When you suspect a set is not a subspace, the productive move is to hunt for that witness rather than to reason about it abstractly.
The square panel is the one worth staring at. It contains and it is closed under addition of small enough vectors, which is why it feels like it should qualify. It fails on scaling: multiply any nonzero point by a large enough and you leave the square. A subspace must be closed under every real scalar, which forces it to be unbounded in every direction it contains at all. So a bounded set can never be a subspace unless it is just .
Pitfalls
Section titled “Pitfalls”Compare
Section titled “Compare”| structure | operations | what it adds |
|---|---|---|
| group | one, | closure, associativity, neutral element, inverses |
| Abelian group | one | plus commutativity |
| vector space | two, and | scaling by scalars, compatible with addition |
| subspace | inherited | a subset closed under both, containing |
| affine subspace (§2.8) | inherited | a subspace translated — no longer contains |
| convex set (§7.3) | inherited | closed under averages only, so it may be bounded |
The last two rows are the ones people conflate. An affine subspace is a subspace moved; a convex set is closed under weighted averages rather than arbitrary combinations, which is why a disc is convex and not a subspace.
-
The set of n-by-n matrices under multiplication satisfies three of the four group axioms. Which one fails?
Closure and associativity follow from the definition of the product, and the identity is a perfectly good neutral element. Discarding the singular matrices leaves the general linear group, which is a group but not Abelian.
pch.quizShowAnswer
D — Existence of inverses — singular matrices have none — Closure and associativity follow from the definition of the product, and the identity is a perfectly good neutral element. Discarding the singular matrices leaves the general linear group, which is a group but not Abelian.
-
Which is the correct statement about multiplying two vectors in R-n?
The book says so explicitly. Element-wise multiplication is common in programming languages but is not part of the vector-space structure, and neither defined product returns a vector.
pch.quizShowAnswer
B — It is not defined; only the outer product giving a matrix and the inner product giving a scalar are — The book says so explicitly. Element-wise multiplication is common in programming languages but is not part of the vector-space structure, and neither defined product returns a vector.
-
Why can a bounded set never be a subspace unless it is just the origin?
Scaling must hold for every real lambda, including enormous ones. Any nonzero vector in the set therefore drags an entire infinite line in with it. This is what separates subspaces from the convex sets of section 7.3.
pch.quizShowAnswer
B — Because closure under scaling requires closure under arbitrarily large scalars, forcing an unbounded line through any nonzero member — Scaling must hold for every real lambda, including enormous ones. Any nonzero vector in the set therefore drags an entire infinite line in with it. This is what separates subspaces from the convex sets of section 7.3.
-
The solution set of Ax = b with b nonzero is not a subspace. What is it?
It is a particular solution plus the null space, which is section 2.3's particular-plus-general shape. Translating a subspace destroys the zero vector and closure, but keeps the flat shape.
pch.quizShowAnswer
B — A subspace translated off the origin, which section 2.8 calls an affine subspace — It is a particular solution plus the null space, which is section 2.3's particular-plus-general shape. Translating a subspace destroys the zero vector and closure, but keeps the flat shape.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – The cheapest subspace test
Section titled “Exercise 1 – The cheapest subspace test”Exercise 2 – Find the counterexample
Section titled “Exercise 2 – Find the counterexample”Exercise 3 – Homogeneous versus inhomogeneous
Section titled “Exercise 3 – Homogeneous versus inhomogeneous”Exercise 4 – A bounded set fails on scaling
Section titled “Exercise 4 – A bounded set fails on scaling”Exercise 5 – The intersection of two subspaces
Section titled “Exercise 5 – The intersection of two subspaces”Recall card
Section titled “Recall card”- A group has four axioms — closure, associativity, a neutral element, and inverses — and adding commutativity makes it Abelian.
- The inverse is with respect to the operation, so it means under addition and under multiplication.
- Square matrices under multiplication fail exactly one group axiom: inverses. Discarding the singular ones gives the general linear group, which is not Abelian.
- A vector space has two operations with different signatures — an inner one taking two vectors, an outer one taking a scalar and a vector — plus the four compatibility conditions.
- Every axiom is load-bearing: the perverse scaling that sends everything to zero satisfies distributivity and outer associativity, and fails only the rule that 1 times x is x.
- There is no vector multiplication. Only the outer product, returning a matrix, and the inner product, returning a scalar.
- A subspace needs three things — nonempty and containing the zero vector, closed under scaling, closed under addition — and checking only two accepts sets that fail.
- A bounded set is never a subspace unless it is just the origin, because closure under scaling admits arbitrarily large scalars.
- Homogeneous solution sets are subspaces; inhomogeneous ones are not — they are subspaces translated off the origin, which is the affine subspace of section 2.8.
- The intersection of arbitrarily many subspaces is a subspace, and conversely every subspace of R-n is the solution space of some homogeneous system.
- An empirical closure test can only disprove, because closure is universally quantified and a sample that misses the awkward region reports a false pass.
Next: when is a vector redundant? — Linear Independence.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading