Linear Combinations, Span and Linear Independence
Linear combinations, spans and linear independence were defined for column vectors in Spans and Linear Independence. The definitions use only addition and scaling, so they work word for word in any vector space. The practical trick for polynomials and matrices is to turn each vector into a column of coordinates and then row reduce as before.
The definitions, in any vector space
Let be vectors in .
| Term | Meaning |
|---|---|
| linear combination | for scalars |
| the set of all linear combinations; always a subspace of | |
| spans | every vector of is some linear combination |
| linearly independent | only when |
| linearly dependent | some nontrivial combination gives , so one is a combination of the others |
The empty combination is , so . A list containing the zero vector is always dependent ( is a nontrivial combination).
Polynomials as coordinate columns
A polynomial in is determined by its coefficients . Addition and scaling of polynomials match addition and scaling of these columns, so questions about polynomials become questions about .
Are , , independent, and do they span ? Put their coefficient columns side by side:
The determinant is nonzero, so the only solution of is (independent), and every is reached (they span ). To write a specific polynomial as a combination, solve the system:
from sympy import symbols, Poly, Matrix, linsolve
x, c1, c2, c3 = symbols("x c1 c2 c3")
p = [1 + x, x + x**2, 1 + x**2]
target = 3 + 5 * x - 2 * x**2
coords = lambda q: [Poly(q, x).coeff_monomial(x**i) for i in range(3)] # (a, b, c)
M = Matrix([coords(q) for q in p]).T # columns = coefficient vectors
print("matrix:", M.tolist(), " det =", M.det())
sol = linsolve((M, Matrix(coords(target))), c1, c2, c3)
print("coefficients:", sol)
(a, b, c), = sol
print("check:", (a * p[0] + b * p[1] + c * p[2]).expand())matrix: [[1, 0, 1], [1, 1, 0], [0, 1, 1]] det = 2
coefficients: {(5, 0, -2)}
check: -2*x**2 + 5*x + 3
So : indeed .
Matrices as columns
The same works in by listing the four entries. Are , and independent? Their entry lists are , , , and . So is a nontrivial combination: they are dependent, and is only two-dimensional.
Functions: identities and sample points
Functions in have no finite coefficient list, but independence is still the question "does (the zero function) force all ?".
- and are independent: at gives , and at gives .
- , and are dependent: for all .
A useful test: evaluate the functions at a few sample points and form the matrix of values. If that matrix has full column rank, the functions are independent (a dependency would make the same combination of columns zero). If the rank is lower, the functions may be dependent, or the points were badly chosen; then look for an identity.
import numpy as np
xs = np.array([0.3, 1.1, 2.0, 2.9, 4.2])
families = {
"sin, cos": [np.sin, np.cos],
"1, sin^2, cos^2": [np.ones_like, lambda t: np.sin(t)**2, lambda t: np.cos(t)**2],
"e^x, e^2x, e^3x": [np.exp, lambda t: np.exp(2 * t), lambda t: np.exp(3 * t)],
"1, x, x^2, (x+1)^2": [np.ones_like, lambda t: t, lambda t: t**2, lambda t: (t + 1)**2],
}
for name, fs in families.items():
V = np.column_stack([f(xs) for f in fs])
r = int(np.linalg.matrix_rank(V))
print(f"{name:20} rank {r} of {len(fs)} ->", "independent" if r == len(fs) else "dependent?")sin, cos rank 2 of 2 -> independent
1, sin^2, cos^2 rank 2 of 3 -> dependent?
e^x, e^2x, e^3x rank 3 of 3 -> independent
1, x, x^2, (x+1)^2 rank 3 of 4 -> dependent?
The last family is dependent because . The rank test is numerical; for a proof, use an identity (for dependence) or a nonzero determinant at specific points (for independence).
In software
- Feature engineering: if one feature column is a combination of others (say ), the design matrix loses rank and linear regression has no unique answer. Libraries warn about "collinearity" or drop a column.
- Polynomial and spline bases: choosing independent basis functions is what makes curve fitting and Bézier/B-spline evaluation well defined (Basis and Dimension).
- Embedding spaces: asking whether a new vector is in the span of known ones is a least-squares problem, used for analogy queries and for checking redundancy (Embeddings and Cosine Similarity).
Exercises
Exercise 1: Shifted powers
Are independent in ? Write as a combination of them.
Answer
Yes; .
Solution
Coefficient columns , , form an upper triangular matrix with diagonal 1, 1, 1, so : independent. For the combination, put , so :
This is the Taylor expansion of the polynomial around .
Exercise 2: Dependent matrices
Show that , and are linearly dependent by finding the combination.
Answer
.
Solution
Solve entry by entry: top-left , bottom-right , bottom-left , top-right . So .
Exercise 3: Is it in the span?
Is in ?
Answer
No. The three polynomials are dependent and span only a plane in , which misses .
Solution
Exercise 4: Exponentials are independent
Prove that , and are linearly independent by evaluating at and computing a determinant.
Answer
The matrix of values has determinant , so the only combination vanishing at those three points, let alone everywhere, is the trivial one.
Solution
Row holds the values at . With , the rows are for : a Vandermonde-type matrix. Its determinant is , nonzero because are distinct and nonzero.
from sympy import Matrix, exp, factor, N
M = Matrix([[exp(k * j) for k in (1, 2, 3)] for j in (0, 1, 2)])
d = M.det()
print("det =", factor(d))
print(" ~", N(d, 6))det = (-1 + E)**3*(1 + E)*exp(4)
~ 1029.92
Test yourself
Which list is linearly dependent?
How can you test whether three polynomials in span ?
- Check that each has degree 2
- Put their coefficient vectors in a matrix and check that its determinant is nonzero
- Check that they have a common root
- Add them and see whether the sum is 0
Any list of vectors that contains the zero vector is…
- independent
- dependent
- a basis
- spanning