Vector Spaces

Last updated: August 2026

Disclaimer: These are my personal notes compiled for my own reference and learning. They may contain errors, incomplete information, or personal interpretations. While I strive for accuracy, these notes are not peer-reviewed and should not be considered authoritative sources. Please consult official textbooks, research papers, or other reliable sources for academic or professional purposes.

1. Why abstract away from $\mathbb{R}^n$

Everything in matrices and eigenvalues was stated for $\mathbb{R}^n$, but nothing in the arguments actually used coordinates — only addition, scalar multiplication, and the axioms they satisfy. Polynomials of degree $\leq n$, continuous functions on $[a,b]$, and $m\times n$ matrices themselves all add and scale the same way $\mathbb{R}^n$ vectors do, without any natural list of coordinates. Formalizing exactly which properties of $\mathbb{R}^n$ were actually being used lets every theorem proved for $\mathbb{R}^n$ transfer immediately to these other settings — this is the entire payoff of the abstraction, not abstraction for its own sake.

2. Vector spaces and subspaces

Definition

A vector space over a field $\mathbb{F}$ (here always $\mathbb{R}$ or $\mathbb{C}$) is a set $V$ with an addition $V\times V\to V$ and scalar multiplication $\mathbb{F}\times V\to V$ satisfying the familiar axioms: addition is commutative and associative with an identity $0$ and inverses; scalar multiplication distributes over both vector and scalar addition, is associative ($a(bv)=(ab)v$), and $1v=v$.

Beyond $\mathbb{F}^n$: $\mathcal{P}_n$ (polynomials of degree $\leq n$), $C[a,b]$ (continuous real functions on $[a,b]$), and $\mathbb{R}^{m\times n}$ (Section 2 of the matrices note uses exactly this fact) are all vector spaces under pointwise/entrywise addition and scaling.

Proposition (Subspace test)

A subset $W\subseteq V$ is a subspace (itself a vector space under $V$'s operations) iff $0\in W$, and $W$ is closed under addition and scalar multiplication.

The remaining axioms (associativity, distributivity, etc.) hold automatically for $W$ because they already hold for all of $V$; only closure and containing $0$ are genuinely restrictive. This is why checking "is this a subspace" is a two- or three-line closure argument rather than re-verifying eight axioms from scratch — used throughout without comment whenever this note collection calls a set a subspace (e.g. eigenspaces in the eigenvalues note, which are kernels, and kernels are always subspaces by exactly this test: $0\in\ker A$, and $Av=0,Aw=0\Rightarrow A(cv+w)=cAv+Aw=0$).

3. Linear independence and span

Definition

$v_1,\ldots,v_k\in V$ are linearly independent if $\sum_i c_iv_i=0 \Rightarrow c_1=\cdots=c_k=0$. Their span is $\{\sum_i c_iv_i : c_i\in\mathbb{F}\}$, the smallest subspace containing them all.

Independence is exactly the condition under which every vector in the span has a unique representation as a combination of $v_1,\ldots,v_k$: if $\sum c_iv_i=\sum c_i'v_i$, subtracting gives $\sum(c_i-c_i')v_i=0$, which independence forces to $c_i=c_i'$ for all $i$. This is the property basis representations rely on in Section 4.

4. Basis, and why dimension is well-defined

Definition

A basis of $V$ is a linearly independent spanning set.

Calling $\dim V$ "the number of vectors in a basis" presupposes that this number does not depend on which basis you pick — a fact that needs proof, not just faith.

Lemma (Steinitz exchange)

If $u_1,\ldots,u_m$ spans $V$ and $w_1,\ldots,w_k\in V$ are linearly independent, then $k\leq m$.

Proof. By induction, swap $w$'s into the spanning list one at a time. Since $u_1,\ldots,u_m$ spans $V$, write $w_1=\sum_i a_iu_i$; not all $a_i$ are $0$ (else $w_1=0$, contradicting independence), so reorder so $a_1\neq0$ and solve for $u_1$ in terms of $w_1,u_2,\ldots,u_m$ — this new list still spans $V$ (it spans everything the old list did, since $u_1$ is recovered from it). Repeat: having replaced $u_1,\ldots,u_{j-1}$ with $w_1,\ldots,w_{j-1}$ in the spanning list, write $w_j$ in terms of $w_1,\ldots,w_{j-1},u_j,\ldots,u_m$; the coefficient on some $u_i$ ($i\geq j$) must be nonzero, since otherwise $w_j$ would be a combination of $w_1,\ldots,w_{j-1}$, contradicting independence of the $w$'s — swap that $u_i$ out. This requires $m\geq j$ at each step $j=1,\ldots,k$, so in particular $m\geq k$.
Theorem (Dimension is well-defined)

