Vector Spaces and Subspaces
- Verify whether a set with operations satisfies the eight vector space axioms
- Test whether a subset is a subspace using the three-condition test: zero vector, closure under addition and scaling
- Determine whether a vector belongs to a span by reducing the corresponding augmented system
- Describe the null space and column space of a matrix geometrically and explain their role in ML model expressivity
Why Axiomatize?
In the previous readings, vectors were -tuples of reals. But "addition" and "scalar multiplication" appear in many other settings — polynomials, functions, matrices. The concept of a vector space abstracts the shared structure, letting us prove theorems once that apply everywhere.
Definition of a Vector Space
A vector space over is a set equipped with two operations — addition and scalar multiplication — satisfying ten axioms:
Addition axioms:
- Closure:
- Commutativity:
- Associativity:
- Zero element: there exists such that
- Additive inverse: for each there exists such that
Scalar multiplication axioms:
- Closure:
- Distributivity over vector addition:
- Distributivity over scalar addition:
- Associativity:
- Identity:
The axioms capture exactly what it means for a set to behave "like" .
Canonical Examples
: column vectors with component-wise operations. The archetypal vector space.
: matrices with component-wise addition and scalar scaling. The zero vector is the zero matrix.
: polynomials of degree , with coefficient-wise addition. E.g., . The zero vector is the zero polynomial.
Function spaces: the set of all functions with and . This is an infinite-dimensional vector space. Fourier analysis lives here.
Trivial space: with the only possible operations. Dimension zero.
Subspaces
A subspace of is a subset that is itself a vector space under the same operations. Rather than checking all ten axioms, a subset is a subspace if and only if:
- Closed under addition:
- Closed under scalar multiplication:
Conditions 2 and 3 can be combined: is a subspace iff for all and scalars : .
Examples of subspaces of :
- (trivial)
- Any line through the origin:
- Any plane through the origin:
- All of
Non-examples: a line not through the origin is not a subspace (it doesn't contain ). The set of vectors with non-negative entries is not a subspace (not closed under negation).
Spanning Sets
The span of a set is the set of all linear combinations:
The span is always a subspace. We say spans if .
When looking for a spanning set for a space arising from a linear system, write the solution set in parametric form — the vectors multiplied by the free parameters form a spanning set for the null space.
Checking Span Membership with Gauss's Method
To test whether lies in , ask: do scalars exist such that
Assemble (columns are the spanning vectors) and apply Gauss's method to . If the system is consistent, is in the span; if it is inconsistent, it is not.
Example. Is in ?
The reduction gives , then back-substitution gives , so . Replacing the right-hand side with a general shows a solution always exists, confirming .
Computing Span Membership with einsum
Once you have the coefficients, einsum is the idiomatic way to verify a linear combination in both PyTorch and TensorFlow. The subscript 'ij,j->i' means: multiply column of by scalar and sum over to produce output index .
import numpy as np
# Spanning vectors as *columns* of A
A = np.array([[1., 2.],
[1., 1.]])
v = np.array([5., 4.])
# Solve A @ c = v (find coefficients)
c = np.linalg.solve(A, v)
print('coefficients:', c) # [3. 1.]
# Verify: einsum 'ij,j->i' means sum_j A_ij * c_j
v_hat = np.einsum('ij,j->i', A, c)
print('reconstructed v:', v_hat) # [5. 4.]
# Does the span cover all of R^2?
# Yes iff det(A) != 0
print('det(A):', np.linalg.det(A)) # -1.0 (nonzero -> span = R^2)
The einsum string 'ij,j->i' is identical in NumPy, PyTorch (torch.einsum), and TensorFlow (tf.einsum). For over-determined systems (more equations than spanning vectors) where an exact solution may not exist, use np.linalg.lstsq — a non-zero residual means is not in the span.
The Null Space and Column Space Revisited
For :
- Null space is a subspace of .
- Column space is a subspace of (the span of the columns of ).
Both are subspaces — they are closed under the linear combinations that define those spaces. This is why the General = Particular + Homogeneous theorem works: is a genuine subspace, so we can form the coset .