Error Correction
Three-Qubit Bit-Flip Code
The simplest quantum error-correcting code, which protects one qubit against a single bit-flip error using three qubits.
Definition
The three-qubit bit-flip code is a basic quantum error-correcting code that encodes one logical qubit into three physical qubits so that a single X (bit-flip) error on any one of them can be detected and corrected. It is the standard first example of quantum error correction.
In depth
If each physical qubit flips independently with probability p, the logical qubit fails when two or three of the three flip. The probability is 3p²(1 − p) + p³ = 3p² − 2p³. For p = 0.01 this is 0.000298, about 34 times smaller than p. For p = 0.1 it is 0.028, only about 3.6 times smaller. At p = 0.5 it equals 0.5 and the code gives no benefit, so the code only helps when p is well below one half, and the benefit grows as p shrinks.
In a circuit, the encoding applies CNOT from the data qubit to two ancilla qubits. A bit flip is then applied to test the code. Decoding applies the same CNOTs in reverse and a Toffoli gate, which flips the data qubit if both the other qubits show the error signature. The interactive widget in our error-correction lesson runs this for an error on qubit 1, where the logical value survives, and for two errors, where it fails, as the formula predicts.
The code also illustrates a general fact: correcting more than the errors a code is designed for fails in a particular way, so the practical goal is to keep the physical error rate low enough that double errors are rare.
Technical Definition
The code maps α|0⟩ + β|1⟩ to α|000⟩ + β|111⟩ using two CNOT gates. Measuring the parities Z₁Z₂ and Z₂Z₃ gives a syndrome that identifies which qubit, if any, was flipped, without measuring the encoded amplitudes. Applying X to the identified qubit restores the state. The code cannot correct phase (Z) errors, and two simultaneous bit flips cause a logical error.
Visual Explanation: An Analogy
Three friends each remember the same number. If one of them misremembers, the other two outvote them. The three-qubit code does that with qubits, using parity checks so that nobody has to say the number out loud.
Key facts
| Item | Detail |
|---|---|
| Qubits | 3 physical for 1 logical |
| Corrects | Any single X error |
| Logical error | 3p² − 2p³ |
| At p = 0.01 | About 0.000298 |
Where the idea comes from
The repetition-style idea appears in the early QEC papers of 1995 and 1996, and the three-qubit version is the standard classroom example in textbooks.
Real-World Use Cases
- Teaching the principles of quantum error correction
- Demonstrating syndrome extraction on small devices
- Forming the building block of larger codes such as Shor's nine-qubit code
How it differs from related ideas
- The classical repetition code is the same idea, with majority voting instead of syndrome parity checks.
- The surface code generalises the idea to protect against both bit and phase errors on a two-dimensional lattice.
Common Misconceptions
- The code does not protect against phase flips. A different, rotated code handles those, and Shor's nine-qubit code combines both.
- The code does not copy the state. The three qubits are entangled, and the amplitudes α and β are never measured.
Frequently asked questions
What is the logical error rate?
3p² − 2p³ for independent bit flips with probability p.
Can it fix two errors?
No. Two flips look like one flip on the third qubit, and the correction makes things worse.
Why use ancilla qubits?
To measure parities without measuring the data directly.