Linear Independence
A set of vectors is linearly independent when none of them is redundant: no vector can be built from the others. Independence is the property that makes coordinates unique, and its failure in data (one feature that is a combination of others) is a common source of broken regressions.
Definition
Vectors are linearly independent if the only solution of
is the trivial one, . Otherwise they are linearly dependent, and a non-trivial solution is called a linear dependence relation.
Equivalent formulation: the vectors are dependent exactly when one of them is a linear combination of the others. If, say, in a dependence relation, divide by it and solve for .
Quick facts:
| Situation | Independent? |
|---|---|
| one vector | yes, unless |
| two vectors | yes, unless one is a multiple of the other |
| any set containing | no ( is a non-trivial relation) |
| more than vectors in | always dependent |
| a subset of an independent set | independent |
The test: pivots in every column
Put the vectors as columns of . Independence means has only , i.e. the homogeneous system has no free variables (Homogeneous Systems). So:
are independent has a pivot in every column .
This also proves the "more than vectors" fact: an matrix with has at most pivots, so some column has none.
When the vectors are dependent, the null space of lists every dependence relation:
from sympy import Matrix
v1, v2, v3 = Matrix([1, 2, 1]), Matrix([0, 1, 3]), Matrix([2, 7, 11])
A = Matrix.hstack(v1, v2, v3)
R, piv = A.rref()
print("pivot columns:", piv, "-> independent:", len(piv) == A.cols)
rel = A.nullspace()[0]
print("dependence relation coefficients:", list(rel))
print("check:", list(rel[0] * v1 + rel[1] * v2 + rel[2] * v3))
B = Matrix.hstack(Matrix([1, 0, 1]), Matrix([1, 1, 0]), Matrix([0, 1, 1]))
print("B pivots:", B.rref()[1], "-> independent:", B.rank() == 3)pivot columns: (0, 1) -> independent: False
dependence relation coefficients: [-2, -3, 1]
check: [0, 0, 0]
B pivots: (0, 1, 2) -> independent: True
The relation says .
Why independence matters: unique coordinates
If are independent and , the coefficients are unique. Proof: if also , subtract to get , and independence forces every . With dependent vectors, every in the span has infinitely many representations. This is why a basis must be independent (Basis and Dimension).
In software: redundant features
In a data matrix (rows = samples, columns = features), a column that is a linear combination of other columns carries no new information. Typical causes: the same quantity in two units, a "total" column next to its parts, or one-hot encoding every category plus an intercept (the "dummy variable trap").
Then the columns are dependent, , is singular, and ordinary least squares has no unique solution: infinitely many weight vectors fit equally well, and numerical solvers return huge, unstable coefficients.
import numpy as np
rng = np.random.default_rng(3)
n = 200
width = rng.uniform(1, 10, n)
height = rng.uniform(1, 10, n)
perimeter = 2 * width + 2 * height # redundant: a combination of two others
X = np.column_stack([width, height, perimeter])
print("columns:", X.shape[1], " rank:", int(np.linalg.matrix_rank(X)))
print(f"condition number of X^T X: {np.linalg.cond(X.T @ X):.1e}")
# null space from the SVD: the right singular vector for the ~0 singular value
_, s, Vt = np.linalg.svd(X)
relation = Vt[-1] / Vt[-1][0]
print("smallest singular value ~ 0:", s[-1] < 1e-9)
print("relation (scaled):", np.round(relation, 4).tolist())columns: 3 rank: 2
condition number of X^T X: 1.7e+16
smallest singular value ~ 0: True
relation (scaled): [1.0, 1.0, -0.5]
The relation reads . Libraries respond with warnings ("singular matrix", "collinearity"); scikit-learn's OneHotEncoder(drop="first") and regularisation (Regularization) are standard fixes. Near-dependence (features that are almost combinations of others) causes the same instability in a milder form, called multicollinearity.
Exercises
Exercise 1: By inspection
Decide without computing: (a) , (b) , (c) .
Answer
All three are dependent.
Solution
(a) . (b) The set contains the zero vector. (c) Three vectors in are always dependent.
Exercise 2: Find a relation
Show that [1, 1, 0], [0, 1, 1], [1, 3, 2] are dependent and write the third as a combination of the first two.
Answer
.
Solution
from sympy import Matrix
A = Matrix([[1, 0, 1], [1, 1, 3], [0, 1, 2]])
print(A.rank(), list(A.nullspace()[0]))2 [-1, -2, 1]
The null-space vector is the relation .
Exercise 3: Choose h
For which are , , dependent?
Answer
.
Solution
Row-reduce the matrix with these columns:
There is a pivot in every column unless . So they are dependent exactly when . (Check : ✓.)
Exercise 4: Detect a redundant column
Build a 100×4 data matrix with seeded random columns , , and a fourth column . Use np.linalg.matrix_rank to show the redundancy, then drop and check the rank is full.
Answer
Rank 3 with , rank 3 (full, 3 columns) without it.
Solution
import numpy as np
rng = np.random.default_rng(0)
a, b, c = rng.normal(size=(3, 100))
X = np.column_stack([a, b, c, a - 3 * c])
print("rank with d:", int(np.linalg.matrix_rank(X)), "of", X.shape[1])
print("rank without d:", int(np.linalg.matrix_rank(X[:, :3])), "of", 3)rank with d: 3 of 4
rank without d: 3 of 3
Test yourself
Five vectors in are given. What can you conclude?
- They are independent
- They are dependent
- They span
- Nothing
The vectors are the columns of . Which condition means they are linearly independent?
- has a pivot in every column
- has a pivot in every row
- is square
- has no zero entries
A dataset has columns price_usd and . What happens to ?
- It becomes the identity
- It becomes skew-symmetric
- Nothing
- It becomes singular, so least squares has no unique solution