5. Interference
Why this layer exists
This chapter is the reason a quantum computer is more than a probabilistic one, and it is the spine of the whole book. Interference is the addition of amplitudes, and the addition of amplitudes depends on their phases, and the phases are the complex numbers you learned in chapter 3. If you understand interference, you understand the one thing that makes a quantum computer quantum. If you only understand probabilities, you have a classical computer with a coin flip in it, and you will be confused about every algorithm after this one.
What breaks without this chapter is the circuit model. Chapter 14 is the first real circuit, and it works by interference. Chapter 15 is the Deutsch oracle, which is interference on a single qubit. Chapter 16 is Grover, which is interference amplified. Chapter 17 is Shor, which is interference in the quantum Fourier transform. Every algorithm in Part III is a circuit that builds interference, and if you do not understand interference, you do not understand the circuit model. This chapter is the why; the rest is the how.
The addition of amplitudes
The probability of an outcome is the squared modulus of its amplitude, by the Born rule:
The amplitude is complex, and it has a phase. When two paths lead to the same outcome, the total amplitude is the sum of the amplitudes:
The probability is the squared modulus of the total amplitude,
and the last term is the interference term. It is the term that classical probability has no analogue for: a classical probability is the sum of the probabilities, $p = p_1 + p_2$, with no cross term. The cross term is the interference, and it is positive (constructive) when the phases align and negative (destructive) when they oppose.
The reason the cross term is the whole game is that it is the only term that depends on the phase. The $|\psi_1|^2$ and $|\psi_2|^2$ terms are the probabilities of the individual paths, and they are what a classical probability would give. The cross term is the quantum bit of extra information, and it is what lets a quantum computer cancel the wrong answers and amplify the right ones.
The double-slit experiment
The double-slit experiment is the canonical example of interference, and it is the one that makes the point clear. A particle passes through two slits and lands on a screen, and the probability of landing at a point $x$ is
where $\psi_1(x)$ and $\psi_2(x)$ are the amplitudes for the particle to reach $x$ through slit 1 and slit 2. The interference term $2\mathrm{Re}(\psi_1^*\psi_2)$ creates the fringe pattern: the probability oscillates between constructive and destructive as the phase difference between the two paths changes.
The reason the double-slit experiment is the canonical example is that it shows the interference is a property of the amplitudes, not the particles. If you measure which slit the particle goes through, you collapse the superposition, and the interference disappears. The interference is there only as long as the superposition is there, and the measurement destroys it. This is the lesson of the chapter: interference is built on the superposition, and measurement destroys it.
In tqp the interference is the cross term, and it is what makes the Hadamard
gate work:
import numpy as np
# two paths to the same outcome
psi1 = np.array([0.6])
psi2 = np.array([0.8])
# total amplitude
psi_total = psi1 + psi2
# probability with interference
p_with = abs(psi_total)**2
# probability without interference (classical)
p_without = abs(psi1)**2 + abs(psi2)**2
# the difference is the interference term
The p_with and p_without differ by the cross term, and the cross term is
the interference.
The Hadamard gate
The Hadamard gate is the canonical example of a gate that builds interference, and it is the gate that every algorithm starts with. It maps
The reason the Hadamard gate builds interference is that it creates a superposition, and the superposition has a relative phase, and the relative phase interferes. The state $|+\rangle$ is the superposition $|0\rangle + |1\rangle$, and the state $|-\rangle$ is the superposition $|0\rangle - |1\rangle$, and the difference is the relative phase, and the relative phase interferes.
The reason the relative phase matters is that it is what makes $|+\rangle$ and $|-\rangle$ orthogonal and measurable. If you measure $|+\rangle$ in the computational basis, you get $|0\rangle$ and $|1\rangle$ each with probability one-half; if you measure $|-\rangle$ in the computational basis, you get $|0\rangle$ and $|1\rangle$ each with probability one-half. The states are the same in the computational basis, but they are different in the Hadamard basis, and the difference is the relative phase.
In tqp the Hadamard gate is H, and it is a unitary:
import numpy as np
from tqp import gates
# Hadamard gate
H = gates.H
# apply to |0>
psi0 = np.array([1, 0])
plus = H @ psi0
# apply to |1>
psi1 = np.array([0, 1])
minus = H @ psi1
# the two states differ in the relative phase
The plus and minus states differ in the relative phase, and the relative
phase is what makes them orthogonal and measurable.
Why interference is physical
The reason interference is physical is that it is a property of the amplitudes, and the amplitudes are physical. The amplitudes are complex, and they have phases, and the phases interfere. The interference is the cross term, and the cross term is the only term that depends on the phase, and the phase is physical. This is the lesson of the chapter: interference is the physical consequence of the phase, and the phase is the physical consequence of the complex amplitudes.
The reason this matters is that it is the thing that makes a quantum computer more than a probabilistic one. A probabilistic computer adds probabilities, and the addition is commutative and positive, and there is no interference. A quantum computer adds amplitudes, and the addition is complex, and the cross term is the interference, and the interference is what lets a quantum computer cancel the wrong answers and amplify the right ones. This is the difference, and it is the whole difference.
Exercises
(a) Why is the interference term the only term that depends on the phase?
Answer
The probability is the squared modulus of the total amplitude, $p = |\psi_1 + \psi_2|^2 = |\psi_1|^2 + |\psi_2|^2 + 2\mathrm{Re}(\psi_1^*\psi_2)$. The $|\psi_1|^2$ and $|\psi_2|^2$ terms are the squared moduli of the individual amplitudes, and they depend only on the magnitudes, not the phases. The cross term $2\mathrm{Re}(\psi_1^*\psi_2)$ depends on the product of the two amplitudes, which includes the phase difference: $\psi_1^*\psi_2 = |\psi_1||\psi_2|e^{i(\theta_2-\theta_1)}$, and the real part is $|\psi_1||\psi_2|\cos(\theta_2-\theta_1)$, which depends on the phase difference. So the cross term is the only term that depends on the phase.
(b) Why does measuring which slit the particle goes through destroy the interference?
Answer
The interference is a property of the superposition: the particle is in a superposition of going through slit 1 and slit 2, and the two amplitudes interfere. If you measure which slit the particle goes through, you collapse the superposition onto one slit, and the superposition is gone, and the interference is gone. The interference is there only as long as the superposition is there, and the measurement destroys it. This is the lesson of the chapter: interference is built on the superposition, and measurement destroys it.
(c) Why are $|+\rangle$ and $|-\rangle$ orthogonal and measurable?
Answer
The states $|+\rangle = (|0\rangle + |1\rangle)/\sqrt{2}$ and $|-\rangle = (|0\rangle - |1\rangle)/\sqrt{2}$ differ in the relative phase between $|0\rangle$ and $|1\rangle$. The inner product is $\langle+|-\rangle = \frac{1}{2}(\langle 0| + \langle 1|)(|0\rangle - |1\rangle) = \frac{1}{2}(1 - 1) = 0$, so they are orthogonal. The orthogonality is what makes them measurable: you can distinguish them with a measurement in the Hadamard basis. The relative phase is what makes them orthogonal, and the orthogonality is what makes them measurable.
(d) Why is a quantum computer more than a probabilistic one?
Answer
A probabilistic computer adds probabilities, and the addition is commutative and positive, and there is no interference. A quantum computer adds amplitudes, and the addition is complex, and the cross term is the interference, and the interference is what lets a quantum computer cancel the wrong answers and amplify the right ones. The interference is the physical consequence of the phase, and the phase is the physical consequence of the complex amplitudes. This is the difference, and it is the whole difference.
Lab: interference in tqp
The first circuit that runs is chapter 14’s, but this lab runs interference
directly, in tqp, so you can see the cross term.
Build labs/ch05/ from the repository root:
mkdir -p labs/ch05
Write a script that does three things:
- Build the two-path amplitude $\psi_1 = 0.6$ and $\psi_2 = 0.8$ and check the probability with interference is $|0.6 + 0.8|^2 = 1.96$ and without is $0.6^2 + 0.8^2 = 1.0$.
- Apply the Hadamard gate to $|0\rangle$ and $|1\rangle$ and check the results are $|+\rangle$ and $|-\rangle$, which differ in the relative phase.
- Measure $|+\rangle$ and $|-\rangle$ in the Hadamard basis and check you get $|+\rangle$ and $|-\rangle$ each with probability one.
Run it:
make lab CH=05
The acceptance test checks that the cross term is the interference, that the Hadamard gate builds the superposition, and that the superposition is measurable in the Hadamard basis.
make test
should be green.
Further reading
The three documents this book keeps open:
- Quantum interference — the cross term, the double-slit experiment, the irreversibility of measurement. The why behind the circuit model.
- The double-slit experiment — the canonical example of interference.
- Hadamard transform — the gate that builds interference.
And the paper behind the cloud QPU, read in Part III:
- Exponential quantum speedup in simulating molecule dynamics (Aspuru-Guzik et al., 2004) — the canonical GPU-class problem, and the honest answer to “what is a QPU for?”.