Five-Qubit Perfect Code
The five-qubit perfect code is what optimality looks like in quantum error correction: the smallest possible code that undoes an arbitrary single-qubit error. To diagnose an error on one of qubits you must tell apart the identity and the three Paulis , , on each qubit — possibilities for a code carrying one logical qubit. Four parity checks supply distinct syndromes, and is exactly : every address in the book is filled, once, with no collisions and no spares. That is the literal meaning of perfect — the quantum Hamming bound is saturated, and the code is non-degenerate. Concretely it is a stabilizer code, the joint eigenspace of four commuting Pauli operators with a beautiful cyclic form, rotated one step at a time. Its logical operators and have weight five, yet lighter weight-three representatives exist, pinning the distance at and the correctable weight at . Because and are braided inside every generator, the code is not CSS — it cannot be split into a bit-flip code and a phase-flip code, sharply separating it from the Shor and Steane families. And in a final twist its codewords are absolutely maximally entangled — every two-qubit marginal completely mixed — making it a perfect tensor that reappears far from its origins, in holographic toy models of spacetime.
- The five-qubit perfect code, written , encodes one logical qubit into five and corrects an arbitrary single-qubit error — the smallest quantum code with distance .
- It is a non-CSS stabilizer code with cyclic generators ; its syndromes are in exact bijection with the weight- error classes.
- Saturating the quantum Hamming bound at makes it perfect (non-degenerate); it also saturates the Singleton bound , making it quantum MDS.
- Logical operators , (weight 5) have weight-3 equivalents such as , so and .
- Continuous single-qubit noise is corrected because syndrome measurement discretizes any channel into the Pauli basis , each with its own unique syndrome.
- Its codewords are AME(5,2) states — every two-qubit marginal is — so the code is a perfect tensor and the tile of the HaPPY holographic code.
- Key idea: saturating the quantum Hamming bound at forces a non-degenerate code whose 16 stabilizer syndromes are in exact bijection with the 16 weight- error classes.
Where this lives today
The five-qubit code remains the reference point of quantum error correction. As the smallest distance-3 code, it is the first thing implemented when a platform claims quantum memory: Knill, Laflamme, Martinez and Negrevergne benchmarked it in liquid-state NMR in 2001, and it has since run on trapped ions and superconducting processors as a proof-of-principle logical qubit. Its trivial sixteen-entry lookup-table decoder makes it ideal for validating syndrome-extraction circuits before scaling to the far larger syndrome spaces of surface codes. Its non-CSS structure keeps it central to fault-tolerance pedagogy — the standard example of limited transversality. And its perfect-tensor character carries it beyond coding: it is the tile of the HaPPY holographic code, a toy model of how bulk information is encoded on a boundary in AdS/CFT, and a primitive for quantum secret sharing where any two of five shares reveal nothing.
The physical picture
Think of error correction as a lost-and-found desk. Every single-qubit error walks in wearing a badge — its syndrome, the pattern of stabilizer checks it trips — and the desk returns the exact inverse operation. For the scheme to work every error must wear a different badge; for it to be perfect every badge must be claimed by exactly one error, none left over. The first figure is that ledger: four parity checks generate sixteen badges, and all sixteen are spoken for.
The second picture shows why four checks suffice so elegantly: the code has a fivefold cyclic symmetry. Label the qubits around a ring; the single generator , rotated one step at a time, produces all four, so no qubit is special. That even-handedness is what makes the codewords' two-qubit marginals maximally mixed — the encoded information is smeared across all five qubits so evenly that any two, examined alone, betray nothing.
The core equations
The code is defined by its stabilizer: the abelian group of Paulis that fix every codeword. Four independent generators suffice — a single weight-4 string with its cyclic shifts — and everything downstream (codespace dimension, distance, syndromes) is read off from them.
where: — the single-qubit Paulis and identity on each tensor factor; — the stabilizer group, an abelian subgroup of the Pauli group not containing ; each generator is a one-step cyclic shift of . Four commuting generators on five qubits leave a -dimensional codespace: one logical qubit. The encoded qubit is manipulated by logical operators — Paulis that preserve the codespace but act nontrivially inside it, lying in the normalizer of but not in . The natural representatives are the all- and all- strings.
where: — logical Paulis realizing the encoded qubit's algebra; both have weight 5, but multiplying by stabilizers gives weight-3 equivalents (e.g. ). and anticommute (five overlaps, odd), exactly as a qubit's and must. The code is perfect because it saturates the quantum Hamming bound: counting weight- errors against available syndromes gives an inequality first holding, with equality, at .
where: — number of physical qubits; — weight- error classes (identity plus on each qubit); — syndromes from generators when . At this reads : equality, so every syndrome is used and the code non-degenerate. Correctability is governed by the Knill–Laflamme conditions, the general criterion for a set of errors to be correctable; for a stabilizer code they reduce to a statement about syndromes.
where: — an orthonormal codespace basis (); — correctable errors (all weight- Paulis); — a Hermitian matrix independent of . Here : distinct errors give orthogonal, uniquely-labelled outcomes — a non-degenerate code. The logical states come from projecting a product state onto the codespace: the projector built from the generators gives an equal superposition over the sixteen stabilizer images of the seed.
where: — the logical-zero codeword; — the projector onto the joint eigenspace; normalizes it. Then , orthogonal to ; both are equal-amplitude sums of sixteen basis states. Syndrome extraction reads one bit per generator — whether the error commutes or anticommutes with each — the four bits indexing the table above.
where: — the -th syndrome bit for a Pauli error ; — the -th generator, measured without disturbing the encoded information since and the commute. A weight- error yields one of the sixteen syndromes in the first figure; the identity gives . Finally, the structural jewel: the codewords are absolutely maximally entangled — trace out any three qubits and the other two are completely mixed (AME(5,2)).
where: — the two-qubit reduced density matrix on qubits of any codeword ; — the maximally mixed two-qubit state. This AME(5,2) property makes the code a perfect tensor — an isometry from any two legs to the other three.
The goal is a hard lower bound: a direct counting argument that no code encoding one logical qubit with distance three exists below five physical qubits, so the five-qubit code is provably optimal, not merely a clever construction. The strategy: count what must be distinguished (error classes) against what distinguishes them (syndromes), demand an injective assignment, and solve the inequality — the quantum Hamming bound at .
Step 1. Count the error classes to diagnose. On qubits the weight- Pauli errors are the identity plus , , on each qubit — a total of . Why: after discretization (Derivation C) any single-qubit channel collapses onto exactly this Pauli set, so distinguishing these classes is necessary and sufficient.
Step 2. Count the syndromes available. A code encoding qubit into uses independent generators, each measured to one parity bit, giving syndromes. Why: the syndrome is the only information extracted, so resolvable error classes cannot exceed syndromes.
Step 3. Demand injectivity for a non-degenerate distance-3 code: each of the error classes needs its own syndrome, so . Evaluate: gives ; gives ; gives . Why: the inequality fails for every , so no or smaller code can correct an arbitrary single error.
Step 4. Read off perfectness. Equality at leaves no slack: all sixteen syndromes are consumed and the code is non-degenerate, saturating the Hamming bound. Why: a strict inequality would leave unused syndromes and permit a degenerate code; equality is precisely the definition of a perfect quantum code. *Verified: and the failures at reproduce the quantum Hamming bound and match the perfect-code result of Laflamme, Miquel, Paz and Zurek (1996), confirmed by direct syndrome enumeration.*
Go deeper · Derivation B · 1 minDistance is exactly three
The goal is to establish that the distance equals three by bracketing it from both sides: no undetectable logical operator of weight one or two exists (giving ), while an explicit weight-three logical operator does (giving ). The distance is the minimum weight of a Pauli in the normalizer not in , so both halves are minimum-weight statements that together pin the correctable weight at .
Step 1. Rule out weight one. Every single-qubit Pauli anticommutes with at least one generator — all fifteen weight-1 errors have nonzero syndrome (the first figure shows none lands on ). Why: a nonzero syndrome means the error is detected, so it is not a silent logical fault; .
Step 2. Rule out weight two. A product of two distinct weight-1 errors has weight , and the stabilizer holds no non-identity element below weight four. A direct check confirms every weight-2 Pauli either anticommutes with a generator or would be undetectable only if in , which it is not. Why: an undetectable non-stabilizer element is a logical operator; none of weight exists, giving .
Step 3. Exhibit weight three. Multiplying by suitable stabilizers yields an equivalent logical operator of weight three, e.g. ; likewise . Why: an equivalent operator differs from by a stabilizer, acting identically on the codespace while weighing only three — capping the distance at .
Step 4. Combine the bounds. With and , the distance is exactly , so the code corrects error and detects any weight-2 error. Why: distance three is the minimum for any single-error-correcting code, and the five-qubit code achieves it. *Verified: an exhaustive search over all non-identity Paulis returns minimum normalizer-minus-stabilizer weight 3, with explicit weight-3 representatives (XXIZI for Z̄, XZIIZ for X̄), consistent with Gottesman's thesis.*
Go deeper · Derivation C · 1 minDiscretization — defeating continuous single-qubit noise
The goal is to explain the apparent miracle by which correcting a discrete set of four Pauli errors defeats the full continuum of physical single-qubit errors — amplitude damping, small rotations, depolarization, everything. The key is that any single-qubit operator expands in the Pauli basis, so a codeword hit by a continuous error becomes a superposition of Pauli-corrupted codewords, and measuring the syndrome projects onto one branch, reversed exactly.
Step 1. Expand the error. Any single-qubit operator (a Kraus element) on qubit is a combination , since span the matrices. Why: a basis statement true of every single-qubit map, so nothing about the specific channel need be known in advance.
Step 2. Apply it to a codeword: , a superposition of the clean codeword and three weight-1 Pauli-corrupted versions, each with its own syndrome. Why: linearity carries the Pauli decomposition to the state, turning a continuous error into a superposition over four discrete, individually-correctable branches.
Step 3. Measure the syndrome. Reading collapses the superposition onto one sector, randomly selecting one branch of . Why: the outcomes of this projective measurement are exactly the four branches, so the continuum is discretized by the measurement, not by any approximation.
Step 4. Recover. Apply the inverse of the identified Pauli and the encoded state is restored exactly. Because the code corrects all four Paulis on every qubit, it corrects every channel on one qubit. Why: correcting a spanning set of errors corrects their span — the discretization theorem, and why quantum error correction is possible despite continuous noise. *Verified: the standard discretization argument of Nielsen and Chuang, specialized to the five-qubit code's complete weight-1 Pauli coverage; the sixteen distinct syndromes over all fifteen single-qubit Paulis plus identity are enumerated numerically.*
Limiting cases
How the five-qubit code sits among neighbouring codes and information-theoretic bounds:
| Case | Result | Meaning |
|---|---|---|
| Quantum Hamming bound | Saturated — perfect, non-degenerate. Contrast Shor, where , highly degenerate. | |
| Quantum Singleton bound | Also saturated: the code is quantum MDS, equivalently a perfect tensor and an AME(5,2) state. | |
| Correctable weight | Corrects every weight-1 error; detects but cannot correct a generic weight-2 error. | |
| Smallest distance-3 code | Five is provably the minimum for any code. | |
| Degeneracy | Non-degenerate: distinct errors give distinct, orthogonal syndromes. |
Worked examples
1 · Decoding a single-qubit error from its syndrome
A logical state is hit by a error on qubit 1, i.e. . Compute the 4-bit syndrome, look it up, and give the recovery. Then confirm no other weight- error produces the same syndrome.
Step 1. Compute each syndrome bit from equation (6): if commutes with , else . Two Paulis anticommute iff they differ (both non-identity, unequal) on an odd number of positions, so with only qubit 1 of each generator matters.
Step 2. Read qubit 1 of each generator against the . For it is : anticommute, . For it is : commute, . For it is : anticommute, . For it is : anticommute, .
Step 3. Assemble . Looking it up (first figure, row , column ) returns the unique culprit on qubit 1; recovery is to reapply , since : the encoded state is restored exactly.
Step 4. Confirm uniqueness. Of the sixteen weight- errors, the identity gives and the fifteen Paulis give the fifteen nonzero syndromes, each once; no other error gives . Syndrome 1011 → recovery , unambiguous — the meaning of a perfect, non-degenerate code.
2 · Two ways the code is optimal — Hamming and Singleton
Show that the code saturates both the quantum Hamming and quantum Singleton bounds, and contrast its non-degeneracy with the Shor nine-qubit code.
Step 1. Hamming (packing) bound. With , , the syndrome count equals the weight- error count . Being equal, no syndrome is wasted — the code is perfect and non-degenerate.
Step 2. Singleton bound. It reads ; for , : , saturated. A code meeting it is quantum MDS — equivalently, its codewords are AME(5,2).
Step 3. Contrast with Shor. The Shor code has syndromes for only weight- errors — a vast surplus, so it is highly degenerate: many errors share a syndrome and correction. The five-qubit code is the opposite extreme — every syndrome does exactly one job, which is why five is the provable minimum while nine is wasteful.
Physics of the portrait
The five-qubit code was discovered twice in the same year, from two directions — one group hunting the smallest possible code, another studying how entanglement can be purified.
:::physicist[five-qubit perfect code|the smallest single-error-correcting code, 5,1,3, discovered 1996|stabilizer quantum error correction] Quantum error correction was born in 1995 when Peter Shor exhibited a nine-qubit code, silencing the belief that no-cloning and measurement back-action made it impossible; Andrew Steane's seven-qubit CSS code followed within months. How small could a single-error-correcting code be? In 1996 two teams answered five, independently. Raymond Laflamme, Cesar Miquel, Juan Pablo Paz and Wojciech Zurek published the explicit five-qubit code and proved it perfect, saturating the quantum Hamming bound. The same year, Charles Bennett, David DiVincenzo, John Smolin and William Wootters reached the identical code from mixed-state entanglement and purification, showing it was entanglement-optimal too — the two viewpoints, minimal redundancy and maximal entanglement, describe one and the same state. Daniel Gottesman's 1997 thesis then supplied the stabilizer formalism that recast the code as four commuting generators with a clean cyclic symmetry, the description used ever since. Decades later the same perfect tensor resurfaced as the tile of the HaPPY holographic code, a toy model of AdS/CFT — a combinatorial optimum from coding theory becoming a building block for quantum gravity.
Origins · 1 minhow this was discovered
Going further
Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, §10.5.6 and §10.3 · Preskill, Lecture Notes on Quantum Computation, Ch. 7 · Gottesman, Stabilizer Codes and Quantum Error Correction (PhD thesis, 1997) · Kitaev, Shen and Vyalyi, Classical and Quantum Computation, §15 · Wilde, Quantum Information Theory, Ch. 10.
Provenance. The stabilizer generators, logical operators, and parameters are from Nielsen and Chuang §10.5.6, Gottesman's thesis (1997), and Laflamme, Miquel, Paz and Zurek, Phys. Rev. Lett. 77, 198 (1996); the mixed-state-entanglement route is Bennett, DiVincenzo, Smolin and Wootters, Phys. Rev. A 54, 3824 (1996). Every claim was re-verified numerically: the Hamming arithmetic and its failure at ; pairwise commutation of the four generators and codespace dimension 2; commuting with every generator and mutually anticommuting; distance by exhaustive minimum-weight search, with weight-3 representatives and ; sixteen weight- errors mapping to sixteen distinct syndromes; the AME(5,2) property ; and orthogonal to . Singleton/MDS and perfect-tensor properties are cross-checked against Bennett et al. and the AME literature.
Prerequisites. Stabilizer Formalism · Knill–Laflamme Conditions · Quantum Hamming and Singleton Bounds · Pauli Group and Clifford Group · Discretization of Errors. Leads to. Syndrome Measurement and Decoding · CSS Codes · Shor Nine-Qubit Code · Code Distance and Logical Operators.
Ask the tutor: Ask me to walk through the sixteen-entry syndrome table by hand, or to show exactly how multiplying by a stabilizer produces the weight-3 logical operator .
Why exactly five qubits — why won't four do?
Because the counting does not close before five. Correcting an arbitrary single error demands a distinct syndrome for each of the weight- Pauli errors, and generators supply only syndromes. The requirement gives at and at : too few syndromes, so some error is misdiagnosed. At the numbers meet exactly, , and the code becomes possible — and perfect, with no slack. Four qubits provably cannot host a distance-3 code.
What does "perfect" actually mean for a quantum code?
It means the code saturates the quantum Hamming (sphere-packing) bound with equality: the number of syndromes exactly equals the number of correctable error classes, so every syndrome is used and none wasted. Equivalently the code is non-degenerate — distinct errors always give distinct, orthogonal syndromes, so the Knill–Laflamme matrix is simply . "Perfect" is about tightness, not reliability: the code still fails on weight-2 errors, just as the classical Hamming code is perfect. Degenerate codes like Shor's have far more syndromes than errors and let several errors share one correction.
Is the five-qubit code a CSS code, and why does it matter?
No. CSS codes have generators that are each purely -type or purely -type, letting bit-flip and phase-flip errors be handled by two independent classical codes. The five-qubit generators, like , mix and within one string, so no such separation exists. This matters practically: CSS shortcuts such as a transversal logical CNOT and independent / decoding do not apply, and you must use the full stabilizer formalism throughout. That extra demand is exactly why the code teaches so well — quantum error correction stripped of the classical scaffolding.
Why can't the code correct a weight-2 error?
Its distance is , and a distance- code corrects errors, here . Correcting up to weight needs the "spheres" of radius around distinct codewords disjoint; distance 3 makes radius-1 spheres disjoint but radius-2 spheres overlap. A generic weight-2 Pauli either shares a syndrome with some weight-1 error — so the decoder miscorrects and leaves a residual logical fault — or lands on a logical operator directly. The code can detect many weight-2 errors but cannot reliably correct them; that needs a distance-5 code.
How can measuring only four Pauli parities correct a continuous error?
This is the discretization theorem. Any single-qubit error, however continuous — a small rotation, amplitude damping, dephasing — expands in the Pauli basis as . On a codeword it gives a superposition of the clean state and three Pauli-corrupted states, each with a distinct syndrome. Measuring the four generators collapses this onto one branch, selecting a definite Pauli error you then invert exactly. The measurement itself does the discretizing — so correcting the four Paulis on every qubit corrects the whole continuum of single-qubit channels.
What is the significance of the codewords being absolutely maximally entangled?
The codewords are AME(5,2) states: trace out any three of the five qubits and the remaining two are exactly maximally mixed, , revealing nothing about the logical state. This is the strongest possible entanglement for five qubits, equivalent both to the code being quantum MDS (saturating the Singleton bound) and to it being a perfect tensor — an isometry from any two legs to the other three. The property that minimizes qubit count also maximizes entanglement, which is why the code doubles as a primitive for quantum secret sharing and the tile of the HaPPY holographic code.
Why is the cyclic symmetry of the generators useful?
Writing the code as the single generator and its cyclic shifts exposes a symmetry: rotating the qubit labels leaves the code invariant, so no qubit is distinguished. This has real payoffs. It makes the AME property manifest — if every qubit is equivalent, so is every pair, and their marginals must be identical (and maximally mixed). It compresses the code to essentially one operator, and makes it a clean, symmetric benchmark where treating all five qubits alike simplifies circuit compilation and error characterization.