Four boxes, one hidden cat and a single look. How a quantum computer finds the cat by making the wrong answers cancel.
Four closed boxes, and a cat hidden in one of them. An ordinary search, the kind any normal computer does, opens one box at a time. With luck, the first box holds the cat. If not, you keep going. After three empty boxes you know the cat is in the last one without opening it, so three looks is the worst case. Find the cat, then let the machine play a thousand games.
How many looks each game took games playedworked out exactly
Play a few games, or let the machine play a thousand. The dashed outlines show the shares worked out exactly. Notice where the average settles.
On average it takes a little over two looks: 2.25 if you stop when one box is left, or 2.5 if you insist on opening the last box to see the cat. Either way an ordinary search needs about half as many looks as there are boxes. With a million boxes that is about half a million looks, and an unlucky search needs 999,999. No cleverness helps: the boxes give no clue, so each look rules out just one box.
For N boxes, opened in any order, stopping when one box is left:
For N = 4 that gives 2.25 and 3. Opening the last box too gives (N + 1) / 2 = 2.5 on average, and at worst N = 4.
A quantum search starts differently. Its qubits are put into a both-ways wave, a superposition, spread evenly over all four boxes at once, like the electron's wave over both slits. Every box gets the same ripple height, its amplitude: one half. A look, reading the qubits, picks just one box. The chance it picks a box is that box's height squared, and one half times one half is one quarter. So each box has one chance in four, no better than a blind guess. Spread the waves, then look.
Ripple height of each box can point up or down
Chance a look shows each box height squared
Notice that after the spread, 100 looks land on all four boxes about equally. The waves alone find nothing yet.
Two qubits are enough to name four boxes: 00, 01, 10 and 11. Putting each qubit into an even both-ways wave gives every name the same ripple height. Ten qubits name 1,024 boxes, and twenty name more than a million. This is not yet useful. A look at this wave shows one box at random, no better than a blind guess. The real work is still to come.
One qubit in an even both-ways wave has height 1/√2 for 0 and for 1. For two qubits the heights multiply:
Each chance is (½)² = ¼, and the four chances add to 1. The animation turns each qubit smoothly from 0 to its even wave, so the chances add to 1 at every moment.

Next comes a quantum check, called the oracle, an old word for someone who knows the answer. It works like a lock that knows its key: it recognises the right box, though nobody has told us which box that is. It opens nothing. It turns the right box's ripple upside down, and that is all. Look now and you learn nothing. An upside-down height squared gives the same chance as an upright one, so every box is still one in four. The mark is hidden. Hide the cat, mark it, then look.
Ripple height of each box
Chance a look shows each box
Notice that the ripple over the cat's box flips, yet the chances on the right do not move at all.
The check is a small circuit built to recognise the answer, and it acts on the whole both-ways wave at once. Drawn as one of Feynman's arrows from explainer 5, the mark is a half turn: the length, and so the chance, never changes, only the direction. That is how the animation shows it. Ordinary chances cannot be negative, so no ordinary machine can hide information like this. Here you choose where the cat hides. In a real search nobody knows, and only the check can tell.
The oracle multiplies the right box's height by −1 and leaves the others alone:
(−½)² = (½)² = ¼, so no single look can see the mark.


Now the clever step. Find the average height of the four ripples. Three point up and one points down, so the average is low: one quarter. Then flip every ripple to the other side of that line, as if in a mirror. An upright ripple, a quarter above the line, lands a quarter below it: at zero. The upside-down one starts three quarters below the line and lands three quarters above it: at full height. The wrong boxes' ripples cancel to nothing, so a look can never pick them. Mark, mirror, look.
Ripple height of each box the average height
Chance a look shows each box
Notice that it is the ripple heights that cancel, not the chances: three heights land on zero, and only then are they squared. Mark and mirror a second time to see a round too many.
Like the mark, the mirror acts on all four ripples at once, and it needs no idea where the cat is. With exactly four boxes, one round of marking and mirroring gives certainty. Mark and mirror a second time and the cat's chance drops back to one in four: too many rounds overshoot. Lov Grover published the method in 1996, while working at Bell Labs.
Mirroring turns every height a into 2ā − a, where ā is the average height:
As one operation on the whole wave the mirror is D = 2|s⟩⟨s| − I, where |s⟩ is the even spread of section 2.
With more boxes, one round is not enough. Each round of marking and mirroring moves a little more height onto the right box, so you repeat it. The rounds needed grow only like the square root of the number of boxes. A million is a thousand times a thousand, so its square root is a thousand, and a little under that, about 785 rounds, does it. The ordinary way needs half a million looks. But stop in time. Extra rounds make the right box fade again. Change the boxes, then the rounds.
Chance that one look finds the cat quantum search, after each roundordinary search, after as many looks
In 1997 Charles Bennett, Ethan Bernstein, Gilles Brassard and Umesh Vazirani proved that no quantum method can search unsorted boxes with fewer than about the square root of the number of boxes in checks. Grover's search reaches that limit, so it is the best possible. The gain is called a quadratic, or square-root, speed-up. It is real, but it is not the vast exponential leap that headlines often promise. For a million boxes it means several hundred times fewer checks.
Call θ the angle with sin θ = 1/√N. After k rounds the chance of the right box is:
For N = 1,000,000: θ ≈ 0.001 radians, k_best = 785 and P ≈ 0.99999996. For N = 4: θ = 30°, and one round gives sin²(90°) = 1.
Cancelling only works while the ripples can meet. Explainer 7 showed what stops that: a record. If a stray bit of air, light or heat bumps the machine and keeps a trace of which box its wave is over, that box can no longer cancel with the others. It is like a secret told to a thousand people: it can never be un-told. With a complete record, the search is back to a blind guess. Slide how much leaks out.
Chance a look shows each box, after one round
Notice that the more of the secret leaks out, the more chance flows back to the wrong boxes, until the search is no better than a blind guess.
This leaking is called decoherence, and it is the main enemy of every quantum computer. Many machines are cooled close to absolute zero, the coldest possible temperature, and shielded from stray light and magnetism. Even so, their waves last only a limited time. A search over a million boxes needs hundreds of rounds in a row, so the waves must survive all of them. Machines that catch and fix their own errors are a large part of the work today.
A record multiplies every cross term between two boxes by c, from 1 (no record) to 0 (a complete one). After one round with four boxes:

A popular story says a quantum computer tries every answer at once and reads them all. It cannot: a look only ever shows one box. The real trick is quieter. It arranges the ripples so that the wrong answers cancel and the right one grows, and only then takes a single look. One look. The cat, every time.
Grover's search weakens some secret codes without breaking them. Guessing a secret key would take about the square root of the usual effort, which roughly halves the key's effective length, so longer keys are the defence. The method shows the honest scale of quantum speed-ups: real, specific and often modest. Some other quantum methods, such as Peter Shor's of 1994 for finding the factors of large numbers, promise far bigger gains, but only for special problems with hidden patterns.
The artwork is made with AI image tools under the author's direction. How these books are made · Privacy · andreaspolymitis.com