The Quantum Engineer

10. Single-Qubit Gates

10.1The Pauli gates: I, X, Y, Z

Four 2×2 matrices do most of the algebra of one qubit. I leaves the state alone. X = [[0,1],[1,0]] is the quantum NOT: it swaps |0⟩ and |1⟩, a 180° rotation about the x-axis. Z = [[1,0],[0,−1]] leaves |0⟩ and |1⟩ fixed but flips the relative phase of superpositions — a 180° rotation about z, so it maps |+⟩ to |−⟩. Y = [[0,−i],[i,0]] is the x-rotation and z-rotation composed; it maps |+⟩ to −i|−⟩'s orthogonal partner and differs from XZ by a factor of i — a global phase, physically irrelevant (10.12). They satisfy the multiplication table X·Y = iZ (and cyclic), plus X² = Y² = Z² = I. Their eigenvectors are exactly the cardinal points of the Bloch sphere: X's are |±⟩, Z's are |0⟩, |1⟩.

import numpy as np

I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.diag([1, -1]).astype(complex)

10.2The Hadamard gate

H = (1/√2)[[1,1],[1,−1]] is the single most used gate in quantum computing. It maps |0⟩ → |+⟩ = (|0⟩+|1⟩)/√2, |1⟩ → |−⟩ = (|0⟩−|1⟩)/√2, and — being its own inverse (H² = I) — maps |+⟩ → |0⟩ and |−⟩ → |1⟩. Two readings. Geometrically: a 180° rotation about the (x+z)/√2 axis, exchanging the poles with two equatorial points. Algebraically: the Z-basis to X-basis change of basis, which is why "measure in the X basis" is universally implemented as H-then-measure-Z (11.6). Algorithmically: H is the interference engine — it creates superposition uniformly (part of every "spread the amplitudes" step) and, applied again, recombines paths so amplitudes can cancel. Grover, the QFT sampler, and every random circuit benchmark start with H.

10.3Phase gates: S and T

Phase gates act only on the amplitude of |1⟩, leaving |0⟩ untouched. S = diag(1, i) adds 90° to the relative phase; T = diag(1, e^{iπ/4}) adds 45°. Powers of Z: S² = Z, T² = S, T⁴ = Z. Why care about tiny angle tweaks? Because relative phase is invisible to Z-measurement but is visible after a Hadamard (or any X-basis rotation), and it is the raw material of interference. Concretely: H T H = a rotation about x by 45°, so combining T, H, and X you can synthesize rotations of arbitrary small angle — and T is the gate that makes the common hardware set {Rz, √X, T-ish pulses} universal for one qubit. On error-corrected hardware, T is famously expensive (it leaves the Clifford subgroup, Part X), so compilers hoard and distill it.

Effect on the equator (relative phase of |1> added by each gate):

  T: +45°   S: +90°   Z: +180°        S = T·T,  Z = S·S

  |+>  --T-->  phase 45°  --H-->  rotated Bloch vector, tilted off the equator

10.4Rotation gates

For any axis â in the Bloch picture, the rotation by angle θ is U = e^{−iθ(â·σ)/2}, where σ is the relevant Pauli matrix. Explicitly: Rx(θ) = cos(θ/2)I − i sin(θ/2)X, and similarly Ry, Rz with Y and Z. Three practical notes. First, the half-angle: a "π rotation" changes the Bloch vector by 180°, which surprises everyone once. Second, Rx and Ry mix amplitudes (they move the pole), while Rz only changes relative phase — hardware implements Rz as a cheap frame update, essentially free. Third, rotations compose like angles about the same axis: Rx(α)·Rx(β) = Rx(α+β), which makes arbitrary-angle pulses natural for analog control. In numpy these are one line each and are the gates you will reach for when building geometric intuition or calibrating a toy simulator.

10.5Arbitrary single-qubit rotations and gate decomposition

The gate decomposition theorem: any 2×2 unitary U equals a product Rz(α)·Ry(β)·Rz(γ) (up to global phase) — the ZYZ decomposition, with three real parameters matching the Bloch sphere's two angles plus the invisible phase. In circuit terms: any single-qubit operation is three rotation gates. Real hardware goes further with Euler-angle scheduling: IBM machines natively implement U(θ, φ, λ) in one pulse, and compilers rewrite every gate into that native form. The engineering lesson generalizes beyond one qubit: decomposition is how an abstract circuit becomes a device schedule, and the cost metric is count of native gates, because each native gate carries error ≈ 10⁻³ (Part XI). Chapter 14 repeats this theme with two-qubit synthesis, where the arithmetic is harsher.

10.6Universality

A gate set is universal if arbitrary unitaries can be approximated to any accuracy by products of its members. The classic result: {H, T, CNOT} is universal for all quantum computation; among single-qubit sets, {H, T} suffices because H plus a 45° phase generates a dense group of rotations (the angles produced are irrational multiples of π, so products never close up — they approximate everything). Contrast with the Clifford group {H, S, CNOT}, which is not universal and — deeper — is classically simulable via the Gottesman–Knill theorem (Part X): exactly the boundary that makes T gates precious. Universality is an asymptotic statement; the engineering question is always at what cost, which is where synthesis (14.10) and error budgets take over.

10.7Global phase vs observable phase

One distinction, stated sharply because it causes real bugs. Global phase: |ψ⟩ and e^{iθ}|ψ⟩ are the same physical state; no measurement distinguishes them. In code, this means comparing states requires comparing projectors or checking inner products up to a phase: abs(np.vdot(psi1, psi2)) ≈ 1, never elementwise equality. Relative (observable) phase: the phase between superposed components is physical — |+⟩ and |−⟩ differ measurably in the X basis, and interference in every algorithm depends on it. The rule of thumb: operations that multiply the whole vector by a phase are free and unobservable; operations that multiply one component by a phase (Z, S, T) are gates that do work. Simulation frameworks differ in whether they preserve global phase; do not diff circuits by their raw state vectors.