Pricing…Open Lab
Chapter 05 of 10 · ~32 min

The Phase-Flip Code

The bit-flip code can't see Z (phase-flip) errors. A Z passes every parity check with a clean syndrome, yet it damages the stored superposition. The fix is to wrap the code in Hadamard gates. That stores the data in the |+++⟩/|−−−⟩ basis instead. Now every Z error turns into an X error, which the repetition code already catches. It works 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 can't even see.

That is the Z error, also called a phase flip. It flips the sign of the 1-part and leaves the 0-part alone: Z(α|0⟩ + β|1⟩) = α|0⟩ − β|1⟩. A quick reminder of terms. Amplitudes are the weights on 0 and 1; their squares give the odds when you measure. The relative phase is the sign (or more generally the angle) between them. New to phases? See phase gates and rotations.

Why can't the bit-flip code see it? The code's protection rests on bits agreeing. It stores 0 as |000⟩ and 1 as |111⟩, and checks that all three bits still match. A Z error changes no bit anywhere. |000⟩ stays |000⟩, and |111⟩ just becomes −|111⟩. So every check passes. Yet the stored state α|000⟩ + β|111⟩ has become α|000⟩ − β|111⟩. That is a truly different logical state.

An everyday example: a guard who checks that three copies of a key have the same shape. Someone swaps the key's color, not its shape. The guard waves it through. The picture breaks in one way: you could still see a color change if you looked. A phase change can't be seen by a plain measurement at all.

Any algorithm that uses interference (amplitudes adding up or cancelling out) depends on that sign. That means almost every quantum algorithm worth running. So the minus sign is full-blown data damage. In this chapter you will watch a Z walk straight past the bit-flip code. Then you will rebuild the code in a rotated basis, where Z errors turn into X errors. The majority vote already knows how to catch those.

What the rest of this chapter covers
  1. Why can't a plain measurement see a phase flip?
  2. Can a Z sneak past the bit-flip code?INTERACTIVE
  3. How do we turn phase flips into bit flips?
  4. Can the phase-flip code fix a Z on q1?INTERACTIVE
  5. What if the Z hits q2 instead?INTERACTIVE
  6. What is the duality lesson — and what does this code still miss?
  7. Which error dominates on real hardware?
Keep learning with Pro

You’ve read the opening of chapter 5. Pro unlocks the other 7 sections — plus every chapter of every course, with circuits you can run right on the page. That’s $11.99 a month, about the price of a coffee, or $99.99 a year (save 30%). The first chapter of every course, and the whole math course, stay free.

Start learning with ProSee plansRead chapter 1 free
The Phase-Flip Code · QPU137