Linear Algebra

Vector Spaces

Sets where you can add and scale — the abstract setting for all linear algebra

A vector space is a set V together with rules for adding elements and multiplying them by scalars (numbers), satisfying eight axioms — closure, associativity, distributivity, etc. Familiar examples — ℝⁿ (n-dimensional real space), polynomials, functions, matrices. Every linear algebra theorem about ℝⁿ generalizes to all vector spaces. The abstraction reveals what "linear" really means.

  • Required operationsAddition; scalar multiplication
  • Number of axioms8 (4 for addition, 4 for scalar multiplication)
  • Standard examplesℝⁿ, ℂⁿ, polynomial spaces, function spaces, matrix spaces
  • SubspacesSubsets that are vector spaces with same operations
  • DimensionNumber of vectors in a basis (for finite-dimensional spaces)
  • Coined byHermann Grassmann (1844); axiomatized by Peano (1888)

Interactive visualization

Press play, or step through manually. The visualization is yours to drive — try it before reading on.

Open visualization fullscreen ↗

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

The eight axioms

A vector space V over a field F (typically the reals ℝ or complex numbers ℂ) consists of:

  • A set V (whose elements are called vectors).
  • An operation + (addition) on V.
  • An operation · (scalar multiplication) where scalars come from F.

satisfying eight axioms:

AxiomStatement
Closure (addition)u + v is in V
Commutativityu + v = v + u
Associativity (addition)(u + v) + w = u + (v + w)
IdentityThere exists 0 such that v + 0 = v
InversesFor each v, there exists −v such that v + (−v) = 0
Closure (scalar mult)c · v is in V
Distributivity (over scalars)c · (u + v) = c·u + c·v
Distributivity (over vectors) and Associativity(c + d)·v = c·v + d·v; c·(d·v) = (cd)·v; 1·v = v

If a set with two operations satisfies all eight, it's a vector space. ℝⁿ does. So do many other things.

Examples of vector spaces

1. ℝⁿ — n-dimensional real space

The canonical example. Vectors are n-tuples of reals; addition and scalar multiplication are componentwise. ℝ¹ is the real line; ℝ² is the plane; ℝ³ is 3D space.

2. The polynomial space P_n

The set of polynomials of degree ≤ n with real coefficients. (3x² + 2x + 1) + (x² − 5) = 4x² + 2x − 4 — addition is well-defined. 2 · (3x² + 1) = 6x² + 2 — scalar multiplication too. Dimension n + 1; basis is {1, x, x², ..., x^n}.

3. The space of continuous functions C[0, 1]

All continuous real-valued functions on [0, 1]. Addition (f + g)(x) = f(x) + g(x). Scalar multiplication (c·f)(x) = c · f(x). The result is again continuous, satisfying closure. This is an infinite-dimensional vector space — no finite basis works.

4. The matrix space M_{m×n}

All m×n matrices with real entries. Addition is entry-wise; scalar multiplication scales all entries. Dimension m·n.

5. The complex numbers ℂ

The complex numbers form a vector space over the reals. Dimension 2 (basis {1, i}). The complex numbers can also be viewed as a vector space over themselves, in which case dimension is 1.

6. Polynomial sequences

Sequences (a₀, a₁, a₂, ...) of real numbers, with componentwise operations. Infinite dimensional. Subspace — those that are eventually 0 (finite-degree polynomial coefficient sequences).

Subspaces — vector spaces inside vector spaces

A subspace W of V is a subset that's closed under V's operations:

  • 0 ∈ W (W is non-empty and contains the zero vector).
  • u + v ∈ W whenever u, v ∈ W (closed under addition).
  • c·v ∈ W whenever v ∈ W and c is a scalar (closed under scalar multiplication).

Examples:

  • {0} is the trivial subspace — the smallest possible.
  • Lines through the origin in ℝ² are subspaces.
  • Planes through the origin in ℝ³ are subspaces.
  • The set of polynomials with f(0) = 0 is a subspace of P_n.
  • The kernel and image of any linear transformation are subspaces.

Subsets NOT through the origin (e.g., a line not passing through 0) are not subspaces — they fail the "contains 0" condition.

Span and linear independence

The span of a set of vectors {v₁, ..., vₖ} is the set of all linear combinations c₁v₁ + ... + cₖvₖ. The span is always a subspace.

A set is linearly independent if the only way to write 0 as c₁v₁ + ... + cₖvₖ is with all cᵢ = 0. Equivalently — no vector in the set is a linear combination of the others.

A basis is a linearly independent set whose span is the entire space. Every vector space has a basis (assuming the axiom of choice for infinite-dimensional spaces). Every basis has the same number of elements — that number is the dimension.

Dimension

Vector spaceDimensionStandard basis
ℝⁿn{e₁, e₂, ..., eₙ} (standard basis vectors)
ℂⁿ over ℂn{e₁, e₂, ..., eₙ}
ℂⁿ over ℝ2n{e₁, ie₁, ..., eₙ, ieₙ}
P_n (polynomials of degree ≤ n)n + 1{1, x, x², ..., x^n}
M_{m × n} (m × n matrices)m·nMatrices with one 1 entry, rest 0
C[a, b] (continuous functions on [a, b])infiniteNo finite basis
ℓ² (square-summable sequences)infinite — Hilbert space(1, 0, 0, ...), (0, 1, 0, ...), ...

Finite-dimensional vector spaces over the same field are isomorphic if they have the same dimension. So ℝⁿ "is" any other n-dimensional real vector space (after choosing a basis). The abstraction lets you transfer linear-algebra results among them.

