ψQuantum Computing 2026

CHAPTER 04

Gates, observables, and the Bloch sphere

Learning goals. Multiply gate matrices, distinguish active transformations from coordinates, derive Bloch coordinates, and understand rotations and noncommuting operations.

4.1 Matrices act on vectors

A matrix is determined by what it does to basis vectors. Its first column is the output for |0|0\rangle; its second is the output for |1|1\rangle. Linearity then fixes the output for every superposition:

U(α|0+β|1)=αU|0+βU|1.U(\alpha|0\rangle+\beta|1\rangle)=\alpha U|0\rangle+\beta U|1\rangle.

For U=(abcd)U=\begin{pmatrix}a&b\\c&d\end{pmatrix} the result is (aα+bβ)|0+(cα+dβ)|1(a\alpha+b\beta)|0\rangle+(c\alpha+d\beta)|1\rangle. Every row forms one output amplitude. A valid closed-system gate preserves all inner products, so it satisfies UU=IU^\dagger U=I. Such a matrix is unitary, with inverse UU^\dagger.

The Pauli gates and Hadamard are

X=(0110),Y=(0ii0),Z=(1001),X=\begin{pmatrix}0&1\\1&0\end{pmatrix},\quad Y=\begin{pmatrix}0&-i\\i&0\end{pmatrix},\quad Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}, H=12(1111).H=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}.

X swaps the amplitudes, Z changes their relative sign, and Y combines a swap with phases. H maps |0|0\rangle to |+|+\rangle and |1|1\rangle to ||-\rangle. These matrices are Hermitian as well as unitary; not every gate is Hermitian.

The phase gates are

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

S has inverse S=diag(1,i)S^\dagger=\operatorname{diag}(1,-i), not S itself.

4.2 Gate order is matrix order in reverse time

If U acts first and V second, the output is VU|ψVU|\psi\rangle. The rightmost matrix acts first. A circuit is conventionally read left to right, which is why translating circuits into matrix products requires care.

Worked example. Apply H to α|0+β|1\alpha|0\rangle+\beta|1\rangle:

H|ψ=(α+β)|0+(αβ)|12.H|\psi\rangle=\frac{(\alpha+\beta)|0\rangle+(\alpha-\beta)|1\rangle}{\sqrt2}.

Applying H again gives

H2|ψ=(α+β+αβ)|0+(α+βα+β)|12=α|0+β|1.H^2|\psi\rangle =\frac{(\alpha+\beta+\alpha-\beta)|0\rangle +(\alpha+\beta-\alpha+\beta)|1\rangle}{2} =\alpha|0\rangle+\beta|1\rangle.

The cancellations show H2=IH^2=I. They also explain interference: the first H creates alternatives, and the second recombines them.

By contrast, XZ=ZXXZ=-ZX. For instance, XZ|0=|1XZ|0\rangle=|1\rangle but ZX|0=|1ZX|0\rangle=-|1\rangle. The minus sign is a global phase when these are complete single-qubit operations. In controlled versions, a phase confined to one control branch becomes relative and can matter. Never discard a phase before checking its role in a larger circuit.

4.3 Implementing a measurement basis

To measure X with a Z detector, apply H first, because 0|H=+|\langle0|H=\langle+| and 1|H=|\langle1|H=\langle-|. To measure Y, apply SS^\dagger and then H, so the total matrix is HSHS^\dagger:

0|HS=0|i1|2=+i|.\langle0|HS^\dagger =\frac{\langle0|-i\langle1|}{\sqrt2}=\langle+i|.

Using SH instead produces a different operation. Writing the bra of the actual measurement is an effective way to verify a basis-rotation circuit.

4.4 Bloch coordinates from amplitudes

Remove a global phase so the first nonzero coefficient is real. Every pure qubit can then be written

|ψ=cosθ2|0+eiϕsinθ2|1,0θπ.|\psi\rangle=\cos\frac\theta2|0\rangle+ e^{i\phi}\sin\frac\theta2|1\rangle,\quad 0\le\theta\le\pi.

Define x=Xx=\langle X\rangle, y=Yy=\langle Y\rangle, and z=Zz=\langle Z\rangle. Matrix multiplication gives

x=α*β+β*α=2Re(α*β),x=\alpha^*\beta+\beta^*\alpha=2\operatorname{Re}(\alpha^*\beta), y=iα*β+iβ*α=2Im(α*β),y=-i\alpha^*\beta+i\beta^*\alpha=2\operatorname{Im}(\alpha^*\beta), z=|α|2|β|2.z=|\alpha|^2-|\beta|^2.

