# Tool to verify $CNOT$ (or any interacting 2-qubit gate)

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).

• If you need to verify the cNOT, presumably you don't trust it to be accurate. Do you trust anything to be accurate? May 26 '21 at 11:18
• What do you mean with accurate? I mean, it must be completely equivalent to a CNOT gate, between two desired qubits. But it could affect other qubits, differently from identity. May 26 '21 at 11:19
• What I mean is that presumably as part of what you're doing you're saying "implement this sequence of gates which I think performs a cNot between qubits x and y", but you don't know and that's what you want to verify. But if you don't know that, what do you know about this and other gates you have to work with? May 26 '21 at 11:22
• I use known gates, say, from the Clifford+T set. I can also fix the input of auxiliary qubits. Did I answer? May 26 '21 at 11:26
• So would you not just perform quantum process tomography on the two qubits that you think are having the gate applied to? (OK, there's maybe a question of what state the rest of the system starts in) May 26 '21 at 12:11

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.