TExcelTAD

Subspaces

A subspace is a vector space sitting inside a bigger one: a subset that is closed under addition and scaling. Instead of checking all eight axioms you only check three things. Subspaces of polynomial, matrix and function spaces are everywhere: symmetric matrices, polynomials with a given root, solutions of a linear equation.

The subspace test

A subset WW of a vector space VV is a subspace if it is a vector space with the same operations. Because the axioms (commutativity, distributivity, …) already hold in VV, it is enough to check:

# Condition
1 0∈W\mathbf{0} \in W
2 u,w∈W⇒u+w∈W\mathbf{u}, \mathbf{w} \in W \Rightarrow \mathbf{u} + \mathbf{w} \in W (closed under addition)
3 w∈W\mathbf{w} \in W, cc a scalar ⇒cw∈W\Rightarrow c\mathbf{w} \in W (closed under scaling)

Conditions 2 and 3 can be merged into one: u,w∈W⇒au+bw∈W\mathbf{u}, \mathbf{w} \in W \Rightarrow a\mathbf{u} + b\mathbf{w} \in W. This is the same test used for Subspaces of Rn\mathbb{R}^n, now applied in any space. The quickest way to rule a set out is usually condition 1: if 0\mathbf{0} is missing, stop.

Examples and non-examples

Set WW In VV Subspace? Reason
{p:p(1)=0}\{p : p(1) = 0\} PnP_n yes (p+q)(1)=0+0(p + q)(1) = 0 + 0, (cp)(1)=c⋅0(cp)(1) = c \cdot 0
{p:p(0)=1}\{p : p(0) = 1\} PnP_n no 0∉W0 \notin W
even functions f(−x)=f(x)f(-x) = f(x) F(R)F(\mathbb{R}) yes sums and multiples of even functions are even
symmetric matrices AT=AA^T = A Mn×nM_{n \times n} yes (A+B)T=A+B(A + B)^T = A + B, (cA)T=cA(cA)^T = cA
upper triangular matrices Mn×nM_{n \times n} yes zeros below the diagonal stay zeros
matrices with det⁡A=0\det A = 0 M2×2M_{2 \times 2} no diag⁡(1,0)+diag⁡(0,1)=I\operatorname{diag}(1, 0) + \operatorname{diag}(0, 1) = I has det⁡1\det 1
solutions of y′′+y=0y'' + y = 0 F(R)F(\mathbb{R}) yes the equation is linear and homogeneous
solutions of y′′+y=1y'' + y = 1 F(R)F(\mathbb{R}) no y=0y = 0 is not a solution
differentiable functions C(R)C(\mathbb{R}) yes sums and multiples of differentiable functions are differentiable
{(x,y):xy=0}\{(x, y) : xy = 0\} (the two axes) R2\mathbb{R}^2 no (1,0)+(0,1)=(1,1)(1, 0) + (0, 1) = (1, 1)

The pattern: sets described by homogeneous linear conditions ("= 0", built from sums and scalar multiples) are subspaces. Anything with "= 1", a product of unknowns, an inequality or a determinant usually is not.

python · try it yourself
from sympy import Matrix

# matrices with det = 0 are not closed under addition
A, B = Matrix([[1, 0], [0, 0]]), Matrix([[0, 0], [0, 1]])
print("det A =", A.det(), " det B =", B.det(), " det(A+B) =", (A + B).det())

# symmetric matrices are closed under combinations
S, T = Matrix([[1, 2], [2, 5]]), Matrix([[0, -3], [-3, 4]])
C = 3 * S - 2 * T
print("3S - 2T =", C.tolist(), " symmetric:", C == C.T)
det A = 0  det B = 0  det(A+B) = 1
3S - 2T = [[3, 12], [12, 7]]  symmetric: True

Finding a basis of a subspace

