The 3-qubit bit-flip code is the simplest quantum error correcting code. It protects against single X (bit-flip) errors by encoding one logical qubit into three physical qubits.
| Logical State | Physical State |
|---|
| |0⟩_L | |000⟩ |
| |1⟩_L | |111⟩ |
┌───┐
q_0: ┤ X ├──■────■── (logical |1⟩)
└───┘┌─┴─┐ │
q_1: ─────┤ X ├──┼──
└───┘┌─┴─┐
q_2: ──────────┤ X ├
└───┘
┌───┐
data_0: ─┤ ├─────
│ Z₁Z₂│
data_1: ─┤ ├──■──
└───┘┌─┴─┐
data_2: ──────┤ Z₂Z₃├
└───┘
| Syndrome | Error Location | Correction |
|---|
| 00 | No error | None |
| 01 | Qubit 2 | X on q2 |
| 10 | Qubit 0 | X on q0 |
| 11 | Qubit 1 | X on q1 |
from circuit import run_circuit
# No error
result = run_circuit(error_qubit=None)
print(f"Success: {result['success_rate']:.2%}")
# Inject error on qubit 1
result = run_circuit(error_qubit=1)
print(f"Corrected: {result['success_rate']:.2%}")
| Scenario | Success Rate |
|---|
| No error | ~100% |
| Single X error | ~100% (corrected) |
| Two X errors | ~0% (uncorrectable) |
- Only corrects X errors: Z (phase-flip) errors not corrected
- Single error only: Two or more errors cause failure
- Overhead: 3 physical qubits per logical qubit
The code uses redundancy and parity checks:
- Redundancy: Information spread across 3 qubits
- Parity: Syndrome measures parity of pairs
- Majority vote: Effective classical interpretation
- Educational: Foundation for understanding QEC
- Building block: Combined with phase-flip code for Shor code
- Repetition code: Extendable to 5, 7, 9 qubits