Three-Qubit Phase-Flip Code
The three-qubit phase-flip code is the simplest quantum code that protects a qubit against a relative-phase error — the Pauli that leaves populations untouched and only flips the sign between and . Phase errors are the characteristic quantum failure: they have no classical analogue, they are invisible to any measurement in the computational basis, and on most real hardware they are the dominant channel, arriving far faster than energy relaxation. The bit-flip code cannot see them at all. Yet the fix is almost embarrassingly cheap, because is nothing but a bit flip wearing a disguise: in the conjugate basis it obeys , , exactly the algebra of in the computational basis. So we do the obvious thing. Rotate the entire error-correcting apparatus of the repetition code into the conjugate basis with a Hadamard on every qubit, run the ordinary majority-vote logic there, and rotate back. Term by term, the bit-flip code maps into the phase-flip code under conjugation by : the codewords become ; the checks become ; and a error is caught the way an error was. This exact duality — swap and every statement survives — is the cleanest window onto the symplectic symmetry of Pauli noise underneath the whole stabilizer formalism. The code corrects any single phase flip and nothing else; its true importance is that it is one half of Shor's nine-qubit code, the first code to defeat an arbitrary single-qubit error.
- The phase-flip code encodes one logical qubit in three as , , protecting against a single Pauli (phase) error.
- It is the exact Hadamard conjugate of the bit-flip code: applying carries one code into the other and swaps the roles of and .
- Its stabilizer group is ; the two syndrome bits locate which qubit was phase-flipped without ever touching the logical amplitudes .
- With code distance against bit flips it cannot correct a single — one is a logical operation — so it is only half of a full quantum code.
- Majority-vote recovery fails at second order, giving logical phase error , a net win for every physical rate .
- Key idea: Conjugating the repetition (bit-flip) code by rotates the protected basis into , turning errors into detectable parity violations: , , with stabilizers .
Where this lives today
The phase-flip code long ago left the textbook and became the working model for the noise that dominates real hardware. Superconducting transmons, semiconductor spin qubits, and many trapped-ion encodings share a stark asymmetry: their dephasing time is far shorter than their relaxation time , so phase errors arrive first and fastest, making a phase-protecting repetition code the natural first line of defence. Google Quantum AI's 2021 demonstration of exponential error suppression ran exactly these one-dimensional bit-flip and phase-flip repetition codes, watching the logical error fall as more physical qubits were added; their later surface-code experiments treat the two-basis stabilizer readout as -type and -type checks that are direct descendants of and . The idea has also become a design principle for hardware. "Biased-noise" qubits — Kerr-cat and dissipative-cat qubits built from driven superconducting oscillators — are engineered so that bit flips are exponentially suppressed at the physical level, leaving phase flips as essentially the only residual error. For such a qubit a phase-flip repetition code alone suffices for the top layer, and Amazon's 2025 "Ocelot" chip is built around cat qubits protected exactly this way, cutting the overhead of fault tolerance dramatically. The open problem the code still frames is the one Shor posed: how to stay below the fault-tolerance threshold with realistic, biased, correlated noise — where knowing which basis your errors live in is worth more than raw redundancy.
The physical picture
Picture three qubits, each casting a vote in the conjugate basis. The logical information is carried by the common sign pattern — all-plus is , all-minus is — while a superposition keeps the two patterns coherently overlaid. A single error flips exactly one vote, breaking the unanimity. Error correction must detect the disagreement without ever asking any qubit for its absolute vote, which would collapse the superposition and destroy . Measuring the relative signs of neighbouring pairs — the -parities and — does exactly this: each returns if its pair agrees and if it disagrees, pinning down the odd one out while learning nothing about the shared value. The first figure follows this through the encoder that prepares the votes.
The whole code is the bit-flip code seen through a Hadamard lens, and it corrects only . That makes it half of a complete scheme: stack it on top of the bit-flip code — so each vote is itself a bit-flip-protected triple — and the remaining gap closes. That two-layer stack is precisely Shor's nine-qubit code. But "cheap protection" is only worth having if it actually lowers the error rate, and it does so only up to a point. The second figure is the ledger every code must satisfy: the encoded logical error against the bare physical rate , showing the quadratic suppression at small and the break-even crossing where redundancy stops helping.
The core equations
The two logical codewords are the all-plus and all-minus strings in the conjugate basis. They are the images of the bit-flip codewords under a Hadamard on every qubit, and they span the two-dimensional code space in which one logical qubit lives.
where: — the eigenstates of with eigenvalue ; — the logical basis of the encoded qubit. Reading: the two codewords are the eigenstates of , maximally spread over the Hadamard basis rather than the computational one. Encoding is a coherent map, not a copy. An arbitrary input qubit is carried into the code space with its amplitudes intact — no-cloning is respected because what is triplicated is the basis, not the unknown numbers .
where: — input amplitudes with . Reading: the superposition is preserved and delocalized; measuring any single qubit would project it and destroy the encoded state, which is exactly why recovery must use stabilizers instead. The stabilizer group is the set of Pauli operators that fix every codeword. Its two generators are -type parity checks — the conjugate-basis analogue of the bit-flip code's -type checks.
where: — Pauli on qubits and identity elsewhere, a parity check in the basis; — the abelian group with for every stabilizer and codeword . Reading: both generators return on any codeword because each pair of votes agrees; an error that disagrees with a generator flips its sign to . The logical operators act within the code space, mapping codewords to codewords. They commute with every stabilizer but lie outside , and they anticommute with each other as a logical Pauli pair must.
where: — the logical bit flip, ; — the logical phase flip, realized by any single up to a stabilizer. Reading: note the reversal — a single physical is the logical , which is why one bit flip is uncorrectable and the distance against noise is . The entire construction is fixed by one line of Clifford algebra: the Hadamard swaps and by conjugation. This is the exact map from the bit-flip code, and every feature of this code is the image of a bit-flip feature.
where: — the bit-flip encoder (two CNOTs from qubit 1 onto 2 and 3); — a Hadamard on each qubit. Reading: conjugation is an isomorphism of the whole apparatus, so codewords, stabilizers, syndromes, and distance all transport under with no independent work. Error detection measures the two generators, returning a two-bit syndrome. Each anticommutes with exactly those generators that overlap it on a single site, so the syndrome is a distinct nonzero fingerprint for each single-qubit phase flip.
where: — the outcomes of the two stabilizer measurements; — a phase flip on qubit . Reading: the four cases map to four distinct syndromes, so a lone phase flip is always located and undone by re-applying . Finally, with independent per-qubit phase flips the majority-vote decoder fails only when two or three qubits flip. Summing those events gives the logical error rate, quadratically smaller than the physical rate at low .
where: — per-qubit phase-flip probability; — probability the decoder yields a residual logical . Reading: for small , , and encoding wins whenever , i.e. for all .
The goal here is to earn every ingredient of the code — codewords, stabilizers, detectable error, and logical operators — from a single structural fact rather than separate assertions: that the phase-flip code is the exact image of the bit-flip repetition code under a transversal Hadamard . Because conjugation by a unitary preserves all commutation relations, eigenvalue equations, and group structure, we may transport the entire already-understood bit-flip apparatus across the map, and the swap it induces does the rest.
Step 1. Fix the single-qubit action from , , and the involutions , , . Apply to the bit-flip codewords: and , so the encoding map is nothing but conjugating the bit-flip encoder. Why: this pins the code space as the Hadamard image of the repetition space, and confirms equations (1) and (2) without any new postulate.
Step 2. Transport the stabilizers. The bit-flip generators are ; conjugating each factor, . Hence , which is equation (3). Why: because conjugation preserves the property "fixes every codeword," the images are automatically the stabilizers of the image code — no recomputation of eigenvalues needed.
Step 3. Transport the error being corrected. The bit-flip code detects a physical ; its image is . So the detectable error becomes the phase flip , and — reading the map the other way — a physical in the old code becomes a physical in the new one, now undetectable. Why: this single substitution is the whole content of the duality, and it explains simultaneously why the code sees and is blind to .
Step 4. Get the logical operators and the distance. Transporting the bit-flip logicals and gives and . Check independently: overlaps each on two sites (even), so it commutes with ; and , so it swaps the codewords. Meanwhile and , so ; it shares one site with and so anticommutes with it. Why: because is a weight-one operator, a single physical bit flip already implements a logical operation, proving the distance against noise is — the code's fundamental limitation, extracted for free from the map.
Go deeper · Derivation B · 1 minCorrecting a single phase flip on qubit two
The goal is to trace a completely general encoded state through the full cycle — error, syndrome extraction, recovery — and verify that the original amplitudes emerge untouched, seeing explicitly how the measurement learns the error location while staying ignorant of the logical data. The subtlety to watch is that both branches of the superposition must yield the same syndrome outcome deterministically; otherwise the measurement would collapse and corrupt the qubit even as it "corrected" it.
Step 1. Apply the error to . Since and , the operator flips only the middle label: . Why: this is the entire physical effect of a phase flip written in the conjugate basis, where it looks like a single flipped vote.
Step 2. Measure . Using : on the eigenvalues are , and on they are . Both branches give , so the outcome is deterministic and no superposition collapses. Why: the stabilizer commutes with the logical content, so it can only report the error, never the value of .
Step 3. Measure . On : ; on : . So , again deterministically, and the syndrome uniquely fingerprints a error by the table in equation (6). Why: only overlaps both generators on a single site, so only anticommutes with both — the fingerprint is unambiguous.
Step 4. Recover by re-applying the indicated operator: . The state is restored exactly, and at no point were or measured. Why: since , undoing a known Pauli is exact and unitary, completing a full error-correction cycle with the logical information intact.
Go deeper · Derivation C · 1 minThe logical error rate and the break-even threshold
The goal is to compute precisely when the code helps rather than harms, by counting the noise configurations the majority-vote decoder gets wrong, summing their probabilities, and comparing to the unencoded rate . The decoder assumes at most one flip and applies the correction a single flip would demand; the interesting content is the events where that assumption is false, and the payoff is a clean quadratic suppression with a sharply defined break-even point.
Step 1. Enumerate the failure events. With zero or one phase flip the syndrome points to the true error (or to none) and recovery succeeds. With two flips, the syndrome instead matches the single un-flipped qubit, so the decoder "corrects" that one — turning two flips into three, which is the logical . With three flips the state is already . Both the two-flip and three-flip cases are logical errors. Why: the decoder is a majority vote, and a majority-vote code with three copies is overwhelmed exactly when the minority is no longer a minority.
Step 2. Sum the two-flip probability. There are ways to place two flips, each with probability , giving . Why: independence lets the joint probability factor, and the binomial coefficient counts the equivalent placements.
Step 3. Add the three-flip probability, . Combining, , confirming equation (7). Why: these are the only remaining error weights, so their sum is the total logical failure probability.
Step 4. Locate the break-even point. Encoding helps when , i.e. , i.e. , i.e. . For this holds precisely when . At the code gives , a -fold reduction; at the threshold both rates equal . Why: the break-even at is identical to the bit-flip code's, exactly as the Hadamard duality demands — the two codes are the same code in different bases.
Limiting cases
How the code behaves as the noise channel and the physical rate are varied:
| Case | Result | Meaning |
|---|---|---|
| Single error | Fully correctable — each location gives a distinct nonzero syndrome and re-applying restores the state exactly. | |
| Single error | Undetectable — commutes with both generators, gives syndrome , and acts as the logical ; distance against bit flips is . | |
| Low phase-flip rate | Quadratic suppression; encoding beats the bare rate for all , with the largest relative gain as . | |
| Continuous dephasing | Syndrome measurement digitizes it — the state collapses onto (no error) or (correctable) with the right probabilities. | |
| Depolarizing noise | Worse than doing nothing — the and parts are uncorrected, so only a phase-biased channel benefits. |
Worked examples
1 · A full correction cycle on a phase-flipped superposition (fully worked)
An encoded state (that is, ) suffers a phase flip on qubit 3. Work out the corrupted state, both syndrome bits, the decoded location, and confirm exact recovery.
Step 1. Apply the error. flips the third label of each branch: . The logical amplitudes are still each — the error has not touched them, only the sign pattern.
Step 2. Measure . On the first two eigenvalues are ; on they are . Both branches agree, so .
Step 3. Measure . On : ; on : . Both agree, so . The syndrome is .
Step 4. Decode. From the table in equation (6), is the unique fingerprint of . Apply : . The state is recovered exactly, and the balanced superposition was never disturbed — both branches returned identical syndrome bits, so the logical information survived the measurement untouched.
2 · Is encoding worth it at ?
Independent phase flips strike each physical qubit with probability . Compute the logical error, compare to the unencoded qubit, and state the margin to break-even.
Step 1. Unencoded, a lone qubit fails with probability .
Step 2. Encoded, from equation (7): .
Step 3. The ratio is : encoding cuts the error roughly -fold. Since we are comfortably on the winning side of the threshold; the margin shrinks as climbs toward , where the advantage vanishes. At the phase-flip code lowers the logical error from to .
Physics of the portrait
The phase-flip code has no single "discoverer" the way a natural constant does, but it entered the world inside one landmark paper. In 1995 Peter Shor showed that a qubit could be shielded from decoherence at all — and the phase-flip repetition code is the piece of his construction that handles the uniquely quantum half of the problem.
Origins · 1 minPeter Shor and how this was discovered
Peter Williston Shor is the applied mathematician whose 1994 factoring algorithm turned quantum computing from a curiosity into a threat to modern cryptography — and who, one year later, supplied the antidote. The immediate objection to his own algorithm was that any real quantum computer would decohere long before finishing: a qubit in superposition seemed impossible to protect, because measuring it to check for errors would destroy the superposition, and the no-cloning theorem forbade the classical trick of keeping backup copies. Shor's 1995 paper, "Scheme for reducing decoherence in quantum computer memory," broke this impasse. His insight was to spread one logical qubit across nine physical qubits in two nested layers: an inner three-qubit repetition code against bit flips, wrapped in an outer three-qubit code — the phase-flip code — against phase flips, the outer layer obtained by conjugating the inner code with Hadamards so that errors become detectable in the basis. Syndrome measurements read out which error occurred without ever reading the logical data, and by discretization the scheme corrects any continuous single-qubit disturbance, not just , , . Shor's nine-qubit code was the existence proof the field needed; the three-qubit phase-flip code is the conceptually decisive half of it, isolating the purely quantum error that has no classical shadow.
Going further
Texts. Nielsen & Chuang, Quantum Computation and Quantum Information, §10.1.2 (the three-qubit codes) · Preskill, Lecture Notes for Physics 219, Ch. 7 · Gottesman, Stabilizer Codes and Quantum Error Correction (PhD thesis, 1997) · Mermin, Quantum Computer Science, Ch. 5 · Kitaev, Shen, Vyalyi, Classical and Quantum Computation, Ch. 14 · Lidar & Brun (eds.), Quantum Error Correction, Ch. 2. The code first appears as the outer layer of Shor's 1995 nine-qubit construction (Phys. Rev. A 52, R2493). Key consistency checks: (i) , and confirm the encoding map and stabilizer images; (ii) the syndrome table follows from evaluating eigenvalues on -corrupted codewords via ; (iii) follows from and , with break-even condition ; (iv) commutes with both generators by even overlap, and anticommutes with .
Prerequisites. Three-Qubit Bit-Flip Code · Pauli Group and Clifford Group · Quantum Error Model and Decoherence Channels · Stabilizer Formalism. Leads to. Shor Nine-Qubit Code · Discretization of Errors · CSS Codes · Syndrome Measurement and Decoding.
Ask the tutor: Ask me to walk a corrupted codeword through the full syndrome table, or to nest this code inside the bit-flip code and watch Shor's nine-qubit code emerge layer by layer.
Why does a phase flip need a special code at all — isn't it just another bit error?
A phase flip is genuinely new physics with no classical counterpart, which is why it needs its own machinery. Classically a bit is 0 or 1 and the only failure is a flip; there is no "sign between 0 and 1" to corrupt. A qubit carries a relative phase in superpositions like , and a error sends this to — the populations are unchanged, so no measurement in the computational basis can see it, and the bit-flip code is completely blind. The phase-flip code exists to catch this uniquely quantum error, by rotating into the basis where it does look like an ordinary flip.
How can measuring the qubits to find the error not destroy the superposition?
The measurements are chosen to commute with the logical information. We never measure a single qubit's value; we measure the joint observables and , which ask only "do these two votes agree?" and are silent about the shared value. On any codeword both branches of a superposition return the identical syndrome bit, so the outcome is deterministic and carries no information about or . A measurement that always yields the same result regardless of the logical state cannot collapse it. That is the central design rule of every stabilizer code: extract the error, not the data.
Why exactly is the code helpless against a single bit flip?
Because a bit flip commutes with every stabilizer generator — the generators are themselves products of operators, and Paulis of the same type always commute. Commuting with all stabilizers means gives the trivial syndrome , so the code sees nothing. And is not harmless: on the codewords it multiplies the branch by while fixing , exactly the action of the logical . So a single bit flip silently applies a logical phase error. Its weight-one nature makes the distance against noise equal to one; only nesting the code inside a bit-flip code raises it.
What does "distance one against X errors" actually mean here?
Code distance is the weight of the smallest error that acts as a nontrivial logical operation while being undetectable. For phase () errors this code has distance three: you need all three qubits flipped to reach the logical , so any single or double is caught. But for bit () errors the logical operator has weight one — a single physical bit flip already is a logical operation and triggers no syndrome. So the distance against noise is , the minimum possible, meaning zero protection. A code's distance is really a per-error-type statement, and this asymmetry, for phase, for bit, is the precise sense in which the code is "half" of a real one.
How does concatenating with the bit-flip code give the Shor code?
You build it in two layers. Start with the phase-flip code: one logical qubit becomes on three qubits, immune to phase flips. Now each of those three qubits is itself fragile to bit flips, so replace each one with a bit-flip-encoded triple, and . Three blocks of three qubits gives nine physical qubits. The inner bit-flip layers correct any single , the outer phase-flip layer corrects any single , a is handled as one of each, and by discretization any continuous single-qubit error is corrected too. That nested construction is exactly Shor's 1995 nine-qubit code — the phase-flip code supplying the outer, quantum-specific layer.
Does the phase-flip code matter on real hardware or is it only pedagogy?
It is both, and the practical side is growing. Many leading qubits — superconducting transmons, spin qubits, some ion encodings — dephase much faster than they relax (), so phase flips are the dominant error and a phase-protecting code targets the real bottleneck. Google's repetition-code experiments used one-dimensional phase-flip (and bit-flip) codes as their first hardware demonstrations of error suppression scaling with qubit number. More strikingly, "cat qubit" hardware is deliberately engineered so bit flips are exponentially rare, leaving phase flips as almost the only error — for which a phase-flip repetition code is the natural and sufficient outer code, as in Amazon's Ocelot chip. Knowing which basis your noise lives in, the whole lesson of this code, translates directly into lower qubit overhead.