Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

QCQI – Chapter 8 Detailed Summary: Grover Search & Amplitude Amplification

Learning Objectives

  • Implement the Grover iterate G=DOfG = D\,O_f where OfO_f marks “good” states and DD is diffusion.

  • Explain the two-dimensional geometry (good/bad subspace), derive the optimal iteration count, and quantify success.

  • Generalize to amplitude amplification with arbitrary state-preparation AA and reflection operators.

  • Understand amplitude estimation / quantum counting at a high level.

  • Build small oracles and diffusion circuits and explore multiple-solution cases.

Problem Statement & Oracle

Unstructured search: given f:{0,,N1}{0,1}f:\{0,\dots,N-1\}\to\{0,1\} with M=f1(1)M=\left|f^{-1}(1)\right|, find any xx with f(x)=1f(x)=1.

Oracle OfO_f acts as a phase flip on marked basis states: Ofx=(1)f(x)x. O_f|x\rangle = (-1)^{f(x)}|x\rangle.

Eureka! Phase oracles are lossless: a global phase on marked states becomes actionable after interference via the diffuser.

State Decomposition & Geometry

Let SS (good) have size MM; define α=1NMxSx|\alpha\rangle=\frac{1}{\sqrt{N-M}}\sum_{x\notin S}|x\rangle and β=1MxSx|\beta\rangle=\frac{1}{\sqrt{M}}\sum_{x\in S}|x\rangle. Initialize s=1Nxx=sinθβ+cosθα|s\rangle=\frac{1}{\sqrt{N}}\sum_x |x\rangle=\sin\theta\,|\beta\rangle+\cos\theta\,|\alpha\rangle with sinθ=M/N\sin\theta=\sqrt{M/N}.

Eureka! Grover is a planar rotation in span{α,β}\{|\alpha\rangle,|\beta\rangle\} by angle 2θ2\theta each iterate.

Grover Iterate

Oracle OfO_f reflects across α|\alpha\rangle (phase flip on β|\beta\rangle). Diffusion D=2s ⁣sID=2|s\rangle\!\langle s|-I reflects across s|s\rangle. Therefore G=DOf G=DO_f is a rotation by 2θ2\theta. After rr iterations, Grs=sin((2r+1)θ)β+cos((2r+1)θ)α. G^r|s\rangle=\sin((2r+1)\theta)|\beta\rangle+\cos((2r+1)\theta)|\alpha\rangle.

Optimal count. Choose r=π4θ12π4NMr^\star=\left\lfloor \frac{\pi}{4\theta}-\frac12\right\rfloor \approx \left\lfloor \frac{\pi}{4}\sqrt{\frac{N}{M}} \right\rfloor. Success sin2((2r+1)θ)1O(M/N)\approx \sin^2((2r^\star+1)\theta)\gtrsim 1- O(M/N).

Eureka! Quadratic speedup: Θ(N/M)\Theta(\sqrt{N/M}) queries vs. classical Θ(N/M)\Theta(N/M).

Diffusion Operator Circuits

Using s=Hn0n|s\rangle=H^{\otimes n}|0^n\rangle, D=Hn(20 ⁣0I)Hn. D = H^{\otimes n}\,(2|0\rangle\!\langle 0|-I)\,H^{\otimes n}. Implement 20 ⁣0I2|0\rangle\!\langle 0|-I by an nn-controlled-ZZ (phase flip on 0n|0^n\rangle), e.g., for n=3n=3: HH–CCX–HH on the last qubit with appropriate XX conjugations to retarget.

Eureka! “Reflect about s|s\rangle    \iff reflect about 0n|0^n\rangle in the Hadamard basis.

Multiple Solutions & Overshoot

With M>1M>1, θ\theta increases; over-iterating rotates past the target. Use the same rr^\star formula with MM known or guessed (or use fixed-point search variants to avoid overshoot).

Amplitude Amplification (General Form)

Given A0=sinθβ+cosθαA|0\rangle = \sin\theta\,|\beta\rangle+\cos\theta\,|\alpha\rangle (any preparation), define reflections S0=I20 ⁣0,Sf=I2Πgood.S_0 = I - 2|0\rangle\!\langle 0|,\qquad S_f=I-2\Pi_{\text{good}}. Then the iterate Q=AS0ASf Q = -A S_0 A^\dagger S_f rotates by 2θ2\theta in the same two-dimensional subspace.

Eureka! Grover is just A=HnA=H^{\otimes n} with the good-subspace projector defined by ff.

Amplitude Estimation & Counting (Idea)

Combine QPE with the Grover iterate QQ to estimate θ\theta (or MM) without scanning rr: phase of QQ’s eigenvectors is ±2θ\pm 2\theta. Quantum counting estimates MNsin2θM\approx N\sin^2\theta.

Worked Nuggets

Mark a single item. Conjugate an nn-controlled-ZZ with XX on bits where the target has 0.

Diffuser for n=3n=3. H3X3CCZX3H3H^{\otimes 3}\, X^{\otimes 3}\, \mathrm{CCZ}\, X^{\otimes 3}\, H^{\otimes 3}.

General success curve. Pr=sin2((2r+1)θ)P_r=\sin^2((2r+1)\theta); the first maximum is near rr^\star.

Pseudo-code Aids

Pseudocode — Grover (one marked string, nn small)

Input: nn, marked bitstring mm, iterations rr Prepare s=Hn0n|s\rangle=H^{\otimes n}|0^n\rangle Repeat rr times: Oracle: for each bit jj with mj=0m_j=0 apply XX on jj; apply nn-controlled-ZZ; undo the XX’s Diffuser: apply HnH^{\otimes n}; XnX^{\otimes n}; nn-controlled-ZZ; XnX^{\otimes n}; HnH^{\otimes n} Measure in computational basis

Pseudocode — Optimal iteration estimate

Input: N=2nN=2^n, guess MM θ=arcsinM/N\theta=\arcsin\sqrt{M/N}; r=π4θ12r^\star=\left\lfloor \frac{\pi}{4\theta}-\frac12\right\rfloor

Pseudocode — Amplitude amplification (general)

Input: state-prep AA, projector Πgood\Pi_{\text{good}} Set S0=I20 ⁣0S_0=I-2|0\rangle\!\langle 0|, Sf=I2ΠgoodS_f=I-2\Pi_{\text{good}} Iterate Q=AS0ASfQ=-A S_0 A^\dagger S_f for rr steps; measure

Schematics

Grover Iterate G=DOfG = D\,O_f (concept)

2D Rotation Picture

Hands-on Notebook (Multi-Backend)

Run: L10_QCQI_Ch08_Grover_and_Amplitude_Amplification

In the first cell set backend to one of: cirq, pennylane, braket, pyquil, or qiskit.

Mini-Lab Ideas

  1. For n=3n=3, mark one string and plot success vs. iterations to observe the sine-squared curve.

  2. Mark M=2M=2 strings; compare measured PrP_r with theory using θ=arcsinM/N\theta=\arcsin\sqrt{M/N}.

  3. Replace HnH^{\otimes n} by a biased AA (e.g., rotate first qubit) and verify amplitude amplification still performs planar rotations.