AI Glossary / Mathematics and optimization / Intermediate
Subspace
Definition
A subspace is a subset of a vector space that is itself a vector space under the same addition and scalar multiplication. It contains the zero vector and is closed under adding vectors and multiplying them by allowed scalars.
What it means
In ordinary three-dimensional space, a line through the origin is a subspace, as is a plane through the origin. A parallel line shifted away from the origin is not a linear subspace. It is an affine set, which follows different rules.
The word “sub” does not require a smaller dimension. The entire vector space is a subspace of itself, and the set containing only the zero vector is the smallest subspace.
Subspaces matter in AI because many models represent data through combinations of a few directions. A low-dimensional representation can preserve selected structure while omitting other directions. That mathematical convenience does not by itself establish that the omitted information is irrelevant to a prediction task.
How it works
To check a candidate set, verify that zero belongs to it and that any linear combination au + bv of its vectors remains in it. For real vector spaces, a and b can be any real numbers, including negative values.
The span of a collection of vectors is the set of all their linear combinations and is always a subspace. A basis is a linearly independent collection that spans the subspace. The number of basis vectors is its dimension.
Matrix column spaces and nullspaces are central examples. The column space contains all possible outputs Ax. The nullspace contains inputs satisfying Ax = 0. An equation Ax = b with a nonzero right-hand side generally describes an affine solution set, if it has solutions, rather than a subspace.
Orthogonal projection finds the closest point in a subspace under Euclidean distance. Its residual lies perpendicular to every direction in that subspace.
Three practical examples
- A principal-component model represents centered observations using a lower-dimensional span of selected directions.
- A least-squares model finds the target-vector approximation available within a design matrix's column space.
- A systems analyst examines a nullspace to identify parameter changes that leave the modeled output unchanged.
Think of it this way
Think of the movements available on a flat sheet passing through a marked origin. Adding two allowed movement vectors or reversing and scaling a movement keeps you on that sheet.
The analogy is geometric. A subspace can live in thousands of dimensions or contain functions rather than physical movements, and a bounded patch of the sheet would fail the unrestricted scaling requirement.
Worked example
A plane, a basis and a projection
Define U as all vectors (a, b, a + b) in three-dimensional real space. It contains (0, 0, 0). Adding (a, b, a + b) and (c, d, c + d) gives (a + c, b + d, a + b + c + d), still in U. Scaling also preserves the defining relationship.
Vectors u1 = (1, 0, 1) and u2 = (0, 1, 1) form a basis: every vector in U is au1 + bu2, and neither basis vector is a multiple of the other. Therefore U has dimension two.
Consider z = (1, 1, 0), which is not in U because 0 differs from 1 + 1. A normal vector to U is n = (1, 1, −1). Its squared length is 3, and z·n = 2.
Subtracting the normal component gives the projection p = z − (2/3)n = (1/3, 1/3, 2/3). This lies in U. The residual z − p = (2/3, 2/3, −2/3) is perpendicular to both basis vectors, confirming the projection condition.
Illustrative case study
A fictional equipment-monitoring team compresses centered sensor measurements into a two-dimensional subspace. Most variation is captured well, but an unusual fault signal appears mainly in a discarded direction.
The team distinguishes reconstruction quality from fault-detection usefulness. It evaluates the compressed representation on known fault examples and preserves an additional residual-based diagnostic. It also stores the training mean because reconstructing original measurements requires adding that mean back.
The lesson is that a subspace defines what a representation can express. Selecting a useful one requires task-specific evidence. A low reconstruction error on common behavior does not guarantee that rare but important departures remain visible.
Common misconceptions and mistakes
- Any subset of a vector space is a subspace. Closure and zero membership are required.
- Any plane is a linear subspace. A shifted plane that misses the origin is affine instead.
- Two basis vectors always mean two dimensions. They must be linearly independent and span the set.
- A subspace must use selected coordinate axes. It can be tilted relative to them.
- Projection preserves every useful feature. It removes components outside the chosen subspace.
Business use
Subspace reasoning helps explain dimensionality reduction, model limitations and redundant parameters. Ask which directions the model can represent and which it necessarily discards. For compressed data, document centering, basis vectors and the metric used to assess approximation.
Evaluate the representation against the downstream task, especially for unusual cases. If a system uses an affine representation around a nonzero mean, keep that offset separate from the linear subspace. This prevents confusion when comparing models, reconstructing measurements or interpreting a visualization.
People also ask
Can a subspace contain only zero?
Yes. It has dimension zero.
Is the union of two subspaces always a subspace?
No. Two distinct lines through the origin generally have a union that is not closed under addition.
Is their intersection a subspace?
Yes. Vectors in the intersection retain closure and include zero.
Check your understanding
Why is the line of points (1, t), for real t, not a subspace of the plane?
Answer: It does not contain the zero vector. It also fails closure under scaling, since multiplying (1, t) by two gives first coordinate 2.
Related terms
- Span
- Basis
- Column space
- Nullspace
- Vector space
- dimension
- orthogonal projection
Learn next
Read basis and principal component analysis. Verify the projection residual's dot product with each basis vector in the example. Then shift the plane by a fixed vector and explain when the result is affine rather than a linear subspace.
More in Mathematics and optimization
- Absolute error loss - Absolute error loss measures a numerical prediction's error as the absolute difference between its predicted and reference values: L(y,y-hat)=|y-y-hat|.
- Active-set method - An active-set method is an optimization approach that works with a changing subset of constraints believed to be tight at the solution.
- Adjoint state method - The adjoint state method computes how a chosen objective changes when the parameters of a mathematical model change.
- Σ-algebra
- Algebraic connectivity - Algebraic connectivity is the second-smallest eigenvalue of a graph's Laplacian matrix.
- Algorithm IMED - Algorithm IMED, short for Indexed Minimum Empirical Divergence, is a method for choosing actions in a stochastic multi-armed bandit problem.
Sources
Aalto Dictionary of Machine Learning, subspace: https://aaltodictionaryofml.github.io/ADictML_Main.pdf. Vector-space definition. The plane, closure proof, projection and fictional monitoring scenario are original teaching examples.
Previous: Subsetting Next: Subspace Gaussian mixture model