Skip to main content
© 2026 ePowerAI — instrumented learning, no login required.
CoursesContact
ePOWERAI
CoursesContact
Week 5: Vector Spaces, Independence, and Basis
Linear Algebra
01Start Here: Python and the Math the Labs Use
02Week 1: Vectors and Linear Combinations
03Week 2: Linear Transformations and Matrices
04Week 3: Elimination and LU Factorization
05Week 4: Determinants
06Week 5: Vector Spaces, Independence, and Basis
07Week 6: The Four Fundamental Subspaces
08Week 7: Orthogonality and Projections
09Week 8: Least Squares and QR
10Week 9: Eigenvalues and Eigenvectors
11Week 10: Diagonalization and Markov Matrices
12Week 11: Differential Equations
13Week 12: Symmetric and Positive Definite Matrices
14Week 13: The SVD and Complex Matrices
15Week 14: The Fourier Matrix, FFT, and PCA
Week 05· Linear Algebra11 min read

Week 5: Vector Spaces, Independence, and Basis

Learning Outcomes
  • Verify whether a set is a vector space or subspace
  • Test vectors for linear independence
  • Find a basis and compute the dimension of a vector space
  • Explain the relationship between a basis and coordinate representation
Prerequisites

Background knowledge assumed:

  • Linear combinations
  • Gaussian elimination and rank

Recommended: Review Week 1: Vectors and Linear Combinations and Week 3: Elimination and LU Factorization before starting.

Vector Spaces and Subspaces#

A vector space is a set VVV of objects (called vectors) together with two operations — addition and scalar multiplication — that stay inside VVV and obey the usual algebraic rules from Week 1: addition is commutative and associative, there is a zero vector, every vector has an additive inverse, and scalars distribute and associate as expected. In this course the default space is Rn\mathbb{R}^nRn, but the same language applies to matrices, polynomials, or functions once the operations are defined.

The practical test is closure: if u,v∈Vu, v \in Vu,v∈V and c∈Rc \in \mathbb{R}c∈R, then both u+vu + vu+v and cucucu must still lie in VVV. Combined with the presence of the zero vector, closure under addition and scalar multiplication is what makes a subset of a larger space into a vector space of its own.

A subspace is a vector space living inside a larger one. Formally, a nonempty subset W⊆VW \subseteq VW⊆V is a subspace of VVV when:

  1. 0∈W0 \in W0∈W,
  2. u,v∈Wu, v \in Wu,v∈W implies u+v∈Wu + v \in Wu+v∈W,
  3. u∈Wu \in Wu∈W and c∈Rc \in \mathbb{R}c∈R implies cu∈Wcu \in Wcu∈W.

(The full list of vector-space axioms then holds automatically because they already hold in VVV.)

Examples in R2\mathbb{R}^2R2 and R3\mathbb{R}^3R3.

  • Any line through the origin in R2\mathbb{R}^2R2 is a subspace: if vvv and www both lie on that line, so do v+wv + wv+w and cvcvcv. Algebraically it is span⁡{v}\operatorname{span}\{v\}span{v} for some nonzero vvv.
  • Any plane through the origin in R3\mathbb{R}^3R3 is a subspace: it is span⁡{v1,v2}\operatorname{span}\{v_1, v_2\}span{v1​,v2​} for two non-parallel vectors in the plane.
  • The set {0}\{0\}{0} (only the zero vector) is a subspace — the trivial subspace.
  • The whole space Rn\mathbb{R}^nRn is a subspace of itself.

Non-examples.

  • A line that does not pass through the origin fails: it does not contain 000, and the sum of two points on the line need not stay on the line when you treat them as vectors from the origin. (Affine lines are important in geometry, but they are not subspaces.)
  • The unit circle x2+y2=1x^2 + y^2 = 1x2+y2=1 in R2\mathbb{R}^2R2 is not a subspace: the sum of two unit vectors is generally not a unit vector, and 000 is not on the circle.
  • The set of vectors with integer components is closed under addition but not under arbitrary real scalar multiplication (scale (1,0)(1,0)(1,0) by 12\frac{1}{2}21​).

Span is always a subspace. For any vectors v1,…,vkv_1, \ldots, v_kv1​,…,vk​ in a vector space VVV,

span⁡{v1,…,vk}={c1v1+⋯+ckvk:ci∈R}\operatorname{span}\{v_1, \ldots, v_k\} = \{ c_1 v_1 + \cdots + c_k v_k : c_i \in \mathbb{R} \}span{v1​,…,vk​}={c1​v1​+⋯+ck​vk​:ci​∈R}

