Lesson 7: Single-Qubit Gates and the Quantum Circuit Model¶
7.1 Learning Outcomes¶
By the end of this hour a student will be able to:
- Write the matrix of every standard single-qubit gate and state its action on the basis states.
- Explain why every quantum gate must be unitary and hence reversible.
- Read and construct quantum circuit diagrams, respecting the left-to-right time convention.
- Compose gates by matrix multiplication in the correct order.
- Apply the \(Z\)–\(Y\) decomposition and state the universality of \(\{H, T\}\) for single qubits.
- Relate each gate to a rotation of the Bloch sphere.
7.2 Why Gates Must Be Unitary¶
By Postulate 2, closed-system evolution is unitary. Three consequences that define the model:
- Reversibility. \(U^{-1} = U^\dagger\) always exists. There is no quantum AND gate that discards information; irreversible classical gates must be embedded in reversible ones (see the Toffoli gate in L08).
- Norm preservation. Probabilities continue to sum to 1 after every gate.
-
Linearity. A gate is defined by its action on a basis, and extends linearly:
\[ U\big(\alpha|0\rangle + \beta|1\rangle\big) = \alpha\,U|0\rangle + \beta\,U|1\rangle . \]
Do not read linearity as "the gate acts on each branch separately and we pick one." The two branches persist and later interfere.
7.3 The Standard Single-Qubit Gates¶
Pauli gates¶
| Gate | Action | Bloch rotation | Nickname |
|---|---|---|---|
| \(X\) | \(\lvert 0\rangle \leftrightarrow \lvert 1\rangle\) | \(\pi\) about \(\hat x\) | bit flip, quantum NOT |
| \(Y\) | \(\lvert 0\rangle \to i\lvert 1\rangle\), \(\lvert 1\rangle \to -i\lvert 0\rangle\) | \(\pi\) about \(\hat y\) | bit + phase flip |
| \(Z\) | \(\lvert 0\rangle \to \lvert 0\rangle\), \(\lvert 1\rangle \to -\lvert 1\rangle\) | \(\pi\) about \(\hat z\) | phase flip |
Note \(Y = iXZ\) and \(X^2 = Y^2 = Z^2 = I\): each Pauli is its own inverse.
Critical point about \(Z\). On \(|0\rangle\) or \(|1\rangle\) alone, \(Z\) does nothing observable (it only adds a global phase). On a superposition it is dramatic:
Phase gates are useless on basis states and essential on superpositions — this is why every algorithm begins with Hadamards.
The Hadamard gate¶
Properties: \(H = H^\dagger = H^{-1}\), so \(H^2 = I\). It is the basis-change gate between \(Z\) and \(X\), and satisfies the crucial conjugation identities
The \(n\)-qubit Hadamard identity (used in every algorithm of Unit II):
and more generally
Proof of the general form. For one qubit, \(H|x\rangle = \frac{1}{\sqrt2}\sum_{y\in\{0,1\}}(-1)^{xy}|y\rangle\) (check \(x=0\) and \(x=1\) separately). Take the tensor product of \(n\) copies and note the phases add in the exponent. \(\blacksquare\)
Phase gates¶
Relations: \(S^2 = Z\), \(T^2 = S\), \(T^4 = Z\), \(T^8 = I\). Bloch action: rotation about \(\hat z\) by \(\pi/2\), \(\pi/4\) and \(\lambda\) respectively.
The \(T\) gate is expensive. In fault-tolerant architectures \(H\), \(S\) and the CNOT (the Clifford gates) are cheap, but \(T\) requires magic-state distillation. Circuit cost in fault-tolerant quantum computing is quoted as \(T\)-count and \(T\)-depth.
Rotation gates¶
\(R_y\) is real, which makes it the natural gate for encoding real-valued data in QML (Unit III).
Universal single-qubit gate (the \(U3\) / \(U\) gate).
Every single-qubit unitary equals \(U(\theta,\phi,\lambda)\) up to a global phase. This is the gate that Qiskit's transpiler targets.
7.4 Decomposition and Universality¶
Theorem (\(Z\)–\(Y\) decomposition). Every single-qubit unitary \(U\) can be written
for real \(\gamma,\alpha,\beta,\delta\).
Sketch. \(U\) is unitary, so its rows are orthonormal; solving the resulting four equations for the three Euler angles plus a phase gives the decomposition, exactly as for \(SO(3)\) Euler angles. \(\blacksquare\)
Theorem (Solovay–Kitaev). The discrete set \(\{H, T\}\) generates a dense subgroup of \(SU(2)\). Any single-qubit unitary can be approximated to accuracy \(\epsilon\) using \(O\!\left(\log^{c}(1/\epsilon)\right)\) gates from \(\{H,T\}\), with \(c \approx 2\) (improvable to \(c\approx 1\)).
Consequence. \(\{H, T, \mathrm{CNOT}\}\) is a universal gate set for quantum computation. You do not need continuously tunable gates.
7.5 The Quantum Circuit Model¶
Reading a circuit¶
q0: ---[H]---*---[X]---[M]---
| |
q1: --------[X]---------|----
v
c : ====================o====
Symbols: [G] = gate G on that wire; * = control of a two-qubit gate;
[X] joined to a * by a vertical bar = the target of a CNOT; [M] = measurement;
==== = a classical wire carrying the measured bit.
Conventions:
- Wires are qubits, not physical wires. A horizontal line is one qubit's world-line.
- Time flows left to right. Gates are applied in reading order.
- A double line is a classical register carrying measurement results.
- The number of wires never changes (no creating or destroying qubits mid-circuit).
- Gates on disjoint qubits in the same column act simultaneously and commute.
The order trap¶
If the circuit is \(|\psi\rangle \to A \to B \to C\), the resulting state is
Matrix order is the reverse of diagram order. This is the single most common examination error.
Circuit depth and width¶
- Width = number of qubits.
- Depth = number of time steps (layers of simultaneously executable gates).
- On NISQ hardware, depth is limited by decoherence: if a gate takes \(t_g\) and coherence time is \(T_2\), the useful depth is roughly \(T_2/t_g\).
Useful gate identities¶
7.6 Solved Problems¶
Problem 1 — Composing a gate sequence¶
A qubit starts in \(|0\rangle\). The circuit applies \(H\), then \(Z\), then \(H\). Find the final state both by tracking states and by multiplying matrices.
Solution.
State-tracking route.
Matrix route. The overall unitary is \(U = H Z H\) (note the reversed order):
So \(U|0\rangle = X|0\rangle = |1\rangle\) ✓.
Result: \(HZH = X\). The circuit is a NOT gate built from a phase flip sandwiched between Hadamards — the standard trick for converting phase information into amplitude information, used in every algorithm of Unit II.
Problem 2 — Effect of T on a superposition¶
Compute \(T|+\rangle\), express it in the Bloch picture, and find \(\Pr[0]\) and \(\Pr[+]\).
Solution.
Bloch angles: \(\theta = \pi/2\) (equator), \(\varphi = \pi/4\). So
Interpretation. \(T\) rotated the state 45° along the equator: \(Z\)-statistics are untouched, but \(X\)-statistics changed from certainty (1.0) to 0.854. Phase gates are invisible to \(Z\) measurement.
Problem 3 — Verifying a decomposition¶
Show that \(H = e^{i\pi/2} R_y(\pi/2) R_z(\pi)\) up to a global phase.
Solution.
Multiply (right-most acts first, so compute \(R_y(\pi/2)\,R_z(\pi)\)):
Therefore \(R_y(\pi/2)R_z(\pi) = -iH\), i.e.
The prefactor \(e^{i\pi/2}\) is a global phase and is unobservable — which is exactly why hardware can implement \(H\) using only \(R_y\) and \(R_z\) pulses.
Problem 4 — Building an arbitrary state¶
Design a circuit that prepares \(|\psi\rangle = \frac{\sqrt3}{2}|0\rangle + \frac{1}{2}e^{i\pi/3}|1\rangle\) from \(|0\rangle\) using \(R_y\) and \(R_z\) (or a phase gate).
Solution. Read the Bloch angles off the target:
Step 1 — set the polar angle with \(R_y(\theta)\) (real rotation, no phase introduced):
Step 2 — set the azimuthal angle with \(P(\varphi)\):
Circuit: \(|0\rangle - [R_y(\pi/3)] - [P(\pi/3)] - |\psi\rangle\).
General recipe. Any single-qubit state is prepared by \(P(\varphi)R_y(\theta)|0\rangle\). This two-gate template is the basis of angle encoding in quantum machine learning (L26).
Problem 5 — Circuit identity and simplification¶
Simplify the circuit \(H - S - H - S - H\) acting on \(|0\rangle\), and identify the resulting gate up to global phase.
Solution. The overall unitary is \(U = H S H S H\) (reverse of diagram order — but note this product is palindromic, so order caution matters less here; we still multiply right to left).
Use \(HSH\) first. With \(S = \begin{pmatrix}1&0\\0&i\end{pmatrix}\):
using \(\frac{1-i}{1+i} = -i\). Recognise the bracket: \(\begin{pmatrix}1&-i\\-i&1\end{pmatrix} = \sqrt2\,R_x(\pi/2)\). So \(HSH = e^{i\pi/4}R_x(\pi/2) = \sqrt{X}\) up to phase.
Now $U = (HSH)\,S\,\underbrace{{}}_{} $ — writing \(U = H S H S H\), group as \((HSH)(SH)\):
So \(U = e^{i\pi/4}\,S^\dagger\) — five gates collapse to one, up to an unobservable phase.
Acting on \(|0\rangle\): \(U|0\rangle = e^{i\pi/4}|0\rangle \simeq |0\rangle\).
Lesson. Circuit optimisation of exactly this kind is what a transpiler does automatically (L38), and it is why gate-count reduction is a first-class engineering concern on NISQ hardware.
7.7 Practice Problems¶
- Compute \(HYH\). [Ans: \(-Y\)]
- What is \(T^\dagger\) as a matrix, and what is \(T\,T^\dagger\)?
- Show \(S = P(\pi/2)\) and \(T = P(\pi/4)\).
- Design a circuit preparing \(\frac{1}{\sqrt2}(|0\rangle + i|1\rangle)\) from \(|0\rangle\) using two gates. [Ans: \(H\) then \(S\)]
- A circuit applies \(X\), then \(H\), then \(Z\) to \(|0\rangle\). Write the final state and the overall matrix. [Ans: state \(\propto|-\rangle\); matrix \(ZHX\)]
- Verify \(R_z(\theta_1)R_z(\theta_2) = R_z(\theta_1+\theta_2)\).
- Prove \(H^{\otimes 2}|01\rangle = \frac12(|00\rangle - |01\rangle + |10\rangle - |11\rangle)\) using the general Hadamard formula.
- Why is \(T\)-count a meaningful cost metric while \(H\)-count is not?
7.8 Summary¶
- Every gate is a unitary matrix, so quantum computation is reversible.
- \(X\) flips bits, \(Z\) flips phase, \(H\) creates superposition and converts phase ↔ amplitude, \(S\) and \(T\) apply partial phases.
- \(H^{\otimes n}|0\rangle^{\otimes n}\) gives the uniform superposition over all \(2^n\) strings; \(H^{\otimes n}|x\rangle = 2^{-n/2}\sum_y(-1)^{x\cdot y}|y\rangle\).
- In circuit diagrams time runs left to right, but matrix products are written right to left.
- \(Z\)–\(Y\) decomposition writes any single-qubit unitary with three rotations; \(\{H,T,\text{CNOT}\}\) is universal (Solovay–Kitaev).
- \(T\) gates dominate fault-tolerant cost; depth is limited by coherence time on NISQ devices.
Next lesson: L08 — Multi-qubit gates, entanglement and the Bell states.
Practise now: unit1-qubit-lab.html → Circuit Builder: drag gates onto a wire, watch the
Bloch vector and state vector update, and read the accumulated unitary matrix.