Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

Controlled gates and CNOT

Conditional quantum operations work coherently, without first measuring the control.

15 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Trace CNOT on basis states and superpositions.
  • State the control, target and bit-order convention.

Controlled-X, often called CNOT or CX, maps

∣c,t⟩⟼∣c,t⊕c⟩.\lvert c,t\rangle\longmapsto\lvert c,t\oplus c\rangle.
InputOutput
0000
0101
1011
1110

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.

For a superposed control, linearity applies the operation to both components coherently:

∣00⟩+∣10⟩2⟼∣00⟩+∣11⟩2.\frac{\lvert00\rangle+\lvert10\rangle}{\sqrt2} \longmapsto\frac{\lvert00\rangle+\lvert11\rangle}{\sqrt2}.

This creates entanglement for that input. CX does not entangle every input: ∣00⟩\lvert00\rangle remains a product state, and a target in ∣+⟩\lvert+\rangle is unchanged by X.

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.

WORKED DIAGRAM · F18Control and target have different roles
Control and target have different rolesThis example starts in |10⟩. CX 0→1 flips the target and produces |11⟩. The upper control dot is not a measurement. Superposed inputs are transformed coherently.|1⟩q0|0⟩q1MMTime and gate order →
This example starts in |10⟩. CX 0→1 flips the target and produces |11⟩. The upper control dot is not a measurement. Superposed inputs are transformed coherently.

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.

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

CX0,1=(1000010000010010).CX_{0,1}=\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0\end{pmatrix}.

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.

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.

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.

L02 · INTERACTIVE LABRuns on your device

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.

Experiment controls
|10⟩ → I
Maximum 20 gates. q0 is the leftmost bit. Editing a circuit recomputes it from the input.

For the chosen input and circuit, predict the nonzero amplitudes, their signs and the measured bitstrings.

Record a prediction to enable the results.

Results are hidden.

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.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
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.

For 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.

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.

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.

PAUSE & THINK

Which input is unchanged by CX from q0 to q1?

Choose your answer

Reference: IBM Quantum — Multiple-system quantum information.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.