Skip to content

Grover search makes a marked input likely to appear when we measure a quantum register. Its mechanism is geometric: one reflection changes the signs of marked amplitudes, and a second reflection converts that phase difference into increased marked probability. Repeating the pair rotates the state toward the marked subspace.

For an unstructured predicate with MM marked inputs among NN, the quantum query complexity for success probability at least 2/32/3 is Θ(N/M)\Theta(\sqrt{N/M}) when 1≤M≤N/21\le M\le N/2, compared with Θ(N/M)\Theta(N/M) classically. These bounds assume the same Boolean oracle problem. They count calls to a supplied coherent oracle, not the gates or memory needed to implement it.

Helpful background. Phase kickback explains how a Boolean answer becomes a phase. Projectors supplies the geometry of the two reflections. Query complexity explains bounded-error oracle comparisons.

Let f:{0,…,N−1}→{0,1}f:\{0,\ldots,N-1\}\to\{0,1\}, with exactly MM inputs satisfying f(x)=1f(x)=1. The task is to output any such input. If M=0M=0, no valid output exists; if M=NM=N, every label works. Apart from querying ff, assume the labels reveal no exploitable structure about which inputs are marked.

The supplied bit oracle acts on an address and a target qubit:

Uf∣x⟩∣y⟩=∣x⟩∣y⊕f(x)⟩.U_f\lvert x\rangle\lvert y\rangle =\lvert x\rangle\lvert y\mathbin\oplus f(x)\rangle.

With the target in ∣−⟩=(∣0⟩−∣1⟩)/2\lvert-\rangle=(\lvert0\rangle-\lvert1\rangle)/\sqrt2, one call applies the search-register phase oracle and returns the target unchanged:

Of∣x⟩=(−1)f(x)∣x⟩,Of=I−2ΠG,O_f\lvert x\rangle=(-1)^{f(x)}\lvert x\rangle, \qquad O_f=I-2\Pi_G,

where ΠG\Pi_G projects onto marked basis states. With a target in ∣0⟩\lvert0\rangle, a bit-oracle call instead checks a measured candidate.

These two uses explain why the access assumption matters. A supplied uncontrolled phase oracle alone cannot distinguish ff from 1−f1-f: their operators differ only by a global minus sign. In particular, for a half-marked set and its complement, no common output distribution can succeed above one half on both. The full bit oracle removes this ambiguity and supports verification. See quantum oracles for the distinction between access types.

Classically, qq independent uniform trials fail with probability (1−M/N)q(1-M/N)^q. Avoiding repeated addresses improves constants but leaves the Θ(N/M)\Theta(N/M) scale for the stated success target. Grover search improves this scale quadratically. It does not replace binary search on a sorted list, which uses additional structure.

Start in the uniform superposition

∣s⟩=1N∑x=0N−1∣x⟩.\lvert s\rangle = \frac1{\sqrt N} \sum_{x=0}^{N-1}\lvert x\rangle.

For 0<M<N0<M<N, define normalized states in the marked and unmarked subspaces:

∣G⟩=1M∑f(x)=1∣x⟩,∣B⟩=1N−M∑f(x)=0∣x⟩.\begin{aligned} \lvert G\rangle &= \frac1{\sqrt M} \sum_{f(x)=1}\lvert x\rangle, \\ \lvert B\rangle &= \frac1{\sqrt{N-M}} \sum_{f(x)=0}\lvert x\rangle. \end{aligned}

They are orthonormal. Introduce an angle θ∈(0,π/2)\theta\in(0,\pi/2) by

sin⁡2θ=MN.\sin^2\theta=\frac MN.

The initial state becomes

∣s⟩=sin⁡θ ∣G⟩+cos⁡θ ∣B⟩.\lvert s\rangle = \sin\theta\,\lvert G\rangle + \cos\theta\,\lvert B\rangle.

Both the phase oracle and the diffusion operation preserve the plane spanned by ∣G⟩\lvert G\rangle and ∣B⟩\lvert B\rangle. The full NN-dimensional calculation therefore collapses to a planar rotation. Equal amplitudes within each class remain equal throughout the ideal algorithm.

Grover search in the plane spanned by the unmarked and marked superpositions

The oracle reflects ∣s⟩\lvert s\rangle across the unmarked axis. Reflection about ∣s⟩\lvert s\rangle then produces Q∣s⟩Q\lvert s\rangle, advancing the state toward ∣G⟩\lvert G\rangle by 2θ2\theta.

