Subspaces of
A subspace is a set of vectors that is closed under the two vector operations: adding and scaling never lead outside it. Lines and planes through the origin are the typical examples. Subspaces are the "flat pieces" of that linear algebra works with: spans, solution sets of homogeneous systems, column spaces.
Definition
A subset of is a subspace if
- (it contains the zero vector),
- closed under addition: ,
- closed under scalar multiplication: .
Conditions 2 and 3 together say is closed under all linear combinations. Condition 1 mostly serves to rule out the empty set; given a non-empty , it follows from 3 with .
Examples and non-examples
| Set | Subspace? | Why |
|---|---|---|
| and itself | yes | the trivial subspaces |
| a line through | yes | |
| the plane in | yes | solutions of a homogeneous equation |
| the plane | no | does not contain |
| the first quadrant | no | leaves it |
| the union of the two axes in | no | is on neither axis |
| no | is in it, is not |
The subspaces of are exactly: , lines through , planes through , and .
Two big sources of subspaces
Spans are subspaces. If and , then and are again combinations. Conversely, every subspace of is the span of finitely many vectors (shown in Basis and Dimension).
Solution sets of homogeneous systems are subspaces. If and , then and . This subspace is the null space of . For the solution set of is not a subspace ( is not a solution); it is a shifted copy of the null space, an affine subspace.
So every subspace can be described in two ways: explicitly as a span, or implicitly as the solutions of equations. Converting between them is row reduction:
from sympy import Matrix
# implicit: the plane x + 2y - z = 0 -> explicit: a span
A = Matrix([[1, 2, -1]])
basis = A.nullspace()
print("plane = span of", [list(v) for v in basis])
# explicit: span{[1,0,2],[0,1,1]} -> implicit: equations whose null space it is
S = Matrix.hstack(Matrix([1, 0, 2]), Matrix([0, 1, 1]))
normals = S.T.nullspace() # vectors n with n·v = 0 for both spanning vectors
print("span = solutions of n·x = 0 for n =", [list(n) for n in normals])plane = span of [[-2, 1, 0], [1, 0, 1]]
span = solutions of n·x = 0 for n = [[-2, -1, 1]]
So the plane spanned by and is , i.e. .
Testing a claim numerically
A proof is needed to show a set is a subspace, but one counterexample shows it is not. Random testing is a fast way to find one (or to build confidence before proving):
import numpy as np
rng = np.random.default_rng(11)
def looks_closed(member, sample, trials=1000):
for _ in range(trials):
u, v, c = sample(), sample(), float(rng.normal() * 3)
if not (member(u + v) and member(c * u)):
return False, np.round(u, 3).tolist(), np.round(v, 3).tolist(), round(c, 3)
return True, None, None, None
plane = lambda p: abs(p[0] + 2 * p[1] - p[2]) < 1e-9
def sample_plane():
x, y = rng.normal(size=2)
return np.array([x, y, x + 2 * y])
quadrant = lambda p: p[0] >= 0 and p[1] >= 0
sample_quadrant = lambda: rng.uniform(0, 1, size=2)
print("plane x+2y-z=0:", looks_closed(plane, sample_plane)[0])
print("first quadrant:", looks_closed(quadrant, sample_quadrant)[0])plane x+2y-z=0: True
first quadrant: False
In software
- Constraints that are homogeneous equations carve out subspaces. In a physics or network simulation, flows with "inflow = outflow at every node" form the null space of the incidence matrix; any combination of valid flows is valid (Application: Resistor Networks).
- Embedding debiasing: researchers estimate a "bias direction" (a subspace spanned by differences like ) in word embeddings and remove each vector's component in that subspace. That is an orthogonal projection onto the complementary subspace (Orthogonal Projections).
- Affine vs linear: game engines keep the distinction between points and directions because of exactly this lesson. Directions (velocities, normals) form a vector space; positions do not, since "position + position" is meaningless, which is why homogeneous coordinates give points and directions (Homogeneous Coordinates).
Exercises
Exercise 1: Subspace or not?
Which of these subsets of are subspaces? (a) , (b) , (c) , (d) .
Answer
(a) and (d) are subspaces; (b) and (c) are not.
Solution
(a) The -plane: solutions of the homogeneous equation . (b) Does not contain (). (c) Contains and (each has a zero coordinate) but not their sum . (d) , a line through .
Exercise 2: Implicit to explicit
Write the subspace of as a span.
Answer
.
Solution
from sympy import Matrix
A = Matrix([[1, -1, 0, 2], [0, 1, 1, -1]])
print([list(v) for v in A.nullspace()])[[-1, -1, 1, 0], [-1, 1, 0, 1]]
Exercise 3: Union and intersection
If and are subspaces of , prove that is a subspace. Give an example showing need not be.
Answer
is always a subspace; the union of the -axis and -axis in is not.
Solution
is in both, so . If , then and lie in ( is closed) and in ( is closed), hence in . For the union: and lie in it, but their sum lies on neither axis.
Exercise 4: Explicit to implicit
Find one linear equation that describes .
Answer
(or any non-zero multiple).
Solution
must be orthogonal to both spanning vectors: and . Adding gives , then . With : . Check: ✓, ✓. (The cross product of the two vectors gives the same normal: .)
Test yourself
Which set is a subspace of ?
Why is the solution set of with never a subspace?
- It may be empty
- It is always a single point
- It does not contain the zero vector
- It is not closed under scaling by 1
What are the possible subspaces of ?
- Only and
- , lines through , planes through , and
- Any line or plane
- Spheres centred at