AI Knowledge Tree

Span, independence, basis, dimension

Build span and linear independence into the notion of a basis, prove that dimension is well defined, and read off coordinates in any basis.

⏱ 32 minPrerequisites:Vector spaces & subspaces

A subspace is defined by closure under linear combination, but that tells you nothing about how many vectors you need to generate it, or whether some of them are redundant. This lesson makes those questions precise.

Span

The span of a set of vectors {v1,…,vk}⊆V\{v_1, \dots, v_k\} \subseteq V is the set of all linear combinations:

span⁡(v1,…,vk)={c1v1+⋯+ckvk:ci∈R}.\operatorname{span}(v_1, \dots, v_k) = \left\{ c_1 v_1 + \cdots + c_k v_k : c_i \in \mathbb{R} \right\}.

Span is always a subspace (closure is built in by definition), and it is the smallest subspace containing every viv_i. "Smallest" means: any subspace that contains all viv_i must contain their span.

Linear independence

A list v1,…,vkv_1, \dots, v_k is linearly independent if the only solution to

c1v1+⋯+ckvk=0c_1 v_1 + \cdots + c_k v_k = 0

is c1=⋯=ck=0c_1 = \cdots = c_k = 0. Otherwise the list is linearly dependent, and at least one vector in it can be written as a combination of the others (subtract the nonzero-coefficient term from both sides).

The condition captures redundancy: a dependent list contains at least one vector that contributes nothing to the span, because it already lives in the span of its neighbors.

Basis and coordinates

A basis of VV is a list that is both spanning and independent. The two conditions together are precisely what is needed to give every element of VV a unique representation[1].

Theorem. If {e1,…,en}\{e_1, \dots, e_n\} is a basis of VV, then every v∈Vv \in V can be written as v=x1e1+⋯+xnenv = x_1 e_1 + \cdots + x_n e_n for a unique tuple (x1,…,xn)∈Rn(x_1, \dots, x_n) \in \mathbb{R}^n.

Proof. Spanning gives existence. Suppose there are two representations:

v=x1e1+⋯+xnen=y1e1+⋯+ynen.v = x_1 e_1 + \cdots + x_n e_n = y_1 e_1 + \cdots + y_n e_n.

Subtracting: (x1−y1)e1+⋯+(xn−yn)en=0(x_1 - y_1)e_1 + \cdots + (x_n - y_n)e_n = 0. Independence forces each coefficient to be zero, so xi=yix_i = y_i for all ii. ■\qquad\blacksquare

The unique tuple (x1,…,xn)(x_1, \dots, x_n) is the coordinate vector of vv in the given basis. Coordinates turn abstract vector-space arguments into concrete Rn\mathbb{R}^n computations.

Dimension is well defined

Different bases of the same space might have different sizes, in principle. The exchange lemma shows they cannot.

Exchange lemma. If {u1,…,um}\{u_1, \dots, u_m\} spans VV and {w1,…,wk}\{w_1, \dots, w_k\} is linearly independent in VV, then k≤mk \le m[2].

Proof sketch. Each wiw_i can be written in terms of the uju_j. Start with the spanning set and swap in w1w_1: since it is a nontrivial combination of the uju_j, at least one uju_j is redundant once w1w_1 is present; remove it. The resulting set still spans VV. Repeat for w2,…,wkw_2, \dots, w_k: each swap removes one uju_j and the spanning property is preserved. We can only do this while uju_j are available, so k≤mk \le m. ■\qquad\blacksquare

Corollary. All bases of VV have the same number of elements.

Proof. If B1B_1 has mm elements and B2B_2 has kk: applying the lemma with B1B_1 spanning and B2B_2 independent gives k≤mk \le m; then swap roles to get m≤km \le k. So m=km = k. ■\qquad\blacksquare

The common size is the dimension dim⁡V\dim V. For Rn\mathbb{R}^n it is nn; for degree-≤d\le d polynomials it is d+1d+1.

Two independent vectors form a basis that tiles the whole plane with integer combinations (left); a dependent pair spans only a line (right).
Two independent vectors form a basis that tiles the whole plane with integer combinations (left); a dependent pair spans only a line (right).

Checking bases numerically

A finite set of vectors in Rn\mathbb{R}^n forms a basis for its span when the matrix whose columns are those vectors has full column rank. Gaussian elimination (or the SVD) reveals rank, and hence whether independence holds.

python · numpy
import numpy as np

# Candidate basis for R^3
B = np.column_stack([
    [1.0, 0.0, 2.0],   # b1
    [0.0, 1.0,-1.0],   # b2
    [2.0, 1.0, 3.0],   # b3 = 2*b1 + b2 -> dependent!
])

rank = np.linalg.matrix_rank(B)
print("rank:", rank)   # 2, not 3 -> columns are dependent

# A genuinely independent set:
B2 = np.column_stack([
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
    [0.0, 0.0, 1.0],
])
print("rank:", np.linalg.matrix_rank(B2))  # 3 -> basis for R^3

# Coordinates of v in the B2 basis (trivial here, but general route: solve Bx=v):
v = np.array([3.0, -1.0, 5.0])
x = np.linalg.solve(B2, v)
print("coordinates:", x)  # [3, -1, 5]

