Shor Nine-Qubit Code

In 1995 quantum computing faced an objection that looked fatal. Classical machines fight noise by copying a bit many times and voting, but the no-cloning theorem forbids copying an unknown quantum state, and every measurement disturbs the thing it reads. If you cannot copy and cannot look, how could you ever protect a qubit? Peter Shor's nine-qubit code is the explicit answer — the first quantum error-correcting code, and a constructive proof that the objection is wrong. It encodes one logical qubit into nine physical qubits so that an arbitrary error on any single physical qubit — not merely a discrete bit flip XX or phase flip ZZ, but any operator on that qubit, including coherent over-rotations and amplitude damping — can be detected and reversed without ever measuring, or disturbing, the logical information. The construction is a two-layer sandwich. The three-qubit bit-flip code beats XX errors by majority vote but is blind to ZZ; its Hadamard-conjugate, the phase-flip code, beats ZZ but is blind to XX. Neither alone is a genuine quantum code. Shor's move was to concatenate them: take the phase-flip code on the outside and re-encode each of its qubits with a bit-flip block on the inside. The nested code inherits both protections at once, and because errors discretize, correcting the Pauli set on each qubit is enough to correct the entire continuum. Two ideas that were each half a code become, when stacked, the whole of one — the gateway to the stabilizer formalism, CSS codes, and the threshold theorem that makes scalable quantum computing possible.

Key takeaways
  • The Shor nine-qubit code is the first quantum error-correcting code: it encodes one logical qubit in nine physical qubits so that an arbitrary error on any single qubit can be detected and corrected.
  • It is built by concatenation — the three-qubit phase-flip code on the outside, each of its qubits re-encoded by a three-qubit bit-flip code — giving a [[9,1,3]][[9,1,3]] stabilizer code.
  • Because errors discretize, correcting the Paulis {X,Z,Y=iXZ}\{X,Z,Y=iXZ\} on each qubit automatically corrects every continuous single-qubit error, amplitude damping and small rotations included.
  • Bit flips are caught by six ZZZZ stabilizers comparing qubits inside each block; phase flips are caught by two weight-six XX stabilizers comparing the relative sign of the blocks.
  • It has distance d=3d=3 and corrects t=1t=1 error; the minimal logical operators are Xˉ≃Z1Z4Z7\bar X\simeq Z_1Z_4Z_7 and Zˉ≃X1X2X3\bar Z\simeq X_1X_2X_3, both weight three.
  • It is a (highly redundant) CSS and degenerate code — the pedagogical ancestor of the leaner five-qubit and Steane seven-qubit codes and of the surface codes running on hardware today.
  • Key idea: concatenate phase-flip protection (the outer code, against ZZ) with bit-flip protection (the inner blocks, against XX); because Y=iXZY=iXZ, correcting independent XX and ZZ errors automatically corrects YY, and by discretization this covers every single-qubit error.

Where this lives today

The Shor code itself is too redundant for a modern processor, but its ideas are the working vocabulary of every quantum error-correction experiment. Its direct descendant, the nine-qubit Bacon–Shor code — a subsystem variant of the same 3×33\times3 layout — was run fault-tolerantly on thirteen trapped-ion qubits by the Maryland group (Egan et al., Nature 598, 281 (2021)), demonstrating an encoded logical qubit whose error rate fell below that of its physical constituents. The concatenation idea Shor introduced, recursively nesting a code inside itself to drive the logical error rate down as a double-exponential in the number of levels, is the engine behind the threshold theorem: below a critical physical error rate, arbitrarily long computations become reliable. Today the field has largely moved from concatenated codes to topological surface codes, which are also CSS and also degenerate but are laid out on a two-dimensional lattice with only local checks — Google's superconducting processors have shown a distance-five and then a distance-seven surface-code logical qubit whose error rate decreases as the code grows (the below-threshold result of Nature 2024), the scaling behaviour Shor's construction first made conceivable. Every one of these systems measures stabilizers exactly as the nine-qubit code taught: joint parities read by ancilla qubits, never touching the logical information, digitizing continuous noise into a discrete Pauli that a lookup table corrects.

The physical picture

Protect a secret two ways at once. The bit-flip code writes the same bit into three qubits so a single flip loses a majority vote in the computational basis; the phase-flip code does the identical thing in the {∣+⟩,∣−⟩}\{|+\rangle,|-\rangle\} basis, where a ZZ error looks like a bit flip. A physical qubit can suffer both kinds of damage, so Shor simply stacks the two protections — three copies of a three-copy code — and gets robustness in both bases simultaneously. The outer layer decides which block carries a phase error; each inner block decides which qubit inside it carries a bit-flip error. The first figure draws that layered architecture: an outer phase-flip code whose three "qubits" are themselves bit-flip blocks.

