Every state on the Bloch sphere can be written in the form
cos(θ/2)∣0⟩+eiϕsin(θ/2)∣1⟩.
When you only need real, non-negative amplitudes — a common starting point for algorithms like
Grover search — the eiϕ factor plays no role, and you can reach the target state with a
single gate: the RY rotation.
What RY does
The RY(θ) gate rotates the Bloch sphere by angle θ about the y-axis:
RY(θ)=(cos(θ/2)sin(θ/2)−sin(θ/2)cos(θ/2)).
Acting on the ground state ∣0⟩=(01), the result is
RY(θ)∣0⟩=cos2θ∣0⟩+sin2θ∣1⟩.
Both amplitudes are real and the probabilities sum to one because
cos2(θ/2)+sin2(θ/2)=1.
The θ=π/2 case gives the same 50/50 split as the Hadamard, yet their matrices are
different. Both prepare ∣+⟩ (up to a global phase), confirming that the Born-rule
probabilities capture everything measurable.
Choosing the angle
To hit a target amplitude α on ∣0⟩ (with 0≤α≤1), solve
cos2θ=α⟹θ=2arccos(α).
For example, to put 75% of the probability into ∣0⟩ you need α=3/4=23,
which gives θ/2=π/6 and θ=π/3.
Try it
Use RY to prepare the state
cos(π/6)∣0⟩+sin(π/6)∣1⟩.
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⟩ should carry ≈0.866=cos(π/6)
and ∣1⟩ should carry ≈0.500=sin(π/6), matching
P(0)=3/4 and P(1)=1/4.
Sign in on the full site to ask questions and join the discussion.