Interference at Work
Deutsch-Jozsa and phase kickback
One query decides a global property
Someone hands you a function on -bit inputs and promises it is one of two kinds: constant (same output for every input) or balanced (output 0 on exactly half the inputs, 1 on the other half). Which is it? Classically you may have to check more than half of all inputs before you can be sure. A quantum computer settles it with a single query. This is the first place the interference from the last lesson does real, provable work.
The intuition to overturn
Run the one-query test
Below is the algorithm on a 2-qubit input. Pick an oracle - two are constant, two are balanced, and crucially you are not told which as you step. Advance through the layers and watch the amplitude on . Constant oracles drive it to certainty; balanced oracles drive it to exactly zero. The verdict never depends on luck.
- 1. Superpose
- 2. Oracle (kickback)
- 3. Interfere
- 4. Measure
Step to the oracle and watch which bars dip below the axis - that flip is the phase kickback.
The one bar to keep your eye on is . After the final layer its amplitude is either (constant) or exactly (balanced), with nothing in between. That razor edge is interference doing the deciding.
Phase kickback: how the oracle marks the input
The whole method rests on one small preparation. Put the oracle's output qubit not in but in , and watch what one query does to . Since maps to :
Read the two ends. If the target is unchanged; if the two terms swap, which is the same as multiplying by . Either way the target comes out exactly as it went in, and the factor has jumped onto the input register. That is : the oracle writes as a sign on the input, never as a bit you would have to read out and collapse.[2]
Interference turns signs into a verdict
Now the three-step choreography. Start the input in , apply a Hadamard to each wire, query once, and apply the Hadamards again:
We only need the amplitude of the all-zeros outcome after the final layer. Because each Hadamard sends every basis state to an equal spread with signs, the amplitude landing back on all-zeros is the plain average of the kicked-back signs:
This single number is the entire algorithm. If is constant, every term has the same sign, the average is , and you measure all-zeros with certainty. If is balanced, the s and s cancel in perfectly matched pairs, the average is , and you never measure all-zeros. So the rule is exact: measure all-zeros and is constant; measure anything else and it is balanced.
One query versus exponentially many
from qiskit import QuantumCircuit
qc = QuantumCircuit(3, 2) # 2 input qubits + 1 output qubit
qc.x(2); qc.h(2) # put the output qubit in |-> (X then H)
qc.h(0); qc.h(1) # Hadamard layer on the input register
apply_oracle(qc) # one query: kicks (-1)^{f(x)} onto the input
qc.h(0); qc.h(1) # second Hadamard layer interferes the branches
qc.measure([0, 1], [0, 1]) # all-zeros -> constant; anything else -> balancedLock it in
- Preparing the output qubit in |-> turns the oracle into phase kickback: U_f leaves it alone and multiplies the input |x> by (-1)^{f(x)}.
- Sandwiching one query between two Hadamard layers makes the all-zeros amplitude equal the average of the signs, (1/N) sum_x (-1)^{f(x)}.
- Constant f gives average +-1 (measure all-zeros with certainty); balanced f gives average 0 (never all-zeros) - a deterministic verdict.
- One quantum query settles a question that classically needs up to 2^(n-1)+1 evaluations: the first clean, provable quantum speedup.
Check yourself
What does phase kickback do when the oracle's output qubit is prepared in |->?
For a promise that f on n bits is constant or balanced, how many queries does each model need for certainty?
Recall: which global property does Deutsch-Jozsa decide in one query, and what is the trick that makes it work?
The problem, the mechanism, and the payoff in one breath. Try to state it, then check.
Match each part of Deutsch-Jozsa to its role.
same output on every input
output 0 on half the inputs, 1 on the other half
the oracle writes f(x) as a sign on the input
interferes the branches into the all-zeros answer
Primary source
IBM Quantum Learning: Fundamentals of Quantum AlgorithmsThe query-algorithms unit builds Deutsch, then Deutsch-Jozsa, exactly this way - phase kickback first, then the Hadamard sandwich - and lets you run the circuits on a simulator so the deterministic all-zeros outcome is something you watch happen rather than take on faith.[1]
Next: Grover's search, where the same cancel-and-reinforce idea becomes a geometric rotation you can watch, and where doing too many steps makes the answer worse.
Sources