# Explanation of output produced by the following quantum circuit

I've recently started reading about quantum computing and I apologize in advance if this is (and I think it probably is) a very simple question.

I've created the following circuit. I believe I understand this circuit. It sends qubit 1 through the Hadamard gate to give it a 50/50 chance of being 0 or 1. The C-NOT gate means, if q is 0 then q remains 0 and if q is 1 then q has a not gate applied to make it 1. Therefore, the two qubits are entangled. It does the same to entangle q and q and for that reason, when the three are measured it is always 000 or 111 with a 50/50 chance of each. (I may not have understood this part well so if this is wrong, please verify my misunderstanding).

I've been fiddling with a similar circuit by adding a Hadamard gate to the third qubit at the beginning which is this circuit producing the below result.  I don't quite understand how those are the four possible results so please can someone explain how this circuit works. Many thanks

• Hi @Dan! For an intro understanding of quantum computing, using 50/50 will work, but it's imperative that you understand linear algebra and braket notation if you'd like to get deeper. The power of quantum computing emerges from destructive / constructive interference, which can only occur with complex amplitudes. – C. Kang Nov 26 '19 at 16:28
• @C.Kang Thanks for the advice. I've been doing things like expressing the combination of two qubits as the tensor product, expressing quantum gates as matrices etc. I didn't add it into the question because I wasn't sure it would be relevant. – Dan Nov 27 '19 at 0:34

Note that $$H | 0 \rangle = | + \rangle = \frac{1}{\sqrt{2}}(| 0 \rangle + | 1 \rangle)$$. So, after the two Hadamard gates the state will be $$| 0 \rangle \otimes H| 0 \rangle \otimes H| 0 \rangle = \frac{1}{2} | 0 \rangle \otimes (| 0 \rangle + | 1 \rangle)\otimes (| 0 \rangle + | 1 \rangle) =$$ $$= \frac{1}{2} (| 000 \rangle + | 001 \rangle + | 010 \rangle + | 011 \rangle)$$ Now after the application of those two CNOT gates the state will be $$\frac{1}{2} (| 000 \rangle + | 001 \rangle + | 111 \rangle + | 110 \rangle)$$ The last histogram confirms this (in the 00000 representation the state of q is the far right symbol)

Yes you are absolutely right with your understanding but here is the game: All the Qubits are starting with the |0> i.e. value 0 until the Hadamard gate is applied. The Hadamard gates just makes the probability of the Qubit being 0 or 1 to be 50-50 i.e $$\frac{1}{\sqrt{2}}|\mathbf{0}> + \frac{1}{\sqrt{2}}|\mathbf{1}>$$

Now in the second example you applied H gate to q1 and q2 which gave them the probability of being 0 or 1 to be 50-50. So, lets see all the possible initial states of the Qubits and their values as outputs on measurement first:

1. State 1:
• q0 |0> ---OUTPUT : 0--- |
• q1 |0> ---OUTPUT : 0--- |
• q2 |0> ---OUTPUT : 0--- |

Final Output: 000

2. State 2:
• q0 |0> ---OUTPUT : 1--- |
• q1 |1> ---OUTPUT : 1--- |
• q2 |0> ---OUTPUT : 1--- |

Final Output: 111

3. State 3:
• q0 |0> ---OUTPUT : 0--- |
• q1 |0> ---OUTPUT : 0--- |
• q2 |1> ---OUTPUT : 1--- |

Final Output: 100

4. State 4:
• q0 |0> ---OUTPUT : 1--- |
• q1 |1> ---OUTPUT : 1--- |
• q2 |1> ---OUTPUT : 0--- |

Final Output: 011

I hope this helps. Please specify if you are still having trouble in understanding.

• Hi. Welcome to Quantum Computing SE! It is preferable that you use MathJax to typeset your posts. – Sanchayan Dutta Nov 26 '19 at 12:21