ANJUNGQuantum Simulator
← All lessons·Lesson 12 of 13 · 8 min

Quantum error correction

Protecting fragile superpositions without ever looking at them.

A seemingly impossible task

Real qubits are fragile — stray fields and vibrations constantly nudge them. Classical computers fight noise with redundancy: store each bit three times, take majority vote. But quantum mechanics seems to slam every door on that idea: no-cloning forbids copying the state, and measuring it to check for damage collapses the very superposition you're protecting.

The escape, found by Peter Shor in 1995, is beautifully sly: don't copy the state — entangle it with helper qubits, and then measure only questions whose answers say nothing about the protected data.

The three-qubit bit-flip code

Two CNOTs spread α|0⟩ + β|1⟩ across three qubits as α|000⟩ + β|111⟩. This is not three copies (that would violate no-cloning) — it's one logical qubit written in the correlations of three physical ones. Amplitudes α and β are never duplicated, only shared.

Suppose noise flips one qubit. The decoding CNOTs compute parities: they leave qubits 1 and 2 holding a two-bit 'syndrome' that reads |00⟩ if nothing happened, |11⟩ if qubit 0 was flipped, |10⟩ or |01⟩ for qubits 1 or 2. The syndrome pinpoints where the error struck while revealing nothing about α and β — the data stays in superposition. A final Toffoli reads the syndrome and flips qubit 0 back if — and only if — it was the victim.

Load the preset: the X in column 3 is the 'noise'. Step through and compare qubit 0's Bloch arrow before encoding and after correction — identical. Drag the X onto a different wire, or remove it: the circuit quietly handles every case.

From three qubits to fault tolerance

The bit-flip code guards against X errors only; a Z error slips through. Real codes protect both at once — Shor's original used nine qubits; today's surface codes tile many physical qubits into each logical one and repeatedly extract syndromes to catch errors as they happen.

This overhead is the central engineering challenge of the field: useful fault-tolerant machines will spend the vast majority of their qubits on error correction. When you read headlines about qubit counts, the honest question is always: how many logical qubits?

Try it yourself
Break a qubit and heal it
Open in simulator →
Key takeaways
  • ◆Redundancy without copying: one logical qubit is spread across entangled physical qubits.
  • ◆Syndrome measurements locate errors while learning nothing about the protected state.
  • ◆Fault tolerance is why real machines need far more physical than logical qubits.