Two-Qubit Gates and the CNOT
Suppose you have two qubits and want to make them interact. A single-qubit gate like Single-Qubit Gates: X, Y, Z, H can rotate one qubit's state. But acting on qubits independently can never produce entanglement. Something new is needed: a gate that lets one qubit's state control what happens to another. The controlled-NOT, or CNOT, is that gate. It is the simplest possible instance of a much larger family called controlled-U operations. CNOT matters because entanglement is the resource that separates quantum computing from classical simulation. Every quantum algorithm with a genuine speedup routes correlations between qubits through two-qubit gates. This includes Shor's factoring algorithm, Grover's search, quantum teleportation, and quantum error correction. Real hardware backs this up directly. IBM's superconducting processors, Google's Sycamore chip, and trapped-ion systems from IonQ and Quantinuum all report their native two-qubit gate fidelity as a headline performance number. This is because it is usually the bottleneck for circuit depth and algorithm success. The big picture is this: single-qubit gates move a point on the Bloch sphere. But they act on a two-dimensional space and can never couple two separate qubits. CNOT is the bridge between the world of Multi-Qubit Systems and Tensor Products, where states can be entangled, and the world of gates, which must be able to create that entanglement on demand. Once you have CNOT plus arbitrary single-qubit gates, you have a universal gate set. That is enough to build any quantum computation. This article gives the precise definition of CNOT as a truth table, a matrix, and a circuit symbol. It generalizes CNOT to controlled-U gates. It proves why CNOT entangles and why it is unitary and reversible. It also works through explicit numeric examples, including the construction of a Bell state. It closes with the classic mistakes people make when reasoning about controlled gates. Finally, it shows where these operations show up in real quantum hardware.
- CNOT flips a target qubit if and only if a control qubit is ; it is the quantum analogue of a controlled classical XOR.
- On basis states , CNOT maps ; it is its own inverse.
- The general recipe is controlled-: apply unitary to a target register only when the control qubit is , leaving -control branches untouched.
- Applying CNOT to a superposed control creates entanglement — this is the mechanism behind the Bell states and teleportation.
- CNOT's matrix is unitary and a permutation matrix (in the computational basis), so it is automatically reversible with zero information loss.
- CNOT plus single-qubit gates forms a universal gate set, the foundation of Universal Gate Sets and the full The Quantum Circuit Model.
CNOT is a reversible, unitary "if-then" gate that conditions one qubit's transformation on another qubit's value, and this conditioning is precisely what generates entanglement.
The idea
A controlled gate takes a single-qubit unitary and promotes it to a two-qubit (or multi-qubit) operation: apply to a target qubit only if a control qubit is in state , and do nothing if the control is . Formally, on computational basis states of the control,
The CNOT (controlled-NOT, also written ) is the special case , the Pauli bit-flip. Since and , CNOT is the quantum lift of the classical operation "flip if ," which is exactly bitwise XOR: the truth table maps . The crucial subtlety, and the reason this gate deserves an entire article, is that quantum control is defined by linearity, not by "looking at" the control qubit and branching classically. When the control qubit is in a superposition , CNOT does not measure it and pick a branch; it applies the linear extension of the two basis rules above to the full two-qubit state. This linear extension of a classical-looking rule is exactly what produces entanglement, a phenomenon with no classical analogue. A gate that only ever acted on product states one qubit at a time — no matter how cleverly chosen — could never create the correlations that make a Bell state instead of a product state.
How it works
Convention. We write two-qubit basis states as with the control qubit listed first, matching the usual circuit diagrams and Nielsen–Chuang ordering. Some tools use the opposite convention, so always check which wire is the control before reading a matrix off a textbook.
Truth table (basis states):
| Input | Output |
|---|---|
Matrix. Ordering basis vectors as , CNOT is
The top-left identity block acts on the subspace (do nothing); the bottom-right anti-diagonal block is exactly the Pauli matrix acting on the target when . This block structure is the matrix expression of "apply or to the target, conditioned on the control," and it generalizes immediately: replace the block with any unitary to get the matrix for controlled-,
Circuit symbol. CNOT is drawn as a solid dot on the control wire connected by a vertical line to a (circled plus) symbol on the target wire. Controlled- replaces the with a boxed .
Algorithm view. Treat CNOT as a subroutine that acts on a 4-dimensional amplitude vector, exactly the way any gate is simulated on a classical computer for testing and small-scale verification. ```
# Simulating CNOT on a 2-qubit state vector
# state is a length-4 complex array indexed by integer c*2 + t
# (c = control bit, t = target bit), i.e. amplitude order |00>,|01>,|10>,|11> function APPLY_CNOT(state, control_index, target_index): new_state = copy(state) for index in 0 .. 3: c = bit(index, control_index) # extract control bit of this basis label t = bit(index, target_index) # extract target bit of this basis label if c == 1: flipped_index = index XOR (1 << target_index) # flip only the target bit new_state[flipped_index] = state[index] else: new_state[index] = state[index] return new_state
# Generalization: controlled-U on a target qubit, U given as a 2x2 unitary matrix function APPLY_CONTROLLED_U(state, control_index, target_index, U): new_state = copy(state) for index in 0 .. 3: c = bit(index, control_index) if c == 0: new_state[index] += state[index] # untouched branch else: t = bit(index, target_index) i0 = index with target bit set to 0 i1 = index with target bit set to 1
# only accumulate once per (i0,i1) pair; shown here for the t=0 half if t == 0: new_state[i0] = U[0][0]state[i0] + U[0][1]state[i1] new_state[i1] = U[1][0]state[i0] + U[1][1]state[i1] return new_state ``` The first routine is just a permutation of amplitudes — no arithmetic beyond bookkeeping — which is why CNOT is cheap to simulate and, on hardware, implementable as a native two-qubit interaction. The second routine shows the general pattern: leave the block alone, and apply the unitary to the amplitude pair indexed by the target qubit whenever .
Notice in the diagram that the control qubit starts in the classical state , but the target starts in superposition produced by a Hadamard gate. Applying CNOT to produces , which after relabeling is exactly an entangled Bell-type state — a preview of The Bell States.
Complexity & correctness
Unitarity and reversibility. CNOT's matrix is a real permutation matrix: every row and column has exactly one and the rest s. Permutation matrices are always orthogonal, hence unitary (), and CNOT is its own inverse since applying the same flip rule twice restores the target bit: . This matches the general requirement that every quantum gate be unitary, guaranteeing reversibility and no loss of quantum information — a strictly stronger constraint than the reversibility of classical logic gates like XOR, because unitarity must hold for every superposition, not just classical bit inputs.
Why controlled- is always unitary. Write . Since and are orthogonal projectors summing to identity, and , are each unitary,
The cross terms vanish because . So controlled- is unitary for any unitary , not just — this is why the construction generalizes so cleanly.
Why CNOT entangles. Take the control in superposition and the target in . Linearity gives
Claim: this state cannot be written as a tensor product whenever . Suppose it could: . Matching coefficients against forces and , while and (both nonzero, both factors of a product state). The first two equations force either or , and either or — but any such choice contradicts and simultaneously. No consistent assignment exists, so the state is not separable: CNOT applied to a superposed control genuinely entangles the two qubits. This is a full proof, not a hand-wave, and it is the precise sense in which "controlled gates create entanglement."
Time and space complexity. Simulating CNOT on a classical computer costs arithmetic operations per basis-state amplitude touched, since it is a fixed permutation of a 4-entry table; on qubits embedded in a -dimensional state vector, applying CNOT to two of the wires costs time (touch every amplitude once) and extra space if done in place, because it only swaps amplitude pairs that differ in the target bit whenever the control bit is 1. This is the same asymptotic cost as any other single fixed two-qubit gate; the exponential blow-up is inherent to full state-vector simulation, not to CNOT specifically. On real hardware, CNOT (or an equivalent native two-qubit entangling gate such as the cross-resonance gate or the Mølmer–Sørensen gate) executes in constant time — one hardware pulse or pulse sequence — independent of , which is the entire point of building a quantum device rather than simulating one.
The tradeoff to be honest about. Two-qubit gates are the accuracy bottleneck of near-term hardware: single-qubit gate fidelities on leading platforms often exceed 99.9%, while two-qubit gate fidelities typically trail at 99–99.9%, because entangling interactions require precise coupling between physical qubits and are more sensitive to crosstalk and calibration drift. Circuit depth in two-qubit gates, not single-qubit gate count, is usually the dominant source of error in a real quantum computation, which is why compilers aggressively minimize CNOT count when mapping abstract circuits to hardware topology.
Worked example
Setup. Prepare qubit 1 (control) in and apply ; prepare qubit 2 (target) in and leave it. Then apply CNOT with qubit 1 as control, qubit 2 as target. This is the standard Bell-state recipe. Step-by-step amplitude trace, using basis order :
| Stage | State (as vector) | State (Dirac notation) |
|---|---|---|
| Initial | ||
| After on qubit 1 | ||
| After CNOT (control=1, target=2) |
Reading off the matrix action directly: CNOT leaves the amplitude alone (control bit 0), and sends the amplitude to the slot (control bit 1, target flips ). The result, , is the Bell state — the canonical maximally entangled two-qubit state, foreshadowing The Bell States directly.
A second, less symmetric trace to show the general controlled- mechanics rather than just this famous special case. Let the control qubit be in and the target qubit start in , but apply controlled- (control qubit 1, target qubit 2, ) instead of CNOT.
| Stage | State (as vector) | State (Dirac notation) |
|---|---|---|
| Initial | ||
| Controlled- acts on target since control bit is 1 | apply to the component: | — |
| Final |
Check separability here: this state factors as , a product state, because the control started in a definite basis state rather than a superposition. This confirms the correctness argument above precisely: entanglement requires the control to be in superposition before the controlled gate acts. A controlled- gate applied to a classical control value never entangles; it merely selects a branch, exactly like classical conditional execution.
Common pitfalls & traps
| Pitfall | What goes wrong | Fix |
|---|---|---|
| Confusing control and target wire order | Reading the matrix with the wrong qubit as "first" flips which basis states swap | Fix a convention (control listed first) and check every diagram against it explicitly |
| Assuming CNOT always entangles | Applying CNOT to any classical control state (like or ) never entangles, only superposed controls do | Check whether the control is in superposition before claiming entanglement |
| Treating "controlled" as classical measurement-and-branch | Leads to wrong predictions for superposed controls, since real hardware applies a coherent linear map, not a measurement | Always apply the linear extension of the truth table, never collapse the control first |
| Forgetting CNOT is self-inverse | Redundant CNOT pairs are sometimes left in circuits, wasting gate budget and fidelity | Recognize and cancel adjacent identical CNOTs during optimization |
| Misreading controlled- for non-diagonal | Assuming controlled- commutes with swapping control/target, which is false unless has special symmetry | Explicitly track which wire carries the projector and which carries |
| Ignoring hardware connectivity | Assuming any two qubits can interact directly; real chips only connect nearest neighbors | Account for SWAP-gate overhead when compiling CNOTs between distant qubits |
Pioneers & history
The controlled-NOT gate is not attributed to a single discoverer in the way a named theorem might be; it emerged from the reversible-computing and quantum-information communities converging on the same construction from different directions, once quantum circuit models crystallized in the 1980s and 1990s.
Origins · 1 minRichard Feynman and how this was discovered
Where this matters
CNOT and controlled- gates are the entangling primitive inside essentially every non-trivial quantum protocol. Quantum teleportation and superdense coding both use a CNOT-plus-Hadamard pair to prepare and later disentangle a Bell pair, exactly the construction shown in the worked example above. Quantum error-correcting codes such as the surface code, used in Google's and IBM's roadmaps toward fault tolerance, rely on layers of CNOTs to spread a single logical qubit's information redundantly across many physical qubits and to extract error syndromes without collapsing the encoded state. Shor's algorithm and Grover's algorithm both compile down, in their circuit-level descriptions, to sequences dominated by controlled operations acting on superposed registers — this is literally where their quantum advantage comes from. On real hardware, the CNOT is rarely implemented directly as drawn; it is compiled from whichever two-qubit interaction is physically native to the device. Superconducting qubits (IBM, Google, Rigetti) typically implement a cross-resonance or CZ-type interaction and synthesize CNOT from it using single-qubit rotations; trapped-ion systems (IonQ, Quantinuum) use the Mølmer–Sørensen gate, which entangles pairs (or larger groups) of ions via shared motional modes; photonic and neutral-atom platforms use their own native entangling mechanisms. In every case, quantum compilers translate the abstract CNOT gates that appear in a written circuit into the native gate set of the target device, and minimizing this translated two-qubit gate count is one of the central optimization problems in real-world quantum compiler engineering. Understanding CNOT precisely — its matrix, its entangling behavior, its cost — is therefore not just a theoretical exercise but the direct prerequisite for reading any quantum hardware benchmark or circuit diagram.
Ask the tutor: How does chaining multiple CNOT and controlled-U gates let you build arbitrary multi-qubit entangled states from a simple starting register?
Is CNOT the only two-qubit gate needed for universal quantum computation?
Not by itself — CNOT alone only permutes computational basis states and cannot create arbitrary superpositions or complex phases. What is true, and proven rigorously by Barenco and collaborators in 1995, is that CNOT together with arbitrary single-qubit unitaries forms a universal gate set: any unitary on any number of qubits can be approximated to arbitrary precision using only these two ingredients. This is why circuit diagrams so often show CNOTs interspersed with single-qubit rotations. CNOT supplies all the entangling power needed, while single-qubit gates supply all the local rotation freedom, and together they span the full space of quantum operations, a foundation covered further under Universal Gate Sets.
Does CNOT actually copy the control qubit's value, like classical fan-out?
No, and this is a subtle but important distinction. On classical basis inputs and , CNOT does look like it "copies" the control's value into the target (if target starts at , it ends up matching the control bit). But if the control starts in superposition , CNOT produces the entangled state , not two independent copies of . Genuine copying of an unknown quantum state is forbidden by the no-cloning theorem, and CNOT does not violate that theorem — it entangles rather than clones.
What is the difference between CNOT and the classical XOR gate?
Classically, XOR takes two bits and outputs their exclusive-or as a single bit, which is irreversible (you cannot recover both inputs from the output alone). CNOT instead outputs two qubits: the control unchanged, and the target replaced by target XOR control — this reversible two-output structure is what makes it unitary. If you only look at the target output on classical basis inputs, it reproduces XOR exactly, which is why CNOT is often called the quantum analogue of XOR. But CNOT's real power comes from what happens on superposed inputs, where XOR has no classical meaning at all.
Can any two qubits on a quantum chip be connected with a CNOT directly?
Usually not. Physical qubits are arranged on a chip or trap according to a fixed connectivity graph, and a native two-qubit entangling gate typically only exists between qubits that are physically adjacent or otherwise coupled. If a circuit calls for a CNOT between two non-adjacent qubits, a compiler must insert SWAP gates (or use other routing strategies) to bring the relevant qubits together first, at the cost of extra gate operations and extra opportunities for error. This routing problem is a major focus of quantum compiler design and directly affects how deep and how noisy a compiled circuit turns out to be.
Why is the control qubit's state left unchanged after a CNOT?
Because the defining rule of every controlled- gate explicitly leaves the control register alone; only the target register is transformed, and only conditionally. Mathematically, the operator acts as the identity on the control's tensor factor in both terms of the sum, so no operation ever alters the control qubit's amplitude structure by itself. This is what allows CNOT to be reused as a diagnostic tool, for instance in quantum error correction, where a control-like ancilla qubit is deliberately left readable after interacting with a data qubit to extract a syndrome without destroying the data.
How does CNOT relate to the Bell states and quantum teleportation?
The standard recipe for producing a Bell pair is to apply a Hadamard to one qubit starting in , then apply CNOT with that qubit as control and a second qubit as target, yielding , as derived step by step in the worked example. Quantum teleportation and superdense coding both begin by preparing exactly this entangled pair using CNOT, then later use a second CNOT (paired with measurements and classical communication) to disentangle and transfer information. This makes CNOT the mechanical engine behind both protocols, not just an abstract example gate.
Is a controlled-Z gate different from CNOT, and does it also entangle?
Controlled-Z (CZ) is the case instead of ; its matrix is diagonal with a single in the entry rather than the off-diagonal block CNOT has. CZ still entangles a superposed control with a superposed target, by exactly the same linearity argument used for CNOT, and CZ can even be converted into CNOT (and vice versa) by sandwiching the target qubit with Hadamard gates. Many hardware platforms, especially superconducting qubits, actually implement CZ or CZ-like interactions natively and synthesize CNOT from CZ plus single-qubit gates, since CZ is often easier to realize with the available physical coupling.