CNOT gate

Also known as: Controlled-NOT gate

On this page 7

The CNOT gate, or Controlled-NOT gate, is a two-qubit quantum logic gate that flips the target qubit if and only if the control qubit is in state 1, and leaves it unchanged otherwise. In quantum computing it is the standard entangling gate of the circuit model and, together with single-qubit gates, forms a universal gate set.

Within the topic of quantum gates & circuits, the CNOT gate is the reference point against which other two-qubit gates are compared, and CNOT count remains one of the most common measures of circuit cost.

How the CNOT gate acts on qubits

On computational basis states, the CNOT gate maps the pair (control, target) from |a, b⟩ to |a, a XOR b⟩. It therefore behaves like a reversible classical XOR, and its 4 by 4 unitary matrix is a permutation that swaps the basis states |10⟩ and |11⟩ while leaving |00⟩ and |01⟩ untouched.

The quantum character appears with superposition on the control. If a Hadamard gate first places the control in an equal superposition and the target starts in |0⟩, the CNOT gate produces the Bell state (|00⟩ + |11⟩) divided by the square root of two. Neither qubit then has a definite state of its own, which is the essence of entanglement. The truth table below shows the action on all basis inputs.

Input controlInput targetOutput controlOutput target
0000
0101
1011
1110
Action of the CNOT gate on basis states

The gate is its own inverse, so applying CNOT twice returns the identity. It is also Hermitian and belongs to the Clifford group, which means it maps Pauli operators to Pauli operators under conjugation.

Phase kickback and the role of basis

The labels control and target depend on the basis. In the Hadamard basis, the roles reverse: conjugating both qubits with Hadamard gates turns a CNOT from qubit A to qubit B into a CNOT from B to A. This symmetry explains phase kickback, in which a phase seemingly applied to the target appears on the control.

Phase kickback is the working principle of algorithms such as Deutsch-Jozsa, Bernstein-Vazirani and phase estimation. A target prepared in the state |−⟩ is an eigenstate of the NOT operation with eigenvalue −1, so a CNOT conditioned on the control writes a relative phase of −1 onto the control instead of changing the target. The table lists how Pauli errors propagate through the gate, which matters for both kickback reasoning and error correction.

Operator before the gateOperator after the gateInterpretation
X on controlX on control and X on targetBit flips spread forward
X on targetX on targetTarget bit flips stay local
Z on controlZ on controlControl phase flips stay local
Z on targetZ on control and Z on targetPhase flips spread backward
Propagation of Pauli operators through CNOT

The CNOT gate is one member of a family of locally equivalent entangling gates. A controlled-Z gate differs from CNOT only by Hadamard gates on the target, and the SWAP gate equals three CNOT gates in alternating directions. Hardware platforms often implement a different native gate and compile CNOT from it, as the following comparison shows.

GateRelation to CNOTTypical native platform
Controlled-Z gateCNOT with Hadamard gates on the targetSuperconducting and neutral-atom processors
iSWAP gateTwo iSWAP gates plus single-qubit gates give CNOTSome superconducting processors
Molmer-Sorensen gateOne gate plus single-qubit rotations gives CNOTTrapped-ion processors
SWAP gateEquals three CNOT gatesCompiled for routing
Toffoli gateNeeds six CNOT gates in standard decompositionCompiled from Clifford and T gates
CNOT and related two-qubit gates

Because these gates are interconvertible with single-qubit operations, compilers treat the number of entangling gates, rather than their exact type, as the main cost of a circuit.

Using CNOT gates in circuit design

Circuit designers rely on the CNOT gate for state preparation, error correction and arithmetic. Chains of CNOT gates create GHZ states, encode logical qubits in repetition and stabilizer codes, and compute parities onto ancilla qubits during syndrome measurement. Reversible adders and modular arithmetic in Shor-type algorithms also consist largely of CNOT and Toffoli gates.

Since two-qubit gates are typically five to ten times noisier than single-qubit gates on current hardware, minimizing CNOT count and CNOT depth is a central compiler objective. The decision table summarizes common optimization strategies.

SituationRecommended approachReason
Limited qubit connectivityQubit mapping and routing with minimal SWAP insertionEach SWAP costs three CNOT gates
Adjacent CNOT pairsCancel identical gatesCNOT is self-inverse
Clifford-only subcircuitsResynthesize with tableau methodsOften yields fewer entangling gates
Arbitrary two-qubit unitaryKAK decompositionNever needs more than three CNOT gates
Strategies for reducing CNOT cost

Limitations and common misconceptions

A frequent misconception is that the CNOT gate copies quantum information. It copies basis values only; for a general superposition it creates entanglement, consistent with the no-cloning theorem. Another misconception is that CNOT alone gives quantum advantage. Circuits of CNOT, Hadamard and phase gates remain Clifford circuits, which the Gottesman-Knill theorem shows can be simulated efficiently on a classical computer.

  • Direction matters on hardware: some devices support CNOT efficiently only in one direction.
  • Errors spread: one faulty CNOT can propagate a single error to two qubits.
  • Fault tolerance: logical CNOT gates are transversal in many codes but still need careful scheduling.
  • Crosstalk: parallel CNOT gates on neighboring pairs can interfere and reduce fidelity.

In simple terms

Think of two light switches wired together in a special way. The first switch is the boss. If the boss is off, nothing happens to the second switch. If the boss is on, the second switch flips to the opposite position.

The quantum version becomes interesting when the boss is both on and off at once, as qubits can be. Then the second switch ends up flipped and not flipped at the same time, and the two switches become linked. This link, called entanglement, is what the CNOT gate creates, and almost every quantum program needs it.

A practical example

A quantum software engineer prepares a three-qubit bit-flip code on a cloud-accessible superconducting processor. The logical state is stored on one qubit, and two CNOT gates copy its basis value onto two partner qubits, so a single bit flip can later be detected and corrected by majority vote.

To read out errors without disturbing the data, the circuit uses two ancilla qubits and four more CNOT gates to compute the parities of qubit pairs. The device supports only nearest-neighbor coupling, so the compiler initially inserts two SWAP operations and the circuit grows to 12 CNOT gates.

By choosing a better physical layout that places each ancilla next to its data qubits, the engineer removes the SWAP operations and cuts the CNOT count to 6. Measured logical error rates fall noticeably, because each removed CNOT eliminates one of the noisiest operations in the circuit.