For N=2nN=2^n, Hadamards prepare ∣s⟩\lvert s\rangle from ∣0n⟩\lvert0^n\rangle. For other NN, the derivation assumes preparation of the uniform state on exactly the NN valid labels and a reflection about it. Padding to a larger power of two is also possible, but then the initial marked fraction and iteration count must use the padded size.

The diffusion operator is

D=2∣s⟩⟨s∣−I.D=2\lvert s\rangle\langle s\rvert-I.

It fixes ∣s⟩\lvert s\rangle and reverses every vector orthogonal to ∣s⟩\lvert s\rangle, so it is reflection about the initial-state axis. One Grover iterate is

Q=DOf.Q=DO_f.

In the ordered basis {∣G⟩,∣B⟩}\{\lvert G\rangle,\lvert B\rangle\},

Of=(−1001),D=(−cos⁡2θsin⁡2θsin⁡2θcos⁡2θ),Q=(cos⁡2θsin⁡2θ−sin⁡2θcos⁡2θ).\begin{aligned} O_f &= \begin{pmatrix} -1&0\\ 0&1 \end{pmatrix}, \\[4pt] D &= \begin{pmatrix} -\cos2\theta&\sin2\theta\\ \sin2\theta&\cos2\theta \end{pmatrix}, \\[4pt] Q &= \begin{pmatrix} \cos2\theta&\sin2\theta\\ -\sin2\theta&\cos2\theta \end{pmatrix}. \end{aligned}

Although the last matrix depends on the chosen coordinate ordering, its action is unambiguous. Write

∣ψ(ϕ)⟩=sin⁡ϕ ∣G⟩+cos⁡ϕ ∣B⟩,Q∣ψ(ϕ)⟩=∣ψ(ϕ+2θ)⟩.\begin{aligned} \lvert\psi(\phi)\rangle &= \sin\phi\,\lvert G\rangle + \cos\phi\,\lvert B\rangle,\\ Q\lvert\psi(\phi)\rangle &= \lvert\psi(\phi+2\theta)\rangle. \end{aligned}

Each iterate advances the state-angle parameter by 2θ2\theta toward the marked axis.

For N=2nN=2^n, the diffusion operator can be written

D=H⊗n(2∣0n⟩⟨0n∣−I)H⊗n.D = H^{\otimes n} \left( 2\lvert0^n\rangle\langle0^n\rvert-I \right) H^{\otimes n}.

If a state has computational-basis amplitudes αx\alpha_x and mean amplitude

α‾=1N∑xαx,\overline{\alpha} = \frac1N\sum_x\alpha_x,

then DD maps

αx⟼2α‾−αx.\alpha_x\longmapsto2\overline{\alpha}-\alpha_x.

This explains the traditional name inversion about the mean. It is the same reflection as 2∣s⟩⟨s∣−I2\lvert s\rangle\langle s\rvert-I, expressed component by component. Multiplying a reflection by an overall phase leaves this uncontrolled search experiment unchanged. In a controlled Grover operation, however, that phase becomes relative to the inactive control branch and must be tracked; this matters for amplitude estimation.

The initial state has angle θ\theta in the good–bad plane. After rr Grover iterations,

Qr∣s⟩=sin⁡ ⁣((2r+1)θ)∣G⟩+cos⁡ ⁣((2r+1)θ)∣B⟩.Q^r\lvert s\rangle = \sin\!\left((2r+1)\theta\right) \lvert G\rangle + \cos\!\left((2r+1)\theta\right) \lvert B\rangle.

Measuring in the computational basis therefore returns a marked input with probability

Pr=sin⁡2 ⁣((2r+1)θ).P_r = \sin^2\!\left((2r+1)\theta\right).

Conditioned on success, each of the MM marked labels is equally likely in the symmetric version of the algorithm.

The first probability maximum occurs when

(2r+1)θ≈π2.(2r+1)\theta\approx\frac\pi2.

Choose the nonnegative integer nearest to

r⋆=π4θ−12.r_\star = \frac{\pi}{4\theta}-\frac12.

Rounding changes the final angle by at most θ\theta, giving

Pr≥cos⁡2θ=1−MNP_r\geq\cos^2\theta = 1-\frac MN

for 0<M<N0<M<N. In particular, for M≤N/2M\le N/2 the success probability is at least one half. Two independent runs, each followed by a bit-oracle check of the measured candidate, succeed with probability at least 3/43/4. Thus the stated 2/32/3 target requires only a constant number of runs. Each verification costs one additional query; an exactly successful promised instance needs no verification. For a sparse marked set,

θ=arcsin⁡MN≈MN,\theta = \arcsin\sqrt{\frac MN} \approx \sqrt{\frac MN},

