The Diffuser (Inversion About Mean)
Each Grover iteration has two steps: the oracle and the diffuser. While the oracle flips the phase of the marked item, the diffuser does the complementary job — it reflects all amplitudes about their mean, amplifying the marked amplitude and suppressing the rest.
Inversion about the mean
Suppose the current state has amplitudes and their average is . The inversion-about-mean map sends each amplitude to
If the marked item has had its amplitude flipped negative by the oracle, it sits far below the mean. After inversion it lands far above the mean, growing closer to 1. All other amplitudes were slightly above the mean and therefore get pushed slightly below it.
The circuit
The diffusion operator can be written as , where is the uniform superposition. A standard decomposition for qubits conjugates a phase-flip of by Hadamards:
The inner operator flips every basis state except . Its circuit applies to every qubit (mapping to ), a controlled- that phase-flips , then again to restore the other states. For 2 qubits the complete gate sequence is:
Step-by-step for 2 qubits
Starting from the uniform superposition :
- Open with to rotate into the computational basis, mapping .
- flips both qubits: .
- phase-flips by .
- restores: , and all other states return to what they were before step 2 (each having picked up the sign applied in step 3 or not).
- Close with to return to the Hadamard basis.
The net effect on any amplitude vector is exactly the inversion-about-mean map.
Try it
Build the 2-qubit diffuser. The starter code applies the opening ; your job is to complete the circuit with , , , and the closing . The grader checks the full unitary matrix, so the circuit must match the exact operator .
Sign in on the full site to ask questions and join the discussion.