# Question about H-gate on entangled qubits

I have a question about the Hadamard Gate on entangled qubits. I’m very newb to quantum computing and does not have any professional knowledge in physics nor mathematics. However I’ve tried some different algorithms in IBM’s quantum experience and think I got the idea about how the qubits works in the block sphere. Because of my poor knowledge in physics I need a simple explanation and I want to understand it...

My problem:

When I do the following operation:

q[0]: H   ( + )   H
q[1]:          *

( + ) = CNOT control
* = target


I get the following results when I measure q[0] and q[1] after 1000 shots:

1/4 times: 11 1/4 times: 01 1/4 times: 10 1/4 times: 00

What I don’t get is why the first qubit is measured as as a 1 (only) 1/2 times and as a 0 1/2 of the times. My theory before the measurement was that q[0] would always be measured as a 1 all the times since I put it in superposition <+| and then put it back (after the second H gate and the CNOT) to be measured along the X-axis. So what have I missed?

• Next time please take a look at your formatted answer and see whether it's legible. – Yuval Filmus Feb 26 '18 at 20:23
• I'm assuming the initial state is zero? – Yuval Filmus Feb 26 '18 at 20:23
• Yes, starting state is zero on both qubits. – Spaxen Feb 26 '18 at 20:47

Assuming that the initial quantum state is $\left| 00 \right\rangle$, the effect of the circuit is $$\frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \cdot \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1\\0\\0\\0 \end{bmatrix} = \begin{bmatrix} 1/2\\1/2\\1/2\\-1/2 \end{bmatrix},$$ where the rows and columns are indexed by $\left|q_0q_1\right\rangle = \left|00\right\rangle,\left|01\right\rangle,\left|10\right\rangle,\left|11\right\rangle$. When you measure the two qubits at the end, you should get each of the four possibilities with probability $(\pm 1/2)^2 = 1/4$, which is exactly what you have observed.

If, however, you apply the CNOT gate with input roles reversed, you get $$\frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \cdot \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1\\0\\0\\0 \end{bmatrix} = \begin{bmatrix} 1\\0\\0\\0 \end{bmatrix},$$ so in this case you will always measure $\left|00\right\rangle$.

• I don’t understand that part mathematic. I just wanna understand how the qubits moves in the block sphere... – Spaxen Feb 26 '18 at 21:17
• Unfortunately it is not possible to understand quantum algorithms without understanding linear algebra. Your intuitive understanding might not match what actually happens in the computation. – Yuval Filmus Feb 26 '18 at 21:50
• Ok... I will try to study and understand matrices, and the matrices you wrote above. I guess the first three are the H, CNOT and H? But what is the last and fourth, the one with one column and four rows? – Spaxen Feb 26 '18 at 22:44
• The vector on the right is the initial state. – Yuval Filmus Feb 26 '18 at 22:59