M.E. Irizarry-Gelpí

Physics impostor. Mathematics interloper. Husband. Father.

More on CNOT gates


For 2-qubit state vectors, there are two traditional CNOT gates:

\begin{align*} \operatorname{CNOT}_{4}(1, 2) &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}, & \operatorname{CNOT}_{4}(2, 1) &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \end{align*}

Here, \(\operatorname{CNOT}_{4}(1, 2)\) uses qubit 1 as the control qubit, and qubit 2 as the target qubit. The other CNOT gate swaps the role of qubits 1 and 2. These two gate are related:

\begin{align*} \operatorname{CNOT}_{4}(2, 1) &= H_{4} \operatorname{CNOT}_{4}(1, 2) H_{4}, & H_{4} &= H_{2} \otimes H_{2}, & H_{2} &= \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \end{align*}

I mentioned this relation earlier. In my opinion, this relation is not obvious. The more obvious relation would involve SWAP gates:

\begin{align*} \operatorname{CNOT}_{4}(2, 1) &= \operatorname{SWAP}_{4}(1, 2) \operatorname{CNOT}_{4}(1, 2) \operatorname{SWAP}_{4}(1, 2), & \operatorname{SWAP}_{4}(1, 2) &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \end{align*}

Indeed, the SWAP gate can be implemented in terms of CNOT gates:

\begin{equation*} \operatorname{SWAP}_{4}(1, 2) = \operatorname{CNOT}_{4}(1, 2) \operatorname{CNOT}_{4}(2, 1) \operatorname{CNOT}_{4}(1, 2) \end{equation*}

These controlled-NOT gates apply the NOT gate if the control qubit is set to 1:

\begin{align*} \operatorname{CNOT}_{4}(1, 2) |00 \rangle &= |00 \rangle, & \operatorname{CNOT}_{4}(1, 2) |01 \rangle &= |01 \rangle, \\ \operatorname{CNOT}_{4}(1, 2) |10 \rangle &= |11 \rangle, & \operatorname{CNOT}_{4}(1, 2) |11 \rangle &= |10 \rangle \end{align*}

You can denote this explicitly with the following notation:

\begin{align*} \operatorname{CNOT}_{4}(1, 2 | 1) &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}, & \operatorname{CNOT}_{4}(2, 1 | 1) &= \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \end{align*}

You can distinguish these gates from the case when applying the NOT if the control qubit is set to 0:

\begin{align*} \operatorname{CNOT}_{4}(1, 2 | 0) |00 \rangle &= |01 \rangle, & \operatorname{CNOT}_{4}(1, 2 | 0) |01 \rangle &= |00 \rangle, \\ \operatorname{CNOT}_{4}(1, 2 | 0) |10 \rangle &= |10 \rangle, & \operatorname{CNOT}_{4}(1, 2 | 0) |11 \rangle &= |11 \rangle \end{align*}

That is

\begin{align*} \operatorname{CNOT}_{4}(1, 2 | 0) &= \begin{bmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}, & \operatorname{CNOT}_{4}(2, 1 | 0) &= \begin{bmatrix} 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \end{align*}

Note that these two sets of controlled gates are related via

\begin{align*} \operatorname{CNOT}_{4}(1, 2 | 0) &= \operatorname{NOT}_{4}(1) \operatorname{CNOT}_{4}(1, 2 | 1) \operatorname{NOT}_{4}(1), \\ \operatorname{CNOT}_{4}(2, 1 | 0) &= \operatorname{NOT}_{4}(2) \operatorname{CNOT}_{4}(2, 1 | 1) \operatorname{NOT}_{4}(2) \end{align*}

Here the 4-dimensional NOT gates are given by

\begin{align*} \operatorname{NOT}_{4}(1) &= \operatorname{NOT}_{2} \otimes I_{2}, & \operatorname{NOT}_{4}(2) &= I_{2} \otimes \operatorname{NOT}_{2}, & \operatorname{NOT}_{2} &= \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \end{align*}

In circuit diagrams, the controlled gates when the control qubit is set to 1 are denoted with a solid black circle, and the controlled gates when the control qubit is set to 0 are denoted with a solid white circle.