Figure
The concatenation architecture: one logical qubit is encoded by the outer three-qubit phase-flip code into three blocks, and each block is re-encoded by the inner three-qubit bit-flip code into a GHZ-like triple, giving nine physical qubits arranged in a three by three grid; six ZZ checks act inside the blocks to catch bit flips and two weight-six X checks act between blocks to catch phase flips
Concatenation: outer phase-flip code, inner bit-flip blocks — a [[9,1,3]] code outer: phase-flip code (protects against Z) inner: bit-flip blocks (protect against X) logical qubit block A block B block C ±±± 1 2 3 4 5 6 7 8 9 ZZZZ X on A and B X₁…X₆ X₄…X₉ (B and C) |0⟩_L = (|000⟩+|111⟩)⊗(|000⟩+|111⟩)⊗(|000⟩+|111⟩) / 2√2 six ZZ + two weight-6 X = 8 generators

Why does a finite set of discrete corrections defeat a continuum of possible errors? The answer is linearity plus measurement. An arbitrary error on qubit ii is a complex combination of the four Paulis I,X,Y,ZI,X,Y,Z acting there. When you measure the eight stabilizers you do not read the logical state — you read only relations between qubits — and that measurement projects the corrupted superposition onto one definite Pauli branch, "collapsing" the continuous error into a discrete one. A fixed Pauli recovery, chosen by the syndrome, then restores the codeword exactly; the continuous error parameters are never needed and never learned. The second figure makes this concrete with real syndrome bits: it tabulates the syndromes that specific single-qubit errors produce, and shows how two errors can conspire to a silent logical fault.

Figure
Concrete syndromes for the Shor code: an X on qubit 1 lights the block-A bit-flip checks as 1,0 while leaving the phase checks at 0,0; a Z on qubit 1 leaves the bit checks at 0 and lights the phase checks 1,0; a Y on qubit 5 lights bit checks 1,1 in block B and phase checks 1,1; and two Z errors on qubits 1 and 4 give phase syndrome 0,1 that a decoder mistakes for a block-C flip, so recovering block C completes the weight-three logical operator Z1 Z4 Z7
Syndromes are real bit strings — and two errors can forge a logical fault error bit-flip syndrome (Z-checks) phase syndrome (X-checks) recovery X on q1 (1,0 | 0,0 | 0,0) (1,0) X₁ Z on q1 (0,0 | 0,0 | 0,0) (1,0) Z on A Y on q5 (0,0 | 1,1 | 0,0) (1,1) Y₅ Z on q1 and q4 (two errors) — phase bits add: (1,0) ⊕ (1,1) = (0,1) Decoder reads phase (0,1) as a single block-C flip → applies Z on C (say Z₇) Net operator on the code: Z₁ · Z₄ · Z₇ = X̄ (a weight-3 logical bit flip) Trivial bit-flip syndrome throughout; the logical error is silent — this is why d = 3, t = 1

Read across the third block-tuple of the bit-flip syndrome as "which qubit inside the block," and across the two phase bits as "which block." The last row is the whole point of the distance: two well-placed errors reach a weight-three logical operator, and no code of distance three can see that coming.

The core equations

The logical basis states are the concatenation written out in full: each of the three blocks is a GHZ-like triple ∣000⟩±∣111⟩|000\rangle\pm|111\rangle, and the outer sign encodes the logical bit. Everything else — stabilizers, logical operators, distance — follows from reading these two states.

∣0⟩L=122 (∣000⟩+∣111⟩)⊗(∣000⟩+∣111⟩)⊗(∣000⟩+∣111⟩)(1)|0\rangle_L=\frac{1}{2\sqrt{2}}\,(|000\rangle+|111\rangle)\otimes(|000\rangle+|111\rangle)\otimes(|000\rangle+|111\rangle) \qquad (1)

where: ∣0⟩L|0\rangle_L — the encoded logical zero on nine qubits; ∣000⟩+∣111⟩|000\rangle+|111\rangle — one inner bit-flip block, an unnormalized 2 ∣+⟩\sqrt2\,|+\rangle in the outer phase-flip layer; 1/(22)=2−3/21/(2\sqrt2)=2^{-3/2} — normalization, since each block has norm 2\sqrt2 and there are three of them, (2)3=22(\sqrt2)^3=2\sqrt2. Read it as three GHZ triples glued with plus signs. The logical one flips every outer sign to minus. That single sign flip, applied to all three blocks at once, is exactly the logical XX operation of the code, as we verify below.

∣1⟩L=122 (∣000⟩−∣111⟩)⊗(∣000⟩−∣111⟩)⊗(∣000⟩−∣111⟩)(2)|1\rangle_L=\frac{1}{2\sqrt{2}}\,(|000\rangle-|111\rangle)\otimes(|000\rangle-|111\rangle)\otimes(|000\rangle-|111\rangle) \qquad (2)

where: ∣000⟩−∣111⟩|000\rangle-|111\rangle — the "minus" block, encoding the outer logical ∣−⟩|-\rangle of the phase-flip code. Note ⟨0∣1⟩L=0\langle 0|1\rangle_L=0: the blocks are orthogonal because ⟨000∣111⟩=0\langle 000|111\rangle=0, so the two logical states are perfectly distinguishable in principle yet inaccessible to any single-qubit measurement. The codespace is the simultaneous +1+1 eigenspace of eight independent, mutually commuting stabilizer generators: six two-body ZZZZ operators comparing qubits inside each block, and two six-body XX operators comparing the relative sign between blocks. This clean split into ZZ-type and XX-type checks is the defining CSS structure.

