# Quantum computing - form a SWAP gate from x3 controlled-NOT gates

Tags:
1. Dec 15, 2012

### SK1.618

1. The problem statement, all variables and given/known data

Show that three controlled-NOT gates (for a 2 qubit system) can be combined to form a SWAP gate. The control qubit alternates between the 2 qubits for each consecutive c-NOT gate. (The diagram is Figure 5 of the following notes: http://www-inst.eecs.berkeley.edu/~cs191/fa07/lectures/lecture9_fa07.pdf )

2. Relevant equations

The explicit matrix form of a controlled-NOT gate is

\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0
\end{matrix}

3. The attempt at a solution

Multiply the following 3 matrices, representing c-NOTs with alternating control gate:

\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0
\end{matrix}

\begin{matrix}
0 & 1 & 0 & 0 \\
1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{matrix}

\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0
\end{matrix}

The correct answer should be (for a SWAP gate):

\begin{matrix}
1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1
\end{matrix}

But this is not what I get. I think there may be a problem with my matrix representation of the second c-NOT gate in the series.

2. Dec 22, 2013

### biggie_smalls

turns out, as you guessed, the matrix representation of the CNOT(2->1) gate is incorrect.

CNOT(2->1) = I$\otimes$|0><0| + X$\otimes$|1><1|

=
1 0 0 0
0 0 0 1
0 0 1 0
0 1 0 0