so

r≈π4NM.r \approx \frac\pi4\sqrt{\frac NM}.

The probability is oscillatory. Continuing past the optimum rotates amplitude away from the marked subspace. More iterations are not automatically better.

For N=4N=4 and M=1M=1,

sin⁡θ=12,θ=π6.\sin\theta=\frac12, \qquad \theta=\frac\pi6.

One iteration gives

P1=sin⁡2(3θ)=sin⁡2π2=1.P_1 = \sin^2(3\theta) = \sin^2\frac\pi2 = 1.

This is the smallest familiar example in which the standard π\pi-phase reflections land exactly on the marked axis.

For N=8N=8 and M=1M=1,

θ=arcsin⁡18≈0.3614.\theta=\arcsin\frac1{\sqrt8} \approx0.3614.

The nearest stopping time is r=2r=2, and

P2=sin⁡2(5θ)≈0.9453.P_2 = \sin^2(5\theta) \approx0.9453.

A third iteration would overshoot:

P3=sin⁡2(7θ)≈0.3301.P_3 = \sin^2(7\theta) \approx0.3301.

The comparison makes the coherent rotation, and the need to stop deliberately, concrete.

There is also an instructive boundary case: if M=N/2M=N/2, then θ=π/4\theta=\pi/4 and Pr=1/2P_r=1/2 for every integer rr. Standard π\pi reflections never improve the initial probability. Independent sampling and verification already take only constant expected cost. For M>N/2M>N/2, this simple strategy is likewise sufficient.

Searching when the marked fraction is unknown

Section titled “Searching when the marked fraction is unknown”

A stopping time chosen for one solution can overshoot when there are several. The randomized method of Boyer, Brassard, Høyer and Tapp avoids needing MM in advance. One convenient version starts with m=1m=1 and repeats:

  1. Test a uniformly sampled label, stopping if it is marked.
  2. Choose an integer jj uniformly from 0≤j<m0\le j<m; prepare a fresh ∣s⟩\lvert s\rangle, apply jj Grover iterations, measure and verify.
  3. After failure, replace mm by min⁡(6m/5,N)\min(6m/5,\sqrt N).

The first test handles dense marked sets cheaply. For M>0M>0, the expected total query cost is O(N/M)O(\sqrt{N/M}), including verification. This is an expected stopping time, not a deterministic cap. If M=0M=0 is allowed, impose a finite budget and specify the probability of incorrectly reporting no solution. Repeated failure alone is not a proof of emptiness.

Other useful variants solve different problems:

  • Amplitude estimation estimates the marked fraction using the eigenphases of a controlled Grover operation.
  • Given a positive lower bound amin⁡≤M/Na_{\min}\le M/N, optimal fixed-point constructions choose phase shifts so that the completed sequence has failure at most ϵ\epsilon, using O(log⁡(1/ϵ)/amin⁡)O(\log(1/\epsilon)/\sqrt{a_{\min}}) queries for 0<ϵ<1/20<\epsilon<1/2. This is a uniform guarantee over allowed marked fractions, not a claim that every intermediate step increases success. The response can have small oscillations within its guaranteed error band.
  • When MM is known, suitable phase adjustments can produce exact success. These are modified reflections; their probabilities need not follow the standard PrP_r above.

Amplitude amplification develops these phase schedules and replaces uniform preparation by an arbitrary reversible state preparation.

The hybrid argument of Bennett, Bernstein, Brassard and Vazirani gives an Ω(N)\Omega(\sqrt N) bound for finding a single marked item with bounded error. Boyer and collaborators analyze multiple solutions and unknown MM; Zalka establishes the optimal leading behavior for near-certain single-solution search, πN/4\pi\sqrt N/4. More generally, the fixed-error bound is Θ(N/M)\Theta(\sqrt{N/M}) for 1≤M≤N/21\le M\le N/2. It applies to the unstructured oracle problem, not every structured problem that can be encoded as search.

For a single marked item and 1≤p≤N1\le p\le N parallel oracle calls per round, the optimal round count is Θ(N/p)\Theta(\sqrt{N/p}). Splitting the candidates into pp groups achieves this scale. Using all pp calls each round gives total work of order Np\sqrt{Np}, so reducing depth by parallel hardware does not reduce total queries by the same factor.

A direct circuit implementation has several separate costs:

Operation Cost in one run Physical meaning
Initial preparation CprepC_{\rm prep} Make the intended distribution over valid labels.
Phase predicate rCfrC_f Evaluate the predicate reversibly, apply its phase, and restore workspace.
Diffusion reflection rCDrC_D Reflect about the prepared state.
Candidate check CverifyC_{\rm verify} when used Read whether the measured label is marked.

