# Why 2 $H$ gates in series create a probability of 100% for one value of the qubit and 0% of the second value of the qubit?

Why 2 $$H$$ gates in series create a probability of 100% for one value of the qubit and 0% of the second value of the qubit since an $$H$$ gate acts like a superposition generator?

• Consider using the title for the question itself, so it will be easier to find for others. – luciano Nov 4 '20 at 18:35

## 3 Answers

The reason for this is because the inverse of Hadamard gate is itself. That is, giving that

$$H = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1& 1\\ 1 & -1 \\ \end{pmatrix}$$

then

$$H^{-1} = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1& 1\\ 1 & -1 \\ \end{pmatrix}$$

so therefore, $$HH|\psi\rangle = H H^{-1} |\psi \rangle = I |\psi \rangle = |\psi\rangle \ \ \ \textrm{where I is the Identity operator.}$$

Now when $$|\psi \rangle = |0 \rangle$$, which is the starting state of your quantum circuit, then applying two consecutive Hadamard gates is the same as doing nothing... hence the qubit stayed at the state $$|0\rangle$$. Thus giving you a 100% probability is it the state $$|0\rangle$$.

To see this in the geometric sense, applying two consecutive Hadamard gates to the qubit in the state $$|0\rangle$$ is like doing the following rotations: The first Hadamard gate rotate the qubit in the red trajectory to the state $$|+\rangle = \dfrac{|0 \rangle + |1 \rangle}{\sqrt{2}}$$. Then the second Hadamard gate rotate the qubit in the blue trajectory, back to the state $$|0\rangle$$ again.

Simply speaking, $$H^2 = HH = I$$ which is identity (you can verify this by direct matrix multiplication). As a result, such operator does not change anything in a quantum state.

The answers above noting that $$H^2=I$$ neatly capture this. If you want an alternative way of seeing this, you can look at what $$H$$ does to each of the computational basis states if applied twice. (Since any state will be a superposition of the basis states, understanding how the operator acts on each basis state will tell you what it does to a general state.)

• When $$H$$ is applied to $$|0 \rangle \equiv \begin{bmatrix}1\\0\end{bmatrix}$$, matrix multiplication means you can read off the first column of $$H$$ to see what the coefficients of $$|0 \rangle$$ are in the standard basis after applying $$H$$ to it. Specifically, $$H$$ takes $$|0 \rangle$$ to $$\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$.
• When $$H$$ is applied to $$|1 \rangle \equiv \begin{bmatrix}0\\1\end{bmatrix}$$, matrix multiplication means you can read off the second column of $$H$$ to see what the coefficients of $$|1 \rangle$$ are in the standard basis after applying $$H$$ to it. Specifically, $$H$$ takes $$|1 \rangle$$ to $$\frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$$.

To apply $$H$$ to each of the computational basis states a second time, we can just re-use the results from above: $$HH |0 \rangle = H\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) \\= \frac{1}{2}((|0\rangle + |1\rangle)+(|0\rangle - |1\rangle)) \\=\frac{1}{2}(2|0\rangle)=|0\rangle,$$ $$HH |1 \rangle = H\frac{1}{\sqrt{2}}(|0\rangle - |1\rangle) \\= \frac{1}{2}((|0\rangle + |1\rangle)-(|0\rangle - |1\rangle)) \\=\frac{1}{2}(2|1\rangle)=|1\rangle.$$ Since applying $$H$$ twice to both computational basis states results in no change, applying $$H$$ to any state results in no change, i.e., $$H^2=I$$.