|q⟩ Bad Qubits

intermediate · Programming · Amplitude Amplification

Reflections as Rotations

The oracle and the diffuser each perform a geometric reflection in a two-dimensional plane. The remarkable — and practically useful — fact is that two reflections always compose into a rotation. This single observation explains why repeating the Grover iteration drives the state toward the marked item rather than just bouncing it around.

The two-dimensional subspace

No matter how many qubits the search uses, the evolution stays entirely inside a two-dimensional real plane spanned by two unit vectors:

Because any quantum state in the problem can be written as a real linear combination of these two vectors, we can draw the whole algorithm on an ordinary 2-D picture. Let θ\theta be the initial angle between the uniform superposition s|s\rangle and the "bad" axis, so that

sinθ=MN,\sin\theta = \sqrt{\frac{M}{N}},

where MM is the number of marked items and NN is the total number. For small M/NM/N this angle is close to zero: the starting state is nearly all "bad," which is why we need amplification.

Reflection 1: the oracle

The oracle UfU_f marks a target state by flipping its phase:

Ufx=(1)f(x)x.U_f|x\rangle = (-1)^{f(x)}|x\rangle.

Geometrically this is a reflection about ψbad|\psi_\text{bad}\rangle: the component of the state along ψbad|\psi_\text{bad}\rangle is unchanged, while the component along ψgood|\psi_\text{good}\rangle reverses sign. In the 2-D picture the state vector tips a little toward the good axis after this step — not much, but the direction changes.

Reflection 2: the diffuser

The diffuser (also called the inversion-about-the-mean operator) is

Us=2ssI,U_s = 2|s\rangle\langle s| - I,

where s=Hn0n|s\rangle = H^{\otimes n}|0^n\rangle is the uniform superposition. This is a reflection about s|s\rangle: any component perpendicular to s|s\rangle has its sign flipped while the component along s|s\rangle is preserved.

Two reflections make a rotation

A classical geometry theorem states: if two lines in a plane meet at angle ϕ\phi, then the composition of reflections in those two lines is a rotation by 2ϕ2\phi about their intersection.

The oracle reflects about ψbad|\psi_\text{bad}\rangle and the diffuser reflects about s|s\rangle. The angle between these two axes is exactly θ\theta (the initial angle between s|s\rangle and ψbad|\psi_\text{bad}\rangle). Therefore one Grover iteration — oracle followed by diffuser — rotates the state by 2θ2\theta toward ψgood|\psi_\text{good}\rangle:

ψk=sin ⁣((2k+1)θ)ψgood+cos ⁣((2k+1)θ)ψbad.|\psi_k\rangle = \sin\!\bigl((2k+1)\theta\bigr)\,|\psi_\text{good}\rangle + \cos\!\bigl((2k+1)\theta\bigr)\,|\psi_\text{bad}\rangle.

After kk iterations the angle between the state and ψbad|\psi_\text{bad}\rangle is (2k+1)θ(2k+1)\theta. We want this to reach π/2\pi/2 (pointing fully at ψgood|\psi_\text{good}\rangle), so the optimal number of iterations is

koptπ4θπ4NM.k_\text{opt} \approx \frac{\pi}{4\theta} \approx \frac{\pi}{4}\sqrt{\frac{N}{M}}.

For N=4N = 4, M=1M = 1 we get θ=arcsin(1/2)=π/6\theta = \arcsin(1/2) = \pi/6, so kopt=π/(4π/6)=3/2k_\text{opt} = \pi/(4 \cdot \pi/6) = 3/2, which rounds to k=1k = 1. One iteration indeed brings the state to angle 3π/6=π/23\pi/6 = \pi/2, achieving certainty. This is why the two-qubit Grover search from the previous module succeeded with a single iteration.

Scaling to larger NN

For a single marked item among NN we have θ1/N\theta \approx 1/\sqrt{N} for large NN. The rotation per step is 2θ2/N2\theta \approx 2/\sqrt{N}, so reaching angle π/2\pi/2 requires roughly π/(4/N)=(π/4)N\pi/(4/\sqrt{N}) = (\pi/4)\sqrt{N} steps. This is the famous O(N)O(\sqrt{N}) speedup: classical random search needs O(N)O(N) oracle calls on average, but Grover's geometric rotation reaches the target in O(N)O(\sqrt{N}) rotations.

The same rotation picture extends to amplitude amplification beyond search: if a subroutine A\mathcal{A} marks a "good" subspace with initial amplitude a=sinθa = \sin\theta, iterating the reflection pair drives aa toward 1 in O(1/a)O(1/a) calls — the general amplitude-amplification theorem (Brassard, Hoyer, Mosca, Tapp).

Sign in on the full site to ask questions and join the discussion.