M.E. Irizarry-Gelpí

Physics impostor. Mathematics interloper. Husband. Father.

CNOT Gates and Bell States


The CNOT gate is a 2-qubit gate. This means that it acts on a 2-qubit vector, which is 4-dimensional. Thus, this gate can be represented as a 4-by-4 matrix. The gotcha is that on a pair of qubits, there can be two CNOT gates. The difference is which qubit is used as control.

By definition, the controlled-NOT gate leaves the state unchanged if the control qubit is not set, otherwise it applies a NOT gate to the target qubit. The familiar case is the first qubit as control:

$$ \operatorname{CNOT}_{12} |00 \rangle = |00 \rangle, \qquad \operatorname{CNOT}_{12} |01 \rangle = |01 \rangle, \qquad \operatorname{CNOT}_{12} |10 \rangle = |11 \rangle, \qquad \operatorname{CNOT}_{12} |11 \rangle = |10 \rangle. $$

This leads to the following matrix representation:

$$ \operatorname{CNOT}_{12} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}. $$

What is the matrix representation of the other CNOT gate, where the second qubit is control? Well, I was quick and wrote:

$$ \begin{pmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} $$

but this is wrong! If you explicitly write down how it acts on basis vectors, you can see why:

$$ \operatorname{CNOT}_{21} |00 \rangle = |00 \rangle, \qquad \operatorname{CNOT}_{21} |01 \rangle = |11 \rangle, \qquad \operatorname{CNOT}_{21} |10 \rangle = |10 \rangle, \qquad \operatorname{CNOT}_{21} |11 \rangle = |01 \rangle. $$

In this case, the matrix representation is:

$$ \operatorname{CNOT}_{21} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix}. $$

Lesson: do not be so quick!

The two CNOT gates are related:

$$ \operatorname{CNOT}_{21} = (H \otimes H)(\operatorname{CNOT}_{12})(H \otimes H). $$

Here, \(H\) is the Hadamard gate:

$$ H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}. $$

You can check this with Python:

import numpy as np

CNOT12 = np.matrix([
    [1, 0, 0, 0],
    [0, 1, 0, 0],
    [0, 0, 0, 1],
    [0, 0, 1, 0],
], dtype=float)

CNOT21 = np.matrix([
    [1, 0, 0, 0],
    [0, 0, 0, 1],
    [0, 0, 1, 0],
    [0, 1, 0, 0],
], dtype=float)

H = np.matrix([
    [1, 1],
    [1, -1],
], dtype=float) / np.sqrt(2)

HH = np.kron(H, H)

print(np.allclose(CNOT21, HH @ CNOT12 @ HH))

The \(\operatorname{CNOT}_{21}\) gate makes an appearance in the following situation: consider constructing a 2-qubit gate \(G\) that when acting on the four Bell states, returns one of the information basis vectors as follows:

$$ G|\Phi^{+} \rangle = |00 \rangle, \qquad G|\Psi^{+} \rangle = |01 \rangle, \qquad G|\Phi^{-} \rangle = |10 \rangle, \qquad G|\Psi^{-} \rangle = |11 \rangle. $$

Since \(G\) is taking an ortho-normal basis to another ortho-normal basis, you can write \(G\) as:

$$ G = |00 \rangle \langle \Phi^{+} | + |01 \rangle \langle \Psi^{+} | + |10 \rangle \langle \Phi^{-} | + |11 \rangle \langle \Psi^{-} |. $$

The matrix representation of \(G\) is given by

$$ G = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 0 & 1 \\ 0 & 1 & 1 & 0 \\ 1 & 0 & 0 & -1 \\ 0 & 1 & -1 & 0 \end{pmatrix}. $$

This matrix can also be written as

$$ G = (H \otimes I) \operatorname{CNOT}_{12}. $$

I leave it as a homework problem to write it in terms of \(\operatorname{CNOT}_{21}\).