Repetition Codes¶
We've seen the pieces separately: a logical qubit can be encoded across several physical qubits, and physical qubits pick up errors like bit flips and phase flips. This page puts them together into the simplest complete example of quantum error correction — the 3-qubit repetition code — and walks through encoding, injecting an error, detecting it, and correcting it.
From One Qubit to an Encoded Qubit¶
Recall the encoding from Physical vs Logical Qubits. The repetition code encodes one logical qubit into three physical qubits by repeating the computational-basis value:
For a general state, this extends linearly:
This is still encoding, not copying. The three physical qubits don't hold three independent copies of an unknown state — the no-cloning theorem rules that out. They hold one shared, correlated pattern that represents a single logical qubit.
Interactive: Build, Break, and Fix the Code¶
Work through the four steps below in order. Everything stays visible as you go, and Reset is always available if you want to start over.
Step 1 — Encode
Step 2 — Inject an error. Click a physical qubit above to give it a bit-flip (X) error.
No error injected yet — the logical information is intact and represented by the whole encoded block.
Step 3 — Detect with parity checks. S₁ compares q₁ and q₂; S₂ compares q₂ and q₃. Neither one looks at a qubit's value directly — only whether pairs agree.
Step 4 — Correct the error. The syndrome tells us which qubit disagrees — flip it back, no need to look at the logical state itself.
For reference, here's the full syndrome table this code relies on — the pattern the interactive above is computing:
| Error | S₁ | S₂ |
|---|---|---|
| None | +1 | +1 |
| X₁ | −1 | +1 |
| X₂ | −1 | −1 |
| X₃ | +1 | −1 |
Each syndrome pattern points to exactly one qubit — that's what makes the error correctable, not just detectable. Note what the correction step did not do: it never asked "what is the logical state?" It only asked "do these pairs of physical qubits agree?" — which is exactly the measurement caveat from Errors and Noise: the logical information is protected precisely because we never measured it directly.
What Can This Code Correct?¶
- ✓ One \(X\) (bit-flip) error
- ✓ That error, on any one of the three physical qubits
- ✗ A \(Z\) (phase-flip) error
- ✗ An arbitrary error by itself
- ✗ Multiple simultaneous \(X\) errors
Try it: apply a phase-flip error and run the same parity checks.
The 3-qubit repetition code protects against bit flips, not phase flips:
| Error | Protected by this code? |
|---|---|
| \(X\) | Yes |
| \(Z\) | No |
| \(Y\) | Only partly — the bit-flip half is fixable, the phase-flip half isn't |
This isn't a flaw in quantum error correction generally — it's a limitation of this particular code, which was only ever built to catch bit flips. Codes that catch both exist; we're building toward them.
Error-Correction Capability¶
For a code to correct one error, it needs enough redundancy to tell every possible single-error case apart from every other one — including "no error." That's exactly what the syndrome table above does: four distinguishable patterns for four possibilities (none, X₁, X₂, X₃).
Preview: code distance
You may see this idea again later as code distance — for now, it's enough to know that the 3-qubit repetition code has distance 3 and can correct one bit-flip error. We'll develop what "distance" formally means in a later section; this is just a preview of the vocabulary.
Takeaway¶
The repetition code gives us the basic pattern behind all of quantum error correction: encode → detect → infer → correct. What changes in later, more powerful codes is how the detection step works — but the pattern itself stays the same.
But how do we generalize these parity checks to arbitrary quantum error-correcting codes?