TExcelTAD
Home › Linear Algebra & Matrix Theory › Definition of Vector Spaces

Definition of Vector Spaces

Everything we did with vectors in Rn\mathbb{R}^n used only two operations: adding vectors and multiplying them by numbers. Polynomials, functions, matrices, sound signals and bit strings can be added and scaled too. A vector space is any collection with those two operations obeying the usual rules, and every theorem proved from the rules then holds for all of them at once.

The axioms

Fix a field of scalars FF, usually R\mathbb{R}, sometimes C\mathbb{C} or GF(2) (Fields). A vector space over FF is a set VV with an addition u+v∈V\mathbf{u} + \mathbf{v} \in V and a scalar multiplication cv∈Vc\mathbf{v} \in V (for u,v∈V\mathbf{u}, \mathbf{v} \in V and c∈Fc \in F) such that, for all u,v,w∈V\mathbf{u}, \mathbf{v}, \mathbf{w} \in V and a,b∈Fa, b \in F:

# Axiom Name
1 u+v=v+u\mathbf{u} + \mathbf{v} = \mathbf{v} + \mathbf{u} addition is commutative
2 (u+v)+w=u+(v+w)(\mathbf{u} + \mathbf{v}) + \mathbf{w} = \mathbf{u} + (\mathbf{v} + \mathbf{w}) addition is associative
3 there is a vector 0\mathbf{0} with v+0=v\mathbf{v} + \mathbf{0} = \mathbf{v} zero vector
4 each v\mathbf{v} has a −v-\mathbf{v} with v+(−v)=0\mathbf{v} + (-\mathbf{v}) = \mathbf{0} additive inverse
5 a(u+v)=au+ava(\mathbf{u} + \mathbf{v}) = a\mathbf{u} + a\mathbf{v} distributive over vectors
6 (a+b)v=av+bv(a + b)\mathbf{v} = a\mathbf{v} + b\mathbf{v} distributive over scalars
7 a(bv)=(ab)va(b\mathbf{v}) = (ab)\mathbf{v} compatible multiplication
8 1⋅v=v1 \cdot \mathbf{v} = \mathbf{v} unit scalar

"In VV" is part of the deal: the sum of two elements and every scalar multiple must land back in VV (closure). The elements of VV are called vectors, whatever they actually are.

A few facts follow from the axioms alone, and so hold in every vector space: the zero vector is unique, 0⋅v=00 \cdot \mathbf{v} = \mathbf{0}, c⋅0=0c \cdot \mathbf{0} = \mathbf{0}, and (−1)⋅v=−v(-1) \cdot \mathbf{v} = -\mathbf{v}. For example, 0⋅v=(0+0)⋅v=0⋅v+0⋅v0 \cdot \mathbf{v} = (0 + 0) \cdot \mathbf{v} = 0 \cdot \mathbf{v} + 0 \cdot \mathbf{v} by axiom 6, and adding −(0⋅v)-(0 \cdot \mathbf{v}) to both sides leaves 0=0⋅v\mathbf{0} = 0 \cdot \mathbf{v}.

A zoo of examples

Space Vectors Addition and scaling Zero vector
Rn\mathbb{R}^n lists (x1,…,xn)(x_1, \ldots, x_n) entry by entry (0,…,0)(0, \ldots, 0)
PnP_n polynomials of degree ≤n\le n add/scale coefficients the zero polynomial
Mm×nM_{m \times n} m×nm \times n matrices entry by entry (Matrix Addition) the zero matrix
F(R)F(\mathbb{R}) all functions f:R→Rf: \mathbb{R} \to \mathbb{R} (f+g)(x)=f(x)+g(x)(f + g)(x) = f(x) + g(x), (cf)(x)=c⋅f(x)(cf)(x) = c \cdot f(x) f(x)=0f(x) = 0
C[a,b]C[a, b] continuous functions on [a,b][a, b] as for functions f(x)=0f(x) = 0
solutions of y′′+y=0y'' + y = 0 functions acos⁡x+bsin⁡xa\cos x + b\sin x as for functions y=0y = 0
GF(2)n\mathrm{GF}(2)^n bit strings of length nn XOR, scalars 0 and 1 00…0
sequences infinite lists (a0,a1,…)(a_0, a_1, \ldots) term by term (0,0,…)(0, 0, \ldots)

The point is not to memorise the list but to notice that "vector" is a role, not a type. A function is a vector in F(R)F(\mathbb{R}). An audio clip of 44 100 samples is a vector in R44 100\mathbb{R}^{44\,100}. A word embedding is a vector in R768\mathbb{R}^{768}.

