Why start with complex numbers?
A classical bit is in one of two states. A classical random bit is described by two non-negative numbers that add up to one: the probability of 0 and the probability of 1. It is tempting to guess that a qubit is a fancier version of the random bit. It is not, and the difference is the subject of this lesson.
A qubit is described by two complex numbers, called amplitudes. Outcome probabilities are obtained from them only at the very end, by taking squared magnitudes. Before that moment amplitudes can add, subtract and rotate against each other, so two routes to the same outcome can cancel. Probabilities cannot do that: adding non-negative numbers never gives zero unless every term is zero. This cancellation, called interference, is the resource every quantum algorithm in this course exploits. To use it you need a working command of complex arithmetic and of vectors with complex entries, which is what we build here. The treatment follows standard conventions, as in Nielsen and Chuang, Chapter 2.
Complex numbers in brief
A complex number is with real (the real part) and real (the imaginary part), where . Three operations matter constantly.
- Conjugate: . Conjugation reflects across the real axis.
- Modulus: , the distance from the origin in the complex plane. A useful identity is , because .
- Polar form: every non-zero can be written with and an angle , the argument or phase.
The polar form rests on Euler's formula,
which places on the unit circle at angle from the positive real axis. Two consequences are worth memorising: for every real , and . Multiplying by therefore rotates a complex number by without changing its length, and multiplying by multiplies the lengths and adds the angles.
Example. has modulus and lies at , so . Its conjugate is , and . Also , and : a minus sign is a phase of , and a factor of is a phase of .
Vectors in and the inner product
A vector in is a column of complex numbers. Quantum mechanics writes such a vector as a ket, , and the conjugate transpose of that column (a row) as a bra, . For one qubit, and the two standard basis vectors are
so a general vector is with complex .
The inner product of and is
The entries of the first vector are conjugated. This convention (linear in the second argument) is used throughout the course; some mathematics texts conjugate the second argument instead, so check when you read elsewhere. The conjugation is what makes a non-negative real number, so we can define the norm . Without conjugation, the vector would have "squared length" , which is useless.
Three properties follow directly from the definition and are checked in the exercise:
- Conjugate symmetry: .
- Linearity in the second argument: .
- Antilinearity in the first: scaling by scales by .
Two vectors are orthogonal when their inner product is zero. A basis of mutually orthogonal unit vectors is orthonormal; is one, and so is with , since .
States, amplitudes and probabilities
A pure quantum state of a system with perfectly distinguishable outcomes is a unit vector . Its components in an orthonormal basis are the amplitudes of the corresponding outcomes. When we measure in the computational basis, outcome occurs with probability
This is the Born rule, which the measurement lesson treats in full. Here we need only its consequence for normalisation: probabilities must add up to one, so . That is why states are unit vectors. Any non-zero vector can be turned into a state by dividing by its norm.
Worked example: normalising and reading off probabilities
Take the unnormalised vector .
- Squared moduli: and , so .
- The state is .
- Computational-basis probabilities: and .
- Overlap with : , so .
The last number is the probability of the outcome "+" if we measured in the basis instead. Notice that it depends on the phase of relative to , not only on the moduli. Replace by (same modulus, phase zero) and the overlap becomes . The computational-basis probabilities, by contrast, did not change. Phases are invisible in one basis and decisive in another.
You can check every number with NumPy (complex literals use j):
import numpy as np
v = np.array([1 + 1j, 2])
psi = v / np.linalg.norm(v)
plus = np.array([1, 1]) / np.sqrt(2)
print(np.round(np.abs(psi) ** 2, 6)) # [0.333333 0.666667]
print(round(abs(np.vdot(plus, psi)) ** 2, 6)) # 0.833333 (= 5/6)
w = np.array([np.sqrt(2), 2]) / np.sqrt(6)
print(round(abs(np.vdot(plus, w)) ** 2, 6)) # 0.971405
np.vdot(a, b) conjugates its first argument, matching our convention.
a @ b and np.dot(a, b) do not conjugate anything.
Global phase and relative phase
Multiply a state by a number of modulus one, . Every amplitude is rotated by the same angle, so every probability , in every basis , is unchanged: . Because no measurement can detect it, a global phase has no physical meaning, and two state vectors that differ only by one represent the same physical state. For unit vectors this is easy to test: and differ by a global phase exactly when (the equality case of the Cauchy–Schwarz inequality).
A relative phase is different. Compare
Both give in the computational basis. Yet they are orthogonal, so a measurement in the basis distinguishes them perfectly. The only difference is the phase on relative to . More generally, for different are genuinely different states. The next lesson turns this relative phase into a longitude on a sphere.
Interference: why amplitudes are not probabilities
Here is the smallest experiment in which amplitudes behave differently from probabilities. Prepare and apply three fixed matrices in turn:
The gates lesson studies these matrices; for now they are simply operations we are allowed to perform. Read the first as a "beam splitter" that sends the system into an equal superposition of two paths, as a delay that gives path 1 an extra phase, and the second as a beam splitter that recombines the paths.
Step by step:
For the last arrow, use and and collect terms. The amplitude of outcome 0 is a sum of two contributions, one for each path, each equal to apart from the phase on path 1. Its squared modulus is
At the two contributions are in phase and (constructive interference). At they cancel and (destructive interference). At , .
Now reason as if each path had only a probability. After the first splitter each path has probability ; at the second splitter each path sends the system to outcome 0 with probability . Adding the two routes gives , whatever is. A phase cannot enter a calculation that uses only probabilities, and a sum of non-negative terms cannot vanish. The observed dependence on , including the perfect cancellation at , is the signature of amplitudes. This is not a curiosity: quantum algorithms are arranged so that the paths leading to wrong answers cancel and those leading to right answers reinforce. You will see exactly this in the algorithms lesson.
Common mistakes
- Forgetting the conjugate. conjugates the bra's
entries. In NumPy use
np.vdot(phi, psi), notphi @ psi; the latter gives for , which is nonsense. - Treating amplitudes as probabilities. Amplitudes can be negative or complex and their moduli need not add to one; only their squared moduli do. Adding probabilities of paths ignores interference.
- Squaring instead of taking the squared modulus. , while . Probabilities are .
- Thinking a phase never matters. A global phase never matters; a relative phase between components often decides everything.
- Comparing states entry by entry. and are the same physical state. Compare with 1 instead.
Summary
- Complex numbers carry a modulus and a phase; is a pure phase of modulus 1.
- The inner product on conjugates its first argument, which makes norms real and non-negative.
- A pure state is a unit vector; outcome probabilities are squared moduli of amplitudes.
- A global phase is unobservable; a relative phase changes predictions in other bases.
- Amplitudes from different paths add before squaring, so they can cancel. The two-path experiment gives , whereas probability-only reasoning gives .
The exercise asks you to implement these definitions and to reproduce the interference curve numerically. Next, Qubits and the Bloch sphere turns the two complex amplitudes of a qubit into a point on a sphere.