[Physics] Matrix representation of CNOT gate in the computational basis

quantum mechanicsquantum-information

A CNOT gate flips the target bit when the control bit is set to $|1\rangle$. Thus, defining it by $|c\rangle |t\rangle \rightarrow |c\rangle |t \oplus c\rangle $ makes sense to me.

On the other hand, its matrix representation

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

doesn't seem right, because if I multiply it by a vector

$$\begin{pmatrix}a \\ b \\ c \\ d \end{pmatrix}$$

representing the control bit ($a|0\rangle + b|1\rangle$) and the taget bit ($c|0\rangle + d|1\rangle$), I always get

$$\begin{pmatrix}a \\ b \\ d \\ c \end{pmatrix}$$

which means I am flipping the target bit regardless the value of control bit.

Can someone please explain what is wrong with my understanding here?

Best Answer

The vector you're trying to apply the gate to is wrong.

The matrix representation lives on the two-qubit space $\mathbb{C}^4$ with basis $\lvert 00\rangle,\lvert 01\rangle,\lvert 10\rangle,\lvert 11\rangle$, where the first number is for the control qubit and the second one for the target. So for your definition of $a,b,c,d$ the vector you have to apply the matrix to is actually $(a\lvert 0\rangle + b\lvert 0 \rangle)\otimes (c\lvert 0 \rangle + d\lvert 1 \rangle)$ which would be represented by the vector $(ac,ad,bc,bd)$.

In more detail: Any state of the two-qubit system can be written as $$ \lvert \psi \rangle = \alpha \lvert 00\rangle + \beta \lvert 01\rangle + \gamma \lvert 10\rangle + \delta \lvert 11\rangle$$ where the states are $\lvert ij\rangle = \lvert i\rangle_\text{control}\otimes \lvert j\rangle_\text{target}$. When you have the control qubit in the general state $a\lvert 0\rangle_\text{control} + b\lvert 1\rangle_\text{control}$ and the target in $c\lvert 0\rangle_\text{target} + d\lvert 1\rangle_\text{target}$, then this corresponds to $\alpha = ac$, $\beta = ad$, $\gamma = bc$ and $\delta = bd$, since the full two-qubit state is $(a\lvert 0\rangle_\text{control} + b\lvert 1\rangle_\text{control})\otimes (c\lvert 0\rangle_\text{target} + d\lvert 1\rangle_\text{target})$.

Related Question