In code, a polynomial of degree ≤2\le 2 can be stored as its coefficient list, and then its vector-space operations are exactly those of R3\mathbb{R}^3:

python · try it yourself
from fractions import Fraction as Fr

def add(p, q):   return [a + b for a, b in zip(p, q)]
def scale(c, p): return [c * a for a in p]
def show(p):
    terms = [f"{a}{['', 'x', 'x^2'][i]}" for i, a in enumerate(p) if a != 0]
    return " + ".join(terms).replace("+ -", "- ") or "0"

p = [1, -2, 3]           # 1 - 2x + 3x^2
q = [Fr(1, 2), 0, -1]    # 1/2 - x^2
print("p + q    =", show(add(p, q)))
print("3p - 2q  =", show(add(scale(3, p), scale(-2, q))))
print("p + (-p) =", show(add(p, scale(-1, p))))
p + q    = 3/2 - 2x + 2x^2
3p - 2q  = 2 - 6x + 11x^2
p + (-p) = 0

Non-examples

Checking a candidate usually comes down to closure and the zero vector:

Set Why it fails
the line y=2x+1y = 2x + 1 in R2\mathbb{R}^2 does not contain 0\mathbf{0}; (0,1)+(1,3)=(1,4)(0, 1) + (1, 3) = (1, 4) is off the line
polynomials of degree exactly 2 x2+(−x2+x)=xx^2 + (-x^2 + x) = x has degree 1
vectors in R2\mathbb{R}^2 with x≥0x \ge 0 (1,0)(1, 0) is in, but (−1)⋅(1,0)(-1) \cdot (1, 0) is not
invertible 2×22 \times 2 matrices I+(−I)=0I + (-I) = 0 is not invertible
Zn\mathbb{Z}^n (integer vectors) over R\mathbb{R} 12⋅(1,0)\frac{1}{2} \cdot (1, 0) is not in Zn\mathbb{Z}^n

An exotic example

The axioms only care about the operations, not what they look like. Let V=R+V = \mathbb{R}^+ (the positive reals) with

u⊕v=u⋅v(vector “addition” is ordinary multiplication)c⊙v=vc(scalar “multiplication” is a power)\begin{aligned} u \oplus v &= u \cdot v && \text{(vector ``addition'' is ordinary multiplication)} \\ c \odot v &= v^c && \text{(scalar ``multiplication'' is a power)} \end{aligned}

The zero vector is the number 1 (since u⊕1=uu \oplus 1 = u), and the "negative" of vv is 1/v1/v. Axiom 6 becomes va+b=va⋅vbv^{a+b} = v^a \cdot v^b, and axiom 5 becomes (uv)a=uava(uv)^a = u^a v^a: the laws of exponents. The logarithm turns this space into ordinary R\mathbb{R} (log⁡(uv)=log⁡u+log⁡v\log(uv) = \log u + \log v), which is why log-probabilities are added in machine learning code instead of multiplying probabilities.

python · try it yourself
import math

add = lambda u, v: u * v
smul = lambda c, v: v ** c
u, v, a, b = 2.0, 5.0, 3.0, -0.5
checks = {
    "commutative": math.isclose(add(u, v), add(v, u)),
    "zero is 1": math.isclose(add(u, 1.0), u),
    "inverse 1/v": math.isclose(add(v, 1 / v), 1.0),
    "a(u+v)=au+av": math.isclose(smul(a, add(u, v)), add(smul(a, u), smul(a, v))),
    "(a+b)v=av+bv": math.isclose(smul(a + b, v), add(smul(a, v), smul(b, v))),
    "a(bv)=(ab)v": math.isclose(smul(a, smul(b, v)), smul(a * b, v)),
}
for name, ok in checks.items():
    print(f"{name:14} {ok}")
commutative    True
zero is 1      True
inverse 1/v    True
a(u+v)=au+av   True
(a+b)v=av+bv   True
a(bv)=(ab)v    True

In software

  • Generic code: interpolation, averaging and gradient steps need only + and scaling, so the same lerp(a, b, t) = a + t·(b − a) works for positions, colours, quaternions (approximately) and neural-network weights.
  • Signals and functions: audio mixing is vector addition and volume is scaling; Fourier analysis treats functions as vectors (Orthogonal Projections and Fourier Series).
  • ML: model weights live in RN\mathbb{R}^N with NN in the billions; "model merging" and LoRA updates are vector additions in that space (Low-Rank Approximation).
  • Coding theory: bit strings form a vector space over GF(2), the basis of error-correcting codes (Application: Error Correcting Codes).

