TExcelTAD
Home › Linear Algebra & Matrix Theory › Linear Combinations, Span and Linear Independence

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 VV

Let v1,…,vk\mathbf{v}_1, \ldots, \mathbf{v}_k be vectors in VV.

Term Meaning
linear combination c1v1+c2v2+⋯+ckvkc_1\mathbf{v}_1 + c_2\mathbf{v}_2 + \cdots + c_k\mathbf{v}_k for scalars c1,…,ckc_1, \ldots, c_k
span⁡{v1,…,vk}\operatorname{span}\{\mathbf{v}_1, \ldots, \mathbf{v}_k\} the set of all linear combinations; always a subspace of VV
spans VV every vector of VV is some linear combination
linearly independent c1v1+⋯+ckvk=0c_1\mathbf{v}_1 + \cdots + c_k\mathbf{v}_k = \mathbf{0} only when c1=⋯=ck=0c_1 = \cdots = c_k = 0
linearly dependent some nontrivial combination gives 0\mathbf{0}, so one vi\mathbf{v}_i is a combination of the others

The empty combination is 0\mathbf{0}, so span⁡{}={0}\operatorname{span}\{\} = \{\mathbf{0}\}. A list containing the zero vector is always dependent (1⋅0=01 \cdot \mathbf{0} = \mathbf{0} is a nontrivial combination).

Polynomials as coordinate columns

A polynomial a+bx+cx2a + bx + cx^2 in P2P_2 is determined by its coefficients (a,b,c)(a, b, c). Addition and scaling of polynomials match addition and scaling of these columns, so questions about polynomials become questions about R3\mathbb{R}^3.

Are p1=1+xp_1 = 1 + x, p2=x+x2p_2 = x + x^2, p3=1+x2p_3 = 1 + x^2 independent, and do they span P2P_2? Put their coefficient columns side by side:

p1p2p31101x110x2011det⁡=1⋅(1⋅1−0⋅1)−0+1⋅(1⋅1−1⋅0)=2≠0\begin{array}{c|ccc} & p_1 & p_2 & p_3 \\ \hline 1 & 1 & 0 & 1 \\ x & 1 & 1 & 0 \\ x^2 & 0 & 1 & 1 \end{array} \qquad \det = 1 \cdot (1 \cdot 1 - 0 \cdot 1) - 0 + 1 \cdot (1 \cdot 1 - 1 \cdot 0) = 2 \ne 0

The determinant is nonzero, so the only solution of c1p1+c2p2+c3p3=0c_1p_1 + c_2p_2 + c_3p_3 = 0 is c=0\mathbf{c} = \mathbf{0} (independent), and every (a,b,c)(a, b, c) is reached (they span P2P_2). To write a specific polynomial as a combination, solve the system:

python · try it yourself
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 3+5x−2x2=5p1+0p2−2p33 + 5x - 2x^2 = 5p_1 + 0p_2 - 2p_3: indeed 5(1+x)−2(1+x2)=3+5x−2x25(1 + x) - 2(1 + x^2) = 3 + 5x - 2x^2.

Matrices as columns

The same works in M2×2M_{2 \times 2} by listing the four entries. Are A=[1001]A = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}, B=[0110]B = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} and C=[1111]C = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} independent? Their entry lists are (1,0,0,1)(1, 0, 0, 1), (0,1,1,0)(0, 1, 1, 0), (1,1,1,1)(1, 1, 1, 1), and C=A+BC = A + B. So A+B−C=0A + B - C = 0 is a nontrivial combination: they are dependent, and span⁡{A,B,C}=span⁡{A,B}\operatorname{span}\{A, B, C\} = \operatorname{span}\{A, B\} is only two-dimensional.

Functions: identities and sample points

Functions in F(R)F(\mathbb{R}) have no finite coefficient list, but independence is still the question "does c1f1+⋯+ckfk=0c_1f_1 + \cdots + c_kf_k = 0 (the zero function) force all ci=0c_i = 0?".

  • sin⁡x\sin x and cos⁡x\cos x are independent: c1sin⁡x+c2cos⁡x=0c_1\sin x + c_2\cos x = 0 at x=0x = 0 gives c2=0c_2 = 0, and at x=π/2x = \pi/2 gives c1=0c_1 = 0.
  • 11, sin⁡2x\sin^2 x and cos⁡2x\cos^2 x are dependent: sin⁡2x+cos⁡2x−1=0\sin^2 x + \cos^2 x - 1 = 0 for all xx.

A useful test: evaluate the functions at a few sample points xjx_j 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.

python · try it yourself
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 (x+1)2=1+2x+x2(x + 1)^2 = 1 + 2x + x^2. 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 total=a+b\text{total} = a + b), 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 1,x−1,(x−1)21, x - 1, (x - 1)^2 independent in P2P_2? Write 3+2x+x23 + 2x + x^2 as a combination of them.

