Whenever we send information through a channel โ be it fiber optic cable, radio, or the internet โ noise can flip bits. Error correction codes add redundancy to detect and fix these errors. Before tackling the quantum case, let's understand the classical approach.
The Channel Model
We send a codeword c through a noisy channel. The receiver gets r = c ⊕ n, where n is the noise vector. Each bit nᵢ = 1 (error) with probability p and nᵢ = 0 (no error) with probability 1−p.
c โ [Channel] โ r = c โ n
The Repetition Code โ The Simplest Code
The simplest idea: repeat each bit multiple times. To transmit message bit m = 0, send the codeword c = (000). To transmit m = 1, send c = (111).
At the receiver, apply a majority rule: whatever value appears most often among the three received bits is the decoded message.
Received r
Decoded
Correct?
Probability
000
0
โ
(1−p)³
001
0
โ
(1−p)²p
010
0
โ
(1−p)²p
011
1
โ
(1−p)p²
100
0
โ (1 error corrected!)
(1−p)²p
101
1
โ
(1−p)p²
110
1
โ
(1−p)p²
111
1
โ (3 errors)
p³
Perr with code:
= 3p²(1−p) + p³ ≈ 3p² (for small p)
Perr without:
= p
Improvement when:
3p² < p ⇔ p < 1/3 → The code always helps if p < 1/2!
Code Notation [n, k, d]
A code that encodes k information bits into n physical bits and can correct up to t = ⌊(d−1)/2⌋ errors is denoted [n, k, d]. The repetition code is a [3, 1, 3] code: n=3 bits, k=1 info bit, minimum distance d=3 (corrects t=1 error).
Rate Rc = k/n (repetition code: Rc = 1/3)
Low rate is the cost of protection — 3 physical bits for 1 logical bit
Classical repetition code โ error probability comparison. Drag slider to change channel error rate p.
0.10
Ex 1.1Error probability with the repetition code
The channel error probability is p = 0.1. What is the decoding error probability with the [3,1,3] repetition code? (Use Perr = 3p²(1−p) + p³.)
For what values of p does the repetition code actually reduce error probability? (Compare 3pยฒ < p.)
p <
3pยฒ < p โ 3p < 1 โ p < 1/3.
Section 02
Three Challenges for Quantum Error Correction
Naively, we might try to apply classical error correction to qubits. But there are three fundamental obstacles that make this impossible without new ideas.
The challenge: quantum information is fragile in ways that classical information is not. Three quantum-specific obstacles must be overcome.
Challenge 1 โ A Continuum of Errors
Classical channel
0 → 0 with prob. 1−p
0 → 1 with prob. p (only 1 type of error: bit-flip)
Surprisingly, this is NOT a real obstacle. Quantum error correction works by discretizing errors. When we perform syndrome measurement (Section 5), the continuous error collapses into one of a discrete set of Pauli errors (I, X, Y, Z). We only need to correct those!
Challenge 2 โ No-Cloning Theorem
Classical (easy)
b โ bbb (copy a bit 3 times)
[3,1] repetition code โ
No-Cloning Theorem: There is no unitary operation U such that U|ฯโฉ|0โฉ = |ฯโฉ|ฯโฉ for all states |ฯโฉ. It is fundamentally impossible to copy an unknown quantum state. So the classical "just repeat it" strategy cannot be directly applied.
The quantum solution: instead of copying, we use entanglement. The quantum repetition code does not clone |ฯโฉ โ it creates a specific entangled 3-qubit state that encodes the same information in a distributed way.
Challenge 3 โ Measurement Collapses the State
Classical decoder
Reads r = c โ n directly โ decides which error occurred
Quantum decoder
If we measure |ฯฬโฉ โ state collapses! We lose ฮฑ and ฮฒ forever.
The quantum solution: We never measure the data qubits directly. Instead, we perform syndrome measurement using ancilla qubits. This extracts information about the error without revealing anything about the actual data (ฮฑ and ฮฒ).
Ex 2.1Why can't we copy a qubit?
Suppose we could clone: U|ฯโฉ|0โฉ = |ฯโฉ|ฯโฉ. Apply U to |+โฉ|0โฉ and expand using superposition. Does the result equal |+โฉ|+โฉ? (Hint: expand |+โฉ = (|0โฉ+|1โฉ)/โ2 and see what linearity gives.)
By linearity, U|+โฉ|0โฉ = (U|0โฉ|0โฉ + U|1โฉ|0โฉ)/โ2 = (|00โฉ + |11โฉ)/โ2. But |+โฉ|+โฉ = (|00โฉ + |01โฉ + |10โฉ + |11โฉ)/2. These are different โ the "cloner" gives an entangled state, not a product state. Contradiction!
Section 03
The Quantum Repetition Code
We want to protect the qubit |ฯโฉ = ฮฑ|0โฉ + ฮฒ|1โฉ. We cannot copy it, but we can encode it into an entangled 3-qubit state.
Encoding
Use two CNOT gates (with |ฯโฉ as control) to create the codeword:
|ฯโฉโโโโโ
|0โฉ
โ
โโโโโ
|0โฉ
โ
โโโโโ
Input:
|ฯโฉ|0โฉ|0โฉ = (ฮฑ|0โฉ + ฮฒ|1โฉ)|0โฉ|0โฉ
After CNOTโ:
ฮฑ|000โฉ + ฮฒ|110โฉ
After CNOTโ:
|ฮจโฉ = ฮฑ|000โฉ + ฮฒ|111โฉ(encoded codeword)
Note:
|ฮจโฉ ≠ |ฯโฉ|ฯโฉ|ฯโฉ โ this is NOT copying! It is an entangled state that encodes ฮฑ and ฮฒ in a distributed way.
Effect of Errors
Suppose the channel applies a Pauli X gate (bit-flip) to one of the qubits. The state becomes:
Instead of measuring |ฮจโฉ directly, we introduce two ancilla qubits and measure them. This gives us the syndrome โ information about which error occurred โ without revealing ฮฑ or ฮฒ.
data
Q. Ch.
โ |ฮจฬโฉ
|0โฉ (anc)
โ
โ
M
sโ
|0โฉ (anc)
โ
โ
M
sโ
Key insight: measuring the ancilla qubits gives information about the error (which qubit was flipped) but reveals nothing about ฮฑ and ฮฒ. The data qubit |ฮจฬโฉ is unchanged by this measurement!
Quantum repetition code โ select an error to see the syndrome and correction.
Error:
Ex 3.1Codeword verification
The encoded state is |ฮจโฉ = ฮฑ|000โฉ + ฮฒ|111โฉ. Apply ZโZโ (Pauli Z on qubits 0 and 1) to |ฮจโฉ. What do you get?
Zโ|0โฉ = |0โฉ, Zโ|1โฉ = −|1โฉ. ZโZโ(ฮฑ|000โฉ+ฮฒ|111โฉ) = ฮฑยท(+1)(+1)|000โฉ + ฮฒยท(−1)(−1)|111โฉ = ฮฑ|000โฉ+ฮฒ|111โฉ = |ฮจโฉ. So ZโZโ is a stabilizer of |ฮจโฉ!
Ex 3.2Syndrome after error Xโ
After an Xโ error, the state becomes ฮฑ|010โฉ + ฮฒ|101โฉ. What is the measurement outcome (sโ, sโ) of the ancilla circuit above? The ancilla measures ZโZโ and ZโZโ.
sโ =sโ =
gโ = ZโZโ anticommutes with Xโ (since X and Z anticommute on qubit 1, and I and Z commute on qubit 0). So syndrome sโ = 1. Similarly gโ = ZโZโ anticommutes with Xโ (qubit 1 factor). So sโ = 1. Both ancillas = 1 โ error is Xโ.
Section 04
Stabilizer Formalism
The stabilizer formalism provides a powerful, systematic language for quantum error correcting codes. It answers the question: what operators leave the codewords unchanged?
Group Theory Reminder
Group (G, ยท)
A set G with a binary operation "ยท" satisfying:
Closure
gโ ยท gโ ∈ G for all gโ, gโ ∈ G
Associativity
(gโ ยท gโ) ยท gโ = gโ ยท (gโ ยท gโ)
Identity
∃ e ∈ G such that e ยท g = g ยท e = g for all g
Inverse
For each g ∈ G, ∃ gโปยน ∈ G such that g ยท gโปยน = e
If also gโ ยท gโ = gโ ยท gโ for all gโ, gโ, the group is abelian.
The Pauli Group ๐ขโ
The Pauli group on n qubits consists of all tensor products of Pauli matrices {I, X, Y, Z} across n qubits, with overall phases ±1 or ±i.
XZ = iY ≠ ZX = −iY. The Pauli matrices do not always commute!
Commutation rule for Paulis: Two Pauli operators either commute (AB = BA) or anticommute (AB = −BA). On a single qubit: X and Z anticommute (XZ = −ZX), while X and X commute. On multiple qubits, two Pauli strings commute iff they anticommute on an even number of qubit positions.
The Stabilizer Set S(C)
Stabilizer Set
Given a quantum error correcting code C (a set of quantum states called codewords), the stabilizer set is:
S(C) = { M ∈ ๐ขโ : M|ฯโฉ = |ฯโฉ for all |ฯโฉ ∈ C }
S(C) is the set of all Pauli operators that leave every codeword unchanged.
SโSโ|ฯโฉ = Sโ|ฯโฉ = |ฯโฉ and SโSโ|ฯโฉ = Sโ|ฯโฉ = |ฯโฉ โ same result โ SโSโ = SโSโ โ
Generator Set G
Generator Set
Instead of listing all elements of S(C), we can specify a small set of generators G = {gโ, gโ, ..., gโ} such that every element of S(C) can be written as a product of generators:
The generator matrix G (rows = generators, columns = qubits):
I
Z
Z
Z
Z
I
rows: gโ, gโ columns: qโ, qโ, qโ
Explore which Pauli operators stabilize the encoded state ฮฑ|000โฉ + ฮฒ|111โฉ.
Test operator:
Ex 4.1Is XโXโXโ a stabilizer?
Apply XโXโXโ to the codeword |ฮจโฉ = ฮฑ|000โฉ + ฮฒ|111โฉ. Does it stabilize |ฮจโฉ? (Recall X|0โฉ = |1โฉ and X|1โฉ = |0โฉ.)
XโXโXโ(ฮฑ|000โฉ+ฮฒ|111โฉ) = ฮฑ|111โฉ+ฮฒ|000โฉ = ฮฒ|000โฉ+ฮฑ|111โฉ. This is NOT the same as |ฮจโฉ = ฮฑ|000โฉ+ฮฒ|111โฉ (unless ฮฑ=ฮฒ). So XโXโXโ is NOT a stabilizer of this code.
Section 05
Syndrome Extraction
The generators of the stabilizer code tell us exactly what to measure. The key insight: measuring a generator either confirms the state is in the code space (eigenvalue +1) or reveals that an error occurred (eigenvalue −1), without disturbing the quantum information.
Commuting vs Anticommuting with Errors
Suppose the channel introduces a Pauli error E on the codeword |ฯโฉ ∈ C. The corrupted state is |ฯฬโฉ = E|ฯโฉ. Now we apply a generator gแตข:
Different errors give different syndromes. This is how we identify which error occurred: by checking which generators anticommute with it. The syndrome S = (sโ, sโ, ..., sโ) uniquely identifies the error (for a good code).
The Ancilla Circuit for Syndrome Measurement
We cannot just apply gแตข and read the eigenvalue โ that would collapse |ฯฬโฉ. Instead, we use an ancilla qubit and controlled-gแตข to extract the eigenvalue into the ancilla:
|ฯฬโฉ
gแตข
|ฯฬโฉ (unchanged)
|0โฉ
H
H
M
sแตข ∈ {0,1}
Let's trace the ancilla through this circuit step by step:
|ฯโโฉ = |"0" or "1"โฉ โ |ฯฬโฉ (ancilla tells us eigenvalue of gแตข)
Measure ancilla:
Get sแตข = 0 if gแตขE commutes (no error signature for gแตข) or sแตข = 1 if anticommutes (error detected!)
Key fact:
|ฯฬโฉ is UNCHANGED throughout this process. The data qubit is unperturbed.
Full Syndrome Table for the Repetition Code
Error ESyndrome (sโ,sโ)CorrectionI(0, 0)None needed โXโ(0, 1)Apply XโXโ(1, 1)Apply XโXโ(1, 0)Apply XโZโ = Zโ = Zโ(0, 0)Ambiguous with I โ cannot correct Z errors! (need Shor/surface code)
Limitation: The quantum repetition code can only correct X (bit-flip) errors, not Z (phase-flip) errors. Z errors produce syndrome (0,0) โ indistinguishable from no error! A full code like the Shor [[9,1,3]] code combines bit-flip and phase-flip repetition codes to handle both.
Syndrome Extraction Map SE
The full syndrome extraction circuit performs the mapping:
SE(|0โฉ โ E|ฯโฉ) = |SEโฉ โ E|ฯโฉ
The ancilla contains the syndrome โ the data is unchanged
Syndrome extraction โ trace the ancilla state for each possible error.
Error applied:
Ex 5.1Syndrome computation
Using generators gโ = ZโZโ and gโ = ZโZโ, compute the syndrome (sโ, sโ) for error E = Xโ (bit-flip on qubit 0). Does Xโ commute or anticommute with each generator?
sโ =sโ =
gโ = ZโZโ: Z and X anticommute on qubit 0 โ gโE = −Egโ โ sโ = 1. gโ = ZโZโ: Xโ only acts on qubit 0; neither Zโ nor Zโ overlaps with Xโ โ gโE = Egโ โ sโ = 0. Syndrome = (0,1).
Ex 5.2Why measuring ancillas doesn't disturb data?
After the syndrome circuit, the state is |S_Eโฉ โ E|ฯโฉ (product state). When we measure the ancilla and get syndrome s, what happens to the data part E|ฯโฉ?
Since the final state is a PRODUCT state |S_Eโฉ โ E|ฯโฉ, measuring the ancilla (first factor) does not affect the data register (second factor). They are no longer entangled. The data qubit remains exactly E|ฯโฉ, which we can then correct by applying Eโปยน.