Skip to content

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:

\[ |0\rangle_L \rightarrow |000\rangle \qquad |1\rangle_L \rightarrow |111\rangle \]

For a general state, this extends linearly:

\[ \alpha|0\rangle + \beta|1\rangle \;\longrightarrow\; \alpha|000\rangle + \beta|111\rangle \]

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

Logical Qubit
α|0⟩ + β|1⟩
encode

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.

q₁
0
q₂
0
q₃
0

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

Encode
↓
Add structured redundancy
↓
Physical error occurs
↓
Measure parity information
↓
Infer error location
↓
Apply correction
↓
Recover encoded logical state

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?

Next: Encoding & Syndrome Measurement →