06 — Search

Finding one item in eight.

+ The questionCan interference find one marked item among eight, and how much faster does it get as the list grows?

A list with one marked item

In 1996 Lov Grover published a way for a quantum computer to find one marked item in an unsorted list of N items in about the square root of N steps. An ordinary search of such a list has no shortcut: it checks items one at a time and, on average, finds the marked one after checking half of them. For a list of a million items that is half a million checks, against fewer than eight hundred rounds of Grover's method. Grover, like Shor, was a researcher at Bell Labs, and his paper was presented in May 1996 at the annual symposium on the theory of computing of the Association for Computing Machinery.

The list in Grover's problem is not a table stored in memory. It is a test: a circuit, called an oracle, that takes an item's number and recognizes whether it is the marked one, much as a lock recognizes its key. The oracle does not know where the marked item is in any useful sense; it can only check an item it is given. A quantum computer can do what an ordinary one cannot: run the check once on a register spread over every item at the same time. The oracle's only effect on that register is to turn the arrow of the marked item through half a turn.

That mark is invisible to a reading, because a turned arrow has the same length as before. As in the Hadamard example of Chapter 4, the mark matters only when arrows are made to interfere, and Grover's contribution was a second step that converts the mark into a larger arrow.

Mark, then reflect

The second step is called inversion about the mean. It takes the average of all the arrows, then replaces each arrow by twice that average minus the arrow itself. An arrow just below the average ends up just above it, and an arrow far below the average ends up far above it. After its half turn, the marked arrow lies far below the average, so the reflection lifts it far above the average. One round of Grover's method is a mark followed by a reflection, and each round moves a little more of the total chance from the unmarked items to the marked one.

The reflection is built from the same three moves as the Hadamard example of Chapter 4. First, a Hadamard on every qubit turns the equal spread back into the string of all 0s. Next, a gate turns the arrow of that one string through half a turn. Finally, a second layer of Hadamards spreads the register out again. The middle step must check every qubit at once, so its gate count grows with the size of the register, and the oracle's own circuit adds to that count. Neither is free. The next section shows why their cost matters. In the language of Chapter 3, the oracle is the step that marks one path, and the reflection is the second mirror that makes the paths interfere.

Solved example: eight items, two rounds

With eight items and three qubits, an equal spread gives each item an arrow of about 0.354, because 0.354² is one eighth, 12.5 %. The oracle turns the marked item's arrow to −0.354. The average of the eight arrows is now (7 × 0.354 − 0.354) ÷ 8, about 0.265. After the reflection, the marked arrow becomes 2 × 0.265 + 0.354 = 0.884, a chance of 78.1 %. Each other arrow becomes 2 × 0.265 − 0.354 = 0.176, a chance of 3.1 %. A second round turns the marked arrow to −0.884, and the average falls to about 0.044. The marked arrow then becomes 0.088 + 0.884 = 0.972, a chance of 94.5 %, with about 0.8 % left on each wrong item. A third round overshoots and the chance falls to 33 %.

15 — Eight items, two rounds
1 · EQUAL SPREAD Hadamard on every qubit 2 · ORACLE MARKS half turn on the marked arrow 3 · AFTER ROUND 1 reflect every arrow about the average 4 · AFTER ROUND 2 mark and reflect again marked item 0.265 0.265 0.044 dashed: average 0.354 0.354 −0.354 0.884 0.177 0.972 −0.088 CHANCE OF READING 12.5 % each unchanged: a turn is invisible marked 78.1 % others 3.1 % each marked 94.5 % others 0.8 % each 94.5 % after two rounds a third round overshoots: 33 %
AmplitudeControl pulseFocal detail
Plate 15 — Each round of Grover's method marks one arrow with a half turn and reflects every arrow about the average. With eight items the marked item's chance rises from 12.5 % to 78.1 % after one round and 94.5 % after two.

The overshoot is part of the method, not a flaw in the example. Each round turns the register through a fixed angle, away from the equal spread over all items and toward the marked one, so a reading should be made when the register points as close to the marked item as it gets. For a list of N items with one marked item, the best number of rounds is close to π/4 times the square root of N. Further rounds turn the register past that point and lower the chance again.

16 — Each round turns the register by a fixed angle
ALL UNMARKED ITEMS MARKED ITEM start · 12.5 % round 1 · 78.1 % round 2 · 94.5 % round 3 · 33 % θ ≈ 20.7° 2θ ≈ 41.4° per round read here eight items: sin θ = 1/√8 chance = squared height on the marked axis best number of rounds ≈ π/4 × √N
AmplitudeFocal detail
Plate 16 — Each round of Grover's method turns the register through the same angle toward the marked item. With eight items the second round lands closest, and a third overshoots, which is why the number of rounds is chosen near π/4 × √N.

The square root, and no further

The table gives the best number of rounds for lists of several sizes, the chance of success after them, and the average number of checks an ordinary search needs. The count of rounds is the largest whole number that does not overshoot, which for some sizes is one fewer than rounding π/4 × √N would suggest.

Items in the listOrdinary checks, on averageGrover roundsChance of successChecks per round
84294.5 %2
10050799.5 %7
10,0005,0007899.9999 %64
1,000,000500,000785above 99.9999 %637
10¹²5 × 10¹¹785,398above 99.9999 %636,620

