# What is CNOT1,3 gate? In general, what is CNOT1,n gate? [duplicate]

I'm familiar with the CNOT gate and I know the matrix of that gate. But what is CNOT1,3 gate and what is its matrix, how to compute it?

• Please, be more specific. Where did you read about CNOT1,n gates? Do you have a reference? Commented Apr 18, 2023 at 7:39
• @MicheleAmoretti i read it in a book. They said:"For n = 2, the indices are length-4 strings y1y2z1z2, which are permuted into y1y2(y1 ⊕ z1)(y2 ⊕ z2). This is a composition of two CNOT operations, one on the first and third indices (preserving the others), which we denote by C1,3, and the other on the second and fourth, written as C2,4. For general n, the final operator is the composition Cn = C1,n+1C2,n+2⋯Cn,2n." Commented Apr 18, 2023 at 7:57
• Ok, it is just notation, not familiar to me. Can you please tell us what is the book? Commented Apr 18, 2023 at 11:01
• Please, if you could, post a picture of a circuit where the gate is used. Commented Apr 18, 2023 at 14:26

Without context, we can only guess. My guess would be that CNOT1,3 means a controlled-not, controlled off qubit 1 and targetting qubit 3. In a 3-qubit setting, the gate would then look like $$|0\rangle\langle 0|\otimes I\otimes I+|1\rangle\langle 1|\otimes I\otimes X.$$

• I think you are right, but how do you get that formular, can i get the general formular to compute any gate like this? Commented Apr 18, 2023 at 7:59
• Yes. You just have a tensor product structure covering all qubits, and put $I$ everywhere that you're not doing anything. Commented Apr 18, 2023 at 8:07

For a general formula, consider an $$n$$-qubit state. Denote $$c$$ and $$t$$ as the indices of the control and target qubits (indexing from 0). Then, a general gate $$CNOT_{c,t}$$ can be given by $$I^{\otimes c} \otimes |0\rangle \langle 0| \otimes I^{\otimes (n-c-1)}$$ $$+ I^{\otimes c} \otimes |1\rangle \langle 1| \otimes I^{\otimes (t-c-1)} \otimes X \otimes I^{\otimes (n-t-1)}$$ where $$I^{\otimes i}$$ denotes the $$i$$-fold tensor product of the identity. Note that here, we have assumed $$c < t$$, however, a similar formula can be arrived in the other case.