|q⟩ Bad Qubits

beginner · Programming · The Bloch Sphere

Phase Gates as Z-Rotations

The Z gate, the S gate, and the T gate all leave 0|0\rangle unchanged and multiply the amplitude of 1|1\rangle by a phase factor. On the Bloch sphere each of them is a pure rotation about the zz-axis — they differ only in how far they turn.

Phase gates as diagonal matrices

All three gates share the same structure:

Z=(1001),S=(100i),T=(100eiπ/4).Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}, \qquad S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}, \qquad T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}.

Because the 0|0\rangle amplitude is always unchanged and 1|1\rangle picks up a phase, none of these gates can ever shift probability from 0|0\rangle to 1|1\rangle or back. They are phase-only operations.

The rotation angle

The general Rz(λ)R_z(\lambda) gate is defined as

Rz(λ)=(eiλ/200eiλ/2).R_z(\lambda) = \begin{pmatrix} e^{-i\lambda/2} & 0 \\ 0 & e^{i\lambda/2} \end{pmatrix}.

Up to a global phase (which is physically unobservable) we can match each phase gate to an RzR_z rotation:

On the Bloch sphere, the north pole 0|0\rangle stays fixed and every equatorial state traces a circular arc. Starting from +|+\rangle on the +x+x axis, a T gate nudges the Bloch vector 45°45° toward the +y+y axis; an S gate advances it 90°90°; a Z gate flips it 180°180° to x-x.

Gate relationships

Because the rotations compose by adding angles, the hierarchy is clear:

T2=S,S2=Z,T4=Z.T^2 = S, \qquad S^2 = Z, \qquad T^4 = Z.

Each identity is just π4+π4=π2\frac{\pi}{4} + \frac{\pi}{4} = \frac{\pi}{2} (or doubling the angle again for the next step). You can verify the first one by multiplying:

T2=(100eiπ/4)2=(100eiπ/2)=(100i)=S.T^2 = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}^2 = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/2} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} = S.

Try it

Apply two T gates in sequence to verify the identity T2=ST^2 = S. The grader compares the full unitary matrix, so leaving the circuit empty will not pass.

Run your code to see the quantum state.

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