Any two bases of $V$ have the same number of elements.

Proof. If $B_1$ (size $m$) and $B_2$ (size $k$) are both bases: $B_1$ spans and $B_2$ is independent, so $k\leq m$ by the lemma; symmetrically, $B_2$ spans and $B_1$ is independent, so $m\leq k$. Hence $m=k$.

This is the fact silently invoked every time a diagonalization argument counts eigenvectors against $n$ in the eigenvalues note, or a rank is called "the" dimension of a column space in the matrices note — dimension is only a meaningful invariant to compare across different bases because of this theorem.

5. Linear maps and the rank–nullity theorem

For a linear map $T:V\to W$ between finite-dimensional spaces, $\ker T = \{v: Tv=0\}$ and $\operatorname{im} T=\{Tv : v\in V\}$ are subspaces of $V$ and $W$ respectively (immediate from the subspace test of Section 2, exactly as for matrix kernels above).

Theorem (Rank–nullity)

$\dim\ker T + \dim\operatorname{im} T = \dim V$.

Proof. Let $v_1,\ldots,v_p$ be a basis of $\ker T$ ($p=\dim\ker T$) and extend it to a basis $v_1,\ldots,v_p,v_{p+1},\ldots,v_n$ of $V$ ($n=\dim V$; extension of an independent set to a basis is always possible in finite dimensions). Claim: $Tv_{p+1},\ldots,Tv_n$ is a basis of $\operatorname{im}T$. Spanning: any $Tv = T(\sum_i c_iv_i) = \sum_{i>p} c_i Tv_i$ since $Tv_i=0$ for $i\leq p$. Independence: if $\sum_{i>p} c_iTv_i=0$, then $T(\sum_{i>p}c_iv_i)=0$, so $\sum_{i>p}c_iv_i\in\ker T$, hence is itself a combination of $v_1,\ldots,v_p$; but $v_1,\ldots,v_n$ are independent, so the only way $\sum_{i>p}c_iv_i$ can equal a combination of $v_1,\ldots,v_p$ is if all the $c_i$ ($i>p$) and the implied coefficients are $0$. So $\dim\operatorname{im}T = n-p = \dim V-\dim\ker T$.

For $T$ represented by a matrix $A$, $\operatorname{im}T$ is the column space, so $\dim\operatorname{im}T=\operatorname{rank}(A)$ and $\dim\ker T$ is the nullity — this is the theorem underlying the rank/nullity claims used without proof in the matrices note's solvability criterion (Section 6 there).

6. Inner products and Cauchy–Schwarz

Definition

An inner product on a real vector space $V$ is $\langle\cdot,\cdot\rangle:V\times V\to\mathbb{R}$ that is symmetric, bilinear, and positive definite ($\langle v,v\rangle\geq0$, with equality iff $v=0$). It induces a norm $\|v\|=\sqrt{\langle v,v\rangle}$.

The dot product $x\cdot y=\sum_ix_iy_i$ on $\mathbb{R}^n$ is the standard example, but far from the only one: $\langle f,g\rangle=\int_a^bf(x)g(x)\,dx$ makes $C[a,b]$ an inner product space, and this is not a curiosity — it is exactly the structure underlying Fourier series (orthogonality of $\sin(nx),\cos(nx)$ under this inner product) and least-squares function approximation.

Theorem (Cauchy–Schwarz)

$|\langle x,y\rangle| \leq \|x\|\,\|y\|$, with equality iff $x,y$ are linearly dependent.

Proof. If $y=0$ both sides are $0$. Otherwise, for any $t\in\mathbb{R}$, positive-definiteness gives $0\leq\|x-ty\|^2 = \|x\|^2 - 2t\langle x,y\rangle + t^2\|y\|^2$, a quadratic in $t$ that is never negative, so its discriminant is $\leq0$: $4\langle x,y\rangle^2 - 4\|x\|^2\|y\|^2\leq0$, i.e. $\langle x,y\rangle^2\leq\|x\|^2\|y\|^2$. Equality in the discriminant means the quadratic has a real root $t^*$, i.e. $\|x-t^*y\|^2=0$, i.e. $x=t^*y$ — dependence.