Answer

Yes; 3+2x+x2=6+4(x−1)+(x−1)23 + 2x + x^2 = 6 + 4(x - 1) + (x - 1)^2.

Solution

Coefficient columns (1,0,0)(1, 0, 0), (−1,1,0)(-1, 1, 0), (1,−2,1)(1, -2, 1) form an upper triangular matrix with diagonal 1, 1, 1, so det⁡=1≠0\det = 1 \ne 0: independent. For the combination, put u=x−1u = x - 1, so x=u+1x = u + 1:

3+2(u+1)+(u+1)2=3+2u+2+u2+2u+1=6+4u+u2check at x=1: 3+2+1=6✓\begin{aligned} &3 + 2(u + 1) + (u + 1)^2 = 3 + 2u + 2 + u^2 + 2u + 1 = 6 + 4u + u^2 \\ &\text{check at } x = 1: \ 3 + 2 + 1 = 6 \quad \checkmark \end{aligned}

This is the Taylor expansion of the polynomial around x=1x = 1.

Exercise 2: Dependent matrices

Show that [1201]\begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}, [0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} and [23−12]\begin{bmatrix} 2 & 3 \\ -1 & 2 \end{bmatrix} are linearly dependent by finding the combination.

Answer

2⋅[1201]−[0110]=[23−12]2 \cdot \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} - \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 2 & 3 \\ -1 & 2 \end{bmatrix}.

Solution

Solve a⋅M1+b⋅M2=M3a \cdot M_1 + b \cdot M_2 = M_3 entry by entry: top-left a=2a = 2, bottom-right a=2a = 2, bottom-left b=−1b = -1, top-right 2a+b=4−1=32a + b = 4 - 1 = 3 ✓\checkmark. So 2M1−M2−M3=02M_1 - M_2 - M_3 = 0.

Exercise 3: Is it in the span?

Is x2x^2 in span⁡{1+x2,x−x2,1+x}\operatorname{span}\{1 + x^2, x - x^2, 1 + x\}?

Answer

No. The three polynomials are dependent and span only a plane in P2P_2, which misses x2x^2.

Solution
columns (1,0,1),(0,1,−1),(1,1,0)(third = first + second)solve a(1,0,1)+b(0,1,−1)+c(1,1,0)=(0,0,1):a+c=0,b+c=0,a−b=1from the first two: a=b=−c→a−b=0≠1→no solution\begin{aligned} &\text{columns } (1, 0, 1), (0, 1, -1), (1, 1, 0) && \text{(third = first + second)} \\ &\text{solve } a(1, 0, 1) + b(0, 1, -1) + c(1, 1, 0) = (0, 0, 1): \\ &\quad a + c = 0, \quad b + c = 0, \quad a - b = 1 \\ &\quad \text{from the first two: } a = b = -c \quad \to \quad a - b = 0 \ne 1 \quad \to \quad \text{no solution} \end{aligned}

Exercise 4: Exponentials are independent

Prove that exe^x, e2xe^{2x} and e3xe^{3x} are linearly independent by evaluating at x=0,1,2x = 0, 1, 2 and computing a determinant.

Answer

The 3×33 \times 3 matrix of values has determinant e4(e−1)3(e+1)≈1029.92≠0e^4(e - 1)^3(e + 1) \approx 1029.92 \ne 0, so the only combination vanishing at those three points, let alone everywhere, is the trivial one.

Solution

Row jj holds the values at x=jx = j. With t=ext = e^{x}, the rows are (t,t2,t3)(t, t^2, t^3) for t=1,e,e2t = 1, e, e^2: a Vandermonde-type matrix. Its determinant is t1t2t3⋅(t2−t1)(t3−t1)(t3−t2)=e3⋅(e−1)(e2−1)(e2−e)=e4(e−1)3(e+1)t_1t_2t_3 \cdot (t_2 - t_1)(t_3 - t_1)(t_3 - t_2) = e^3 \cdot (e - 1)(e^2 - 1)(e^2 - e) = e^4(e - 1)^3(e + 1), nonzero because 1,e,e21, e, e^2 are distinct and nonzero.

python · try it yourself
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?

  1. sin⁡x,cos⁡x\sin x, \cos x
  2. 1,x,x21, x, x^2
  3. 1,sin⁡2x,cos⁡2x1, \sin^2 x, \cos^2 x
  4. ex,e2xe^x, e^{2x}

How can you test whether three polynomials in P2P_2 span P2P_2?

  1. Check that each has degree 2
  2. Put their coefficient vectors in a 3×33 \times 3 matrix and check that its determinant is nonzero
  3. Check that they have a common root
  4. Add them and see whether the sum is 0

Any list of vectors that contains the zero vector is…

  1. independent
  2. dependent
  3. a basis
  4. spanning