Thus this implementation uses roughly Cprep+r(Cf+CD)+CverifyC_{\rm prep}+r(C_f+C_D)+C_{\rm verify} gates before repetitions, synthesis and error-correction overhead. This is a circuit estimate, not a universal gate lower bound. Reversible computation explains workspace restoration, and universal gate sets explains decomposing the reflections into available gates.

A classical database does not automatically provide coherent predicate access. Loading arbitrary data, accessing it reversibly and comparing entries may dominate the search. Conversely, a compact arithmetic predicate can often be implemented without loading a list. The physical implementation determines whether a query advantage becomes a runtime advantage.

For nn binary variables with one satisfying assignment, N=2nN=2^n and the Grover query count is Θ(2n/2)\Theta(2^{n/2}). This is still exponential in nn. It improves naive exhaustive enumeration, while classical pruning or other quantum algorithms may exploit structure unavailable to the black-box model.

The same qualification applies to key or preimage search: reversible checking gives an ideal square-root query reduction, but the number of targets, oracle gates, depth, parallelism and fault tolerance determine concrete cost. Grover search returns one candidate; it does not reveal all function values or list every solution at once.

The Dürr–Høyer minimum-finding algorithm uses repeated searches below a changing threshold to find an unstructured list minimum in O(N)O(\sqrt N) value queries with bounded error. Its threshold updates are essential additional steps. Quantum algorithms for optimization compares this approach with methods that exploit more structure.

Show that OfO_f and DD map every vector in

span⁡{∣G⟩,∣B⟩}\operatorname{span}\{\lvert G\rangle,\lvert B\rangle\}

back into the same span. Explain why this is sufficient to analyze the uniform-start algorithm in two dimensions.

Solution

The oracle acts as

Of∣G⟩=−∣G⟩,Of∣B⟩=∣B⟩,O_f\lvert G\rangle=-\lvert G\rangle, \qquad O_f\lvert B\rangle=\lvert B\rangle,

so it preserves the span. Since ∣s⟩\lvert s\rangle lies in the span, for any vector ∣v⟩\lvert v\rangle in it,

D∣v⟩=2∣s⟩⟨s∣v⟩−∣v⟩D\lvert v\rangle = 2\lvert s\rangle\langle s\vert v\rangle -\lvert v\rangle

is also a linear combination of ∣G⟩\lvert G\rangle and ∣B⟩\lvert B\rangle. The initial state lies in this invariant plane, so every later state does as well.

For N=4N=4 and one marked item, calculate the marked amplitude before and after one Grover iteration.

Solution

Initially,

sin⁡θ=12,θ=π6.\sin\theta=\frac12, \qquad \theta=\frac\pi6.

The marked amplitude in the normalized good direction is 1/21/2. One iterate changes the angle from θ\theta to 3θ=π/23\theta=\pi/2, so the marked amplitude becomes

sin⁡π2=1.\sin\frac\pi2=1.

There is only one marked basis state, hence measurement returns it with certainty.

Let rr be the integer nearest to π/(4θ)−1/2\pi/(4\theta)-1/2. Prove that the final success probability is at least cos⁡2θ\cos^2\theta.

Solution

Nearest-integer rounding gives

∣r−(π4θ−12)∣≤12.\left| r-\left(\frac{\pi}{4\theta}-\frac12\right) \right| \leq\frac12.

Multiplying by 2θ2\theta yields

∣(2r+1)θ−π2∣≤θ.\left| (2r+1)\theta-\frac\pi2 \right| \leq\theta.

Write the final angle as π/2+δ\pi/2+\delta, where ∣δ∣≤θ\lvert\delta\rvert\leq\theta. Then

Pr=sin⁡2(π2+δ)=cos⁡2δ≥cos⁡2θ.P_r = \sin^2\left(\frac\pi2+\delta\right) = \cos^2\delta \geq \cos^2\theta.

Using sin⁡2θ=M/N\sin^2\theta=M/N gives Pr≥1−M/NP_r\geq1-M/N.

Suppose N=1024N=1024 and M=16M=16. Estimate θ\theta, the optimal number of standard iterations, and the classical and quantum query scales.

Solution

Here

sin⁡θ=161024=18,θ=arcsin⁡18≈0.1253.\begin{aligned} \sin\theta &= \sqrt{\frac{16}{1024}} = \frac18, \\ \theta &= \arcsin\frac18 \approx0.1253. \end{aligned}

The real-valued optimum is