S=⟨ Z1Z2, Z2Z3,  Z4Z5, Z5Z6,  Z7Z8, Z8Z9,  X1X2X3X4X5X6,  X4X5X6X7X8X9 ⟩(3)\mathcal{S}=\langle\, Z_1Z_2,\,Z_2Z_3,\;Z_4Z_5,\,Z_5Z_6,\;Z_7Z_8,\,Z_8Z_9,\;X_1X_2X_3X_4X_5X_6,\;X_4X_5X_6X_7X_8X_9\,\rangle \qquad (3)

where: ZiZjZ_iZ_j — compares two qubits within a block, detecting bit flips (XX errors); X1⋯X6X_1\cdots X_6 and X4⋯X9X_4\cdots X_9 — compare adjacent blocks, detecting phase flips (ZZ errors); ⟨⋅⟩\langle\cdot\rangle — the abelian group generated by these eight Paulis. Any XX-type generator overlaps any ZZ-type generator on an even number of qubits, so all eight commute and can be measured together; eight independent generators on nine qubits leave 9−8=19-8=1 logical qubit. The logical operators live in the normalizer N(S)N(\mathcal S) but outside S\mathcal S. Strikingly, logical XX is built from ZZ's and logical ZZ from XX's — the fingerprint of the concatenation, in which "flip the outer sign" (Xˉ\bar X) is a ZZ-type operation and "read the outer sign" (Zˉ\bar Z) is an XX-type one.

Xˉ=Z1Z2⋯Z9≃Z1Z4Z7,Zˉ=X1X2⋯X9≃X1X2X3(4)\bar X = Z_1Z_2\cdots Z_9 \simeq Z_1Z_4Z_7,\qquad \bar Z = X_1X_2\cdots X_9 \simeq X_1X_2X_3 \qquad (4)

where: Xˉ\bar X — logical Pauli-XX, swapping ∣0⟩L↔∣1⟩L|0\rangle_L\leftrightarrow|1\rangle_L; the canonical form Z⊗9Z^{\otimes 9} reduces modulo stabilizers to the weight-three Z1Z4Z7Z_1Z_4Z_7 (one ZZ per block); Zˉ\bar Z — logical Pauli-ZZ, applying a relative phase; X⊗9X^{\otimes 9} reduces to the weight-three X1X2X3X_1X_2X_3 (XX on one full block). The symbol ≃\simeq means "equal up to a stabilizer," which does not change the action on the codespace. They anticommute, XˉZˉ=−ZˉXˉ\bar X\bar Z=-\bar Z\bar X, as a logical Pauli pair must. Counting these weights gives the code's headline parameters. The distance is the minimum weight over all nontrivial logical operators, and here that minimum is three, so the code corrects one arbitrary single-qubit error.

[[n,k,d]]=[[9,1,3]],t=⌊d−12⌋=⌊22⌋=1(5)[[n,k,d]]=[[9,1,3]],\qquad t=\left\lfloor\frac{d-1}{2}\right\rfloor=\left\lfloor\frac{2}{2}\right\rfloor=1 \qquad (5)

where: n=9n=9 — physical qubits; k=1k=1 — logical qubits (=n=n minus the eight generators); d=3d=3 — code distance, the lightest logical operator's weight; t=1t=1 — arbitrary single-qubit errors correctable. The five-qubit perfect code achieves the same t=1t=1 with [[5,1,3]][[5,1,3]], so the Shor code is deliberately redundant — its transparency, not its efficiency, is the point. Finally, the abstract criterion that certifies all of this is the Knill–Laflamme condition. It is the exact, if-and-only-if statement of when a set of errors is correctable, and the Shor code satisfies it for every weight-≤1\le 1 Pauli.

⟨iˉ∣ Ea†Eb ∣jˉ⟩=Cab δij(6)\langle \bar i|\,E_a^\dagger E_b\,|\bar j\rangle = C_{ab}\,\delta_{ij} \qquad (6)

where: ∣iˉ⟩,∣jˉ⟩|\bar i\rangle,|\bar j\rangle — the logical basis states ∣0⟩L,∣1⟩L|0\rangle_L,|1\rangle_L; Ea,EbE_a,E_b — correctable errors, here all Paulis of weight ≤1\le 1; CabC_{ab} — a Hermitian matrix independent of the logical labels i,ji,j; δij\delta_{ij} — Kronecker delta. The δij\delta_{ij} says different errors never leak information distinguishing ∣0⟩L|0\rangle_L from ∣1⟩L|1\rangle_L; the i,ji,j-independence of CabC_{ab} says the errors deform both logical states identically. Degeneracy shows up as a singular CabC_{ab} — several errors sharing a syndrome — which the Shor code has and which does no harm.

Derivation ABuilding the nine-qubit code by concatenating two three-qubit codes