is a subspace of VVV. It is the smallest subspace containing every viv_ivi​: any subspace that contains the viv_ivi​ must contain all their linear combinations. Week 1 introduced span as “what these vectors generate”; here we recognize that the generated set is itself a vector space.


Once you know a span is always a subspace, the remaining question is how to describe that subspace economically: which vectors in a generating set are redundant, mere combinations of the others? That is the question of linear independence.

Linear Independence#

A set of vectors v1,…,vkv_1, \ldots, v_kv1​,…,vk​ is linearly independent if the only linear combination that produces the zero vector is the trivial one:

c1v1+c2v2+⋯+ckvk=0⟹c1=c2=⋯=ck=0.c_1 v_1 + c_2 v_2 + \cdots + c_k v_k = 0 \quad\Longrightarrow\quad c_1 = c_2 = \cdots = c_k = 0.c1​v1​+c2​v2​+⋯+ck​vk​=0⟹c1​=c2​=⋯=ck​=0.

If there exist coefficients, not all zero, that still sum to zero, the set is linearly dependent. Dependence means redundancy: if c1≠0c_1 \neq 0c1​=0, the equation c1v1+⋯+ckvk=0c_1 v_1 + \cdots + c_k v_k = 0c1​v1​+⋯+ck​vk​=0 rearranges to express v1v_1v1​ as a combination of the rest.

Matrix test. Form the matrix MMM whose columns are v1,…,vkv_1, \ldots, v_kv1​,…,vk​:

M=[v1v2⋯vk].M = \begin{bmatrix} v_1 & v_2 & \cdots & v_k \end{bmatrix}.M=[v1​​v2​​⋯​vk​​].

The equation c1v1+⋯+ckvk=0c_1 v_1 + \cdots + c_k v_k = 0c1​v1​+⋯+ck​vk​=0 is exactly Mc=0M c = 0Mc=0, where c=(c1,…,ck)⊤c = (c_1, \ldots, c_k)^\topc=(c1​,…,ck​)⊤. By Week 3, the nullspace of MMM is nontrivial precisely when elimination produces fewer than kkk pivots — that is, when

rank⁡(M)<k.\operatorname{rank}(M) < k.rank(M)<k.

So:

  • rank⁡(M)=k\operatorname{rank}(M) = krank(M)=k (full column rank)   ⟺  \iff⟺ the columns are independent,
  • rank⁡(M)<k\operatorname{rank}(M) < krank(M)<k   ⟺  \iff⟺ the columns are dependent.

If k>nk > nk>n (more vectors than the ambient dimension of Rn\mathbb{R}^nRn), rank is at most nnn, so the vectors are automatically dependent.

Worked example. Take

v1=(121),v2=(210),v3=(032)v_1 = \begin{pmatrix} 1 \\ 2 \\ 1 \end{pmatrix}, \quad v_2 = \begin{pmatrix} 2 \\ 1 \\ 0 \end{pmatrix}, \quad v_3 = \begin{pmatrix} 0 \\ 3 \\ 2 \end{pmatrix}v1​=​121​​,v2​=​210​​,v3​=​032​​

in R3\mathbb{R}^3R3. Form

M=(120213102).M = \begin{pmatrix} 1 & 2 & 0 \\ 2 & 1 & 3 \\ 1 & 0 & 2 \end{pmatrix}.M=​121​210​032​​.

Elimination: subtract 222 times row 1 from row 2, and 111 times row 1 from row 3:

(1200−330−22).\begin{pmatrix} 1 & 2 & 0 \\ 0 & -3 & 3 \\ 0 & -2 & 2 \end{pmatrix}.​100​2−3−2​032​​.

Replace row 3 by row3−23 row2\text{row}_3 - \frac{2}{3}\,\text{row}_2row3​−32​row2​:

(1200−33000).\begin{pmatrix} 1 & 2 & 0 \\ 0 & -3 & 3 \\ 0 & 0 & 0 \end{pmatrix}.​100​2−30​030​​.

There is a zero row and only two pivots, so rank⁡(M)=2<3\operatorname{rank}(M) = 2 < 3rank(M)=2<3. The three vectors are dependent. Explicitly, the free variable c3c_3c3​ gives a nontrivial null vector; you can check that

v3=2v1−v2,v_3 = 2 v_1 - v_2,v3​=2v1​−v2​,

