Curriculum / Noise & Error Correction / Repetition Codes

Lesson 4 of 14Code challengePro+150 XP

Repetition Codes

Classical error correction adapted for quantum, majority vote.

Repetition Codes: The Simplest Error Correction

The 3-qubit repetition code is the simplest quantum error correcting code. It protects against single bit-flip (X) errors by encoding one logical qubit into three physical qubits: similar to classical triple modular redundancy, but with an important quantum twist.

The classical analogy:

In classical communication, you protect a bit by sending it three times: 0 → 000, 1 → 111. If one bit flips (say 010), majority voting recovers the original: two 0s, one 1 → output 0. This works for single errors.

The quantum version:

The 3-qubit bit flip code encodes:

  • Logical |0⟩ → |000⟩ (all three qubits in state 0)
  • Logical |1⟩ → |111⟩ (all three qubits in state 1)

Crucially, you CANNOT simply copy a quantum state due to the no-cloning theorem. Instead, CNOT gates spread the logical qubit's information:

Encoding circuit:
|ψ⟩ ──●──●── |ψ encoded⟩ (qubit 0)
|0⟩ ──⊕───── |ψ encoded⟩ (qubit 1)
|0⟩ ──────⊕─ |ψ encoded⟩ (qubit 2)

If |ψ⟩ = α|0⟩ + β|1⟩, the encoded state is α|000⟩ + β|111⟩: a superposition of the two codewords. This is not three independent copies but one entangled logical state.

Why CNOT encoding doesn't violate no-cloning

The no-cloning theorem says you cannot copy an unknown quantum state. The repetition code doesn't clone: it encodes. The CNOT gates create an entangled state α|000⟩ + β|111⟩, not three independent copies of α|0⟩+β|1⟩. You cannot extract the original α|ψ⟩ from any single physical qubit; it's spread across all three. This entanglement is what makes quantum error correction possible and what distinguishes it from classical redundancy.

Error detection without measurement:

To detect which qubit (if any) flipped, we measure the parities of pairs without measuring the logical qubit:

Syndrome (anc0, anc1)Error
(0, 0)No error
(1, 0)Qubit 0 flipped
(1, 1)Qubit 1 flipped
(0, 1)Qubit 2 flipped
  • anc0 = parity of qubits 0 and 1 (measured via CNOT chain)
  • anc1 = parity of qubits 1 and 2

This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.

How this lesson works

A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.

Part of: Noise & Error Correction

Understand quantum noise and build error correction codes to protect quantum information.

This lesson is part of Pro

Unlock Noise & Error Correction and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.