The goal is to construct the Shor code from the ground up as an outer phase-flip code whose three qubits are each replaced by an inner bit-flip block, and to show that this nesting produces a genuine quantum code — one that corrects both XX and ZZ on any single qubit — where each three-qubit layer alone corrects only one error type and is not a quantum code at all. We build the encoding map layer by layer and read off why the eight stabilizers take the form they do.

Step 1. Start with the outer three-qubit phase-flip code, which encodes ∣0⟩L↦∣+++⟩|0\rangle_L\mapsto|{+}{+}{+}\rangle and ∣1⟩L↦∣−−−⟩|1\rangle_L\mapsto|{-}{-}{-}\rangle and is stabilized by XAXBX_AX_B and XBXCX_BX_C on its three qubits A,B,CA,B,C. Why: the phase-flip code is the Hadamard transform of the bit-flip code, so it corrects a single ZZ (which is a bit flip in the ±\pm basis) but is completely blind to XX — it is only half a code.

Step 2. Replace each outer qubit by an inner three-qubit bit-flip block through ∣+⟩↦12(∣000⟩+∣111⟩)|+\rangle\mapsto\frac{1}{\sqrt2}(|000\rangle+|111\rangle) and ∣−⟩↦12(∣000⟩−∣111⟩)|-\rangle\mapsto\frac{1}{\sqrt2}(|000\rangle-|111\rangle). Substituting into Step 1 gives exactly equations (1) and (2). Why: the inner code corrects a single XX inside each block by majority vote, patching the outer code's blind spot without disturbing its phase protection.

Step 3. Lift the stabilizers. Each inner block contributes its two bit-flip checks Z1Z2,Z2Z3Z_1Z_2,Z_2Z_3 (and the analogues on blocks B, C), giving six ZZ-type generators. Why: a bit flip inside a block changes the parity of neighbouring qubits, which is precisely what the two ZZZZ operators per block read out — three qubits, two independent parities, exactly enough to locate one flip.

Step 4. Lift the outer XX checks. The outer XAX_A acting on a ±\pm qubit becomes X1X2X3X_1X_2X_3 on its block (it flips ∣000⟩±∣111⟩|000\rangle\pm|111\rangle into itself up to the sign it is testing), so XAXB↦X1⋯X6X_AX_B\mapsto X_1\cdots X_6 and XBXC↦X4⋯X9X_BX_C\mapsto X_4\cdots X_9. Why: comparing the relative sign of two blocks requires flipping all six of their qubits at once, which is why the phase checks are weight-six rather than weight-two.

Step 5. Collect: six ZZZZ plus two weight-six XX generators, all commuting, eight independent operators stabilizing a two-dimensional space. A single XX error is caught by the inner ZZZZ checks of its block; a single ZZ error is caught by the outer XX checks; a single Y=iXZY=iXZ trips both. Why: because the two error types are read by disjoint check types, the two layers of protection do not interfere, and the concatenated code corrects what neither layer could alone. *Note: each of the nine single-qubit Paulis Xi,Zi,YiX_i,Z_i,Y_i yields a nonzero syndrome on the eight generators — confirming that every single-qubit error is detectable and that the encoding reproduces equations (1)–(3).*

Go deeper · Derivation B · 2 minCorrecting an arbitrary single-qubit error by discretization
Derivation BCorrecting an arbitrary single-qubit error by discretization

The goal is to prove the property that makes the Shor code a true quantum code and not merely a corrector of discrete flips: the ability to reverse the three Paulis X,Y,ZX,Y,Z on each qubit implies the ability to reverse any single-qubit operation on that qubit, including non-unitary noise such as amplitude damping and coherent over-rotations, even though those errors form a continuum. We take a general error, apply it to a codeword, and trace it through the syndrome measurement to see the continuum collapse to a discrete choice.

Step 1. Expand the error. Any linear operator on qubit ii is a combination of the four Paulis, E=eII+eXXi+eYYi+eZZiE=e_I I + e_X X_i + e_Y Y_i + e_Z Z_i, because {I,X,Y,Z}\{I,X,Y,Z\} spans the space of 2×22\times2 matrices. Why: this is the algebraic heart of the argument — a continuous, possibly non-unitary error lives in a four-dimensional space with a discrete Pauli basis.

Step 2. Apply it to a codeword. Linearity gives E∣ψ⟩=eI∣ψ⟩+eXXi∣ψ⟩+eYYi∣ψ⟩+eZZi∣ψ⟩E|\psi\rangle = e_I|\psi\rangle + e_X X_i|\psi\rangle + e_Y Y_i|\psi\rangle + e_Z Z_i|\psi\rangle, a superposition of four branches, one per Pauli. Why: the corrupted state is not "a little bit wrong" in some fuzzy way — it is a coherent sum of four cleanly-labelled error branches.

Step 3. Measure the eight stabilizers. On qubit ii the operators Ii,Xi,Yi,ZiI_i,X_i,Y_i,Z_i carry distinct syndromes (up to the harmless block degeneracy), so the measurement projects the superposition onto a single branch with probability ∣eP∣2|e_P|^2, yielding a definite Pauli error Pi∣ψ⟩P_i|\psi\rangle and its syndrome. Why: stabilizer measurement is a projective measurement in the "error basis," and it collapses the continuous coefficients into one discrete outcome — you learn which Pauli, never the amplitudes.

