|q⟩ Bad Qubits

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

Angle Conventions (θ/2)

Every rotation gate RX(θ)R_X(\theta), RY(θ)R_Y(\theta), and RZ(θ)R_Z(\theta) encodes an angle, but there is one detail that surprises many learners: the parameter θ\theta you pass is the Bloch-sphere rotation angle, while the matrix contains θ/2\theta/2 — a factor of one-half hidden inside the formula.

Where the θ/2\theta/2 comes from

The rotation gates are defined as matrix exponentials of the Pauli operators:

RX(θ)=ei(θ/2)X,RY(θ)=ei(θ/2)Y,RZ(θ)=ei(θ/2)Z.R_X(\theta) = e^{-i(\theta/2)X}, \quad R_Y(\theta) = e^{-i(\theta/2)Y}, \quad R_Z(\theta) = e^{-i(\theta/2)Z}.

Expanding via the Euler formula eiϕP=cosϕIisinϕPe^{-i\phi P} = \cos\phi\, I - i\sin\phi\, P (valid when P2=IP^2 = I, which holds for all three Paulis) gives, for example:

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

The entries involve θ/2\theta/2, not θ\theta. This is a direct consequence of how spin-12\tfrac{1}{2} particles represent rotations: the Hilbert-space representation of a rotation by angle ϕ\phi in three-dimensional space is ei(ϕ/2)n^σe^{-i(\phi/2)\hat{n}\cdot\vec{\sigma}}, where n^\hat{n} is the rotation axis and σ=(X,Y,Z)\vec{\sigma} = (X, Y, Z) are the Pauli matrices. The factor of 12\tfrac{1}{2} is not a notational quirk — it is a physical fact about spin-12\tfrac{1}{2} systems.

The practical rule

Because the convention is baked into the definition, you always pass the angle you want to rotate on the Bloch sphere. The gate handles the internal 12\tfrac{1}{2}. A few important checkpoints:

| Desired Bloch rotation | Angle to pass | What the matrix computes | |---|---|---| | 0° (no rotation) | θ=0\theta = 0 | cos0=1,  sin0=0\cos 0 = 1,\; \sin 0 = 0 → identity | | 90°90° (π/2\pi/2 rad) | θ=π/2\theta = \pi/2 | cos(π/4)=12\cos(\pi/4) = \tfrac{1}{\sqrt{2}} | | 180°180° (π\pi rad, half-turn) | θ=π\theta = \pi | cos(π/2)=0,  sin(π/2)=1\cos(\pi/2) = 0,\; \sin(\pi/2) = 1 → Pauli (up to phase) | | 360°360° (2π2\pi rad, full turn) | θ=2π\theta = 2\pi | cosπ=1\cos\pi = -1I-I (global phase 1-1) |

Notice that a full 360°360° turn gives I-I, not +I+I. The state picks up a global phase of 1-1, which is unobservable, but the qubit needs a 720°720° rotation to return to exactly the original matrix. This is a signature of the double-cover structure shared by all spin-12\tfrac{1}{2} systems.

Verifying with RX(π)R_X(\pi) on 0|0\rangle

Substituting θ=π\theta = \pi into the RXR_X matrix confirms the half-angle directly:

RX(π)=(cosπ2isinπ2isinπ2cosπ2)=(0ii0).R_X(\pi) = \begin{pmatrix} \cos\tfrac{\pi}{2} & -i\sin\tfrac{\pi}{2} \\ -i\sin\tfrac{\pi}{2} & \cos\tfrac{\pi}{2} \end{pmatrix} = \begin{pmatrix} 0 & -i \\ -i & 0 \end{pmatrix}.

Applying this to 0=(10)|0\rangle = \binom{1}{0}:

RX(π)0=(0i)=i1.R_X(\pi)|0\rangle = \begin{pmatrix} 0 \\ -i \end{pmatrix} = -i|1\rangle.

The state is 1|1\rangle up to the global phase i-i — a complete population transfer, as expected for a 180°180° rotation.

Try it

Apply RXR_X with the correct angle to map 0|0\rangle to 1|1\rangle (up to global phase). The grader checks the full statevector, so you must pass θ=π\theta = \pi — passing π/2\pi/2 will land on the equator and fail.

Run your code to see the quantum state.

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