# How to perform measurement of a qubit?

I am trying to implement the Deutsch algorithm. My steps were:

1. Write down $$|01\rangle$$ in a matrix form $$A$$;
2. Apply $$H^{\oplus2}$$ gate to $$A$$ matrix;
3. Multiply it with $$U_f$$ matrix;
4. Apply $$H$$ to the first qubit;

After the above steps, I got a matrix:

array([[ 0.        ],
[ 0.        ],
[-0.70710678],
[ 0.70710678]])


How should I perform a measurent step on the first qubit to get the answer?

• What basis is the vector in? Mar 1, 2019 at 21:52
• Basis vectors are {1,0} and {0,1} Mar 1, 2019 at 22:41

You haven’t specified the order of entries in your vector. In general, the $$i$$’th entry is obtained with probability $$|x_i|^2$$.
Let’s consider two examples. In the first, the order of entries is $$|00\rangle, |01\rangle, |10\rangle, |11\rangle$$. The two final entries will be obtained with probability $$1/2$$ each, and so the first qubit will be measured as $$|1\rangle$$. If you measure only the first qubit, then you will still always get $$|1\rangle$$, and the other qubit will remain in the superposition $$\frac{1}{\sqrt{2}}(|1\rangle-|0\rangle)$$.
If the order of entries is instead $$|00\rangle, |10\rangle, |01\rangle, |11\rangle$$, then once again the two final entries will be obtained with probability $$1/2$$ each. This means that the first qubit will be measured as $$|0\rangle$$ or $$|1\rangle$$ with equal probability.