Step 4. Recover. Knowing the syndrome fixes the Pauli PP; applying Pi†P_i^\dagger gives Pi†(Pi∣ψ⟩)=∣ψ⟩P_i^\dagger(P_i|\psi\rangle)=|\psi\rangle, the exact codeword. Why: Paulis are self-inverse up to phase, so the recovery is a single fixed gate, and the state is restored perfectly with no residual dependence on ePe_P.

Step 5. Conclude for channels. Writing a general noise channel as E(ρ)=∑kEkρEk†\mathcal E(\rho)=\sum_k E_k\rho E_k^\dagger with each EkE_k supported on one qubit, every Kraus branch is corrected by the argument above, so E\mathcal E restricted to single-qubit support is corrected exactly. Why: correctness for each Pauli, plus linearity, upgrades automatically to correctness for arbitrary — including dissipative — single-qubit noise.

E∣ψ⟩=∑P∈{I,X,Y,Z}eP Pi∣ψ⟩  →measure S  Pi∣ψ⟩  →  Pi†    ∣ψ⟩E|\psi\rangle=\sum_{P\in\{I,X,Y,Z\}} e_P\,P_i|\psi\rangle \;\xrightarrow{\text{measure } \mathcal S}\; P_i|\psi\rangle \;\xrightarrow{\;P_i^\dagger\;}\;|\psi\rangle

The substance of this argument is the orthogonality of single-qubit Pauli syndromes, which can be confirmed by commuting each of Xi,Yi,ZiX_i,Y_i,Z_i against the eight generators.

Go deeper · Derivation C · 2 minThe distance is exactly three
Derivation CThe distance is exactly three

The goal is to prove that the minimum weight of a nontrivial logical operator is three, which fixes d=3d=3 and hence t=1t=1, and to exhibit the lightest logical operators explicitly — correcting a common error that mislabels Z1Z2Z3Z_1Z_2Z_3 as a logical operator when it is in fact a detectable error. A logical operator must commute with all eight stabilizers (so it is undetectable) yet lie outside S\mathcal S (so it acts nontrivially on the codespace); we hunt for the lightest such Pauli.

Step 1. No weight-one logical exists. Every single-qubit Pauli is detected: XiX_i or YiY_i anticommutes with a ZZZZ check of its block, and ZiZ_i anticommutes with a weight-six XX check (a single ZZ overlaps X1⋯X6X_1\cdots X_6 on one qubit, an odd count). So d>1d>1. Why: with a nonzero syndrome, a weight-one error is caught and corrected, so it can never be a silent logical operation.

Step 2. No weight-two logical exists. A representative trap is Z1Z2Z3Z_1Z_2Z_3 — it is not weight two, but it illustrates the check: Z1Z2Z3Z_1Z_2Z_3 overlaps X1⋯X6X_1\cdots X_6 on three qubits, an odd count, so it anticommutes and is detected, not logical. Genuine weight-two Paulis are likewise caught: for instance Z1Z4Z_1Z_4 overlaps X4⋯X9X_4\cdots X_9 on the single qubit 4 and so anticommutes with it. Every weight-two Pauli triggers some generator. So d>2d>2. Why: distance is about undetectable operators, and an odd overlap with any generator means detection — light Paulis cannot hide.

Step 3. A weight-three logical exists — logical ZZ. Take Zˉ≃X1X2X3\bar Z\simeq X_1X_2X_3: it commutes with every ZZZZ check (overlapping Z1Z2Z_1Z_2 on qubits 1,2 and Z2Z3Z_2Z_3 on qubits 2,3, each an even count) and with both XX checks trivially, yet equals X⊗9X^{\otimes 9} modulo the stabilizer X4⋯X9X_4\cdots X_9, so it is a nontrivial logical of weight three. Why: flipping one whole block's phase reference is undetectable because it respects every parity check, but it is exactly the logical ZZ action on the outer code.

Step 4. A weight-three logical exists — logical XX. Take Xˉ≃Z1Z4Z7\bar X\simeq Z_1Z_4Z_7, one ZZ per block: it overlaps each weight-six XX check on exactly two qubits (even, hence commuting) and commutes with all ZZ checks, yet equals Z⊗9Z^{\otimes 9} modulo three ZZZZ stabilizers. Why: this is the two-error failure mode made honest — two of its three ZZ's are the uncorrectable pair Z1,Z4Z_1,Z_4, and the third completes the silent logical bit flip.

Step 5. Conclude. Both nontrivial logicals reach minimum weight three and none is lighter, so d=3d=3 and t=⌊(3−1)/2⌋=1t=\lfloor(3-1)/2\rfloor=1: exactly one arbitrary single-qubit error is guaranteed correctable. Why: distance three is the smallest distance that corrects a full error, and it is the price of the Shor code's simplicity.