Exercises

Exercise 1: Trace-zero matrices

Is the set of 2×22 \times 2 matrices with trace 0 a vector space (with the usual operations)?

Answer

Yes.

Solution

The axioms 1–8 are inherited from M2×2M_{2 \times 2}, so only closure and the zero vector need checking. tr⁡(A+B)=tr⁡A+tr⁡B=0+0=0\operatorname{tr}(A + B) = \operatorname{tr} A + \operatorname{tr} B = 0 + 0 = 0, tr⁡(cA)=c⋅tr⁡A=0\operatorname{tr}(cA) = c \cdot \operatorname{tr} A = 0, and the zero matrix has trace 0. (It is a subspace of M2×2M_{2 \times 2}, see Subspaces.)

Exercise 2: Polynomials with p(0)=1p(0) = 1

Is {p∈P2:p(0)=1}\{p \in P_2 : p(0) = 1\} a vector space?

Answer

No.

Solution

It does not contain the zero polynomial (which has p(0)=0p(0) = 0), and it is not closed under addition: if p(0)=q(0)=1p(0) = q(0) = 1 then (p+q)(0)=2(p + q)(0) = 2.

Exercise 3: A broken addition

On R2\mathbb{R}^2 define (x1,y1)⊕(x2,y2)=(x1+x2,0)(x_1, y_1) \oplus (x_2, y_2) = (x_1 + x_2, 0) and the usual scalar multiplication. Which axiom fails?

Answer

Axiom 3: there is no zero vector. Axioms 5 and 6 fail too, for vectors with y≠0y \ne 0.

Solution

A zero vector z\mathbf{z} would need (x,y)⊕z=(x,y)(x, y) \oplus \mathbf{z} = (x, y) for every vector, but the result always has second entry 0. So (0,1)⊕z≠(0,1)(0, 1) \oplus \mathbf{z} \ne (0, 1) for every z\mathbf{z}. Axiom 6 fails as well: (1+1)⋅(0,1)=(0,2)(1 + 1) \cdot (0, 1) = (0, 2), but 1⋅(0,1)⊕1⋅(0,1)=(0,0)1 \cdot (0, 1) \oplus 1 \cdot (0, 1) = (0, 0). Axioms 1, 2 and 8 still hold, which shows that each axiom has to be checked separately.

Exercise 4: Solutions of an ODE

Show that the solutions of y′′−3y′+2y=0y'' - 3y' + 2y = 0 form a vector space, and check with SymPy that exe^x, e2xe^{2x} and 4ex−7e2x4e^x - 7e^{2x} are all solutions.

Answer

The left side is linear in yy, so sums and multiples of solutions are solutions, and y=0y = 0 is one. All three functions give 0.

Solution

If L(y)=y′′−3y′+2yL(y) = y'' - 3y' + 2y, then L(y1+y2)=L(y1)+L(y2)L(y_1 + y_2) = L(y_1) + L(y_2) and L(cy)=c⋅L(y)L(cy) = c \cdot L(y). So L(y1)=L(y2)=0L(y_1) = L(y_2) = 0 implies L(y1+y2)=0L(y_1 + y_2) = 0 and L(cy1)=0L(cy_1) = 0.

python · try it yourself
from sympy import symbols, exp, diff, simplify

x = symbols("x")
L = lambda y: simplify(diff(y, x, 2) - 3 * diff(y, x) + 2 * y)
for y in [exp(x), exp(2 * x), 4 * exp(x) - 7 * exp(2 * x), exp(3 * x)]:
    print(f"L({y}) = {L(y)}")
L(exp(x)) = 0
L(exp(2*x)) = 0
L(-7*exp(2*x) + 4*exp(x)) = 0
L(exp(3*x)) = 2*exp(3*x)

The last line is a function that is not a solution, for comparison.

Test yourself

Which set is a vector space with the usual operations?

  1. Polynomials of degree exactly 3
  2. The line y=x+1y = x + 1 in R2\mathbb{R}^2
  3. All 3×33 \times 3 symmetric matrices
  4. Vectors in R3\mathbb{R}^3 with all entries ≥0\ge 0

In the space R+\mathbb{R}^+ with u⊕v=uvu \oplus v = uv and c⊙v=vcc \odot v = v^c, what is the zero vector?

  1. 0
  2. 1
  3. ee
  4. There is none

Which fact holds in every vector space?

  1. Vectors are lists of numbers
  2. 0⋅v=00 \cdot \mathbf{v} = \mathbf{0} for every vector v\mathbf{v}
  3. Every vector has a length
  4. Vectors can be multiplied by each other