Cauchy–Schwarz is what makes $\cos\theta = \langle x,y\rangle/(\|x\|\|y\|)$ well-defined (the ratio is guaranteed to lie in $[-1,1]$) — the algebraic fact underneath the geometric notion of "angle" in any inner product space, not just $\mathbb{R}^2$ or $\mathbb{R}^3$.

7. Orthogonal projection as best approximation

Given a subspace $W\subseteq V$ and $x\in V$, which point of $W$ is closest to $x$?

Theorem (Best approximation)

If $u_1,\ldots,u_k$ is an orthonormal basis of $W$, the point of $W$ minimizing $\|x-w\|$ is $P_Wx = \sum_{i=1}^k\langle x,u_i\rangle u_i$, and the minimizing residual $x-P_Wx$ is orthogonal to all of $W$.

Proof. First check $x-P_Wx\perp W$: for each basis vector $u_j$, $\langle x-P_Wx, u_j\rangle = \langle x,u_j\rangle - \sum_i\langle x,u_i\rangle\langle u_i,u_j\rangle = \langle x,u_j\rangle-\langle x,u_j\rangle=0$ using orthonormality ($\langle u_i,u_j\rangle=1$ if $i=j$, else $0$); orthogonality to every basis vector gives orthogonality to all of $W$ by linearity. Now for any $w\in W$, write $x-w = (x-P_Wx)+(P_Wx-w)$, a sum of a vector orthogonal to $W$ and a vector in $W$ (since $P_Wx-w\in W$). The Pythagorean identity (immediate from bilinearity and orthogonality: $\|a+b\|^2=\|a\|^2+\|b\|^2$ when $\langle a,b\rangle=0$) gives $\|x-w\|^2 = \|x-P_Wx\|^2+\|P_Wx-w\|^2 \geq \|x-P_Wx\|^2$, with equality iff $w=P_Wx$.

For $W=\operatorname{span}\{u\}$ one-dimensional, this reduces to the familiar $P_Wx = \dfrac{\langle x,u\rangle}{\langle u,u\rangle}u$ (no need for $u$ to be unit-length; the normalization is absorbed into the denominator).

A vector x, its orthogonal projection onto a line W, and the residual vector connecting the projection to x, meeting at a right angle, with the Pythagorean identity verified numerically.
Figure — The residual $x-P_Wx$ is exactly what the theorem says it is: perpendicular to $W$. $x=(1.5,3)$ projected onto $W=\operatorname{span}\{(3,1)\}$. The right-angle marker at the foot of $P_Wx$ is not decorative — it is the theorem's own conclusion, and the printed identity $\|x\|^2=\|P_Wx\|^2+\|x-P_Wx\|^2$ ($11.25 = 5.62+5.62$) is the Pythagorean step inside the proof, verified numerically rather than only symbolically.

8. Gram–Schmidt orthogonalization

The best-approximation formula above needs an orthonormal basis of $W$ to start from. Gram–Schmidt builds one from an arbitrary basis $v_1,\ldots,v_k$ by inductively subtracting off the projection onto everything already orthogonalized:

$$w_1=v_1,\qquad w_j = v_j - \sum_{i<j}\frac{\langle v_j,w_i\rangle}{\langle w_i,w_i\rangle}w_i \ \ (j\geq2), \qquad u_i = \frac{w_i}{\|w_i\|}.$$

Correctness is an induction on $j$ using exactly Section 7's theorem: assuming $w_1,\ldots,w_{j-1}$ (equivalently $u_1,\ldots,u_{j-1}$) are already an orthogonal basis of $W_{j-1}=\operatorname{span}\{v_1,\ldots,v_{j-1}\}$, the sum being subtracted is precisely $P_{W_{j-1}}v_j$, so $w_j = v_j - P_{W_{j-1}}v_j$ is (by the best-approximation theorem's proof) orthogonal to all of $W_{j-1}$, and nonzero because $v_j\notin W_{j-1}$ (linear independence of the original basis).

