3

Is there any tool to define a circuit and verify if it works as desired? It would be interesting to find ways of performing interacting gates - e.g. CNOT gate - between non adjacent qubits.

Hence I'd like an efficient way to define a circuit with any number of qubits, and verify whether it performs the CNOT between two of them (no matter what happens the other qubits).

Daniele Cuomo
  • 2,068
  • 10
  • 25

1 Answers1

1

Assume that you have a control qubit with index 0, then $l$ qubits does not interact with a gate and $l+1$th qubit is a target qubit (e.g. having three qubits, 0 is the control, 1 is idle and 2 is the target). Let's denote $U$ a single qubit gate acting on the target qubit if the control is $|1\rangle$ and $N=2^{l+2}$. Then a matrix description of such gate is $$ \begin{pmatrix} I_{N/2} & O_{N/2} \\ O_{N/2} & I_{N/4} \otimes U \end{pmatrix}, $$ where $I_{N/2}$ and $I_{N/4}$ are identity matrices of order $N/2$ and $N/4$ respectively and $O_{N/2}$ is zero matrix of order $N/2$.

Based on the matrix above, you can infer, how your controlled gate with non-adjacent qubits works.

For example, lets take CNOT gate with control qubit 0, idle (or non-used) qubit 1 and target qubit 2. In this case $l=1$, $N=8$ and $U=X=\begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix}$, hence the matrix describing such gate is $$ \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{pmatrix}. $$

Based on the matrix, you can see that states $|0xy\rangle$ are left unchanged as the control qubit is in state $|0\rangle$. If the control qubit is $|1\rangle$ then the gate works followingly:

  • $|100\rangle \rightarrow |101\rangle$
  • $|101\rangle \rightarrow |100\rangle$
  • $|110\rangle \rightarrow |111\rangle$
  • $|111\rangle \rightarrow |110\rangle$

As you can see the middle qubit remains unchanged. This means that the gate works only with qubits 0 and 2.

Martin Vesely
  • 15,244
  • 4
  • 32
  • 75