Complex Numbers & Functions
Complex Numbers & Functions
A quantum amplitude is not a probability — it is a complex number. Probabilities are the shadow it casts. Everything distinctively quantum, from interference to the Fourier transform that powers Shor's algorithm, lives in the phase that the shadow throws away. This lesson rebuilds the complex field from the ground up so that phase is never mysterious again.
Learning Objectives
By the end of this lesson you will be able to:
- Manipulate complex numbers fluently in both Cartesian () and polar () form, converting between them and computing modulus, argument, and conjugate.
- Derive Euler's formula from the Maclaurin series and use it to prove de Moivre's theorem.
- Define the -th roots of unity with and prove their summation property .
- Explain why quantum amplitudes must be complex — that relative phase is physically observable through interference — and connect this to the Fourier machinery developed later in the course.
- Compute and visualize roots of unity in NumPy and verify their algebraic identities numerically.
Intuition
A real number is a point on a line; a complex number is a point in a plane. That extra dimension is not a bookkeeping convenience — it is rotation. Multiplying by rotates the plane by ; multiplying by rotates it by . The single most important picture to carry forward is this:
A unit-modulus complex number is a pure rotation by angle .
Why does quantum mechanics need this and not just real probabilities? Consider two paths an amplitude can take to the same outcome. Classically you add probabilities: , and more paths can only help. Quantum mechanically you add amplitudes: $\alpha = \alpha_1 + \alpha_2\alpha_1 = \tfrac12\alpha_2 = -\tfrac12$, the outcome probability is : the two paths cancel. That sign — more generally, that relative phase — is the whole game. Real numbers give you only the signs ; complex numbers give you a continuous dial of cancellation. We forward-reference this as interference, the engine of every quantum speedup.
Hold two facts together as you read the theory: complex numbers are (1) the algebra of rotations and (2) the only number system rich enough to let amplitudes interfere continuously while still collapsing to real probabilities via .
Theory
The complex field
Definition (complex numbers). The set with the symbol satisfying , equipped with
forms a field: addition and multiplication are commutative, associative, and distributive;
and are the identities; and every nonzero has an inverse (derived below).
We call the real part and the imaginary
part. (We freely write where Python writes 1j; see Appendix B §1.)
Definition (conjugate and modulus). The complex conjugate of is , and the modulus is
The conjugate flips the sign of the imaginary part (a reflection across the real axis). Two identities we use constantly:
The first gives the multiplicative inverse for :
which proves is a field. Conjugation is an involution () and is additive (); together with it is a field automorphism. This is exactly the operation that turns a ket into a bra: $\langle\psi| = |\psi\rangle^{\dagger}$ conjugates amplitudes (see Appendix C §1).
Cartesian and polar form
Plotting at Cartesian coordinates in the complex plane (Argand diagram), the point also has polar coordinates :
We call the modulus and the argument. The argument is only defined modulo ;
the principal value is the standard choice (NumPy's
np.angle returns it). Use atan2, not , so the correct quadrant is selected.
Euler's formula — derivation via power series
We want a meaning for . Take the real Maclaurin series of , , — each converges for all real arguments, and the exponential series converges absolutely for every complex argument, so we may extend it to and rearrange freely:
Substitute and use the cycle :
Split into even (, giving ) and odd (, giving ) terms. Absolute convergence lets us regroup:
This is Euler's formula:
Immediate consequences:
- — the unit circle, as the intuition promised.
- gives Euler's identity .
- , hence the inverse-on-the-circle: .
- The complex exponential of a general factors a stretch and a rotation:
We can now read polar form as an exponential:
Multiplication becomes transparent — moduli multiply, arguments add:
This is the precise sense in which multiplying by rotates by .
De Moivre's theorem
Setting and iterating the multiplication rule (or, formally, by induction on using ) gives de Moivre's theorem:
It is just in disguise. It is the workhorse for deriving multiple-angle identities and, next, the roots of unity.
The -th roots of unity
We want all solutions of for a positive integer . Write . Then . Matching moduli forces ; matching arguments (modulo ) forces for integer , i.e. . Distinct values arise only for . Defining the primitive -th root of unity
the roots are exactly the powers of :
Geometrically they are the vertices of a regular -gon inscribed in the unit circle, starting at and stepping counter-clockwise by . (We use the sign convention $\omega = e^{+2\pi i/N}$ throughout the program; see Appendix C §4. The DFT in lesson 3 uses as its forward kernel — a deliberate, consistent choice.)
Theorem (vanishing sum). For ,
Proof. The sum is a finite geometric series with ratio . Since , $\omega = e^{2\pi i/N}\neq 12\pi/N\in(0,2\pi)2\pi$), so the closed form applies:
But , so the numerator is while the denominator $1-\omega\neq 00\blacksquare$
This is the algebraic heart of all Fourier analysis: distinct frequency components cancel when summed over a full period. We generalize it now.
Corollary (orthogonality of roots). For integers ,
matching the DFT/QFT orthogonality in Appendix E §6.
Proof. Let . If then every term is and the average is . Otherwise and the same geometric-series argument gives
Other useful properties.
- Closure / group structure. The roots are closed under multiplication: . They form the cyclic group under addition of exponents — the same group that indexes computational basis states in the QFT.
- Conjugate = inverse. , since .
- Product of all roots. $\prod_{k=0}^{N-1}\omega^{k} = \omega^{,0+1+\cdots+(N-1)} = \omega^{N(N-1)/2} = (-1)^{N-1}$.
Why quantum amplitudes are complex
A pure state is with and (Appendix C §1). Measurement gives outcome with probability — so why not just store the probabilities and stay real and nonnegative?
Because evolution mixes the components, and the mixing is sensitive to phase. Apply a Hadamard to versus $|-\rangle = \tfrac1{\sqrt2}(|0\rangle-|1\rangle)$:
Both and have the same measurement statistics in the computational basis (), so the probability vector cannot tell them apart. Yet sends one to a certain and the other to a certain . The only thing distinguishing them is the relative phase versus — a phase . Relative phase is therefore physically observable: it changes future measurement outcomes after interference.
Two more points pin this down:
- Global phase is unobservable. and give identical statistics for every measurement, because . Only phase differences between amplitudes matter — exactly the relative phase above.
- Why not just signs ? Real amplitudes ( up to scale) allow only two-way cancellation. Continuous phases let amplitudes interfere by any angle, and the canonical phases are precisely the roots of unity . When a quantum register holds a uniform superposition and we apply a phase to basis state , the interference pattern is governed by sums like — which, by the vanishing-sum theorem above, are zero except at special . That selective cancellation is the Quantum Fourier Transform, developed in Term 2.4 · The Quantum Fourier Transform.
So: amplitudes are complex because nature lets probability amplitudes rotate and interfere, and is the minimal arena — a field where recovers probabilities — in which continuous rotation lives.
Worked Examples
Example 1 — Polar form, powers, and a root
Let .
Modulus and argument. . The point is in the first quadrant, so . Thus
A power, via de Moivre. Compute :
The phase wraps exactly once around the circle and lands back on the positive real axis — a clean illustration of "arguments add (mod ), moduli multiply."
A square root. $\sqrt z = \sqrt2,e^{i\pi/6} = \sqrt2(\cos\tfrac\pi6 + i\sin\tfrac\pi6) = \sqrt2\big(\tfrac{\sqrt3}{2} + \tfrac{i}{2}\big) = \tfrac{\sqrt6}{2} + \tfrac{\sqrt2}{2},i$. (The other root is its negative.)
Example 2 — The cube roots of unity and their sum
Take , . The roots are:
They are the vertices of an equilateral triangle on the unit circle. Their sum:
confirming . Note also , as the conjugate-inverse property predicts.
Example 3 — Interference: distinguishing from
Let and consider . The Hadamard H = \tfrac1{\sqrt2}\begin{psmallmatrix}1&1\\1&-1\end{psmallmatrix} acts as
In the amplitudes and cancel by destructive interference (their relative phase is ); in the amplitudes cancel instead. A purely real, nonnegative probability description for both inputs could never predict these opposite, deterministic outputs. The complex (here, just signed) relative phase is doing physical work — this is the smallest possible instance of the interference that the Fourier methods in this course exploit at scale.
Hands-on (Python)
import numpy as np
import matplotlib.pyplot as plt
# ----- Cartesian <-> polar -----
z = 1 + 1j * np.sqrt(3) # 1 + i*sqrt(3)
print("z =", z)
print("|z| =", abs(z)) # 2.0 = modulus
print("arg(z) [rad] =", np.angle(z)) # ~1.047 = pi/3
print("conj(z) =", z.conjugate()) # 1 - i*sqrt(3)
print("z * conj(z) =", (z * z.conjugate()).real) # |z|^2 = 4.0
# Reconstruct z from polar form r * e^{i*theta}
r, theta = abs(z), np.angle(z)
z_polar = r * np.exp(1j * theta)
print("polar matches Cartesian:", np.isclose(z, z_polar)) # True
def roots_of_unity(N):
"""Return the N-th roots of unity as a complex array [omega^0, ..., omega^{N-1}]."""
k = np.arange(N)
omega = np.exp(2j * np.pi / N) # primitive root ω = e^{2πi/N}
return omega ** k # equivalently np.exp(2j*np.pi*k/N)
# ----- Verify the vanishing-sum theorem Σ ω^k = 0 for several N -----
for N in (2, 3, 4, 8, 16):
s = roots_of_unity(N).sum()
print(f"N={N:2d}: Σ ω^k = {s:.2e} (|sum| = {abs(s):.2e})")
assert np.isclose(s, 0.0, atol=1e-12), "vanishing-sum theorem failed!"
# ----- Verify orthogonality (1/N) Σ_x ω^{x(j-k)} = δ_{jk} -----
N = 8
omega = np.exp(2j * np.pi / N)
x = np.arange(N)
# Build the N x N matrix M[j, k] = (1/N) Σ_x ω^{x(j-k)}; it should be the identity.
M = np.array([[np.mean(omega ** (x * (j - k))) for k in range(N)] for j in range(N)])
print("orthogonality gives identity:", np.allclose(M, np.eye(N), atol=1e-12)) # True
def plot_roots_of_unity(N):
"""Plot the N-th roots of unity on the unit circle."""
roots = roots_of_unity(N)
fig, ax = plt.subplots(figsize=(5, 5))
circle = plt.Circle((0, 0), 1.0, fill=False, linestyle="--", color="gray")
ax.add_patch(circle)
ax.scatter(roots.real, roots.imag, zorder=3)
for k, w in enumerate(roots):
ax.annotate(rf"$\omega^{{{k}}}$", (w.real, w.imag),
textcoords="offset points", xytext=(6, 6))
ax.axhline(0, color="black", lw=0.5); ax.axvline(0, color="black", lw=0.5)
ax.set_aspect("equal"); ax.set_xlim(-1.3, 1.3); ax.set_ylim(-1.3, 1.3)
ax.set_title(rf"$N={N}$ roots of unity, $\omega=e^{{2\pi i/{N}}}$")
ax.set_xlabel("Re"); ax.set_ylabel("Im")
plt.tight_layout(); plt.show()
plot_roots_of_unity(8)
# ----- Interference demo: H distinguishes |+> from |-> -----
H = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)
ket_plus = np.array([1, 1], dtype=complex) / np.sqrt(2)
ket_minus = np.array([1, -1], dtype=complex) / np.sqrt(2)
print("H|+> =", np.round(H @ ket_plus, 12).real) # [1, 0] -> |0>
print("H|-> =", np.round(H @ ket_minus, 12).real) # [0, 1] -> |1>Running this prints |z|=2.0, arg(z)≈1.047 (), confirms to machine
precision for every , verifies the orthogonality matrix is the identity, draws the regular
-gon of roots, and shows that maps and
— interference made visible.
Exercises
Attempt each before expanding the solution.
1. (Easy) Cartesian ↔ polar. Write in polar form with , then compute .
Solution
. The point is in the second quadrant: . So . Then . Reduce the argument mod : , so $z^4 = 16,e^{i4\pi/3} = 16(-\tfrac12 - \tfrac{\sqrt3}{2}i) = -8 - 8\sqrt3,i$.
2. (Easy) Conjugate identities. Prove directly from , , and use it to show .
Solution
, so . Meanwhile $z^{}w^{} = (a-bi)(c-di) = (ac - bd) - (ad+bc)i-adi - bci-(ad+bc)i$, and ). They match. Then $|zw|^2 = (zw)(zw)^{} = z w z^{} w^{} = (zz^{})(ww^{*}) = |z|^2|w|^2|zw| = |z||w|$. (In polar form this is just "moduli multiply.")
3. (Medium) De Moivre → trig identity. Use de Moivre with to derive .
Solution
. Expand the left side with the binomial theorem: $\cos^3\theta + 3\cos^2\theta(i\sin\theta) + 3\cos\theta(i\sin\theta)^2 + (i\sin\theta)^3 = \cos^3\theta - 3\cos\theta\sin^2\theta + i(3\cos^2\theta\sin\theta - \sin^3\theta)$. Match real parts: . Substitute $\sin^2\theta = 1 - \cos^2\theta\cos3\theta = \cos^3\theta - 3\cos\theta(1-\cos^2\theta) = 4\cos^3\theta - 3\cos\theta\blacksquare$
4. (Medium) Sum of a subset of roots. For , compute where . Explain the result group-theoretically.
Solution
is a primitive cube root of unity. As runs over , runs over the cube roots twice (period 3). So by the vanishing-sum theorem for . Group-theoretically, is the subgroup generated by , which is the cyclic group of order ; the sum over any nontrivial finite cyclic subgroup (here covered twice) vanishes.
5. (Hard) Geometric-series proof, general phase. Show that for any real with , $\big|\sum_{k=0}^{N-1} e^{ik\phi}\big| = \big|\frac{\sin(N\phi/2)}{\sin(\phi/2)}\big|\sum_{k}\omega^k = 0\phi = 2\pi/N$.
Solution
Sum the geometric series with ratio : . Factor out the half-angle from numerator and denominator ("$1-e^{i\alpha} = e^{i\alpha/2}(e^{-i\alpha/2} - e^{i\alpha/2}) = -2i,e^{i\alpha/2}\sin(\alpha/2)$"):
Taking the modulus (the leading exponential has modulus 1) gives . For : , so while for . Hence , i.e. .
6. (Hard) Phase encodes a number. A single qubit is prepared in for some unknown . (a) Show that measuring in the computational basis cannot reveal . (b) Show that applying first and then measuring gives outcome with probability , so the relative phase becomes measurable. (This is the seed of phase estimation.)
Solution
(a) and likewise for outcome , independent of — the global phase on is washed out by .
(b) $H|\psi_\varphi\rangle = \tfrac1{\sqrt2}\big[\tfrac1{\sqrt2}(|0\rangle+|1\rangle) + e^{2\pi i\varphi}\tfrac1{\sqrt2}(|0\rangle-|1\rangle)\big] = \tfrac12\big[(1+e^{2\pi i\varphi})|0\rangle + (1-e^{2\pi i\varphi})|1\rangle\big]|0\rangle\tfrac12(1+e^{2\pi i\varphi})1+e^{i\alpha} = e^{i\alpha/2}(e^{-i\alpha/2}+e^{i\alpha/2}) = 2e^{i\alpha/2} \cos(\alpha/2)\alpha = 2\pi\varphie^{i\pi\varphi}\cos(\pi\varphi)$, so . The previously hidden phase now controls a measurable probability — interference has converted relative phase into statistics. This is exactly the mechanism scaled up in Term 2.4.
Checkpoint
1. State Euler's formula and give the one-line reason $|e^{i\theta}|=1$.
. Its modulus is , so it lies on the unit circle — a pure rotation by .
2. Why does $\sum_{k=0}^{N-1}\omega^k = 0$ for $N>1$, in one sentence?
It is a geometric series with ratio ; its closed form has numerator because .
3. What is the difference between global phase and relative phase, and which is physical?
A global phase multiplies the whole state and is unobservable ($|e^{i\gamma}\alpha|^2 = |\alpha|^2\beta/\alpha$); it is physically observable because it changes interference and hence future measurement statistics.
4. Concretely, why can't real nonnegative probabilities replace complex amplitudes?
Because evolution mixes amplitudes, and the result depends on phases. and share the probability vector but maps them to and respectively — opposite deterministic outcomes. Only the complex (relative) phase distinguishes the inputs.
5. How are the $N$-th roots of unity related to the group $\mathbb Z/N\mathbb Z$?
, so the roots are closed under multiplication and form a cyclic group isomorphic to via . This is the group that indexes basis states in the (Quantum) Fourier Transform.
6. What single identity from this lesson is the algebraic core of the DFT/QFT?
The orthogonality relation — distinct frequency components cancel over a full period, leaving only the matching term. We use it to prove the DFT matrix is unitary in lesson 3.
Further Reading
- [NC, §2.1] — complex linear algebra background the program relies on.
- [Axl] — Linear Algebra Done Right: clean treatment of as the scalar field.
- Appendix E §6 — roots of unity, the QFT kernel, Euler's formula, in the program's exact notation.
- Appendix C §1, §4 — global vs. relative phase; the Fourier sign convention.
← Prev: Classical Information Theory · Up: Term 0 · Next: Fourier Series & Transforms →