d=min⁡L∈N(S)∖Swt⁡(L)=wt⁡(X1X2X3)=wt⁡(Z1Z4Z7)=3d=\min_{L\in N(\mathcal S)\setminus\mathcal S}\operatorname{wt}(L)=\operatorname{wt}(X_1X_2X_3)=\operatorname{wt}(Z_1Z_4Z_7)=3

One can confirm d=3d=3 by enumerating all weight-≤2\le2 Paulis on nine qubits against the eight generators — every one has a nonzero syndrome — and then exhibiting the weight-three normalizer elements X1X2X3X_1X_2X_3 and Z1Z4Z7Z_1Z_4Z_7. Note that Z1Z2Z3Z_1Z_2Z_3 is detected, not logical.

Limiting cases

Pushing the code into special regimes sharpens exactly what "single-error correction" buys and what it does not.

CaseResultMeaning
Single Pauli errorE∈{Xi,Yi,Zi}, i=1,…,9E\in\{X_i,Y_i,Z_i\},\ i=1,\dots,9Perfectly corrected: each yields a definite (or harmlessly degenerate) syndrome and a unique recovery Pauli.
Arbitrary single-qubit errorEi=αI+βXi+γYi+δZiE_i=\alpha I+\beta X_i+\gamma Y_i+\delta Z_iCorrected by discretization: the syndrome projects onto one Pauli branch and recovery is exact, independent of α,β,γ,δ\alpha,\beta,\gamma,\delta.
Two phase errors, different blocksZ1Z4⇒Z_1Z_4\Rightarrow phase syndrome (0,1)(0,1)Uncorrectable: mis-decoded as a block-C flip, recovery Z7Z_7 completes Z1Z4Z7=XˉZ_1Z_4Z_7=\bar X — a silent logical bit flip, since d=3d=3.
Phase-flip degeneracyZ1,Z2,Z3Z_1,Z_2,Z_3: same syndrome, same actionThe three intra-block ZZ's share syndrome (1,0)(1,0) and act identically on the codespace; the code is degenerate and the ambiguity is harmless.
Correlated two-qubit error inside a blockX1X2X_1X_2Detected but miscorrected: syndrome matches X3X_3, recovery gives X1X2X3=ZˉX_1X_2X_3=\bar Z — beyond the t=1t=1 guarantee.

Worked examples

1 · Correcting a Y error on qubit 5 (fully worked)

A phase-and-bit error Y5=iX5Z5Y_5=iX_5Z_5 strikes the middle qubit of the middle block. Compute the six-bit bit-flip syndrome and the two-bit phase syndrome, and state the recovery.

Step 1. Split the error. Y5=iX5Z5Y_5=iX_5Z_5 is simultaneously a bit flip and a phase flip on qubit 5, so it will trip both the ZZ-type and the XX-type checks. Handle the two parts separately. Y₅ = i·X₅·Z₅.

Step 2. Bit-flip syndrome from the X5X_5 part. Qubit 5 sits in block B, whose checks are Z4Z5Z_4Z_5 and Z5Z6Z_5Z_6. X5X_5 anticommutes with both (it overlaps each on qubit 5, an odd count), and commutes with all checks in blocks A and C. The six-bit syndrome (Z1Z2,Z2Z3∣Z4Z5,Z5Z6∣Z7Z8,Z8Z9)(Z_1Z_2,Z_2Z_3\mid Z_4Z_5,Z_5Z_6\mid Z_7Z_8,Z_8Z_9) is therefore (0,0∣1,1∣0,0)(0,0\mid 1,1\mid 0,0). Bit syndrome = (0,0 | 1,1 | 0,0), pinpointing qubit 5.

Step 3. Phase syndrome from the Z5Z_5 part. Z5Z_5 overlaps X1⋯X6X_1\cdots X_6 on qubit 5 (odd, anticommute) and X4⋯X9X_4\cdots X_9 on qubit 5 (odd, anticommute), so the two-bit phase syndrome (X1 ⁣⋯ ⁣X6, X4 ⁣⋯ ⁣X9)(X_1\!\cdots\!X_6,\,X_4\!\cdots\!X_9) is (1,1)(1,1) — the signature of a phase flip on block B. Phase syndrome = (1,1), pinpointing block B.

Step 4. Recover. The bit syndrome (1,1)(1,1) within block B uniquely identifies qubit 5, so apply X5X_5. The phase syndrome (1,1)(1,1) identifies block B, so apply a single ZZ to that block; by degeneracy Z4,Z5,Z6Z_4,Z_5,Z_6 all act identically, so choose Z5Z_5. The combined recovery X5Z5X_5Z_5 inverts Y5Y_5 up to an irrelevant global phase, restoring the codeword exactly. Recovery = X₅ then Z₅ (any block-B qubit) ≡ Y₅⁻¹ — state restored.

2 · How two errors forge a logical fault

Errors Z1Z_1 and Z4Z_4 occur together. Show that the code fails, and identify the resulting logical operation.

Step 1. Bit-flip syndrome. Both are pure ZZ errors, which commute with every ZZZZ check, so the entire six-bit bit-flip syndrome is (0,0∣0,0∣0,0)(0,0\mid 0,0\mid 0,0) — no bit-flip alarm at all. Bit syndrome = all zeros.