π4θ−12≈5.77,\frac{\pi}{4\theta}-\frac12 \approx5.77,

so choose r=6r=6. Classical sampling takes order

NM=64\frac NM=64

queries, whereas Grover search takes order

NM=8\sqrt{\frac NM}=8

queries, with the leading constant setting the particular stopping time.

For N=8N=8 and M=1M=1, compare the success probabilities after two and three iterations. Why does this rule out a stopping policy of “continue until success is certain” without knowledge of θ\theta?

Solution

With θ=arcsin⁡(1/8)\theta=\arcsin(1/\sqrt8),

P2=sin⁡2(5θ)≈0.9453,P_2=\sin^2(5\theta)\approx0.9453,

whereas

P3=sin⁡2(7θ)≈0.3301.P_3=\sin^2(7\theta)\approx0.3301.

The unitary evolution rotates rather than relaxes toward the target. It contains no internal signal announcing that the probability has peaked. A stopping rule must use knowledge of MM, estimation, randomized schedules, or a fixed-point design.

Assume the clean phase oracle Of∣x⟩=(−1)f(x)∣x⟩O_f\lvert x\rangle=(-1)^{f(x)}\lvert x\rangle. Show that Of=I−2ΠGO_f=I-2\Pi_G. Then consider N=4N=4 with one marked input. Suppose a faulty implementation leaves an orthogonal workspace label ∣x⟩\lvert x\rangle for each address. What happens if the workspace is discarded before applying DD?

Solution

The projector ΠG\Pi_G has eigenvalue 11 on marked basis states and 00 on unmarked basis states. Therefore I−2ΠGI-2\Pi_G has eigenvalue −1-1 when f(x)=1f(x)=1 and +1+1 when f(x)=0f(x)=0, exactly matching OfO_f.

If evaluating the predicate instead produces

∣x⟩∣0⟩⟼∣x⟩∣wx⟩,\lvert x\rangle\lvert0\rangle \longmapsto \lvert x\rangle\lvert w_x\rangle,

then different xx values remain correlated with different workspace states. The input register no longer undergoes the intended clean reflection OfO_f. In the stated four-item example, tracing out the orthogonal workspace gives ρ=I/4\rho=I/4. Since DρD†=I/4D\rho D^\dagger=I/4, the marked probability stays 1/41/4, instead of becoming one. To implement the clean phase oracle on the search register, the workspace must finish in a common state independent of xx. Compute–phase–uncompute is the usual way to achieve this; merely discarding correlated workspace is not.

An unstructured constraint problem has nn binary variables and one satisfying assignment. Express the classical and Grover query counts in terms of nn. What claim is justified?

Solution

There are N=2nN=2^n assignments. Exhaustive classical search requires

Θ(2n)\Theta(2^n)

predicate queries, while Grover search requires

Θ(2n)=Θ(2n/2).\Theta(\sqrt{2^n}) = \Theta(2^{n/2}).

The justified claim is a quadratic improvement in NN, or a halving of the exponent in this black-box enumeration model. It is not a polynomial-time algorithm in nn, and it does not establish an efficient algorithm for arbitrary structured instances.

  • C. H. Bennett, E. Bernstein, G. Brassard, and U. Vazirani, “Strengths and weaknesses of quantum computing,” SIAM Journal on Computing 26, 1510–1523, 1997, doi:10.1137/S0097539796300933.
  • M. Boyer, G. Brassard, P. Høyer, and A. Tapp, “Tight bounds on quantum searching,” Fortschritte der Physik 46, 493–505, 1998, arXiv:quant-ph/9605034.
  • G. Brassard, P. Høyer, M. Mosca, and A. Tapp, “Quantum amplitude amplification and estimation,” Contemporary Mathematics 305, 53–74, 2002, arXiv:quant-ph/0005055.
  • C. Dürr and P. Høyer, “A quantum algorithm for finding the minimum,” 1996, arXiv:quant-ph/9607014.
  • L. K. Grover, “A fast quantum mechanical algorithm for database search,” in Proceedings of the 28th Annual ACM Symposium on Theory of Computing, 212–219, 1996, doi:10.1145/237814.237866.
  • M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press, 2010, doi:10.1017/CBO9780511976667.
  • T. J. Yoder, G. H. Low, and I. L. Chuang, “Fixed-point quantum search with an optimal number of queries,” Physical Review Letters 113, 210501, 2014, doi:10.1103/PhysRevLett.113.210501.
  • C. Zalka, “Grover’s quantum searching algorithm is optimal,” Physical Review A 60, 2746–2751, 1999, doi:10.1103/PhysRevA.60.2746.