Linear Independence and Bases
- Test a set of vectors for linear independence by solving the homogeneous equation
- Construct a basis for a subspace from a spanning set by removing dependent vectors via row reduction
- Compute the coordinate representation of a vector in a non-standard basis
- Explain why word and token embeddings implicitly define coordinate systems and what linear independence means in that context
Linear Independence
A set of vectors from a vector space is linearly independent if the only way to write as a linear combination is the trivial one:
If any non-trivial combination exists, the set is linearly dependent — at least one vector is redundant (it lies in the span of the others).
Testing for Independence
Form the matrix whose columns are and row-reduce . The set is independent iff the only solution is , i.e., iff every column contains a pivot (no free variables).
Dependency Relations
If the set is dependent, the reduction reveals the dependency: any free variable corresponds to a non-trivial combination equaling . This tells you exactly which vector is redundant and how to express it.
Example: are , , independent?
Free variable : set to get , . So — the set is dependent.
Basis
A basis for a vector space is a set of vectors that simultaneously:
- Spans : every vector in is a linear combination of the
- Is linearly independent: no vector is redundant
A basis is the minimal spanning set — remove any vector and it no longer spans. It is also the maximal independent set — add any vector and dependence appears.
Existence of Bases
Every vector space has a basis (this requires the Axiom of Choice for infinite-dimensional spaces, but is elementary for finite-dimensional ones). Starting from any spanning set, you can build a basis by removing redundant vectors one at a time until independence is achieved.
The Standard Basis for
The standard basis has equal to the column of the identity matrix with a in position :
Any vector is uniquely expressed as .
Other Bases for
The space of degree- polynomials has basis (standard) or equally — any three independent polynomials that span .
Unique Representation
The most important property of a basis is uniqueness of representation:
Theorem: if is a basis for , then every can be written as in exactly one way.
Proof: suppose . Subtracting: . Independence forces for all .
The coefficients are the coordinates of with respect to basis , written . Choosing a basis is choosing a coordinate system.
Why Bases Matter for ML
In machine learning, features are basis representations: the columns of a data matrix form (implicitly) a basis for the feature space. PCA changes basis to one aligned with the directions of maximum variance. Neural network weight matrices change basis between layers. Understanding what a basis is — a minimal, non-redundant, complete coordinate system — makes all of these operations transparent.
Testing Independence and Computing Representations
import numpy as np
# Columns of A are v1, v2, v3
A = np.array([[1., 0., 1.],
[2., 1., 4.],
[0., 1., 2.]])
# Rank via SVD: independent iff rank equals number of columns
_, S, Vh = np.linalg.svd(A, full_matrices=True)
rank = int(np.sum(S > 1e-9))
nullity = A.shape[1] - rank
print('rank:', rank) # 2 (< 3 → dependent)
print('nullity:', nullity) # 1
# Null vector reveals the dependency: c1*v1 + c2*v2 + c3*v3 = 0
null_vec = Vh[-1] # last row of Vh (smallest singular value)
c = null_vec / null_vec[-1] # scale so c3 = 1
print('dependency (c1,c2,c3):', np.round(c, 4)) # [-1. -2. 1.] → v3 = v1 + 2*v2
# Coordinate representation Rep_B(v): solve B @ coords = v
B = np.array([[1., 0., 0.],
[1., 1., 0.],
[0., 1., 1.]])
v = np.array([2., 3., 1.])
coords = np.linalg.solve(B, v)
print('Rep_B(v):', np.round(coords, 4))
print('verify: ', np.round(np.einsum('ij,j->i', B, coords), 4))
The einsum string 'ij,j->i' is the matrix–vector product , identical in NumPy, PyTorch (torch.einsum), and TensorFlow (tf.einsum). The SVD-based null vector is in an orthonormal basis; c = null_vec / null_vec[-1] rescales it to the free-variable parameterization from the row-reduction.