Step 2. Phase syndrome of each error alone. Z1Z_1 (block A) gives (1,0)(1,0); Z4Z_4 (block B) gives (1,1)(1,1). Since Pauli syndromes add mod 2, the combined phase syndrome is (1,0)⊕(1,1)=(0,1)(1,0)\oplus(1,1)=(0,1). Combined phase syndrome = (0,1).

Step 3. Decoder's mistake. A phase syndrome of (0,1)(0,1) is exactly what a single phase flip on block C produces, so a minimum-weight decoder concludes "block C flipped" and applies a ZZ to block C — say Z7Z_7. It cannot know two errors occurred; (0,1)(0,1) has weight-one and weight-two explanations, and it picks the lighter one. Decoder applies Z₇.

Step 4. The net effect. The true errors times the recovery give Z1⋅Z4⋅Z7=Z1Z4Z7=XˉZ_1\cdot Z_4\cdot Z_7=Z_1Z_4Z_7=\bar X, a weight-three logical operator. The syndrome is now clean, the decoder believes it succeeded, and the logical qubit has been silently bit-flipped. Net operation = Z₁Z₄Z₇ = X̄ — an undetected logical error, the hallmark of exceeding t = 1.

Physics of the portrait

The Shor code is where a young theorist turned a philosophical worry — that quantum information might be intrinsically unprotectable — into a concrete construction, one year after inventing the factoring algorithm that made protection urgent.

Origins · 1 minPeter Shor and how this was discovered
PS
Peter Shor
born 1959, American mathematician · quantum algorithms and quantum error correction

Peter Williston Shor (born 14 August 1959) was a researcher at AT&T Bell Laboratories when, in 1994, he found the polynomial-time quantum algorithm for factoring integers that made large-scale quantum computing suddenly worth building — and made its fragility suddenly worth solving. Many believed the fragility was fatal: quantum states cannot be cloned, so the classical trick of redundant copies is unavailable, and any measurement to check for errors would collapse the very superposition being protected. In a 1995 paper, "Scheme for reducing decoherence in quantum computer memory" (Phys. Rev. A 52, R2493), Shor dissolved both objections at once. He showed that one can measure stabilizers — joint parities that reveal errors without revealing, or disturbing, the logical state — and that concatenating a phase-flip code with a bit-flip code yields a nine-qubit code correcting an arbitrary single-qubit error. Andrew Steane found a related seven-qubit code independently soon after, and within two years Calderbank, Shor, and Steane had the CSS family, Knill and Laflamme had the general correctability conditions, and Gottesman had the stabilizer formalism that revealed all these codes as one construction. Shor, later the Morss Professor of Applied Mathematics at MIT, received the Nevanlinna Prize, the Gödel Prize, and a MacArthur Fellowship; the nine-qubit code remains the canonical first example through which every student meets quantum error correction.

History
1995
— Shor publishes the nine-qubit code, the first quantum error-correcting code
1996
— Steane's seven-qubit CSS code and the five-qubit perfect code appear
1996
— Calderbank, Shor and Steane introduce the CSS code family
1997
— Knill and Laflamme give the general conditions for a correctable code
1997
— Gottesman's stabilizer formalism unifies these codes as one construction
2021
— the nine-qubit Bacon-Shor code is run fault-tolerantly on trapped ions

Going further

Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, §10.2 (Shor code) and §10.3 (discretization) · Preskill, Lecture Notes for Physics 219, Ch. 7 · Watrous, The Theory of Quantum Information, Ch. on error correction · Wilde, Quantum Information Theory, Ch. 24 · Kitaev, Shen and Vyalyi, Classical and Quantum Computation, §15 · Gottesman, Stabilizer Codes and Quantum Error Correction (PhD thesis, 1997). The eight generators mutually commute — every XX-type overlaps every ZZ-type on an even number of qubits — and are independent, giving k=9−8=1k=9-8=1. The canonical logicals Xˉ=Z⊗9\bar X=Z^{\otimes9} and Zˉ=X⊗9\bar Z=X^{\otimes9} commute with all stabilizers and anticommute with each other ((−1)9=−1(-1)^9=-1), reducing to the weight-three representatives Z1Z4Z7Z_1Z_4Z_7 and X1X2X3X_1X_2X_3. Distance d=3d=3 follows by exhausting all weight-≤2\le2 Paulis against the generators (each has nonzero syndrome) and exhibiting those weight-three normalizer elements — noting that Z1Z2Z3Z_1Z_2Z_3 is detected, not logical. The worked syndromes are Y5→Y_5\to bit (0,0∣1,1∣0,0)(0,0\mid1,1\mid0,0) and phase (1,1)(1,1), and Z1Z4→Z_1Z_4\to phase (0,1)(0,1) mis-decoded to Z1Z4Z7=XˉZ_1Z_4Z_7=\bar X. The Bacon–Shor trapped-ion result is Egan et al., Nature 598, 281 (2021).

