
Tutorial 7 of 12 · Simulated in your browser
Why a quantum computer is not parallel randomness: amplitudes add before they are squared, so paths can cancel.
Start on heads. Each flip sends every outcome half to heads and half to tails, so probabilities only ever average.
Use the same step control below: the coin has one flip after the first gate and a second after the last.
Final chance of |0⟩ = cos²(φ/2) = 100%. At 0° the paths to |1⟩ cancel; at 180° the paths to |0⟩ do.
Each outcome can be reached through the middle state |0⟩ or |1⟩. The two arrows are those paths’ amplitudes, coloured by phase; the white arrow is their sum, and its length squared is the chance. Arrows that point opposite ways cancel.
Three qubits, one Hadamard each: eight equal amplitudes, one per three-bit string.
Measure it. You get one string, picked at random with equal odds. Nothing was “tried” that you can read out.
no measurements yet
Newest first. An algorithm’s job is to choose gates so that the wrong strings cancel and the right one is left large.
The popular picture says a quantum computer tries every answer at once. It does not, and the way to see why is to compare it with a coin. Flip a fair coin and you get heads or tails with equal odds. Flip it again and you are still at equal odds: randomness only ever blurs. Scott Aaronson’s blog carries the same warning in its banner, that quantum computers will not solve hard problems instantly by trying all solutions in parallel.
A qubit behaves differently because its two outcomes carry amplitudes, and amplitudes are added before they are squared into probabilities. The Hadamard gate H turns |0⟩ into an equal mix of |0⟩ and |1⟩ with amplitude 1/√2 each, so a measurement now gives 50/50, the same as the coin. Apply H again and there are two paths to each outcome. Both paths to |0⟩ contribute +½, which sum to 1. The paths to |1⟩ contribute +½ and −½, which sum to 0. The wrong answer has cancelled, and |0⟩ now comes out every time.
Put a phase gate between the two Hadamards and the cancellation can be dialled. With a phase φ in the middle, the amplitude for |0⟩ is (1 + e^{iφ})/2, so the chance of |0⟩ is cos²(φ/2). At φ = 0 it is 1, at φ = π/2 it is ½, and at φ = π it is 0, so every shot gives |1⟩. The path diagram shows the same sum as arrows: the two arrows to each outcome, added head to tail, in the phase colours.
Now the myth. Put three qubits through a Hadamard each and they hold eight amplitudes of equal size, one per three-bit string. Measuring gives exactly one string, chosen at random with equal odds, so nothing has been tried “in parallel” in a way you can read out. What an algorithm does is arrange its gates so that the amplitude of wrong answers cancels and the right one is left large. Aaronson’s post on Shor’s algorithm explains period finding and the Fourier transform with clocks, which is this cancellation at work.
The next page, Grover’s search, is this effect repeated: each step moves amplitude from the wrong answers towards the right one.
Qubit order: bit strings are written with qubit 0 on the left, as in Nielsen and Chuang’s book. (Qiskit puts it on the right.)
Shtetl-Optimized Shtetl-Optimized (the blog’s banner line). Scott Aaronson. Live page.
Aaronson, Shor “Shor, I’ll do it”. Scott Aaronson, 24 February 2007.
Everything here is paraphrased from the sources, not quoted, and every figure that is not plain arithmetic is attributed. The simulator is this site’s own and is tested against the formulas on the page. Where a source is silent the page says so.