Table of Contents

CX (CNOT) gate

CX gate (controlled-X, also called CNOT or controlled-NOT) is a two-qubit gate that flips the target qubit if and only if the control qubit is $\lvert 1\rangle$, and does nothing otherwise. It is the standard entangling gate in quantum computing.

$$\text{CX} = \begin{pmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\end{pmatrix}$$

The rows and columns are ordered $\lvert 00\rangle, \lvert 01\rangle, \lvert 10\rangle, \lvert 11\rangle$, with the first qubit as control and the second as target:

$$\text{CX}\lvert 00\rangle = \lvert 00\rangle \qquad \text{CX}\lvert 01\rangle = \lvert 01\rangle \qquad \text{CX}\lvert 10\rangle = \lvert 11\rangle \qquad \text{CX}\lvert 11\rangle = \lvert 10\rangle$$

Creating entanglement

A Hadamard gate on the control followed by CX is the standard circuit for producing a Bell state from the product state $\lvert 00\rangle$:

$$\lvert 00\rangle \xrightarrow{H \otimes I} \frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}}\otimes\lvert 0\rangle \xrightarrow{\text{CX}} \frac{\lvert 00\rangle + \lvert 11\rangle}{\sqrt{2}} = \lvert\Phi^+\rangle$$

The resulting state cannot be written as a product of two single-qubit states — it is entangled.

Properties

The CX gate is its own inverse: $\text{CX}^2 = I$. Together with all single-qubit gates it forms a universal gate set for quantum computation. In the Hadamard basis, the roles of control and target are exchanged: $H\otimes H \cdot \text{CX} \cdot H\otimes H = \text{CX}^{T}$ (control and target flipped).

List of code implementations