“The universe is an enormous direct product of representations of symmetry groups.”
— Steven Weinberg
Welcome to the first step of our journey. We are about to discover that the diverse landscapes of physics—the swing of a pendulum, the spin of an electron, the glow of a star—are all built from the same mathematical clay. That clay is the vector space.
In this session, we will:
A vector space over a field \(\mathbb{F}\) (usually the real numbers \(\mathbb{R}\) or the complex numbers \(\mathbb{C}\)) is a set \(V\) equipped with two operations:
These operations must satisfy a familiar list of axioms: commutativity, associativity, existence of a zero vector, existence of additive inverses, distributivity of scalars, and so on. You have seen these before—they are the rules that make vectors “behave nicely.”
But a definition without a soul is empty. The magic happens when we realise that the elements of \(V\) need not be geometric arrows. They can be positions, quantum states, functions, or even abstract symbols. The only requirement is that they obey the same handful of rules.
Let us meet three very different physical systems, each of which forms a vector space.
Imagine a particle that can only move along a straight line (the \(x\)-axis). Its position is a real number \(x\). The set of all possible positions is \(\mathbb{R}\). Is this a vector space? Yes!
But wait—does “addition of positions” make physical sense? In everyday language, we add displacements, not positions. However, if we fix an origin, every position can be thought of as a displacement from that origin. Then adding two positions means: start at the origin, go to the first position, then go from there by the displacement equal to the second position. This yields a new position (the sum). So indeed, positions form a vector space once we choose an origin.
More naturally, the space of displacements (arrows from one point to another) is a vector space. Displacements add tip‑to‑tail, and scaling a displacement changes its length. This is the classic picture of vectors as arrows.
A spin‑½ particle, like an electron, has an internal degree of freedom: its spin can point “up” or “down” along some axis. In quantum mechanics, the state of the spin is not simply “up or down” but a superposition of both possibilities. Mathematically, the state is a vector in a two‑dimensional complex vector space, usually denoted \(\mathbb{C}^2\).
This is radically different from classical physics. Here, addition does not correspond to any classical notion of “combining” objects—it is the purely quantum phenomenon of superposition.
Consider the electric field \(\mathbf{E}(\mathbf{r})\) at every point in space. This is a function that assigns a vector to each location. The set of all such functions (subject to suitable conditions like square‑integrability) is a vector space—often called a function space.
Here the vectors are entire fields. The vector space is infinite‑dimensional because specifying a field requires infinitely many numbers (one for each point in space). Yet the algebraic rules are exactly the same as for the humble displacements in one dimension.
Let us put these three examples side by side.
| System | Vectors are … | Addition means … | Scalar multiplication means … |
|---|---|---|---|
| Classical particle | Positions / displacements | Combining displacements (tip‑to‑tail) | Stretching a displacement |
| Quantum spin | State vectors in \(\mathbb{C}^2\) | Superposition of possibilities | Changing amplitude and phase |
| Electromagnetic field | Electric field functions | Fields from different sources add | Amplifying the field strength everywhere |
Despite the wildly different physical interpretations, the mathematical operations are identical. In every case:
This is the first glimpse of the unity we will explore throughout this book. Physics may seem fragmented into separate domains, but beneath the surface, a common mathematical language flows.
The ability to add vectors is so central that it has a special name in physics: the principle of superposition. Let’s see what it enables in each of our three worlds.
In each case, the same mathematical act—addition—produces phenomena that define the character of the field.
We have seen that many different physical systems are instances of the same abstract structure: a vector space. Mathematicians have a way of capturing this idea: they organise vector spaces into a category, called \(\mathbf{Vect}\).
Why introduce this language now? Because it gives us a bird’s‑eye view. Instead of studying each physical system in isolation, we can study the relationships between them. For example, the Fourier transform is a linear map from the space of wave functions to the space of momentum functions—it connects two different physical representations of the same quantum system.
Throughout this book, we will gradually build up the categorical toolkit. For now, just remember: vector spaces are objects, and the maps that respect their structure are the arrows that connect them.
Enough talk—let’s write some code. We will use Python with three libraries:
Our goal: implement the three physical systems and show that the same addition and scalar multiplication operations work for all, while the visualisations differ.
First, install the libraries if you haven’t already:
pip install discopy numpy matplotlib sympy
Now, open a Jupyter notebook or Python script and import what we need:
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
from discopy.tensor import Tensor, Dim
We represent a displacement vector as a Tensor from
DisCoPy. (Don’t worry about the details yet—think of it as a generalised
array.)
# Two displacement vectors
from discopy.tensor import Tensor, Dim
import numpy as np
import matplotlib.pyplot as plt
# Two displacement vectors (as morphisms from unit to 2D)
v1 = Tensor([2, 1], Dim(1), Dim(2))
v2 = Tensor([1, 3], Dim(1), Dim(2))
# Addition works as expected (since both have same dom/cod)
v_sum = v1 + v2
print("v1 + v2 =", v_sum.array)
Now visualise them as arrows:
def draw_vector(v, origin=(0,0), color='b', label=None):
# v.array is a numpy array of shape (1,2) because dom=Dim(1), cod=Dim(2)
arr = v.array.flatten() # flatten to 1D for plotting
plt.arrow(origin[0], origin[1], arr[0], arr[1],
head_width=0.1, head_length=0.1, fc=color, ec=color, label=label)
plt.figure(figsize=(6,6))
draw_vector(v1, color='blue', label='v1')
draw_vector(v2, origin=v1.array.flatten(), color='red', label='v2')
draw_vector(v_sum, color='green', label='v1+v2')
plt.xlim(-1,5); plt.ylim(-1,5)
plt.grid(); plt.legend(); plt.title('Classical Displacement Addition')
plt.show()
You should see the two vectors added tip‑to‑tail, with the resultant vector closing the triangle.
We represent spin states as complex vectors in \(\mathbb{C}^2\). DisCoPy’s
Tensor can handle complex numbers.
import numpy as np
import matplotlib.pyplot as plt
from discopy.tensor import Tensor, Dim
def scale_tensor(t, factor):
"""Return a new tensor with the array multiplied by factor."""
return Tensor(t.array * factor, t.dom, t.cod)
# --- Quantum spin state ---
up = Tensor([1, 0], Dim(1), Dim(2))
down = Tensor([0, 1], Dim(1), Dim(2))
# Superposition: (|up> + |down>) / √2
plus_raw = up + down # array becomes [1, 1]
plus = scale_tensor(plus_raw, 1 / np.sqrt(2))
print("|+> =", plus.array) # shape (1,2)
probs = np.abs(plus.array.flatten())**2
print("Probabilities:", probs)
# Visualise
plt.figure()
plt.bar(['|↑⟩', '|↓⟩'], probs, color='purple')
plt.ylim(0, 1)
plt.ylabel('Probability')
plt.title('Quantum Superposition')
plt.show()
The bar chart shows that the particle has a 50% chance to be found up and 50% down—a direct consequence of vector addition.
We’ll work with 1D waves for simplicity. Define two sine waves and add them pointwise.
# Define spatial domain
x = np.linspace(0, 4*np.pi, 500)
# Two waves with different amplitudes, phases
A1, k1, phi1 = 1.0, 1.0, 0.0
A2, k2, phi2 = 0.8, 2.0, np.pi/4
wave1 = A1 * np.sin(k1 * x + phi1)
wave2 = A2 * np.sin(k2 * x + phi2)
wave_sum = wave1 + wave2
# Plot
plt.figure()
plt.plot(x, wave1, label='wave1')
plt.plot(x, wave2, label='wave2')
plt.plot(x, wave_sum, 'k--', label='sum')
plt.xlabel('Position x')
plt.ylabel('Electric field')
plt.legend()
plt.title('EM Wave Superposition')
plt.show()
You’ll see interference patterns—places where the waves reinforce or cancel. This is vector addition in function space.
Let’s use SymPy to derive the interference condition symbolically.
# Define symbols
k, x, A1, A2, phi1, phi2 = sp.symbols('k x A1 A2 phi1 phi2', real=True)
# Two waves with same k (for simplicity)
wave1 = A1 * sp.sin(k*x + phi1)
wave2 = A2 * sp.sin(k*x + phi2)
# Sum and simplify using trigonometric identity
wave_sum = sp.simplify(wave1 + wave2)
print("Sum of waves:", wave_sum)
# Combine into a single sine
amplitude = sp.sqrt(A1**2 + A2**2 + 2*A1*A2*sp.cos(phi1 - phi2))
phase = sp.atan2(A1*sp.sin(phi1) + A2*sp.sin(phi2),
A1*sp.cos(phi1) + A2*sp.cos(phi2))
print("Amplitude =", amplitude)
print("Phase =", phase)
This shows that the sum of two sine waves is another sine wave with modified amplitude and phase—a perfect illustration of vector addition in the space of sinusoidal functions.
In the next session, we will dig deeper into the concept of a basis and discover how coordinates allow us to turn abstract vectors into concrete numbers—and why physics should be independent of the basis we choose.
To solidify your understanding, complete the following tasks. They are designed to be solved with the Python tools we introduced.
Classical: Create three displacement vectors in 2D. Compute their sum in different orders and verify that addition is commutative and associative. Visualise each order to see that the final resultant is the same.
Quantum: Create the state \(|\psi\rangle = \frac{1}{\sqrt{3}}|{\uparrow}\rangle + \sqrt{\frac{2}{3}}|{\downarrow}\rangle\). Compute its probabilities and verify they sum to 1. What is the probability of measuring spin up? Now create another state \(|\phi\rangle = \frac{1}{\sqrt{2}}(|{\uparrow}\rangle - |{\downarrow}\rangle)\) and compute their inner product \(\langle\phi|\psi\rangle\). What does this inner product represent physically?
Electromagnetic: Generate two waves with different frequencies (e.g., \(k_1=1\), \(k_2=1.5\)). Plot their sum and observe the beat pattern. Explain how this arises from vector addition.
Symbolic: Use SymPy to derive the general formula for the sum of two waves with different wave numbers. Is the result still a pure sine wave? Why or why not?
Categorical thought (optional): Write a short paragraph explaining how the concept of a vector space unifies the three systems you explored. Use the language of objects and maps if you can.
Tensor class is more powerful than we have
shown; it can represent tensors of arbitrary dimension and supports
categorical operations like composition and monoidal products. We will
explore these later.In the next chapter, we will meet bases—the coordinate systems that let us label vectors—and learn why physics must be invariant under changes of basis. Prepare to rotate your point of view!