so 2v1−v2−v3=02v_1 - v_2 - v_3 = 02v1​−v2​−v3​=0 with coefficients not all zero. Any two of {v1,v2}\{v_1, v_2\}{v1​,v2​} (or {v1,v3}\{v_1, v_3\}{v1​,v3​}, or {v2,v3}\{v_2, v_3\}{v2​,v3​}) are independent and span the same plane.

Exercise · Fill in the blank

Are v1=(1,2,1), v2=(2,1,0), v3=(0,3,2) linearly independent? Form the matrix with these as columns and compute its rank.


Independence strips away redundancy by itself, but it does not guarantee that the set reaches every vector in the space. Spanning guarantees full coverage but may carry excess. A basis fuses the two ideas: a minimal generating set — independent enough to have no waste, large enough to touch every point.

Basis and Dimension#

A basis of a vector space VVV is a set of vectors that is both:

  1. Linearly independent, and
  2. Spanning — every vector in VVV is a linear combination of the basis vectors.

Standard basis. The standard basis of Rn\mathbb{R}^nRn is

e1=(10⋮0),e2=(01⋮0),…,en=(00⋮1).e_1 = \begin{pmatrix} 1 \\ 0 \\ \vdots \\ 0 \end{pmatrix}, \quad e_2 = \begin{pmatrix} 0 \\ 1 \\ \vdots \\ 0 \end{pmatrix}, \quad \ldots, \quad e_n = \begin{pmatrix} 0 \\ 0 \\ \vdots \\ 1 \end{pmatrix}.e1​=​10⋮0​​,e2​=​01⋮0​​,…,en​=​00⋮1​​.

These nnn vectors are independent (the matrix they form is III, rank nnn) and span Rn\mathbb{R}^nRn (any x=(x1,…,xn)⊤x = (x_1, \ldots, x_n)^\topx=(x1​,…,xn​)⊤ equals x1e1+⋯+xnenx_1 e_1 + \cdots + x_n e_nx1​e1​+⋯+xn​en​). So {e1,…,en}\{e_1, \ldots, e_n\}{e1​,…,en​} is a basis of Rn\mathbb{R}^nRn.

Same number of vectors. A standard theorem of linear algebra — see Strang, §3.4 — says that every basis of a given space has the same number of vectors. That common number is the dimension of the space, written dim⁡(V)\dim(V)dim(V). In particular:

dim⁡(Rn)=n,\dim(\mathbb{R}^n) = n,dim(Rn)=n,

and if W=span⁡{v1,…,vk}W = \operatorname{span}\{v_1, \ldots, v_k\}W=span{v1​,…,vk​} with the viv_ivi​ independent, then dim⁡(W)=k\dim(W) = kdim(W)=k. More generally, the dimension of a span equals the rank of the matrix whose columns are the spanning vectors: drop dependent columns until you have a basis, and count what remains.

Finding a basis from a spanning set. Start with vectors that span VVV (for example, the columns of a matrix). Run elimination and keep only the columns that produce pivots; those pivot columns form a basis of the column space. The number of pivots is both the rank and the dimension of that subspace.

Examples.

  • A line through the origin in R3\mathbb{R}^3R3 has dimension 111: any single nonzero vector on the line is a basis.
  • A plane through the origin has dimension 222: two independent vectors in the plane form a basis.
  • The three dependent vectors v1,v2,v3v_1, v_2, v_3v1​,v2​,v3​ from the previous section span a 222-dimensional subspace of R3\mathbb{R}^3R3; a basis is {v1,v2}\{v_1, v_2\}{v1​,v2​}.

By the same theorem (Strang, §3.4), a set with more vectors than dim⁡(V)\dim(V)dim(V) cannot be independent, and one with fewer cannot span VVV: either would force a basis with the wrong number of vectors. A basis hits the count exactly and satisfies both properties.


Coordinates Relative to a Basis#

Once a basis B={b1,…,bn}B = \{b_1, \ldots, b_n\}B={b1​,…,bn​} of VVV is fixed, every vector v∈Vv \in Vv∈V can be written uniquely as

v=c1b1+c2b2+⋯+cnbn.v = c_1 b_1 + c_2 b_2 + \cdots + c_n b_n.v=c1​b1​+c2​b2​+⋯+cn​bn​.

The scalars (c1,…,cn)(c_1, \ldots, c_n)(c1​,…,cn​) are the coordinates of vvv relative to BBB, often written [v]B[v]_B[v]B​. Uniqueness is exactly linear independence: if two coefficient lists produced the same vvv, their difference would be a nontrivial combination equal to zero. Existence is exactly spanning.