Substituting the angular form yields

(x,y,z)=(sinθcosϕ,sinθsinϕ,cosθ).(x,y,z)=(\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta).

Its length is one. The north and south poles are |0,|1|0\rangle,|1\rangle; the positive x and y directions are |+,|+i|+\rangle,|+i\rangle. The sphere represents pure qubit states modulo global phase, not the physical path or shape of a particle.

For (2|0+3i|1)/13(2|0\rangle+3i|1\rangle)/\sqrt{13},

(x,y,z)=(0,12/13,5/13),x2+y2+z2=(144+25)/169=1.(x,y,z)=(0,12/13,-5/13),\quad x^2+y^2+z^2=(144+25)/169=1.

Thus equal X probabilities do not place the state at the sphere’s center. They only imply its x coordinate is zero.

Bloch coordinates and the three measurement axes.

4.5 Rotations and generators

For a unit vector 𝐧\boldsymbol n, let A=nxX+nyY+nzZA=n_xX+n_yY+n_zZ. Since A2=IA^2=I, the exponential series separates into even and odd powers:

eiθA/2=Icos(θ/2)iAsin(θ/2).e^{-i\theta A/2} =I\cos(\theta/2)-iA\sin(\theta/2).

This is R𝐧(θ)R_{\boldsymbol n}(\theta), rotating the Bloch vector by angle θ\theta about 𝐧\boldsymbol n. For example,

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}, Rz(θ)=diag(eiθ/2,eiθ/2).R_z(\theta)=\operatorname{diag}(e^{-i\theta/2},e^{i\theta/2}).

The half-angle is necessary: a 2π2\pi rotation gives I-I, physically the same pure state but a different vector representative. H corresponds to a half-turn about (x+z)/2(x+z)/\sqrt2, up to global phase; it is not simply a quarter-turn about y.

4.6 Observables and uncertainty

An observable is Hermitian: A=AA^\dagger=A. Its eigenvalues are real, and its orthonormal eigenvectors specify a projective measurement. A gate is unitary. Some matrices, including the Paulis, serve both roles, but “apply Z” and “measure Z” are different physical instructions.

The commutator is [A,B]=ABBA[A,B]=AB-BA. Since [X,Y]=2iZ[X,Y]=2iZ, the uncertainty relation gives ΔXΔY|Z|\Delta X\Delta Y\ge|\langle Z\rangle|. In |0|0\rangle, both X and Y outcomes are random, so ΔX=ΔY=1\Delta X=\Delta Y=1, saturating the bound. This is a statement about measurement distributions across identically prepared copies.

Laboratory L05 — Bloch sphere and gates. Adjust θ,ϕ\theta,\phi, rotate the view, and apply H, X, Y, Z, S, or a rotation. Read all three expectations and basis probabilities. Check the recurring example’s coordinates.

4.7 Exercises

4.1. Verify HZH=XHZH=X using the matrix columns or its action on both basis states.

Show solution / guidance

H|0=|+H|0\rangle=|+\rangle, Z|+=|Z|+\rangle=|-\rangle, H|=|1H|-\rangle=|1\rangle. The other input maps to |0|0\rangle. These outputs are exactly X’s columns.

4.2. Calculate Z probabilities after HSH|0HSH|0\rangle.

Show solution / guidance

The intermediate state is (|0+i|1)/2(|0\rangle+i|1\rangle)/\sqrt2. The final amplitudes are (1+i)/2,(1i)/2(1+i)/2,(1-i)/2. Each has squared modulus 2/4=1/22/4=1/2.

4.3. Find the Bloch coordinates of (|0+eiπ/3|1)/2(|0\rangle+e^{i\pi/3}|1\rangle)/\sqrt2.

Show solution / guidance

θ=π/2,ϕ=π/3\theta=\pi/2,\phi=\pi/3, so (x,y,z)=(1/2,3/2,0)(x,y,z)=(1/2,\sqrt3/2,0).

4.4. Derive Z probabilities after Ry(θ)|0R_y(\theta)|0\rangle and verify normalization.

Show solution / guidance

The state is cos(θ/2)|0+sin(θ/2)|1\cos(\theta/2)|0\rangle+\sin(\theta/2)|1\rangle. The probabilities are cos2(θ/2),sin2(θ/2)\cos^2(\theta/2),\sin^2(\theta/2) and sum to one.

4.5. Why can a unitary not reset both |0|0\rangle and |1|1\rangle to |0|0\rangle?

Show solution / guidance

The input overlap is zero; the proposed output overlap is one. Reset is possible as an open-system process that exports information, not as a unitary on the qubit alone.