QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
03 · Grover's search0%

You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.

Learn/QC 202Quantum Algorithms·Lesson 3 of 5

Grover's search

Amplitude amplification: find a marked item in √N steps, and why you must stop at the right time.

Intermediate14 min read4 sections · 2 questions+45
By the end you will be able to
  1. 01Describe one Grover iteration as two reflections.
  2. 02Compute the optimal number of iterations for N = 4 and N = 1024.
  3. 03Explain why too many iterations make things worse.
G=(2∣s⟩⟨s∣−I)Uw​,kopt​≈4π​N​
U_w flips the phase of the marked state; the diffusion operator reflects about the uniform state |s⟩. Each iteration rotates the state by a fixed angle toward the target.

Picture the state as an arrow in the plane spanned by the marked item and everything else. The oracle reflects it across one axis, the diffusion across the other; two reflections make a rotation by 2θ where sin θ = 1/√N. After about (π/4)√N rotations the arrow points at the marked item. Keep going and it rotates past it: the success probability oscillates.

Hands-on

N = 4: one iteration is exact

The oracle marks |11⟩ with a CZ. For four items one Grover iteration already gives probability 1. Simulate, then duplicate the oracle + diffusion gates (drag a box around them, then press Duplicate in the small toolbar that appears) and see the success drop.

OpenQASM 3
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
h q[1];
barrier q;
cz q[0], q[1];
barrier q;
h q[0];
h q[1];
z q[0];
z q[1];
cz q[0], q[1];
h q[0];
h q[1];
c = measure q;
Sign in to run (nothing is saved)
Open in the IDE Open in the Playground
NClassical (average)Grover iterations
421
1 02451225
1 000 000500 000785
Knowledge check

2 questions · one try each counts

Question 1

Grover's advantage is…

Sign in to answer and climb the ranks; you will come back to this lesson.

Question 2

What happens if you run 2·k_opt iterations?

Sign in to answer and climb the ranks; you will come back to this lesson.

Key takeaway

Grover rotates the state toward the marked item by a fixed angle per iteration; stop after about (π/4)√N. Quadratic, optimal, and the template for amplitude amplification everywhere.

Finished reading?

Knowledge check: 2 questions waiting above. Questions are optional. Mark it complete, or press Next: moving on marks it complete too.

Up next
Lesson 4 · 14 min
QFT and phase estimation
The Fourier transform on amplitudes, and the routine that reads eigenphases: the engine inside Shor.
Further reading
  • Docs: Grover in the learning path
More in Quantum Algorithms
  • Deutsch–Jozsa: one query instead of many
  • Bernstein–Vazirani: read a hidden string
  • Shor's algorithm: the overview
Bernstein–Vazirani: read a hidden stringQFT and phase estimation
In this lesson0%
  1. Introduction
  2. Try it: N = 4: one iteration is exact
  3. Knowledge check
  4. Key takeaway
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in