Quantum Search
Grover's Algorithm
The Search Problem
Imagine you have an unsorted database of N items and need to find one specific item that satisfies some condition. Classically, you might need to check all N items in the worst case.
Grover's algorithm finds the answer in approximately √N steps, a quadratic speedup. For 1 million items, that's 1,000 steps instead of 1,000,000.
The Speedup
See It In Action
Watch the Oracle mark the target with a phase flip, then see the Diffusion operator amplify it by reflecting all amplitudes about their mean.
How It Works
What You're Seeing
Oracle: Marks the target by flipping its amplitude negative (phase flip).
Diffusion: Reflects all amplitudes about their mean, the target pops up while others shrink.
Result: After 3 iterations, the target has ~96% probability of being measured. Classical search would need ~8 checks on average.
Grover's Algorithm Visualized
Watch the quantum search algorithm find a target in √N steps
Grover's Algorithm
Mark target with negative phase
Reflect amplitudes about mean
Database Search
Click any cell to set as search target
Geometric View
Angle: 14.5°State vector rotates ~29° per iteration
|t⟩ = target, |s'⟩ = other states
Quantum Amplitudes
Step by Step
What does "reflection" mean?
A mirror placed at the mean.
The diffusion operator performs a reflection about the mean. Each amplitude bounces to the opposite side of the mean, the same distance away.
Before Diffusion
After Diffusion
Formula
new = 2 × mean − old
Think of it like a mirror at the mean. The target was far below; it bounces way above. The others were just slightly above; they drop just slightly below.
The circuit behind it
Both operators built from gates you already know.
Oracle Circuit
Flips the phase of the target state. For a specific target, this is a multi-controlled Z gate that activates only when all qubits match the target pattern.
Diffusion Circuit
- 1H on all qubits, exit superposition basis
- 2X on all qubits, flip bits
- 3Multi-controlled Z, phase flip |11...1⟩
- 4X on all qubits, flip back
- 5H on all qubits, return to superposition
Key Insight
The diffusion operator is H⊗n · (2|0⟩⟨0| − I) · H⊗n. The Hadamards transform to/from the computational basis, and the middle part flips the phase of |00...0⟩. Together: "reflection about the mean."
Hands-on exercise
20 minutes
Goal , Implement Grover's search algorithm and observe quantum speedup.
Open in Google ColabReflection
- 01Why does Grover's algorithm provide a quadratic speedup instead of an exponential one?
- 02In what real-world scenarios might a quadratic speedup be practically significant?