2

In the qiskit textbook chapter 1.3.1 "The CNOT-Gate" it says that the matrix representation on the right is the own corresponding to the circuit shown above, with q_0 being the control and q_1 the target, but shouldn't this matrix representation be for the case of q_1 being the control and q_0 the target? This seems to be presented the other way round...or there seems to be something I am not quite getting yet.

Thanks so much :)

Quick edit: By "right" I am referring to this: enter image description here

epelaez
  • 2,875
  • 1
  • 8
  • 31
Alvo
  • 23
  • 4
  • Alright, I was guessing you meant something else. In this terms @Egretta.Thula is the correct one. Cheers! :) – Ole Pannier Jul 27 '21 at 13:48
  • I went to the textbook and it says that the left matrix corresponds to the circuit above: "In our case, the left matrix corresponds to the CNOT in the circuit above". – epelaez Jul 27 '21 at 13:50
  • Related: https://quantumcomputing.stackexchange.com/a/15287/9858 – KAJ226 Jul 27 '21 at 14:24

2 Answers2

11

Qiskit uses "little endian" bit ordering. That means, if A and B are $2 \times 2$ unitary matrices then $B \otimes A$ (note the order) is equivalent to applying $A$ to first qubit and $B$ to second qubit.

Hence, $$CNOT = I \otimes P_0 + X \otimes P_1$$ where $$ P_0 = \left( {\begin{array}{*{20}{c}} 1&0 \\ 0&0 \end{array}} \right) , P_1 = \left( {\begin{array}{*{20}{c}} 0&0 \\ 0&1 \end{array}} \right) $$

If you do the matrix multiplication, you should get $$CNOT = \left( {\begin{array}{*{20}{c}} 1&0&0&0 \\ 0&0&0&1 \\ 0&0&1&0 \\ 0&1&0&0 \end{array}} \right)$$

Egretta.Thula
  • 9,972
  • 1
  • 11
  • 30
  • Thank you so much! That's what I was missing :) – Alvo Jul 27 '21 at 13:56
  • But the examples are not presented like this in text, right? Is there a footnote or anything that introduces this convention? It does make sense but it seems a bit inconsistent since the tensor product is not introduced nor treated with this convention... – Alvo Jul 27 '21 at 14:03
  • Actually, it is in the same web page. Just (re)read section 2 in the same chapter (Single Qubit Gates on Multi-Qubit Statevectors). Notice the circuit where $H$ is applied to $q_0$ and $X$ is applied to $q_1$ and see how its unitary is calculated. – Egretta.Thula Jul 27 '21 at 14:11
  • See here: https://qiskit.org/documentation/stubs/qiskit.circuit.library.CXGate.html#qiskit.circuit.library.CXGate – KAJ226 Jul 27 '21 at 14:20
  • @Egretta.Thula I am so sorry. I just copied it the other way round while doing the math, anticipating the change of order and basically changing it twice. Thanks so much for your patience!!! :))) – Alvo Jul 27 '21 at 14:33
  • @KAJ226 Thank you! :) – Alvo Jul 27 '21 at 14:35
-4

enter image description here

Hi there. the Matrix for 0,1 is to represent Q[0] = 1 to be effective, right, so that I wrote & got the answer for the Coefficient to be |01> is 1 in the last column of the Density Matrix.

Consequently do note that the for CNOT for 1,0 to be effecive Q[1] must be one so i get the representation of the the co-efficient of |10> to be 1 as the the last column of the matrix.

Also my Dears, Please do kindly note that the Density Matrix column has direct Relationship with the State Specially the 1st & last column.

p._phidot_
  • 107
  • 4
  • 2
    The image that you linked isn't correctly displayed and please write your equations using Latex. Just enclose them in '$' for inline equations and '$$' for equations centered in their own line. – epelaez Aug 02 '21 at 00:09