The Phase-Flip Code
The bit-flip code is blind to Z (phase-flip) errors: a Z passes every parity check with a clean syndrome while corrupting the stored superposition. The fix is to encode in the |+++⟩/|−−−⟩ basis by wrapping the code in Hadamards, which turns every Z error into an X error the repetition code already catches — because H·Z·H = X.
What error does the bit-flip code miss?
The three-qubit bit-flip code ended on a cliffhanger: it catches any single X error, but there is a second kind of error it cannot even see. The Z error, or phase flip, negates the amplitude of the 1-component while leaving the 0-component alone: Z(α|0⟩ + β|1⟩) = α|0⟩ − β|1⟩. (Amplitudes are the weights on 0 and 1 whose squares give measurement probabilities; the relative phase is the sign — more generally the angle — between them. New to phases? See phase gates and rotations.)
Why is that invisible to the bit-flip code? The code's protection is built entirely on agreement between bit values: it stores 0 as |000⟩ and 1 as |111⟩ and checks whether the three bits still agree. A Z error changes no bit anywhere — |000⟩ stays |000⟩, and |111⟩ merely becomes −|111⟩ — so every check passes. Yet the stored state α|000⟩ + β|111⟩ has become α|000⟩ − β|111⟩: a genuinely different logical state. For any algorithm that relies on interference — which is to say, any quantum algorithm worth running — that minus sign is full-blown data corruption.
In this chapter you will watch a Z walk straight through the bit-flip code's defenses, then rebuild the code in a rotated basis where Z errors become X errors — which the majority vote already knows how to catch.
You’ve read the opening of chapter 5 — 7 more sections follow, with worked examples and circuits you can run on the page. A free account unlocks every chapter of every course (paid plans aren’t live yet — early readers get everything free).