# Why isn't $Ry(\pi/2)$ gate equivalent to Hadamard gate?

I've been experimenting with quantum circuits and can't quite fathom how the difference between states comes together.

Speaking in terms of simulations using qiskit, the following code yelds the same results:

circuit = QuantumCircuit(1)
circuit.h(0)
state = Statevector.from_instruction(circuit)
display(plot_bloch_multivector(state, title="H", reverse_bits=False))

circuit = QuantumCircuit(1)
circuit.ry(0.5*np.pi,0)
state = Statevector.from_instruction(circuit)
display(plot_bloch_multivector(state, title="Y", reverse_bits=False)) According to this page, the H-Gate is equivalent to the following circuit: The state vector remains the same, which makes sense as it's only rotating around the x-axis.

Even negating the initial qubit state and make it a $$|1\rangle$$ does not bring any difference to the table.

So, I went deeper and looked at the maths behind it. Applying the H gate to $$|0\rangle$$ results in:

$$H|0\rangle =\ \begin{pmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} =\ \begin{pmatrix}\frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}}\end{pmatrix} =\ \frac{|0\rangle + |1\rangle}{\sqrt{2}} =\ |+\rangle$$

Now, using the RY-Gate, we can construct a matrix using $$\frac{\pi}{2}$$. This is where my understanding of the mathematical application stops tho, and I can't quite figure out how to do the rest of the calculation. This is as far as I've come, but I can't quite "translate" the result into a comparable qubit state:

$$\begin{pmatrix} \cos(\frac{\pi}{4}) & -\sin(\frac{\pi}{4})\\ \sin(\frac{\pi}{4}) & \cos(\frac{\pi}{4}) \end{pmatrix}|0\rangle =\ \begin{pmatrix} 0.707 & -0.707\\ 0.707 & 0.707\end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} =\ \begin{pmatrix} 0.707 \\ 0.707 \end{pmatrix}$$

Reason for this question is that I am trying different circuits to classify IRIS for comparison, and I am seeing much better accuracy when using my basic Y-Rotation based circuit in comparison to qiskits ZZFeature and RealAmplitudes circuit.

• Interesting that $\ket{0}$ works in the preview window but not in the post itself? Oct 24, 2021 at 11:20
• The issue with ket happens to me sometimes. What is even worse, \ket works usually fine with other SE sites, but not the one where you need them the most, here in QC SE! you can still write them as | and langle or range Oct 24, 2021 at 13:52

While Hadamard gate is defined as $$H= \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix},$$ $$y$$-rotation by $$\pi/2$$ leads to gate $$Ry(\pi/2)= \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -1 \\ 1 & 1 \end{pmatrix}.$$ So, there is a difference in position of -1 in the second column. Application of the $$X$$ gate returns the -1 in $$Ry(\pi/2)$$ to right place to obtain Hadamard gate.

You can easily see that $$H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$ and $$Ry(\pi/2)|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$. Application of $$X$$ after $$Ry$$ leads to the same quantum state.

However, while $$H|1\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$$, $$Ry(\pi/2)|1\rangle = \frac{1}{\sqrt{2}}(-|0\rangle + |1\rangle)$$. Application of $$X$$ after $$Ry$$ switches states $$|0\rangle$$ and $$|1\rangle$$ and leads to $$XRy(\pi/2)|1\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$$.

This all means that $$XRy(\pi/2)=H$$.

• You cannot neglect the $X$ even if you choose to ignore the global phase. Consider that $\sqrt2 H\begin{bmatrix}a\\b\end{bmatrix} = \begin{bmatrix}a+b\\a-b\end{bmatrix}$ and $\sqrt2 R_y(\pi/2)\begin{bmatrix}a\\b\end{bmatrix} = \begin{bmatrix}a-b\\a+b\end{bmatrix}$ which in general differ by more than just the global phase. The reason that it looked like the difference is in global phase only is that $|+\rangle$ and $|-\rangle$ just happen to be the eigenstates of $X$. So the last paragraph could use an update. The rest LGTM. Oct 24, 2021 at 18:49
• Could you elaborate on how you went from $RY(\frac{\pi}{2})$ to that matrix? Seems as if I am missing a key step there Oct 24, 2021 at 18:51
• @AdamZalcman: Thanks Adam, you are absolutely right. We can neglect the global phase only in case it is involving in all basis states, i.e. the whole matrix is multiplied by some, generally complex, number. Oct 24, 2021 at 21:01
• @Redimo: calculated sinus and cosinus values, then factored out the $\frac{1}{\sqrt{2}}$ and finally multiplied by $X$ from left side. This proves the equivalence of Hadamard gate and $XRy(\pi/2)$. Oct 25, 2021 at 9:29
• Oh wow, that went right over my head. Thanks a lot! Oct 25, 2021 at 9:42

Just to emphasise the point on the accepted answer...

The two gates, when applied to a specific state, give the same output. That does not mean they are the same, because the action on another state may be different (and I don't just mean a global phase).

For example, if you take the state $$|+\rangle=(|0\rangle+|1\rangle)/\sqrt{2}$$ then $$H|+\rangle=|0\rangle,$$ but $$R_Y(\pi/2)|+\rangle=|1\rangle.$$ The two outcomes are orthogonal. So, in this case, you can definitely tell which of the two you have just by measuring the output.