9 min read
Superposition and Interference at Scale
Put every qubit into superposition at once with H, and see amplitudes cancel exactly via interference.
Suggested before this lesson
Everything up to this point has used one or two qubits at a time. Quantum algorithms (starting with Deutsch-Jozsa a few lessons from now) get their power from doing this at scale: putting an entire register into superposition at once, then using interference to cancel out the amplitudes of wrong answers before you ever measure. This lesson builds both pieces.
You already know qc.h([0, 1, 2]) broadcasts H across a list of qubits (from How Circuits and Gates Take Their Arguments). Do that to every qubit in an -qubit register, starting from , and you get a perfectly uniform superposition over all basis states:
Every one of the basis states gets exactly the same amplitude, , not approximately equal, exactly equal. That exactness is the whole point: it's what lets later interference cancel some of them down to exactly zero, rather than just "small."
Circuit
h
Step through the circuit: after gate 3 of 3
4 / 4
Exact State
| Basis state | Re | Im | Probability |
|---|---|---|---|
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 | ||
| 0.354 | 0 |
Live preview of the circuit detected in your code
Superposition alone isn't enough to make an algorithm useful: you also need a way to steer probability toward the right answer. That's interference: routing two different computational "paths" so their amplitudes for the same outcome add up (constructive) or cancel out (destructive).
The simplest possible example is one qubit and two Hadamards in a row. You already know . What does a second do?
Circuit
h
Step through the circuit: after gate 2 of 2
3 / 3
Exact State
| Basis state | Re | Im | Probability |
|---|---|---|---|
| 1.000 | 0 | ||
| 0 | 0 |
Each basis state after the second is reached by two different paths through the intermediate state: one contributing a positive amplitude to , one contributing a negative amplitude of the same size. They cancel to exactly zero, and the state lands back on with certainty. is its own inverse (), and this cancellation is why: it's not a coincidence of these particular numbers, it's interference doing exactly what it's supposed to do.
This (steering amplitude toward a "yes" answer and cancelling it away from every "no" answer) is the mechanism every algorithm in the rest of this track relies on.
Python
Python
Python