Two panels: left shows two non-orthogonal vectors v1 and v2 with the projection of v2 onto v1 and the resulting orthogonal residual w2; right shows the resulting orthonormal pair u1, u2 at a right angle, with their dot product confirmed near zero numerically.
Figure — Gram–Schmidt is repeated application of Section 7's projection formula. Left: $v_2$'s component along $u_1$ is subtracted off, leaving $w_2\perp u_1$ by construction — not a new idea, the same orthogonal-residual fact proved in Section 7. Right: normalizing gives an orthonormal pair; the printed dot product ($\approx5\times10^{-17}$) confirms orthogonality up to floating-point roundoff rather than merely asserting it.

9. Computation

The figures above are generated by vector-spaces/generate_figures.py. The snippet below verifies the rank–nullity theorem on a concrete linear map, and confirms Cauchy–Schwarz including its equality case.

import numpy as np

# Rank-nullity on a concrete linear map R^4 -> R^3
A = np.array([
    [1.0, 2.0, -1.0, 0.0],
    [2.0, 4.0,  0.0, 1.0],
    [1.0, 2.0,  1.0, 1.0],
])
rank = np.linalg.matrix_rank(A)
n = A.shape[1]
nullity = n - rank
print(f"rank(A) = {rank}, nullity(A) = {nullity}, rank + nullity = {rank + nullity} (= n = {n})")

# Cauchy-Schwarz: strict for generic vectors, equality exactly when parallel
rng = np.random.default_rng(0)
x = rng.normal(size=5)
y = rng.normal(size=5)
print(f"generic:  |<x,y>| = {abs(x @ y):.4f}  <=  ||x|| ||y|| = {np.linalg.norm(x)*np.linalg.norm(y):.4f}")

y_parallel = 3.0 * x
lhs = abs(x @ y_parallel)
rhs = np.linalg.norm(x) * np.linalg.norm(y_parallel)
print(f"parallel: |<x,y>| = {lhs:.4f}  ==  ||x|| ||y|| = {rhs:.4f}")

Actual output:

rank(A) = 2, nullity(A) = 2, rank + nullity = 4 (= n = 4)
generic:  |<x,y>| = 1.0838  <=  ||x|| ||y|| = 1.8912
parallel: |<x,y>| = 2.2240  ==  ||x|| ||y|| = 2.2240

Confirms the rank–nullity theorem numerically (this particular $A$ has two independent columns, so a $2$-dimensional kernel), and Cauchy–Schwarz both as a strict inequality for generic vectors and as an exact equality once $y$ is forced parallel to $x$ — exactly the equality condition proved in Section 6.

10. Common pitfalls

Pitfall — A spanning set need not be a basis

Spanning only requires enough vectors; a spanning set with redundant (dependent) vectors is not a basis, and "the dimension" is not "however many spanning vectors happen to be on hand" — it is the size of an independent spanning set, well-defined only by the theorem of Section 4.

Pitfall — The subspace test needs all three conditions

Closed under addition alone, or under scalar multiplication alone, is not sufficient. The set $\{(x,y):xy\geq0\}\subset\mathbb{R}^2$ is closed under scalar multiplication by nonnegative scalars but not under addition ($(1,0)$ and $(0,-1)\cdot(-1)=(0,1)$... more simply, $(1,-1)+(-1,1)$ type combinations easily leave such cone-like sets); the standard cautionary example is any single quadrant union or cone that is not a full linear subspace.

Pitfall — "Orthogonal" and "orthonormal" are not the same word

Orthogonal only means pairwise perpendicular ($\langle u_i,u_j\rangle=0$ for $i\neq j$); orthonormal additionally requires unit length ($\langle u_i,u_i\rangle=1$). The clean projection formula $P_Wx=\sum_i\langle x,u_i\rangle u_i$ in Section 7 requires orthonormality specifically — for a merely orthogonal basis, each term needs the $\langle u_i,u_i\rangle$ normalization restored, exactly as in the one-dimensional formula noted after the theorem.

Pitfall — Infinite-dimensional spaces need more care

$C[a,b]$ has no finite basis, and the Steinitz exchange argument of Section 4 as stated is a finite-dimensional argument; infinite-dimensional vector spaces do have bases (Hamel bases), but proving this in general requires the axiom of choice, and such bases are typically unusable in practice (uncountable, non-constructive). Function spaces are instead usually handled through the orthonormal-sequence machinery of Section 8 (e.g. Fourier series) rather than through a Hamel basis — a genuinely different and more useful notion of "basis" in that setting, outside this note's scope.

11. Connections

12. References