The problem: you cannot copy a qubit to protect it
Classical error correction protects a bit by copying it — send 000 instead of 0, and majority vote fixes a single flip. Quantum information cannot use that trick directly: the no-cloning theorem forbids making an independent copy of an unknown quantum state. The 3-qubit bit-flip code, one of the simplest quantum error-correcting codes, gets around this by entangling one logical qubit across three physical qubits instead of copying it — CNOT gates spread a single qubit's state into a correlated triple without ever duplicating the unknown amplitudes:
|0⟩ → |000⟩ |1⟩ → |111⟩ α|0⟩+β|1⟩ → α|000⟩ + β|111⟩ (entangled, NOT three independent copies)
Reading damage without reading the state
Measuring a qubit directly to check for errors would collapse its superposition and destroy the very information you are protecting. The fix is to measure only parity — whether pairs of qubits agree — using ancilla qubits and the two-qubit operators Z₁Z₂ and Z₂Z₃, which commute with the encoded states |000⟩ and |111⟩ and so reveal nothing about α or β, only about consistency between the three physical qubits. The four possible outcomes of these two parity checks form the error syndrome:
syndrome (Z1Z2, Z2Z3) meaning (+1, +1) no error (-1, +1) qubit 1 flipped (-1, -1) qubit 2 flipped (+1, -1) qubit 3 flipped
The syndrome pinpoints exactly which physical qubit flipped, if any, without ever measuring the logical value α|000⟩ + β|111⟩ itself — the superposition survives untouched. Once identified, correction is a single, deterministic X gate on the flagged qubit. This is the core trick of every stabiliser code: measure operators that commute with the code space (so they don't disturb the encoded information) but anticommute with specific errors (so they reveal exactly which error occurred).
What this code does and does not protect against
The 3-qubit code corrects any single bit-flip (X) error on any one of the three physical qubits — exactly analogous to a classical majority-vote repetition code, and for good reason: bit flips commute with the Z-basis parity checks the same way classical bit errors do. But it is blind to phase-flip (Z) errors, which leave the parities untouched while still corrupting the encoded superposition. A separate 3-qubit phase-flip code handles that case by encoding in the |+⟩/|−⟩ basis instead; Peter Shor's 9-qubit code (1995) — the first quantum error-correcting code ever published — nests the two constructions together (a bit-flip code applied to each block of a phase-flip code) to correct an arbitrary single-qubit error of either type, or any combination.
Why the physical-to-logical error rate improves
If each physical qubit has an independent bit-flip probability p per error-correction cycle, the 3-qubit code fails only when two or more of the three qubits flip simultaneously — an event of probability roughly 3p² for small p, since it must choose 2 of 3 qubits to fail. When 3p² < p, i.e. p < 1/3, the encoded logical qubit is more reliable than any single physical qubit, and the advantage compounds: this is the basic argument, generalised to larger distance-d codes (like the surface code, d qubits per side), behind fault-tolerant quantum computing — with a low enough physical error rate, adding more qubits per logical qubit drives the logical error rate down exponentially instead of up.
P_logical ≈ 3p²(1-p) + p³ ≈ 3p² for small p break-even point: p < 1/3 ⇒ encoding helps rather than hurts
From toy code to real hardware
The 3-qubit code is a teaching example, not what runs on today's quantum processors — real machines (superconducting qubits from IBM and Google, trapped ions from Quantinuum and IonQ) mostly implement the surface code, which arranges dozens to thousands of physical qubits in a 2D lattice and measures many overlapping X- and Z-type stabilisers at once, correcting both bit- and phase-flip errors simultaneously with a distance that scales with lattice size. Google's 2023–2024 surface-code experiments were the first to demonstrate that a larger code distance measurably reduces the logical error rate below the physical one — the threshold theorem in action, on real hardware, using exactly the syndrome-measure-and-correct loop this simulation shows at the smallest possible scale.
Frequently asked questions
Why can't quantum error correction just copy the qubit like classical codes do?
The no-cloning theorem proves that no operation can duplicate an arbitrary unknown quantum state. The 3-qubit code sidesteps this by entangling the qubit across three physical qubits with CNOT gates, spreading the information without ever creating an independent copy of it.
How does measuring the syndrome not destroy the encoded qubit?
The syndrome measurement checks only the parity between pairs of qubits (Z1Z2 and Z2Z3), operators that commute with both basis states of the code, |000⟩ and |111⟩. That means the measurement reveals which qubit flipped without collapsing or revealing the superposition α|000⟩ + β|111⟩ itself.
Does the 3-qubit bit-flip code protect against all quantum errors?
No — it corrects bit-flip (X) errors only and is blind to phase-flip (Z) errors, which leave its parity checks unchanged. Shor's 9-qubit code combines a bit-flip code with a phase-flip code to handle both, and real hardware today mostly uses the more efficient surface code instead.
Try it live
Everything above runs in your browser — open Quantum Error Correction and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Quantum Error Correction simulation