Grover’s algorithm finds a marked item among unstructured candidates using about oracle queries, where any classical method needs on the order of . It is the standard example of a quadratic speedup, and the same mechanism, amplitude amplification, shows up inside quantum counting, minimum finding and many proposals for speeding up search-like subroutines. The most useful thing to understand about it is geometric: the whole algorithm is a rotation in a two-dimensional plane.

Each round makes the right answer's bar taller and the wrong ones shorter. Image: Danski14, CC BY-SA 3.0, via Wikimedia Commons.
Mental Model
- Two reflections make a rotation. The oracle reflects about the “unmarked” axis, the diffuser reflects about the uniform state, and together they rotate by per iteration.
- The state never leaves a 2D plane spanned by the marked superposition and the unmarked superposition, so the success probability is after iterations.
- You can overshoot. More iterations are not better, and the probability oscillates.
- The speedup is quadratic, and that is provably the best possible for unstructured search in the query model.
- Each iteration calls the oracle once, so the cost of running the oracle as a circuit decides whether the speedup is worth anything in practice.
1. The Setup
Let and let of the items be marked (). Define two normalized states:
They are orthogonal. The uniform superposition lies in their span:
So is the angle between and the unmarked axis . For and large , , which is tiny: the start state is almost orthogonal to the answer.
2. Oracle and Diffuser
The oracle is the phase oracle from the Deutsch-Jozsa page: . In the plane it flips the sign of the component, which is a reflection about the axis.
The diffuser is
a reflection about . In a circuit it is Hadamards, a phase flip on (X gates around a multi-controlled Z), and Hadamards again. One Grover iteration is .
3. The Rotation Angle
The composition of two reflections about lines at angle to each other is a rotation by . The two mirror lines here are and , and the angle between them is . So each iteration rotates the state by towards . Starting at angle from , after iterations the angle is :
The success probability is
Common mistake
Rotating by per step instead of . The single reflection moves the state by up to to the other side of the axis, and it is the second reflection that completes the rotation. Check against , : , one iteration gives , and Grover on two qubits indeed finds the item exactly in one step.
4. How Many Iterations
We want , so . For , and
Overshooting is real. The state keeps rotating past and the probability falls again. In the table below, the probabilities come from the formula and were cross-checked by simulating the state vector.
| Iterations | , | , |
|---|---|---|
| 0 | 0.1250 | 0.0625 |
| 1 | 0.7813 | 0.4727 |
| 2 | 0.9453 | 0.9084 |
| 3 | 0.3301 | 0.9613 |
| 4 | 0.0122 | 0.5817 |
For , rad and , so the best integer choice is with . Taking makes things much worse (0.330). For the best choice is with . The success probability is never exactly 1 unless happens to hold.
5. Worked Example: N = 8
The marked item is . Start with every amplitude .
- Oracle: the marked amplitude becomes .
- Diffuser: it reflects each amplitude about the mean. The mean is . A reflected amplitude is . Unmarked: . Marked: .
The marked probability is , matching . The circuit below runs the real thing on Qiskit’s statevector simulator.
import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
n, target = 3, "101" # printed order: q2 q1 q0
def mcz(qc): # phase flip on |1...1>
qc.h(n - 1); qc.mcx(list(range(n - 1)), n - 1); qc.h(n - 1)
def oracle(qc): # sign flip on |target>
zeros = [i for i, b in enumerate(reversed(target)) if b == "0"]
qc.x(zeros); mcz(qc); qc.x(zeros)
def diffuser(qc): # 2|s><s| - I up to a global phase
qc.h(range(n)); qc.x(range(n)); mcz(qc); qc.x(range(n)); qc.h(range(n))
qc = QuantumCircuit(n); qc.h(range(n))
for k in range(1, 5):
oracle(qc); diffuser(qc)
print(k, round(Statevector(qc).probabilities_dict()[target], 4))Running this prints 0.7812, 0.9453, 0.3301, 0.0122, the same numbers as the formula (the first differs from 0.78125 only by rounding).
6. Amplitude Amplification
Nothing in the argument needs the uniform start state. Take any circuit that prepares a state whose “good” component has amplitude , with for success probability . Replace by and use an oracle that flags the good states. The same rotation analysis applies, and repetitions of and boost the success probability close to 1, compared with repeated tries classically. This generalization is amplitude amplification (Brassard, Høyer, Mosca, Tapp). Grover’s algorithm is the special case .
When is unknown, you can estimate it with quantum counting (phase estimation applied to , see the QPE page) or run the algorithm with randomly chosen iteration counts of growing size, as in the Boyer-Brassard-Høyer-Tapp scheme.
7. Why Quadratic, and Why Not Better
Bennett, Bernstein, Brassard and Vazirani (1997) proved that any quantum algorithm that finds a marked item among with the oracle as a black box needs queries. Zalka (1999) tightened this to show that Grover’s constant is optimal. So Grover is optimal in the query model for unstructured search.
Two cautions about what this does and does not say. First, it is a statement about black-box queries. It does not prove that NP-complete problems need exponential quantum time, because a problem with exploitable structure may be solvable without treating it as a black box. Second, a quadratic speedup is modest after overheads. Each oracle call is a full circuit, error-corrected quantum hardware runs far slower than classical clocks, and Babbush and coauthors (2021) argued that with these constants a quadratic speedup alone is hard to turn into a practical advantage. This is why most serious proposals for near-term advantage look for super-quadratic structure elsewhere.
Related
- Deutsch-Jozsa and Bernstein-Vazirani: the phase oracle used here.
- Quantum Fourier Transform and Phase Estimation: quantum counting estimates from the eigenphase of .
- Shor’s Algorithm: an exponential speedup that uses structure instead of black-box search.
- Measurement and the Born Rule: why of the angle is a probability.
- QGSS Lab 4a: what counts as a validated quantum separation.