While operations on individual qubits allow for rotation and alteration of probability amplitudes, a single qubit cannot perform complex logic in isolation. Building algorithms that offer a computational advantage requires qubits to interact. The Controlled-NOT gate (CNOT) is the primary mechanism for facilitating this interaction.
The CNOT gate operates on two qubits simultaneously. Unlike the Pauli or Hadamard gates which act on a single wire in a circuit, the CNOT connects two wires. This connection establishes a conditional relationship between the two bits, serving as the quantum equivalent of a classical XOR gate or a programmable if statement.
The CNOT gate distinguishes its two inputs by assigning them specific roles: the control qubit and the target qubit.
The logic is deterministic and follows a simple rule:
The control qubit itself never changes state during this operation. It only dictates what happens to the target. In a circuit diagram, this is represented by a solid dot on the control wire connected vertically to a circle with a plus sign () on the target wire.
Standard representation of a CNOT gate where q0 acts as the control and q1 acts as the target.
Because the CNOT gate acts on basis states (states that are definitely 0 or 1), we can map out exactly how it transforms the four possible input combinations of a two-qubit system. Remember from the previous section on Tensor Products that our two-qubit system has four basis states: , , , and .
The standard convention reads from left to right, where the first qubit is the control and the second is the target ().
This behavior demonstrates that the CNOT is a reversible operation. If you apply the CNOT gate twice in succession, the target flips and then flips back, returning the system to its original state.
In the previous section, we established that a system with qubits is described by a vector of size . For two qubits, our state vector has 4 elements. Consequently, any gate acting on this system must be a unitary matrix.
The matrix for the CNOT gate is constructed by looking at how it permutes the basis vectors. The basis vectors are ordered as , , , .
Notice the structure of this matrix. The top-left block is the Identity matrix (), representing the case where the control qubit is and nothing happens to the target. The bottom-right block is the Pauli-X matrix (), representing the bit-flip operation that occurs when the control qubit is .
The matrix heatmap highlights how the CNOT gate swaps the amplitudes of the and states while leaving and untouched.
The power of the CNOT gate becomes evident when the control qubit is in superposition. In classical logic, the control bit is definitely 0 or definitely 1. In quantum logic, the control qubit can be in a state like the one created by a Hadamard gate:
If we use this superposition as the control for a CNOT gate, the target qubit responds to both states of the control simultaneously. This does not mean the target chooses one or the other. Instead, the linearity of quantum mechanics dictates that the CNOT applies the Identity operation to the part of the superposition where control is and the X operation to the part where control is .
Mathematically, if our system starts in the state:
Applying the CNOT gate transforms the state to:
The state became because the control was 1. The state stayed because the control was 0. The result is a state where the values of the two qubits are perfectly correlated. This specific output is one of the Bell States, which we will examine in detail in the following section on Entanglement.
In most quantum programming frameworks like Qiskit, applying a CNOT gate is straightforward. You specify the method (often .cx or .cnot) and provide the indices of the control and target qubits.
Assuming you have initialized a quantum circuit with 2 qubits:
# Create a quantum circuit with 2 qubits
qc = QuantumCircuit(2)
# Apply X gate to qubit 0 to set it to |1> (optional setup)
qc.x(0)
# Apply CNOT: qubit 0 is control, qubit 1 is target
qc.cx(0, 1)
It is important to track which qubit is the Least Significant Bit (LSB) in your specific library, as this affects how the state vector is printed or visualized. However, the logical operation remains the same: the target flips if and only if the control is active.
A common point of confusion is whether a CNOT gate works in reverse. While the gate itself is reversible in time (applying it twice undoes the action), you cannot simply swap the control and target roles without physically changing the circuit connections.
However, an interesting phenomenon occurs if you wrap a CNOT gate in Hadamard gates. If you apply Hadamard gates to all four input and output lines of a CNOT, the direction of the control effectively reverses. The control becomes the target, and the target becomes the control. This is known as "phase kickback," a primitive utilized in many advanced quantum algorithms.
For now, focus on the standard operation: verify the state of the control qubit. If it is , apply an X gate to the target. This simple conditional logic is the glue that binds independent qubits into a unified computational system.
Was this section helpful?
© 2026 ApX Machine LearningEngineered with