The advantage grows with the list, but only as a square root: a list a hundred times longer needs ten times as many rounds. Before Grover's paper appeared, Charles Bennett, Ethan Bernstein, Gilles Brassard and Umesh Vazirani had shown that no quantum method can do better than a square root on a problem with no structure, and a 1999 analysis by Christof Zalka showed that Grover's method is exactly the best possible. A quantum computer cannot search an unstructured space exponentially faster than an ordinary one.

If several items are marked, fewer rounds are needed. With t marked items among N, the count falls to about π/4 times the square root of N/t. A 1996 paper by Michel Boyer, Gilles Brassard, Peter Høyer and Alain Tapp showed how to proceed when t is not known in advance. The table also measures Grover's method against the plainest ordinary method, which checks items one by one. For many practical problems, such as scheduling or circuit verification, ordinary software exploits structure and rarely needs to check most candidates, so the real baseline is far stronger than half the list. The next two chapters turn to problems that hide a period, which are a different matter.

The oracle is a circuit someone has to build

Grover's method is often described as searching a database. A database stored in ordinary memory would have to be loaded into the quantum computer for every round, and each loading costs at least as much as reading the database. The method pays only when the oracle is a computation built from gates, such as a test of whether a candidate solves a puzzle. Every round runs that whole computation, so the oracle's gate count multiplies the cost of every round in the table.

A square root is not enough, yet

The table counts rounds, not seconds. The seconds decide whether the method is worth running. An error-corrected quantum computer performs each protected operation hundreds of thousands of times more slowly than an ordinary processor performs an instruction, because each protected operation is built from many physical gates and checks, as Part V explains. In 2021 Ryan Babbush and colleagues at Google worked out how long a square-root advantage takes to overcome that slowness on the error-corrected machines then foreseen.

Their assumptions were generous to the quantum side. Error correction works in repeated cycles, each a round of checks for errors across the physical qubits. Babbush and colleagues assumed a cycle of one microsecond. They also assumed a well-chosen code and a factory of about 130,000 physical qubits preparing the magic states that each Toffoli gate consumes (Chapter 4). Even so, one protected Toffoli gate took about 170 microseconds, while an ordinary processor performs a comparable logic operation in a fraction of a nanosecond. A search round that needs a hundred such gates in sequence lasts about 17 milliseconds.

Solved example: when a square-root speedup pays

Suppose each quantum round takes time tQ and each ordinary check takes time tC. The quantum search wins once the square root of N rounds take less time than N checks. The two times are equal when the square root of N equals tQ ÷ tC, and the quantum search then runs for the square root of N times tQ, which is tQ² ÷ tC. Any longer search favors the quantum side. As a best case, Babbush and colleagues took 17 milliseconds per round and 33 nanoseconds per check. The break-even time is 0.017² ÷ 0.000000033, about 8,760 seconds, or 2.4 hours. Any shorter search is faster on one ordinary processor core, and against 3,000 cores working in parallel, the break-even stretches to about a year.

For a realistic optimization problem, Babbush and colleagues found break-even times of 320 days against one core and about 880 millennia against a million cores. Speedups that grow faster, such as a fourth-power advantage, brought the figure down to minutes or hours. In a fourth-power advantage, the ordinary method needs the fourth power of the quantum method's number of steps, where Grover's method gives only the square. The authors concluded that early error-corrected machines should look beyond square-root speedups, or that error correction must become much cheaper first. That verdict sets the scope of the rest of this guide: the problems that justify the price of a reliable answer are those with a much larger advantage, and Chapters 7 and 8 show the best-known one.

17 — When a square-root speedup pays
1 s 1 h 1 day 1 year 10⁶ 10⁸ 10¹⁰ 10¹² 10¹⁴ 10¹⁶ 10¹⁸ 10²⁰ RUNNING TIME, LOG LIST SIZE N, ITEMS (LOG) one core: N × 33 ns 3,000 cores quantum: √N × 17 ms against 3,000 cores: about a year break-even after 2.4 hours of running at N ≈ 2.7 × 10¹¹ items best case from Babbush et al. 2021: 17 ms per quantum round, 33 ns per classical check
AmplitudeReadoutFocal detail
Plate 17 — A quantum search runs fewer rounds, but each protected round is far slower than a classical check. In the best case of a 2021 analysis the quantum side wins only for searches that run longer than 2.4 hours, or about a year against 3,000 cores.
Discount a square-root speedup by the step time

When a proposal rests on Grover's method or another square-root speedup, ask for the time of one quantum round on the intended machine, error correction included. Ask also for the time of one ordinary step on competing hardware, counting parallel processors. Square the first, divide by the second, and compare the result with the running time the problem allows. If the break-even lies beyond that time, the speedup will not be seen.

+ What this chapter established
  • Grover's method searches N unsorted items in about π/4 × √N rounds, each a half-turn mark from an oracle followed by an inversion of all arrows about their mean.
  • With eight items, two rounds raise the marked item's chance from 12.5 % to 78.1 % and then 94.5 %, and a third round overshoots to 33 %.
  • No quantum method searches an unstructured list faster than the order of √N, so the advantage is a square root, never exponential.
  • Because error-corrected operations are slow, a square-root speedup needs hours to hundreds of thousands of years of running time before it beats ordinary hardware.
Created with Claude (Anthropic).
Educational reference material, not engineering, regulatory or clinical advice. Product and company names referenced are the property of their respective owners.