Lesson 30 · 90 min · core
Grover's Search & Amplitude Amplification
Grover's algorithm finds one of marked items among with oracle queries, quadratically fewer than the queries of classical search. This lesson derives the phase oracle and the diffuser together with its gate form, proves that one Grover iteration is a rotation by in a two-dimensional invariant plane, derives the optimal iteration count with success probability at least , computes the case exactly (, , ), proves the Bennett–Bernstein–Brassard–Vazirani lower bound with the hybrid argument, and generalises everything to amplitude amplification with an arbitrary state preparation .
Prerequisites: The Deutsch–Jozsa Algorithm
Objectives and key results
Write the phase oracle and prove .
Prove that the Grover iterate acts on as a rotation by with , so the marked amplitude after iterations is .
Derive and the success bound .
Compute , and for , by hand.
Reproduce the hybrid-argument proof that every quantum search algorithm needs queries.
State and prove the amplitude-amplification theorem for .
- definition · Phase oracle and diffuser
- identity · Gate form of the diffuser
- theorem · Rotation picture
- formula · Optimal iteration count
- theorem · BBBV lower bound
- theorem · Amplitude amplification
The phase oracle and the diffuser#
Definition
Phase oracle
Let and let be the set of marked items, with , i.e. iff . The phase oracle is the diagonal unitary It is obtained from the bit oracle of the Deutsch–Jozsa lesson by phase kickback, . Since is diagonal with entries , and .
Definition
Diffuser (inversion about the mean)
With , the diffuser is the reflection . Its action on a state is with the mean , because .
Gate form of the diffuser
and , where is the -qubit controlled- ( for , for ). Hence the gate sequence implements up to the unobservable global phase .
Proof (5 steps)
- Step 1:Distribute the product over the difference.
- Step 2:, so , and on every qubit.
- Step 3:is self-inverse and maps the all-ones string to the all-zeros string, so conjugation moves the projector.
- Step 4:Factor out .
- Step 5:Combine the previous three lines.
∎
Unitary verified: (max deviation 0.0e+0)
The invariant plane and the rotation by 2θ#
Definition
Marked and unmarked states
Define the orthonormal pair and . Then with defined by .
One Grover iteration is a rotation by 2θ
On the plane , is the reflection about and is the reflection about ; their product is the rotation by . Consequently and the probability of measuring a marked item after iterations is .
Proof (7 steps)
- Step 1:only contains unmarked (sign ), only marked (sign ). So maps into itself and acts there as .
- Step 2:; on the operator is , the reflection about .
- Step 3:In the basis : , then use the double-angle formulas.
- Step 4:and .
- Step 5:Matrix multiplication: the second column is negated. The result is the rotation matrix by angle .
- Step 6:Rotations compose by adding angles and .
- Step 7:Born rule: and for .
∎
The optimal number of iterations#
Optimal iteration count and success probability
Let . Then , and .
Proof (5 steps)
- Step 1:The amplitude is exactly when the angle is ; this real is in general not an integer.
- Step 2:Definition of the floor function.
- Step 3:Multiply the previous inequality by .
- Step 4:and is decreasing in on , with .
- Step 5:for . For , and the bound is tight: .
∎
Worked example: N = 8, M = 1#
Closed form via the Chebyshev recursion
- Step 1:and the double-angle formula.
- Step 2:Sum-to-product: with , .
- Step 3:Triple-angle formula (equivalently the recursion with : ).
- Step 4:Square.
- Step 5:Recursion with .
- Step 6:Square; this is the optimum since .
- Step 7:Recursion with .
- Step 8:Square: the third iteration overshoots ().
The same numbers by inversion about the mean
- Step 1:The oracle flips the marked sign; seven entries and one .
- Step 2:Diffuser . Check: .
- Step 3:Second oracle call.
- Step 4:So and for each of the other : .
- Step 5:Third oracle call.
- Step 6:, , and .
Result
Circuit · 3 qubits
Two Grover iterations for with the oracle for substituted; the histogram shows and for each other outcome.
- |000⟩0.0078
- |001⟩0.0078
- |010⟩0.0078
- |011⟩0.0078
- |100⟩0.0078
- |101⟩0.9453
- |110⟩0.0078
- |111⟩0.0078
Quick check
For , , what is the success probability after three Grover iterations? Give a decimal.
Quick check
For , , how many iterations maximise the success probability and what is it?
import { Statevector, matrix } from '@/lib/quantum-simulator';
// Grover search on n = 3 qubits (N = 8, qubit 0 = MSB) with one marked item w = 5 = |101>.
// Oracle O = I - 2|w><w| (diagonal), diffuser gate form H X CCZ X H = -(2|s><s| - I).
const w = 5;
const phaseFlip = (m) => matrix.fromRows(Array.from({ length: 8 }, (_, i) => Array.from({ length: 8 }, (_, j) => (i === j ? (i === m ? -1 : 1) : 0))));
const oracle = phaseFlip(w);
const ccz = phaseFlip(7); // CCZ = I - 2|111><111|
const theta = Math.asin(1 / Math.sqrt(8));
let sv = Statevector.zero(3).applyGate('H', [0]).applyGate('H', [1]).applyGate('H', [2]);
for (let k = 0; k <= 4; k++) {
const a = sv.amplitudes();
const pw = a[w].re ** 2 + a[w].im ** 2;
const formula = Math.sin((2 * k + 1) * theta) ** 2;
console.log('k = ' + k + ' P(101) = ' + pw.toFixed(7) + ' sin^2((2k+1)theta) = ' + formula.toFixed(7));
sv = sv.applyMatrix(oracle, [0, 1, 2]);
for (const q of [0, 1, 2]) sv = sv.applyGate('H', [q]);
for (const q of [0, 1, 2]) sv = sv.applyGate('X', [q]);
sv = sv.applyMatrix(ccz, [0, 1, 2]);
for (const q of [0, 1, 2]) sv = sv.applyGate('X', [q]);
for (const q of [0, 1, 2]) sv = sv.applyGate('H', [q]);
}Expected output
k = 0 P(101) = 0.1250000 sin^2((2k+1)theta) = 0.1250000 k = 1 P(101) = 0.7812500 sin^2((2k+1)theta) = 0.7812500 k = 2 P(101) = 0.9453125 sin^2((2k+1)theta) = 0.9453125 k = 3 P(101) = 0.3300781 sin^2((2k+1)theta) = 0.3300781 k = 4 P(101) = 0.0122070 sin^2((2k+1)theta) = 0.0122070
Optimality: the BBBV lower bound#
Model: a quantum query algorithm on (index register and workspace) applies , where marks the single item and the do not depend on . Let be the run with the identity in place of every oracle call (no marked item).
Bennett–Bernstein–Brassard–Vazirani lower bound
If for every the measurement of the index register of yields with probability at least , then with , in particular .
Proof (13 steps)
- Step 1:Hybrid quantity (Nielsen–Chuang §6.6): total squared distance between the run with oracle and the oracle-free run after steps.
- Step 2:Add and subtract .
- Step 3:Unitaries preserve norms, triangle inequality, and .
- Step 4:Square the previous line and sum over .
- Step 5:Cauchy–Schwarz; the are the index-register probabilities of a normalised state.
- Step 6:Insert into the previous bound and take square roots.
- Step 7:Induction on : .
- Step 8:Choose the workspace state and a global phase so that (success probability at least ).
- Step 9:and by Cauchy–Schwarz.
- Step 10:Reverse triangle inequality .
- Step 11:Expand and apply Cauchy–Schwarz to the cross term .
- Step 12:and (valid once , i.e. ); as , .
- Step 13:Combine the upper and lower bounds on . Grover's is therefore optimal up to a constant factor.
∎
Amplitude amplification#
Definition
Amplitude amplification setting
Let be any unitary (a quantum algorithm without measurements) and a "good" predicate. Write with the normalised projection onto good basis states, onto bad ones, so is the success probability of . Define and , and the iterate .
Amplitude amplification (Brassard–Høyer–Mosca–Tapp)
. With applications of , and , a good state is measured with probability at least ; classical repetition of needs runs.
Proof (5 steps)
- Step 1:and , exactly as for .
- Step 2:and ; this is the reflection about , which maps to itself.
- Step 3:Same computation as for Grover with , , .
- Step 4:Rotation by of the angle- vector .
- Step 5:Grover search is the special case , and the success bound follows from the optimal- theorem with replaced by .
∎
References
- L. K. Grover, A fast quantum mechanical algorithm for database search, Proceedings of the 28th ACM Symposium on Theory of Computing, 212–219 (1996).doi:10.1145/237814.237866
- 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
- G. Brassard, P. Høyer, M. Mosca and A. Tapp, Quantum amplitude amplification and estimation, Contemporary Mathematics 305, 53–74 (2002).doi:10.1090/conm/305/05215
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press (2010), §6.1–§6.6.doi:10.1017/CBO9780511976667
Hands-on labs
Grover search on three qubits
1 step · auto-gradedOpen labBuild Grover's algorithm for items and one marked item : the uniform superposition followed by two iterations of the phase oracle and the diffuser . The grader substitutes three different oracles (, , ) into the placeholder and requires the distribution with , every other outcome having probability .