The 3-qubit bit-flip code, step by step
The simplest quantum code: three qubits, two parity checks, and one error fixed. With every case written out.
8 min read · reviewed December 2026
Encoding
The qubit a|0⟩ + b|1⟩ becomes a|000⟩ + b|111⟩. This is not three copies of the qubit. It is one entangled state in which the pair of values |000⟩ and |111⟩ carries the original amplitudes.
Checking for flips
Two parity checks compare qubits 1 and 2, and qubits 2 and 3. Both give 0 for |000⟩ and for |111⟩, so they do not disturb the superposition. If one qubit has flipped, one or both checks give 1, and the pattern points to the culprit.
| Flipped pattern | Syndrome (q1⊕q2, q2⊕q3) | Decoder output | Result |
|---|---|---|---|
| 000 | 00 | 000 | recovered |
| 100 | 10 | 000 | recovered |
| 010 | 11 | 000 | recovered |
| 001 | 01 | 000 | recovered |
| 110 | 01 | 111 | logical error |
| 011 | 10 | 111 | logical error |
| 101 | 11 | 111 | logical error |
| 111 | 00 | 111 | logical error |
What it cannot do
Two flips look like one flip on the third qubit, so the decoder makes things worse and produces a logical error. The table shows it. Also, the code cannot see a phase flip: Z on any qubit changes the sign of the |111⟩ part and every check still reads 0.
Does it help?
Only if flips are rare. The chance of two or more flips out of three is 3p² − 2p³, which is smaller than p when p is below one half. The table gives exact values for larger repetition codes too.
P(logical error) = 3p² − 2p³
| Qubits | p = 1% | p = 5% | p = 10% | p = 20% |
|---|---|---|---|---|
| 1 (no code) | 1.00% | 5.00% | 10.00% | 20.00% |
| 3 | 2.98e-4 | 0.725% | 2.80% | 10.40% |
| 5 | 9.85e-6 | 0.116% | 0.856% | 5.79% |
| 7 | 3.42e-7 | 1.94e-4 | 0.273% | 3.33% |
| 9 | 1.22e-8 | 3.32e-5 | 8.91e-4 | 1.96% |
Try it
Questions
Why is the syndrome table not the same as reading the qubits?
The syndrome compares neighbours. 000 and 111 give the same syndrome, so it never reveals which logical value is stored.
Is the 3-qubit code used in practice?
Not alone. It shows the principle. Real codes protect against both bit and phase errors.
What if the checks themselves fail?
Then the syndrome lies. Fault-tolerant design handles that. This lab assumes perfect checks.
Read next
Sources and further reading
- P. W. Shor, “Scheme for reducing decoherence in quantum computer memory” (1995)
- A. M. Steane, “Error correcting codes in quantum theory” (1996)
- D. Gottesman, “Stabilizer codes and quantum error correction” (PhD thesis, 1997)
- Google Quantum AI, “Quantum error correction below the surface code threshold”
- M. Nielsen and I. Chuang, Quantum Computation and Quantum Information, chapter 10
Check the original sources for exact citations.