# Measure a state in Hadamard basis [closed]

I can't understand how a state measure on the Hadmard basis collapses to $$|+\rangle =\dfrac{|0\rangle+|1\rangle}{\sqrt{2}}$$ or $$|-\rangle =\dfrac{|0\rangle-|1\rangle}{\sqrt{2}}$$

as they dont see to be deterministic outputs as $$|0\rangle$$ or $$|1\rangle$$.

When a measurement is performed in a certain basis, an orthogonal projection is performed on the state in question. So given a state $$|\psi\rangle$$, a measurement in the hadamard basis would result in the following:

$$\frac{|+\rangle\langle+|\psi\rangle}{|\langle+|\psi\rangle|}$$ with probability $$|\langle+|\psi\rangle|^{2}$$ or $$\frac{|-\rangle\langle-|\psi\rangle}{|\langle-|\psi\rangle|}$$ with probability $$|\langle-|\psi\rangle|^{2}$$.

So give, for example, a state $$|0\rangle$$, it would result in one of the above two states with equal probabilty $$\frac{1}{2}$$

That's the beauty of the Hadamard gate or the $$\text{H}$$ gate which is represented by the following matrix: It puts the qubit in what is known as superposition. So for example if we apply the $$\text{H}$$ gate on $$|0⟩$$ or $$|1⟩$$, we get the output qubit $$|+⟩$$ and $$|-⟩$$ respectively with $$|+\rangle=\frac{1}{\sqrt{2}} ( |0\rangle+ |1\rangle)$$

$$|-\rangle=\frac{1}{\sqrt{2}} ( |0\rangle- |1\rangle)$$

That is in the $$|+⟩$$ state or the $$|-⟩$$,when we "measure" our qubit there is $$\frac{1}{2}$$ probability of the state collapsing into $$|0⟩$$ and $$\frac{1}{2}$$ probabilty of the state collapsing into $$|1⟩$$

• Thanks, I get the Hadamard gate, what I don't understand is when the "measuring " of a state is done on a Hadamard basis rather than on computation basis, in this basis the QBIT should the collapse to |+⟩ or |−⟩ and not |0⟩ or |1⟩ Jun 3 at 7:42

The main idea is that when we apply measurement to qubit by default in qiskit it measures in Z bases. So applying a H gate before measurement changes the measurement bases to X bases where we have |+> and |-> bases instead of |0> and |1> bases as like in normal Z measurement.

So based on what state you measure we can have the below results.

For |0> state when measured in X basis (which is H followed by measurement):  The Hadamard action on |0> states brings it to |+> state and when we measure along Z (meaning that you are projecting on Z basis) it may collapse 50% to 0 and 50% to 1.

For |1> state when measured in X basis  As like you would expect we get 50% probability for 0 and 1. (with 1 phase shifted by Pi).

Now when you measure |+> the states in H bases which is X measurement.  Since we measure |+> on |+> and |-> bases we get 100% probability of |+> state and since we don't have direct X measurement to see |+> state we take a H gate and perform Z measurement. The output |0> denotes that its 100% in |+> state. Since we don't have any visualization for X measurement, we use Z bases to visualize the outcome by applying H gate. The reason for operation is that H distinguishes between + and - state by 0 and 1. If the outcome of this kind of measurement is 0 it denotes that we are in + state.

Now when you measure the states |-> in H bases which is X measurement.  The reason being that here we have initialized the qubit to |-> state and since we measure the qubit in |+> and |-> bases we ought to get |-> bases as the result of measurement. Since we are in the X view we are not able to see the 50% probability of 0 and 1, and so it is collapsed to 1 based on the H operation.