Three-Qubit Bit-Flip Code
A qubit in a laboratory is a fragile thing: stray fields, control-pulse errors, and coupling to the environment all conspire to flip it. The three-qubit bit-flip code is the first honest answer to that fragility, and the natural doorway into the whole theory of quantum error correction. It confronts one restricted enemy — the bit-flip channel, in which each physical qubit independently suffers a Pauli error with probability — and defeats it by spreading a single logical qubit across three physical qubits in an entangled, redundant way. A lone flip can then be detected and reversed, and the logical error probability falls from to . The construction is modelled on the classical majority-vote repetition code , , yet two quantum commandments force a new design. First, the no-cloning theorem forbids copying an unknown state, so the encoded state is emphatically not ; it is a coherent superposition assembled with two CNOTs. Second, checking for errors must never read the logical amplitudes , or the qubit collapses. The escape is syndrome measurement: we measure only the parities and , which commute with the encoded data yet announce which qubit was flipped. Three deeper features follow — linearity, discretization of continuous errors, and the fact that the redundancy lives in correlations rather than copies. The code is one-sided (it does nothing against phase errors), but it is the miniature that instantiates the stabilizer formalism and forms half of Shor's nine-qubit code.
- Encode into the entangled codeword using two CNOTs — not three copies, which no-cloning forbids.
- Diagnose errors by measuring the generators and ; their joint eigenvalues form a two-bit syndrome that locates a flipped qubit without touching .
- The four syndromes name the no-error case and the three flips uniquely, so any one bit flip is undone by reapplying the indicated .
- Encoding wins whenever : the failure probability is , quadratically small () at low .
- It is distance- against but blind to (a single is undetected, acting as logical ); Hadamard-conjugating it gives the phase-flip code, and concatenating the two gives Shor's nine-qubit code.
- Key idea: encode and measure the commuting parity checks and ; their joint eigenvalues form a syndrome that names the flipped qubit while leaving untouched, so reapplying the matching restores the logical state.
Where this lives today
The three-qubit bit-flip code is no museum piece — its exact logic is what today's hardware teams run as their first real error-correction experiment. In 2021 Google's hardware group ran the repetition code — the bit-flip code's direct descendant, extended to 21 physical qubits at distance 11 — through many rounds of stabilizer measurement and reported exponential suppression of the logical bit-flip error as the code distance grew, exactly the scaling the result foreshadows for . Because the repetition code corrects only one error type, it isolates and stress-tests the syndrome-extraction machinery — repeated parity measurement, leakage, correlated errors — before that machinery is trusted inside the surface code. That paid off: by 2023–2024 the same lineage pushed a surface-code logical qubit below threshold, so adding qubits lowered the logical error. Trapped-ion and neutral-atom machines run the same small codes with real-time decoding and mid-circuit measurement. Every one of these demonstrations begins, conceptually and often literally, with the encode–measure–correct cycle of the three-qubit bit-flip code.
The physical picture
Write the logical bit three times and take a majority vote — that is the classical repetition code, and the quantum code borrows its skeleton. The quantum twist is that you may not read the three bits to vote, because the qubit is in a superposition and reading would collapse it. Instead you ask only "do neighbours agree?" by measuring the parities and — enough to spot a single dissenter without learning whether the agreed value was 0 or 1. The codespace is the simultaneous eigenspace of the two parity operators; an error on qubit anticommutes with whichever checks touch that qubit, flipping their eigenvalues to . Because the three flips touch the checks differently, each leaves a distinct two-bit fingerprint — the syndrome — that names the qubit to repair. The first figure is the whole anatomy on one page.
The payoff is not that the code is clever but that it works, quantitatively. Because the decoder misjudges only when two or more qubits flip, the residual logical error scales as the square of the physical rate. The second figure plots against the physical error rate, sitting well below the break-even diagonal until the two curves meet at . Left of that crossing, encoding is a net win; right of it, it makes matters worse.
The core equations
The starting point is the codewords. We reserve a two-dimensional subspace of the eight-dimensional three-qubit Hilbert space for the logical qubit, choosing the two computational states maximally separated under bit flips.
where: — logical basis states; — computational basis states of three physical qubits. Reading: the codespace is their span, so a general encoded qubit is . Encoding an unknown qubit means mapping its amplitudes onto that codeword linearly — the encoder is a unitary, and two CNOTs do the job. What is copied is the basis label, never the amplitude, so no-cloning is respected.
where: — logical amplitudes with ; the arrow is the isometric encoder acting on the data qubit plus two ancillas in . Reading: the output is entangled, not a product — the crucial departure from classical repetition. Errors are detected by the stabilizer group: the abelian group of Pauli operators that fix every codeword. Two commuting generators suffice, and their common eigenspace is the codespace.
where: — stabilizer group; — two-qubit parity check, eigenvalue iff qubits agree in the basis. Reading: three qubits minus two generators leaves encoded qubit. The operators that move information within the codespace are the logical operators — Pauli strings that commute with every stabilizer but are not in , obeying the same algebra as single-qubit and .
where: — logical bit flip, exchanging ; — logical phase flip, where any single acts identically on the codespace. Reading: has weight one, so a single physical is a logical fault. Measuring the two generators returns their eigenvalues, and this pair is the syndrome — nondestructive because the generators commute with and .
where: — measured eigenvalues of the two generators. Reading: the four outcomes decode as , , , — a one-to-one dictionary. With independent bit flips at rate , the decoder fails exactly when two or three qubits flip. Binomial counting gives the logical failure probability.
where: — per-qubit physical bit-flip probability; — probability the decoded logical qubit is wrong. Reading: precisely when , with leading behaviour — the quadratic suppression that justifies the scheme. A subtle worry is that physical noise is continuous. The channel can deposit a coherent over-rotation, which expands into a superposition of "no error" and "full ".
where: — coherent rotation angle about the axis on qubit . Reading: syndrome measurement projects this superposition onto one branch or the other with probabilities — the continuum collapses to the two cases the code already handles. Finally, that a finite error set is correctable is certified by the Knill–Laflamme conditions, the master criterion of quantum error correction.
where: — logical basis states, ; — correctable errors, here ; — a Hermitian matrix independent of the logical indices. Reading: says errors never leak information about ; says they are distinguishable — the two halves of correctability.
The goal is to show, line by line, that two controlled-NOT gates on a data qubit and two fresh ancillas produce exactly the entangled codeword — not the forbidden three-copy state — and then to verify that the generators and genuinely fix that codeword, so the encoding lands in the intended eigenspace. This ties the encoder, the codespace, and the stabilizer together, the scaffolding every later step rests on.
Step 1. Prepare the input : data qubit plus two ancillas in . Why: the ancillas start in a fixed known state, since the encoder is a fixed unitary and cannot depend on the secret .
Step 2. Apply CNOT from qubit 1 to qubit 2: gives . Why: the gate copies qubit 1's basis label onto qubit 2, which looks like cloning but is not — a superposition input yields an entangled output, not two copies.
Step 3. Apply CNOT from qubit 1 to qubit 3, sending this to . Why: the second CNOT completes the weight-three entangled codeword; trying instead would produce cross terms like , outside the codespace.
Step 4. Verify and , and identically for . Why: both codewords are eigenstates of both generators, so by linearity every superposition is stabilized — the encoder output sits in the common eigenspace, confirming defines this code. *Verified: the two CNOTs give and both generators return on both codewords, matching Nielsen and Chuang section 10.1.*
Go deeper · Derivation B · 1 minCorrecting a continuous single-qubit rotation
The goal is to prove the discretization theorem in miniature: even a continuous over-rotation — an error the code was never explicitly designed for — is corrected exactly, because syndrome measurement projects the continuum onto the two discrete cases the code does handle. This is the argument that rescues quantum error correction from the objection that real noise is analog.
Step 1. Apply the error to : expanding gives . Why: any single-qubit unitary is a combination of and a Pauli, so the post-error state is a superposition of the no-error and branches.
Step 2. Note lies in the syndrome- subspace, while lies in the syndrome- subspace. Why: the branches carry orthogonal syndromes, so the stabilizer measurement separates them cleanly with no residual coherence.
Step 3. Measure the generators: with probability the outcome is and the state collapses to ; with probability it is and collapses to . Why: the Born rule weights each branch by its squared amplitude, and measurement leaves a definite, correctable Pauli error.
Step 4. Apply the indicated recovery — nothing in the first case, in the second, since . Both branches end at exactly . Why: recovery is deterministic given the syndrome, so is fully digitized away — the recovery fidelity is 1 regardless of . *Verified: orthogonal syndromes give a clean projective split and both branches recover deterministically — the discretization theorem, Nielsen and Chuang section 10.1.*
Go deeper · Derivation C · 1 minVerifying the Knill-Laflamme conditions for the bit-flip error set
The goal is to certify, without reference to any decoder, that is correctable by checking the Knill–Laflamme conditions directly on and . Passing this test is the decoder-independent statement that recovery exists — the same criterion that generalizes to every stabilizer and topological code.
Step 1. Take distinct errors, with . Acting on this gives a Hamming-weight-2 string, orthogonal to both and . Why: two flips can never turn 000 into 000 or 111, so the overlap with either codeword vanishes.
Step 2. Hence the off-diagonals vanish: , , and the cross term . Why: a vanishing off-diagonal () means the errors are perfectly distinguishable — the non-degenerate case.
Step 3. Take equal errors, , so , independent of . Why: the diagonal entries carry no dependence on — the "no deformation" half: errors do not distort the logical information.
Step 4. Assemble: , a Hermitian, logical-index-independent matrix, so both conditions hold and the set is correctable. Why: is non-degenerate — the four errors are correctable and pairwise distinguishable. *Verified: ; off-diagonals vanish by weight counting and diagonals equal 1, matching the Knill–Laflamme theorem (Phys. Rev. A 55, 900).*
Limiting cases
| Case | Result | Meaning |
|---|---|---|
| Single bit flip | Perfectly corrected — a unique nonzero syndrome names , and reapplying restores the codeword exactly. | |
| Two bit flips | Misread as the single flip on the third qubit, so majority decoding fails — logical error of order . | |
| Phase error | Syndrome is trivial ; the error is invisible and acts as logical — no protection at all. | |
| Continuous rotation | Syndrome measurement collapses to "no flip" or "full flip"; correction is exact in either branch. | |
| High noise | Break-even — the encoded and unencoded curves meet; above it, encoding hurts. |
Worked examples
1 · Tracing a bit flip through the full cycle (fully worked)
A qubit is encoded, then qubit 2 suffers an error. Follow the state through syndrome measurement and recovery, and confirm the amplitudes survive.
Step 1. Encode: the two CNOTs give , so , , sitting in the eigenspace of both generators.
Step 2. Apply : it flips the middle qubit of each term, giving . The amplitudes ride along untouched — the error moved the support, not the weights.
Step 3. Measure : on , ; on , . Both branches agree, so with certainty and nothing is disturbed. Likewise gives on both, so .
Step 4. Decode : uniquely . The measurement returned only these two sign bits and revealed nothing about versus .
Step 5. Recover by applying : . The state is restored exactly, with and intact — a full detect-and-correct cycle with zero disturbance to the logical information.
2 · When does encoding actually pay off?
Compare the encoded and unencoded error at and at , and find the break-even rate.
Step 1. At : , a factor better than the bare .
Step 2. At : , a factor improvement — the gain grows as because .
Step 3. Break-even at : , so . Encoding helps for every and hurts above it; the lower the physical rate, the larger the quadratic payoff.
3 · Digitizing a coherent over-rotation
A calibration error rotates qubit 1 by rad about the axis, . What are the branch probabilities, and the state after recovery?
Step 1. Expand: , the two branches carrying syndromes and .
Step 2. With : for the no-error branch, for the flip branch — about a chance the syndrome flags qubit 1.
Step 3. Whichever branch is realized, recovery restores exactly: nothing on , on . The continuous -rad error is digitized to a coin flip between "no correction" and "one ", with post-recovery fidelity exactly 1 — the analog error is fully absorbed by the discrete code.
Physics of the portrait
The bit-flip code is not usually named for a person, but its birth is inseparable from one 1995 paper. In the mid-1990s the prevailing wisdom held that quantum error correction was impossible — measurement collapses the state, no-cloning bars redundancy, errors are continuous. The person who showed all three objections surmountable was Peter Shor.
Origins · 1 minPeter Shor and how this was discovered
Peter Williston Shor, an American mathematician at MIT, had already detonated the field in 1994 with his polynomial-time quantum factoring algorithm — a result that made large-scale quantum computers suddenly worth building, and their fragility suddenly the central obstacle. The reigning view was that decoherence would wash out any quantum computation long before it finished, and that classical-style error correction was forbidden here: you cannot copy an unknown state (no-cloning), you cannot look at it without collapsing it (measurement), and the errors form a continuum. In 1995 Shor answered all three at once. His nine-qubit code stores one logical qubit in an entangled block whose inner layer is precisely the three-qubit bit-flip code studied here, wrapped by an outer phase-flip layer: redundancy without cloning comes from entanglement, collapse is avoided by measuring only commuting parity checks, and the continuum is defeated by the discretization those measurements enforce. Within a year Steane gave an independent seven-qubit code, Calderbank–Shor and Steane produced the CSS family, Knill and Laflamme wrote down the general conditions for a code to work, and Gottesman recast the subject in the stabilizer language this article speaks. Shor shared the Gödel and Nevanlinna Prizes, and the small code at the heart of his construction remains the first thing every student of quantum error correction learns to run.
Going further
Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, section 10.1 (the definitive introduction) · Preskill, Lecture Notes on Quantum Computation, chapter 7 · Wilde, Quantum Information Theory, chapter 22 · Kitaev, Shen and Vyalyi, Classical and Quantum Computation, section 13 · Mermin, Quantum Computer Science, chapter 5 · Gottesman, Stabilizer Codes and Quantum Error Correction (PhD thesis, 1997).
Provenance. Every result here is textbook-standard and recomputable. A verifier should confirm: (1) the two-CNOT encoder yields and both generators return on both codewords; (2) the syndrome dictionary , , , gives four distinct outcomes; (3) by binomial counting, with break-even at ; (4) the Knill–Laflamme matrix ; and (5) the discretization branch probabilities for . The historical claims trace to Shor (Phys. Rev. A 52, R2493, 1995), Steane (1996), Knill and Laflamme (Phys. Rev. A 55, 900, 1997), Gottesman's thesis (1997), and the Google repetition-code and surface-code experiments (Nature, 2021–2024).
Builds on: Quantum Error Model and Decoherence Channels · Pauli Group and Clifford Group · Discretization of Errors. Leads to: Three-Qubit Phase-Flip Code · Shor Nine-Qubit Code · Stabilizer Formalism · Syndrome Measurement and Decoding · Knill–Laflamme Conditions.
Ask the tutor: Ask me to walk an or two-qubit error through the syndrome table, derive the phase-flip dual by Hadamard conjugation, or show how two of these blocks nest into Shor's nine-qubit code.
Why can't I just make three copies of the qubit and vote?
Two reasons that reinforce each other. First, the no-cloning theorem says no unitary can turn an unknown into two independent copies, so "write it three times" is not available. Second, even if you could, is a different, unprotected state — it spreads amplitude across all eight basis strings with no clean parity structure. The code instead builds the entangled codeword with two CNOTs, storing the information in correlations, and replaces voting with parity checks that compare neighbours without reading them.
How can we detect an error without measuring — and collapsing — the qubit?
By measuring the right observables. The generators and commute with both logical operators and , so measuring them cannot disturb the encoded amplitudes. On an uncorrupted codeword they return deterministically — a certain outcome causes no collapse. After an error they distinguish only which orthogonal syndrome subspace the state occupies, never whether the logical value leans toward or . The parities ask "do the qubits agree?", never "what is the qubit?" — exactly the information a corrector needs and a snoop must not have.
What actually happens to a continuous, partial rotation error?
It gets digitized. The noise turns the encoded state into a superposition of the untouched codeword (weight ) and the fully -flipped codeword (weight ). These carry different syndromes, so measuring the stabilizers collapses the superposition onto one — either "no error" or "a complete ", each of which the code handles exactly. The angle only sets the probability of each outcome; it never leaves a half-corrected residue. This is the discretization theorem, and it is why correcting a finite set of Pauli errors suffices to correct the entire continuum.
Why is this called a distance-3 code if it only fixes bit flips?
Distance is the smallest weight of a logical operator, stated relative to an error model. Against -type errors alone, the lightest logical bit flip is , weight 3, so the code has distance 3 and corrects any single (a distance-3 code corrects error). Against the full Pauli group the story changes: has weight 1, so a single is already a logical fault and the distance collapses to 1. Both are true at once — distance-3 for the noise it was built for, distance-1 for the noise it ignores. That asymmetry is exactly why it is only half of a complete code.
How does this code become Shor's nine-qubit code?
By concatenation with its mirror image. Conjugating every operator by Hadamards turns into and vice versa, giving the three-qubit phase-flip code, which protects against errors using codewords . Shor nests them: encode the logical qubit into three "block" qubits with the phase-flip code, then encode each block into three physical qubits with the bit-flip code, for nine qubits total. The outer layer catches phase errors between blocks while each inner block catches bit flips, and together they correct an arbitrary single-qubit error — the first code ever to do so. The bit-flip code thus appears, literally, three times inside the first complete quantum code.
Is 3p² − 2p³ the whole story of how well the code performs?
It is the story for the idealized model — independent bit flips at rate , perfect gates, flawless instantaneous measurement. Real devices break each assumption: encoding and syndrome-extraction circuits inject their own errors, measurements are noisy and slow, and errors can be correlated. A fault-tolerant analysis therefore replaces the clean with a threshold statement — encoding helps only if the physical rate is below a code- and circuit-dependent threshold, which the repetition-code experiments test directly. The formula remains the right intuition and leading behaviour, but the threshold is what governs a running machine.