A subspace defined by linear conditions is the null space of a matrix once you use coordinates. Example: W={p∈P3:p(1)=0 and p′(1)=0}W = \{p \in P_3 : p(1) = 0 \text{ and } p'(1) = 0\}. Write p=a+bx+cx2+dx3p = a + bx + cx^2 + dx^3:

p(1)=a+b+c+d=0p′(1)=b+2c+3d=0→the null space of [11110123]\begin{aligned} p(1) &= a + b + c + d = 0 \\ p'(1) &= b + 2c + 3d = 0 && \to \quad \text{the null space of } \begin{bmatrix} 1 & 1 & 1 & 1 \\ 0 & 1 & 2 & 3 \end{bmatrix} \end{aligned}

Two independent equations in four unknowns leave a 2-dimensional subspace:

python · try it yourself
from sympy import Matrix, symbols, factor

x = symbols("x")
conditions = Matrix([[1, 1, 1, 1], [0, 1, 2, 3]])
for v in conditions.nullspace():
    p = sum(c * x**i for i, c in enumerate(v))
    print(list(v), "->", p, "=", factor(p))
[1, -2, 1, 0] -> x**2 - 2*x + 1 = (x - 1)**2
[2, -3, 0, 1] -> x**3 - 3*x + 2 = (x - 1)**2*(x + 2)

Both basis polynomials have the factor (x−1)2(x - 1)^2, as they must: p(1)=p′(1)=0p(1) = p'(1) = 0 means 1 is a double root. So W={(x−1)2⋅(αx+β)}W = \{(x - 1)^2 \cdot (\alpha x + \beta)\}, all cubics with a double root at 1.

Building new subspaces

If UU and WW are subspaces of VV:

Construction Subspace?
U∩WU \cap W (vectors in both) always
U∪WU \cup W (vectors in either) only if one contains the other
U+W={u+w:u∈U,w∈W}U + W = \{\mathbf{u} + \mathbf{w} : \mathbf{u} \in U, \mathbf{w} \in W\} always; the smallest subspace containing both
span⁡{v1,…,vk}\operatorname{span}\{\mathbf{v}_1, \ldots, \mathbf{v}_k\} always; the smallest subspace containing the vi\mathbf{v}_i

The union fails for the xx-axis and the yy-axis in R2\mathbb{R}^2 (see the table above); their sum is all of R2\mathbb{R}^2.

In software

  • Constraints in solvers: "the result must satisfy these linear equations" defines a subspace (or a shifted one); constrained least squares and physics joint solvers project onto it.
  • Data validation: symmetric matrices (covariances, distance matrices) are a subspace, so averaging them or adding them keeps them symmetric, but a determinant or rank condition does not survive averaging.
  • Linear codes: a code is a subspace of GF(2)n\mathrm{GF}(2)^n, which is what makes encoding a matrix product and decoding a null-space check (Application: Error Correcting Codes).
  • ML: LoRA restricts a weight update to a low-dimensional set of matrices; fine-tuning in a subspace keeps updates cheap (Low-Rank Approximation).

Exercises

Exercise 1: Skew-symmetric matrices

Is {A∈M3×3:AT=−A}\{A \in M_{3 \times 3} : A^T = -A\} a subspace? What does a general element look like, and what is its dimension?

Answer

Yes. A general element is [0ab−a0c−b−c0]\begin{bmatrix} 0 & a & b \\ -a & 0 & c \\ -b & -c & 0 \end{bmatrix}; the dimension is 3.

Solution

0T=0=−00^T = 0 = -0; (A+B)T=AT+BT=−A−B=−(A+B)(A + B)^T = A^T + B^T = -A - B = -(A + B); (cA)T=c⋅AT=−cA(cA)^T = c \cdot A^T = -cA. The diagonal must satisfy aii=−aiia_{ii} = -a_{ii}, so it is 0, and the entries below the diagonal are minus those above. The three entries above the diagonal are free.

Exercise 2: Equal endpoints

Is W={f∈C[0,1]:f(0)=f(1)}W = \{f \in C[0, 1] : f(0) = f(1)\} a subspace of C[0,1]C[0, 1]? What about {f:f(0)=f(1)+1}\{f : f(0) = f(1) + 1\}?

Answer

The first is a subspace; the second is not.

Solution

f(0)=f(1)f(0) = f(1) is the homogeneous linear condition f(0)−f(1)=0f(0) - f(1) = 0: the zero function satisfies it, and (af+bg)(0)−(af+bg)(1)=a⋅0+b⋅0=0(af + bg)(0) - (af + bg)(1) = a \cdot 0 + b \cdot 0 = 0. The second condition fails for the zero function, since 0≠0+10 \ne 0 + 1.

Exercise 3: A union

Let UU be the xx-axis and WW the line y=xy = x in R2\mathbb{R}^2. Is U∪WU \cup W a subspace? Describe U+WU + W.

Answer

U∪WU \cup W is not a subspace; U+W=R2U + W = \mathbb{R}^2.

Solution

(1,0)∈U(1, 0) \in U and (1,1)∈W(1, 1) \in W, but their sum (2,1)(2, 1) is on neither line. U+WU + W contains (1,0)(1, 0) and (1,1)(1, 1), which are independent, so it is all of R2\mathbb{R}^2: (x,y)=(x−y)(1,0)+y(1,1)(x, y) = (x - y)(1, 0) + y(1, 1).

Exercise 4: Polynomials vanishing at two points

Find a basis and the dimension of W={p∈P3:p(1)=0 and p(−1)=0}W = \{p \in P_3 : p(1) = 0 \text{ and } p(-1) = 0\}, using SymPy.

Answer

dim⁡W=2\dim W = 2; a basis is x2−1x^2 - 1 and x3−xx^3 - x (that is, (x2−1)⋅1(x^2 - 1) \cdot 1 and (x2−1)⋅x(x^2 - 1) \cdot x).

Solution
p(1)=a+b+c+d=0p(−1)=a−b+c−d=0\begin{aligned} p(1) &= a + b + c + d = 0 \\ p(-1) &= a - b + c - d = 0 \end{aligned}
python · try it yourself
from sympy import Matrix, symbols, factor

x = symbols("x")
for v in Matrix([[1, 1, 1, 1], [1, -1, 1, -1]]).nullspace():
    p = sum(c * x**i for i, c in enumerate(v))
    print(list(v), "->", factor(p))
[-1, 0, 1, 0] -> (x - 1)*(x + 1)
[0, -1, 0, 1] -> x*(x - 1)*(x + 1)

SymPy's basis is (x−1)(x+1)=x2−1(x - 1)(x + 1) = x^2 - 1 and x(x−1)(x+1)=x3−xx(x - 1)(x + 1) = x^3 - x, matching the answer.

Test yourself

Which set is a subspace of M2×2M_{2 \times 2}?

  1. Matrices with determinant 0
  2. Invertible matrices
  3. Matrices whose entries add up to 0
  4. Matrices with entry (1,1)(1,1) equal to 1

What is the quickest way to show that a set is NOT a subspace?

  1. Find two elements whose sum is in the set
  2. Show the zero vector is not in it, or find a sum or multiple that leaves it
  3. Show it is infinite
  4. Show it has a basis

If UU and WW are subspaces, which of these is always a subspace?

  1. U∪WU \cup W
  2. U∩WU \cap W
  3. The complement of UU
  4. UU minus WW