Builds on: Three-Qubit Bit-Flip Code · Three-Qubit Phase-Flip Code · Discretization of Errors · Quantum Error Model and Decoherence Channels · Pauli Group and Clifford Group. Leads to: Stabilizer Formalism · CSS Codes · Steane Seven-Qubit Code · Knill–Laflamme Conditions · Syndrome Measurement and Decoding.

Ask the tutor: name any single-qubit Pauli on qubits 1 through 9 and I will compute its full six-bit and two-bit syndrome, give the recovery, and then show you a two-error pair that slips past the code as a logical fault.

Why does the Shor code need nine qubits when the five-qubit code corrects the same errors?

Because it trades efficiency for transparency. The five-qubit code is the perfect [[5,1,3]][[5,1,3]] code, saturating the quantum Hamming bound: with t=1t=1 it uses the fewest qubits any distance-three code possibly can. The Shor code uses nine because it is built by literally nesting two three-qubit codes, 3×3=93\times3=9, and that concatenated structure makes everything visible — the ZZ-checks are the inner bit-flip votes, the XX-checks are the outer phase-flip votes, and logical XX and ZZ read off the blocks by eye. The five-qubit code is more compact but its stabilizers mix XX and ZZ on the same qubits and carry no such intuitive story. For learning, and historically, transparency won.

How can you detect an error without measuring — and collapsing — the qubit?

You never measure the qubits; you measure relations between them. Each stabilizer, like Z1Z2Z_1Z_2, asks "do qubits 1 and 2 agree?" without asking what either value is. Its eigenvalue is +1+1 on the whole codespace, so measuring it on an uncorrupted codeword returns +1+1 and leaves the state untouched; an error that flips the agreement returns −1-1 and reveals that something went wrong without revealing the logical bit. This is the central trick of the entire field: the syndrome lives in the parities, which are unentangled with the logical information, so extracting it disturbs nothing you care about. The logical qubit's superposition survives intact through every round of checking.

What does it mean that the Shor code is degenerate?

Degenerate means distinct errors can share a syndrome and act identically on the codespace, so the decoder need not — and cannot — tell them apart. In the Shor code, a ZZ on qubit 1, 2, or 3 all produce the same phase syndrome (1,0)(1,0) and all impose the same phase on block A, because they differ only by the stabilizers Z1Z2,Z2Z3Z_1Z_2,Z_2Z_3, which act trivially on codewords. The decoder applies one recovery, say Z1Z_1, and it correctly undoes whichever of the three actually happened. Far from a defect, degeneracy is a feature: it lets a code with relatively few stabilizers cover many physical errors, and it is one reason surface codes tolerate such high error rates.

Is the Shor code a CSS code, and why does that matter?

Yes. A CSS (Calderbank–Shor–Steane) code is one whose stabilizers split into a purely XX-type set and a purely ZZ-type set, with no generator mixing the two — and the Shor code's six ZZZZ checks and two weight-six XX checks do exactly that. This split matters because it decouples the two error types: XX errors are handled entirely by the ZZ-checks and ZZ errors entirely by the XX-checks, so the code is built from two independent classical linear codes, one for each basis. That structure makes CSS codes easy to construct, easy to analyze, and friendly to fault-tolerant gates; the Steane and surface codes are CSS too. The Shor code is the first and most redundant member of the family.

Why is logical X made of Z operators and logical Z made of X operators?

It looks backwards but it is the signature of the concatenation. The outer code is a phase-flip code, whose computational basis is {∣+⟩,∣−⟩}\{|+\rangle,|-\rangle\}. In that basis, the logical bit-flip Xˉ\bar X — the operation swapping ∣0⟩L↔∣1⟩L|0\rangle_L\leftrightarrow|1\rangle_L, i.e. ∣+++⟩↔∣−−−⟩|{+}{+}{+}\rangle\leftrightarrow|{-}{-}{-}\rangle — is applied by ZZ operators, since ZZ swaps ∣+⟩↔∣−⟩|+\rangle\leftrightarrow|-\rangle. Conversely the logical phase Zˉ\bar Z, which distinguishes the two outer states, is read by XX operators. Concretely Xˉ≃Z1Z4Z7\bar X\simeq Z_1Z_4Z_7 places one ZZ in each block, and Zˉ≃X1X2X3\bar Z\simeq X_1X_2X_3 flips one whole block. The apparent role-reversal is just the Hadamard-transformed logic of the outer phase-flip layer showing through.

Does the Shor code protect a qubit indefinitely, or only for one round?

Only for one round of noise between corrections, and only against a single-qubit error within that round. To protect for a long time you repeat the cycle — apply noise, measure the eight stabilizers, decode, recover — many times, and the code keeps the logical error rate low provided at most one physical error accumulates per cycle. If the physical error rate per qubit per cycle is pp, the logical error rate scales like p2p^2 (two errors needed to cause a logical fault), a suppression only if pp is small. Fault tolerance then demands that the syndrome extraction itself be built from gadgets that do not spread one error into many; concatenating the code with itself and staying below the threshold is what turns single-round protection into indefinite protection.

Before this

Where this leads