|q⟩ Bad Qubits

beginner · Programming · Rotation Gates & Universal Single-Qubit Ops

RY for Real Amplitudes

Every state on the Bloch sphere can be written in the form cos(θ/2)0+eiϕsin(θ/2)1\cos(\theta/2)|0\rangle + e^{i\phi}\sin(\theta/2)|1\rangle. When you only need real, non-negative amplitudes — a common starting point for algorithms like Grover search — the eiϕe^{i\phi} factor plays no role, and you can reach the target state with a single gate: the RY rotation.

What RY does

The RY(θ)R_Y(\theta) gate rotates the Bloch sphere by angle θ\theta about the yy-axis:

RY(θ)=(cos(θ/2)sin(θ/2)sin(θ/2)cos(θ/2)).R_Y(\theta) = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}.

Acting on the ground state 0=(10)|0\rangle = \binom{1}{0}, the result is

RY(θ)0=cos ⁣θ20+sin ⁣θ21.R_Y(\theta)|0\rangle = \cos\!\tfrac{\theta}{2}\,|0\rangle + \sin\!\tfrac{\theta}{2}\,|1\rangle.

Both amplitudes are real and the probabilities sum to one because cos2(θ/2)+sin2(θ/2)=1\cos^2(\theta/2) + \sin^2(\theta/2) = 1.

A few special cases are worth memorising:

| θ\theta | P(0)P(0) | P(1)P(1) | Resulting state | |---|---|---|---| | 00 | 11 | 00 | 0\|0\rangle | | π/2\pi/2 | 1/21/2 | 1/21/2 | cos(π/4)0+sin(π/4)10.7070+0.7071=+\cos(\pi/4)\|0\rangle + \sin(\pi/4)\|1\rangle \approx 0.707\|0\rangle + 0.707\|1\rangle = \|{+}\rangle | | π\pi | 00 | 11 | 1\|1\rangle | | 2π2\pi | 11 | 00 | 0-\|0\rangle (global phase, same as 0\|0\rangle physically) |

The θ=π/2\theta = \pi/2 case gives the same 50/50 split as the Hadamard, yet their matrices are different. Both prepare +|+\rangle (up to a global phase), confirming that the Born-rule probabilities capture everything measurable.

Choosing the angle

To hit a target amplitude α\alpha on 0|0\rangle (with 0α10 \le \alpha \le 1), solve

cos ⁣θ2=αθ=2arccos(α).\cos\!\tfrac{\theta}{2} = \alpha \quad\Longrightarrow\quad \theta = 2\arccos(\alpha).

For example, to put 75% of the probability into 0|0\rangle you need α=3/4=32\alpha = \sqrt{3/4} = \tfrac{\sqrt{3}}{2}, which gives θ/2=π/6\theta/2 = \pi/6 and θ=π/3\theta = \pi/3.

Try it

Use RYR_Y to prepare the state cos(π/6)0+sin(π/6)1\cos(\pi/6)|0\rangle + \sin(\pi/6)|1\rangle. The grader checks the full statevector, so the angle must be exact.

Run your code to see the quantum state.

After pressing Run, look at the amplitudes: 0|0\rangle should carry 0.866=cos(π/6)\approx 0.866 = \cos(\pi/6) and 1|1\rangle should carry 0.500=sin(π/6)\approx 0.500 = \sin(\pi/6), matching P(0)=3/4P(0) = 3/4 and P(1)=1/4P(1) = 1/4.

Sign in on the full site to ask questions and join the discussion.