33. Simple Quantum Codes
33.1Three-qubit bit-flip code
The code from 32.4 gets a name: |0_L⟩ = |000⟩, |1_L⟩ = |111⟩, with stabilizer generators Z0 Z1 and Z1 Z2. It corrects any single X (bit-flip) error. With independent flips at rate p and perfect syndrome extraction, the logical error rate is p_L = 3p^2 - 2p^3 — the same majority-vote formula as 32.1, because the syndrome table plus conditional correction is majority vote. The limitation is equally clear: the stabilizers contain only Z, so Z errors commute with everything and are invisible, and a triple flip looks like no error at all while being a logical flip. This code protects against one error class; real hardware flips bits and phases.
33.2Three-qubit phase-flip code
Phase errors (Z flips) are just as physical as bit flips: Z|+⟩ = |−⟩, so a phase flip corrupts superpositions in the Hadamard basis. The fix is the same code with every operator conjugated by H: encode in the |±⟩ basis as α|+++⟩ + β|−−−⟩, with stabilizers X0 X1 and X1 X2. The syndrome table is identical, with X and Z exchanged and the basis states relabeled. This is the first instance of a pattern that recurs throughout coding theory: applying a basis change to every qubit maps one code to a dual code protecting the complementary error class. Still nothing protects against X and Z simultaneously — that takes more structure.
33.3Shor code
Shor's 1995 code was the first to correct an arbitrary single-qubit error. The construction is concatenation: an outer 3-qubit phase-flip code whose three "qubits" are each a 3-qubit bit-flip code — 9 physical qubits, one logical. The stabilizer has 8 generators:
Z0 Z1Z1 Z2Z3 Z4Z4 Z5Z6 Z7Z7 Z8X0 X1 X2 X3 X4 X5X3 X4 X5 X6 X7 X8
The within-block Z-parities catch bit flips; the two six-qubit X operators compare the signs of the three blocks and catch phase flips. Since any single-qubit error is a linear combination of I, X, Z (and Y = iXZ), and correction is linear, correcting X and Z errors corrects everything: this is the standard argument that discrete syndromes suffice for continuous error space (34.1).
33.4Steane code
The Steane code, [[7,1,3]], gets the same protection with fewer qubits via the CSS construction: take a classical code closed under transposition — the [7,4,3] Hamming code — and use its parity-check matrix rows as both X-type and Z-type stabilizers:
X0 X1 X2 X4X0 X1 X3 X5X0 X2 X3 X6Z0 Z1 Z2 Z4Z0 Z1 Z3 Z5Z0 Z2 Z3 Z6
|0_L⟩ is the uniform superposition of the 8 even-weight Hamming codewords; |1_L⟩ covers the odd-weight ones. Bit and phase errors are handled by separate, independent classical decoders — CSS codes split the problem cleanly. Historically, Steane's code mattered because its full Clifford gate set (H, S, CNOT) is transversal (33.6), making it the first practical substrate for fault-tolerant logic.
33.5Logical qubits
Everything above defines a logical qubit (logical qubit): a two-dimensional subspace, the codespace, spanned by |0_L⟩ and |1_L⟩, maintained by ongoing measurement and correction. The general notation is [[n, k, d]]: n physical qubits, k logical qubits, distance d (35.10). The bit-flip code is [[3,1,3]], Shor is [[9,1,3]], Steane is [[7,1,3]]. Two properties matter in practice. The logical qubit is not a "stronger physical qubit" — it is an actively maintained subspace whose quality is defined operationally by measured logical error rates (35.11). And codes are typically degenerate: different physical errors can act identically on the codespace, so more physical events are correctable than there are distinct syndromes.
33.6Logical gates
Computing on encoded data means applying unitaries that map the codespace to itself. For the bit-flip code, the logical Paulis are products: logical X̄ = X0 X1 X2 swaps |000⟩ and |111⟩; logical Z̄ = Z0 Z1 Z2 phases |111⟩ by −1. Either can be multiplied by stabilizers to give equivalent implementations — a freedom called gauge. The engineering question is which gates run without decoding. A transversal gate (transversal gate) applies a single-qubit gate to each physical qubit in the block, so a physical fault cannot spread between qubits — fault tolerance comes free. Steane's code implements the entire Clifford group transversally; but no code has a universal transversal set (Eastin–Knill theorem), which is why 36.6 exists.