In the standard basis of Rn\mathbb{R}^nRn, the coordinates of a vector are just its usual components. In a different basis, the same geometric vector has different numbers attached to it — the change-of-basis story that returns when you study similarity and diagonalization later in the course.

Worked example. Let

b1=(11),b2=(1−1)b_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix}, \quad b_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix}b1​=(11​),b2​=(1−1​)

in R2\mathbb{R}^2R2. These are independent (neither is a scalar multiple of the other) and there are two of them in a 222-dimensional space, so B={b1,b2}B = \{b_1, b_2\}B={b1​,b2​} is a basis of R2\mathbb{R}^2R2. For v=(42)v = \begin{pmatrix} 4 \\ 2 \end{pmatrix}v=(42​), solve c1b1+c2b2=vc_1 b_1 + c_2 b_2 = vc1​b1​+c2​b2​=v:

(111−1)(c1c2)=(42).\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} c_1 \\ c_2 \end{pmatrix} = \begin{pmatrix} 4 \\ 2 \end{pmatrix}.(11​1−1​)(c1​c2​​)=(42​).

Adding the two equations: 2c1=62c_1 = 62c1​=6, so c1=3c_1 = 3c1​=3. Subtracting: 2c2=22c_2 = 22c2​=2, so c2=1c_2 = 1c2​=1. Thus

[v]B=(31),[v]_B = \begin{pmatrix} 3 \\ 1 \end{pmatrix},[v]B​=(31​),

meaning v=3b1+1⋅b2v = 3b_1 + 1\cdot b_2v=3b1​+1⋅b2​ (as in the Week 1 span example). In the standard basis the same vector is simply (4,2)⊤(4, 2)^\top(4,2)⊤. The vector did not change — only the labels relative to the chosen basis did.

Why bases matter. Coordinates turn abstract linear algebra into numerical linear algebra: matrices store the action of a linear map on a basis, and changing basis changes the matrix without changing the map. Week 6 will use independence and dimension to classify the four fundamental subspaces of a matrix (column space, nullspace, row space, left nullspace) and relate their dimensions by the rank–nullity theorem.


Knowledge check#

Question 1 of 4

A basis for a vector space must be:

Linearly independent and span the space
Just linearly independent
Just spanning
Orthogonal

Browser lab: rank and independence#

Test three vectors for independence using numpy.linalg.matrix_rank.

python · runs in browser
import numpy as np

v1 = np.array([1, 2, 1])
v2 = np.array([2, 1, 0])
v3 = np.array([0, 3, 2])

M = np.column_stack([v1, v2, v3])
rank = np.linalg.matrix_rank(M)

print("M =\n", M)
print("rank(M) =", rank)
print("Independent:", rank == M.shape[1])

print("Notice: rank(M) = 2 < 3, so Independent prints False — v3 = 2v1 - v2.")

Done when#

You can test a set of vectors for linear independence by computing the rank of the matrix they form, and give a basis and dimension for a given space. Check it against the browser lab: for v1=(1,2,1)v_1=(1,2,1)v1​=(1,2,1), v2=(2,1,0)v_2=(2,1,0)v2​=(2,1,0), v3=(0,3,2)v_3=(0,3,2)v3​=(0,3,2) the output shows rank(M) = 2 and Independent: False, and you can exhibit the dependence v2+v3=2v1v_2 + v_3 = 2v_1v2​+v3​=2v1​.


Further Reading#

  • Strang, G. Introduction to Linear Algebra, 5th ed. — Chapters 3.1–3.4 cover vector spaces, independence, basis, and dimension with worked examples that complement this week's treatment.
  • 3Blue1Brown — Essence of Linear Algebra YouTube series. Episodes "Linear combinations, span, and basis vectors" and "Linear independence" offer geometric intuition for the abstract ideas in this week.
  • Lay, D., Lay, S., and McDonald, J. Linear Algebra and Its Applications, 6th ed. — Chapter 2.8–2.9 on subspaces of Rn\mathbb{R}^nRn, basis, and dimension from an applied perspective.
← Previous
Week 4: Determinants
Next →
Week 6: The Four Fundamental Subspaces
On this page
  • Vector Spaces and Subspaces
  • Linear Independence
  • Basis and Dimension
  • Coordinates Relative to a Basis
  • Knowledge check
  • Browser lab: rank and independence
  • Done when
  • Further Reading