9 min read
Phase Kickback
The ancilla-in-|−⟩ trick that turns a bit-flip gate into a phase gate on the control qubit.
Suggested before this lesson
This lesson is about a single trick, but it's the trick every algorithm from here through Deutsch-Jozsa is built on, so it earns a lesson of its own rather than being buried inside a bigger circuit.
Recall : you can reach it from with then , since the flips to , then turns that into instead of .
has a property doesn't: it's an eigenstate of with eigenvalue . Applying to doesn't just permute it; it comes back multiplied by :
Check it yourself: swaps the and amplitudes, and 's amplitudes are ; swapping them gives , which is times the original. This one fact is the entire trick.
Now put a second qubit (the control) into superposition with , and use it as the control of a targeting the ancilla (already sitting in ). A applies to its target only on the branch where the control is . So on that branch, the target picks up the we just found, and since that branch is entangled with the control being , the ends up multiplying the control's amplitude instead of changing the ancilla at all.
Circuit
x
h
cx
Step through the circuit: after gate 4 of 4
5 / 5
Exact State
| Basis state | Re | Im | Probability |
|---|---|---|---|
| 0.500 | 0 | ||
| -0.500 | 0 | ||
| -0.500 | 0 | ||
| 0.500 | 0 |
Bloch Sphere
control
ancilla
Before the , the control sits at on its Bloch sphere. After it, the control has moved to , even though the gate is defined as something that acts on the target, not the control. The ancilla, meanwhile, is exactly where it started: , untouched. The effect of the gate has been "kicked back" from the target onto the control's phase. This is phase kickback.
Live preview of the circuit detected in your code
Every oracle-based algorithm coming up (Deutsch-Jozsa and Bernstein-Vazirani) queries a "black box" function via exactly this pattern: an ancilla parked in , and controls (the qubits you actually care about) that pick up a phase of whenever the function says "flip." Because the ancilla itself never has to be measured or even change, a single query can imprint information about the function onto the phase of every qubit in your input register simultaneously, information a later round of Hadamards can then turn back into readable probabilities.
Python
Python