The rank check catches the dependent column; solving the system recovers coordinates.

Exercises

Exercise 1. Decide whether v1=(1,2,1)v_1 = (1, 2, 1), v2=(2,1,0)v_2 = (2, 1, 0), v3=(4,5,2)v_3 = (4, 5, 2) are linearly independent in R3\mathbb{R}^3. If they are dependent, exhibit an explicit nontrivial combination equal to 00.

Solution

Step 1. Test for a relation c1v1+c2v2+c3v3=0c_1 v_1 + c_2 v_2 + c_3 v_3 = 0. Try the guess v3=a v1+b v2v_3 = a\,v_1 + b\,v_2 suggested by the entries. The third coordinate gives 2=a⋅1+b⋅02 = a\cdot 1 + b\cdot 0, so a=2a = 2.

Step 2. The first coordinate gives 4=2⋅1+b⋅24 = 2\cdot 1 + b\cdot 2, so b=1b = 1. Check the second coordinate: 2⋅2+1⋅1=52\cdot 2 + 1\cdot 1 = 5, which matches v3v_3's second entry.

Step 3. So v3=2v1+v2v_3 = 2 v_1 + v_2, i.e. 2v1+v2−v3=02 v_1 + v_2 - v_3 = 0 with coefficients (2,1,−1)≠0(2, 1, -1) \neq 0. The list is linearly dependent.

Exercise 2. Let {e1,e2}\{e_1, e_2\} be a basis of a 2-dimensional space VV, and set f1=e1+e2f_1 = e_1 + e_2, f2=e1−e2f_2 = e_1 - e_2. Show {f1,f2}\{f_1, f_2\} is also a basis, and find the coordinates of v=3e1+e2v = 3 e_1 + e_2 in the basis {f1,f2}\{f_1, f_2\}.

Solution

Step 1. By the corollary, any independent list of dim⁡V=2\dim V = 2 vectors in VV is a basis, so it suffices to show independence. Suppose c1f1+c2f2=0c_1 f_1 + c_2 f_2 = 0. Expanding, (c1+c2)e1+(c1−c2)e2=0(c_1 + c_2) e_1 + (c_1 - c_2) e_2 = 0. Independence of {e1,e2}\{e_1, e_2\} forces c1+c2=0c_1 + c_2 = 0 and c1−c2=0c_1 - c_2 = 0, hence c1=c2=0c_1 = c_2 = 0. So {f1,f2}\{f_1, f_2\} is independent and therefore a basis.

Step 2. Write v=x1f1+x2f2=(x1+x2)e1+(x1−x2)e2v = x_1 f_1 + x_2 f_2 = (x_1 + x_2) e_1 + (x_1 - x_2) e_2. Matching against v=3e1+e2v = 3 e_1 + e_2 gives x1+x2=3x_1 + x_2 = 3 and x1−x2=1x_1 - x_2 = 1.

Step 3. Adding the two equations: 2x1=42 x_1 = 4, so x1=2x_1 = 2 and x2=1x_2 = 1. The coordinate vector of vv in {f1,f2}\{f_1, f_2\} is (2,1)(2, 1). Check: 2f1+f2=2(e1+e2)+(e1−e2)=3e1+e22 f_1 + f_2 = 2(e_1 + e_2) + (e_1 - e_2) = 3 e_1 + e_2.

Exercise 3 (code). The polynomials of degree at most 22 form a space of dimension 33 with standard basis {1,t,t2}\{1, t, t^2\}. Represent 1+t1 + t, 1−t1 - t, and t2t^2 by their coordinate vectors in that basis, and verify numerically that they form a basis of the space (full rank), then recover the coordinates of p(t)=5+3t−2t2p(t) = 5 + 3t - 2t^2 in this new basis.

Solution
python · numpy
import numpy as np

# Columns are coordinate vectors in the standard basis {1, t, t^2}.
B = np.column_stack([
    [1.0, 1.0, 0.0],   # 1 + t
    [1.0, -1.0, 0.0],  # 1 - t
    [0.0, 0.0, 1.0],   # t^2
])

assert np.linalg.matrix_rank(B) == 3   # full rank -> basis of degree<=2 polys

p = np.array([5.0, 3.0, -2.0])         # 5 + 3t - 2t^2 in standard coords
x = np.linalg.solve(B, p)              # coordinates in the new basis
print("coordinates:", x)               # [4, 1, -2]

# Reconstruct: x0*(1+t) + x1*(1-t) + x2*t^2 must equal p.
assert np.allclose(B @ x, p)

The new vectors have full rank, so they are a basis, and the recovered coordinates (4,1,−2)(4, 1, -2) rebuild pp: 4(1+t)+1(1−t)−2t2=5+3t−2t24(1 + t) + 1(1 - t) - 2 t^2 = 5 + 3t - 2t^2.

With the space and its dimension pinned down, the next lesson asks what happens to dimension when a linear map connects two spaces.


References

  1. [1]Axler, S. (2015). Linear Algebra Done Right (3rd ed.), ch. 2. Springer. Span, independence, and bases (doi:10.1007/978-3-319-11080-6).↩
  2. [2]Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press. The exchange argument and the well-definedness of dimension.↩