The Three-Qubit Phase-Flip Code
The three-qubit bit-flip code (module 14, lessons 3–5) protected against errors by encoding each logical qubit as three physical qubits in the basis. A phase-flip error is the gate, which does nothing to but flips the sign of :
A error on the logical state turns it into , flipping the relative phase. Since commutes with the computational basis it is invisible to the bit-flip code. We need a different approach.
Basis change: from Z errors to X errors
The key insight is that and are related by the Hadamard:
This means a error in the basis looks like an error in the basis. If we first rotate every physical qubit from the basis into the basis by applying , a phase-flip becomes a bit-flip — and the bit-flip code already handles those.
Encoding procedure
Starting from a logical qubit in state :
-
Fan out using two CNOTs so qubits 1 and 2 mirror qubit 0:
-
Rotate into the X basis by applying to every qubit:
Here and . The logical codewords are therefore
A phase-flip on any single physical qubit maps on that qubit — exactly a bit flip in the basis. Majority-vote decoding (in the basis) then corrects any single-qubit error.
Why this works
After encoding, a error on physical qubit sends on that qubit. Applying before measuring converts this to a plain error in the computational basis, and the two-ancilla parity checks and (syndrome measurement, lesson 4) locate and correct it. The original logical state is recovered by the inverse process.
The three-qubit phase-flip code corrects any single-qubit phase-flip error with only three physical qubits and two ancilla parity checks, at the cost of being unable to correct bit-flip errors — a trade-off that motivates the nine-qubit Shor code, which combines both codes.
Try it
Build the encoding circuit for the logical state. The grader checks the full three-qubit statevector, which must equal for .
Sign in on the full site to ask questions and join the discussion.