Controlled gates and CNOT
Conditional quantum operations work coherently, without first measuring the control.
- Trace CNOT on basis states and superpositions.
- State the control, target and bit-order convention.
A reversible truth table
Section titled “A reversible truth table”Controlled-X, often called CNOT or CX, maps
| Input | Output |
|---|---|
| 00 | 00 |
| 01 | 01 |
| 10 | 11 |
| 11 | 10 |
In this book’s playground, q0 is the control and q1 the target. CX preserves q0 and flips q1 only on the branch where q0 is 1.
No intermediate measurement
Section titled “No intermediate measurement”For a superposed control, linearity applies the operation to both components coherently:
This creates entanglement for that input. CX does not entangle every input: remains a product state, and a target in is unchanged by X.
Reverse it
Section titled “Reverse it”Applying the same CX twice restores the input because XOR with the same control twice cancels. The gate is unitary and self-inverse.
Practice: prepare H on q1 only, then CX. Predict the four amplitudes. Compare it with H on q0 followed by CX. The difference is a useful way to catch swapped control and target conventions.
Read the control and target explicitly
Section titled “Read the control and target explicitly”The filled dot is the control. The circled plus marks the target’s conditional X. In this diagram, q0 is the control and q1 the target, and input 10 becomes 11. Reversing those wire roles gives a different gate. A phrase such as “apply CNOT” is incomplete unless the surrounding notation specifies its direction.
The control is not a classical test performed by measuring first. CX is one joint unitary operation. It applies the same reversible truth table linearly to all basis components. This coherent conditional action lets it create entanglement when the control is in a superposition, while preserving information that a measurement-based branch would generally discard.
Worked example: transform four amplitudes
Section titled “Worked example: transform four amplitudes”For a two-qubit column with entries a, b, c and d in order 00, 01, 10, 11, CX from q0 to q1 exchanges c and d and leaves a and b alone. It is a permutation of amplitudes, not an independent update to the two local probability lists. The matrix is therefore
On plus tensor zero, the nonzero entries initially lie at 00 and 10. The permutation moves the second of those to 11 and creates a Bell state. On plus tensor plus, all four amplitudes are identical, so the permutation leaves the state unchanged. CX can entangle suitable inputs, but it does not entangle every input.
On zero tensor an arbitrary target state, the gate is inactive. On one tensor that target, it applies X to the target. These cases are useful unit tests, but the plus-control case is the coherence test that connects the basis rules. A correct implementation must satisfy all of them with the same linear operation.
A target can influence the control’s phase
Section titled “A target can influence the control’s phase”Prepare the target in minus, an eigenstate of X with eigenvalue negative one. For control zero, nothing happens. For control one, X contributes a negative sign while leaving the target’s physical state unchanged. A superposed control therefore acquires a relative sign between its two branches. This is phase kickback.
The name “control” describes the basis-state truth table, not a universal one-way flow of every quantum effect. With an eigenstate target, the operation’s useful observable effect can appear as a phase on the control. This is why classical if-statements are an incomplete mental model for controlled quantum gates. The joint state and chosen basis determine the transformation.
Undoing and swapping
Section titled “Undoing and swapping”Applying the same CX twice restores every amplitude, so CX is its own inverse. A SWAP can be built from three CX gates: one direction, the reverse direction, then the first direction again. This construction exchanges the full states of the two wires, including their relationships with other systems. It is not the same as merely exchanging printed measurement labels after an experiment.
In hardware, connectivity may restrict which pairs can interact directly. Routing a logical CX can introduce SWAPs and extra errors. The playground implements an ideal abstract gate and does not charge those hardware costs. Use it to establish the functional truth table first, then consider mapping and resource questions separately.
Test basis and superposed inputs
Section titled “Test basis and superposed inputs”The lesson’s lab starts at input 10. Add CX from q0 to q1, predict output 11 and reveal. Add the same CX again and predict restoration of 10. Next reset, change the input to 00, apply H to q0 and add CX. Predict the signed Bell amplitudes before revealing.
Quantum gate playground
Choose a basis-state input and a one-, two- or three-qubit register. Build gates left to right and inspect their complex statevector after recording a prediction.
Prepare your experiment using the controls. Record a prediction, then reveal the statevector or run the experiment.
Changing the preparation or circuit starts a new prediction.
Take it further
Compare H|0⟩ with H|1⟩ using one qubit. Their Z probabilities agree; their amplitude signs do not. Add a second H to distinguish them.
Initial setup · reference state
| Basis | Amplitude a + bi | Magnitude | Phase (rad) | Probability |
|---|---|---|---|---|
| |00⟩ | 0 + 0i | 0.000000 | undefined | 0.0% |
| |01⟩ | 0 + 0i | 0.000000 | undefined | 0.0% |
| |10⟩ | 1 + 0i | 1.000000 | 0.000000 | 100.0% |
| |11⟩ | 0 + 0i | 0.000000 | undefined | 0.0% |
Signs and complex phases are part of the state. Phase is undefined for a zero amplitude. A shared global phase changes no probabilities; relative phases can affect a later operation. Values are rounded to six decimal places.
Prediction to try: For the chosen input and circuit, predict the nonzero amplitudes, their signs and the measured bitstrings.
Challenge: Compare H|0⟩ with H|1⟩ using one qubit. Their Z probabilities agree; their amplitude signs do not. Add a second H to distinguish them.
Open the live experiment studioFor the non-entangling comparison, reset to 00, apply H to each wire and then CX. Check that the uniform amplitude column stays unchanged. Explain the result through the permutation rule rather than assuming that any two-qubit gate must create correlations. You can also reverse the control and target selectors to test the convention explicitly.
Practice: phase kickback by hand
Section titled “Practice: phase kickback by hand”Expand plus tensor minus into four amplitudes, then apply the CX permutation. Factor the output into one-qubit states. Which subsystem changes physical state, and which remains an X eigenstate?
Check your reasoning
The input amplitudes are one half, negative one half, one half and negative one half. CX exchanges the last two, producing one half, negative one half, negative one half and one half. This is minus tensor minus. The target remains minus, while the control changes from plus to minus through the kicked-back relative sign.
Check your understanding
Section titled “Check your understanding”A circuit record should name both qubits even when the diagram looks obvious. In larger registers, the control and target may be far apart or displayed in a different order. An asymmetric input such as 10 is especially valuable because reversing the gate direction changes its output. A symmetric input alone can conceal that implementation mistake and give false confidence in the wiring.
Which input is unchanged by CX from q0 to q1?
Answer: |+⟩|+⟩. The uniform four-entry amplitude vector is unchanged by the CX permutation. CX does not entangle every input.
Reference: IBM Quantum — Multiple-system quantum information.
Ready for the next step?
Your progress stays in this browser.