Why the abstraction matters

  • Theorems prove once, apply everywhere. The rank-nullity theorem, eigenvalue theorems, change-of-basis formulas — proven for general vector spaces, immediately applicable to functions, polynomials, matrices, etc.
  • Function spaces enable PDE and quantum theory. Quantum states, signal processing, differential equations all live in function spaces. The vector-space framework provides the language.
  • Linear-algebra reasoning extends to "vectors" that don't look like arrows. Polynomials, matrices, and operators all behave linearly; vector-space axioms encode this uniformly.
  • Abstract definitions reveal essential structure. The 8 axioms strip away "what does this thing look like?" to focus on "how does it combine?" The latter is what matters for linear methods.

JavaScript — checking vector-space axioms

// Verify ℝⁿ is a vector space (sample checks)
function add(u, v) { return u.map((x, i) => x + v[i]); }
function scale(c, v) { return v.map(x => c * x); }
function zero(n) { return Array(n).fill(0); }

// Test commutativity
const a = [1, 2, 3], b = [4, 5, 6];
console.log(JSON.stringify(add(a, b)) === JSON.stringify(add(b, a)));  // true

// Test distributivity
const c = 5;
const lhs = scale(c, add(a, b));
const rhs = add(scale(c, a), scale(c, b));
console.log(JSON.stringify(lhs) === JSON.stringify(rhs));  // true

// Test linear independence — does 2·u + 3·v = 0 force u = v = 0?
function isLinearlyIndependent(vectors) {
  // For small examples: try all small integer combinations
  // For real applications: compute matrix rank
  // ...
}

Where vector spaces appear

  • Linear algebra textbooks. The setting for linear transformations, matrix theory, eigenvalues, and SVD.
  • Functional analysis. Hilbert spaces (infinite-dim with inner product) and Banach spaces (with a norm) — the function-space generalizations.
  • Quantum mechanics. Wavefunctions live in a Hilbert space. Operators are linear transformations on it.
  • Differential equations. Solutions to linear ODEs form a vector space; the dimension equals the order of the ODE. Boundary-value problems are also linear.
  • Machine learning. Word embeddings, image features, neural network activations all live in vector spaces. Linear methods (SVM, PCA) operate on them.
  • Computer graphics. 3D space ℝ³, 4D homogeneous coordinates, color spaces (RGB is ℝ³, but with constraints).

Common mistakes

  • Confusing vector space with ℝⁿ. ℝⁿ is one example. Polynomials, functions, matrices are also vector spaces. The abstraction is broader than the concrete.
  • Confusing affine subset with subspace. A line through (1, 0) parallel to the x-axis is NOT a subspace — it doesn't contain 0. Subspaces always pass through the origin.
  • Forgetting that all 8 axioms are required. Skipping verification of associativity or commutativity has bitten people. Always check all eight when proving something is a vector space.
  • Mixing up basis vs spanning set vs linearly independent set. Basis = both linearly independent AND spanning. A spanning set isn't always a basis (might be too big). A linearly independent set isn't always a basis (might not span). Both conditions together are required.
  • Trying to define dimension in non-vector-space settings. Sets that aren't vector spaces don't have linear-algebra dimension. Don't try to apply rank, span, or basis to non-linear objects.
  • Forgetting field choices. ℂⁿ is 2n-dimensional over ℝ but n-dimensional over ℂ. The base field matters when discussing dimension.

Frequently asked questions

What's a vector space, intuitively?

A set where you can add elements and scale by numbers, with the operations behaving the way you'd expect arithmetic to behave. ℝⁿ is the canonical example, but the concept is much broader — polynomials, smooth functions, matrices, infinite sequences, all form vector spaces. The abstraction lets you apply linear-algebra reasoning to any of these.

What's a subspace?

A subset W of a vector space V that's itself a vector space under V's operations. Three conditions — W is non-empty (contains 0), W is closed under addition (u + v ∈ W if u, v ∈ W), W is closed under scalar multiplication (c·v ∈ W if v ∈ W, c scalar). Examples — lines through origin in ℝ², planes through origin in ℝ³, polynomials of degree ≤ n in the polynomial space.

What's a basis?

A linearly independent set of vectors that span the entire space. "Linearly independent" — no vector is a combination of the others. "Span" — every vector in the space can be written as a linear combination of the basis. The standard basis of ℝ³ is {(1,0,0), (0,1,0), (0,0,1)} — three vectors, and every 3-vector is a unique combination of them.

What's dimension?

The number of vectors in a basis. ℝⁿ has dimension n. The polynomial space of degree ≤ n has dimension n+1 (the basis is {1, x, x², ..., x^n}). The space of all polynomials has infinite dimension. Dimension is well-defined — every basis of a given vector space has the same number of elements (this is a theorem).

How is a vector space different from ℝⁿ?

ℝⁿ is the most concrete vector space — n-tuples of real numbers. A general vector space might consist of polynomials, functions, infinite sequences, or matrices. The "vectors" don't have to look like arrows or tuples. The defining axioms are abstract; ℝⁿ is one specific example.

What's a function space?

A vector space whose "vectors" are functions. C[0, 1] (continuous functions on [0, 1]) is a vector space — you can add functions and multiply them by scalars. Linear differential operators (d/dx) are linear transformations on these spaces. Quantum mechanics, signal processing, and PDE theory work in function spaces.

How do vector spaces relate to physics?

Quantum states form a complex vector space (Hilbert space). Forces, velocities, accelerations live in 3D vector spaces. Spacetime is a 4D vector space (or pseudo-vector space with the Minkowski metric). Most of physics is rephrasing problems in terms of vector spaces and finding the right operators (linear transformations) to solve them.