|q⟩ Bad Qubits

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

RX and the X Axis

The Bloch sphere pictures a qubit's state as a point on the surface of a unit sphere. The north pole is 0|0\rangle, the south pole is 1|1\rangle, and the equator holds all equal-weight superpositions. Any single-qubit gate is a rotation of this sphere. The RX(θ)RX(\theta) gate is the specialised rotation that spins the Bloch vector around the xx axis by angle θ\theta.

The matrix

The RXRX rotation gate is defined as

RX(θ)=eiθX/2=cos ⁣θ2Iisin ⁣θ2X=(cosθ2isinθ2isinθ2cosθ2).RX(\theta) = e^{-i\theta X/2} = \cos\!\tfrac{\theta}{2}\,I - i\sin\!\tfrac{\theta}{2}\,X = \begin{pmatrix} \cos\tfrac{\theta}{2} & -i\sin\tfrac{\theta}{2} \\ -i\sin\tfrac{\theta}{2} & \cos\tfrac{\theta}{2} \end{pmatrix}.

The factor of 12\tfrac{1}{2} appears because a rotation by angle θ\theta on the Bloch sphere corresponds to a rotation by θ2\tfrac{\theta}{2} in the two-dimensional complex vector space of qubits (the spin-12\tfrac{1}{2} representation).

Substituting special values makes the connection concrete:

How it differs from X

The Pauli XX gate is exactly iRX(π)iRX(\pi): it flips 01|0\rangle \leftrightarrow |1\rangle with no extra freedom. RX(θ)RX(\theta) generalises this: by choosing θ\theta you can reach any point along the arc from 0|0\rangle to 1|1\rangle on the Bloch sphere. This continuous control is what makes rotation gates central to building arbitrary single-qubit operations — any single-qubit unitary can be decomposed into three rotations (the Euler angle decomposition).

Try it

Apply RX(π)RX(\pi) to qubit 0. The grader checks the full state vector, so the amplitudes must match those predicted by the matrix above: 0i1|0\rangle \to -i|1\rangle.

Run your code to see the quantum state.

After running, inspect the State Vector panel: you should see amplitude i0.0001.000i-i \approx -0.000 - 1.000i on the 1|1\rangle component, confirming the half-turn around the xx axis.

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