Skip to content

The repetition code

Real qubits are fragile. Stray fields, heat and imperfect control all disturb them, and a long computation will fail unless those errors are found and fixed while it runs. This lesson builds the simplest scheme that does so.

It assumes you know the material in the Quantum Information track up to entanglement.

To send a bit down a noisy line, send it three times: 0 becomes 000 and 1 becomes 111. If one copy is flipped on the way, say 000 arrives as 010, the receiver takes a majority vote and recovers 0. The scheme fails only if two or more copies flip, which is much less likely than one.

Three reasons this should not work for qubits

Section titled “Three reasons this should not work for qubits”

Suppose we want to protect an unknown state α∣0⟩+β∣1⟩\alpha\ket{0} + \beta\ket{1}.

  1. We cannot copy it. The no-cloning theorem says there is no operation that turns an unknown ∣ψ⟩\ket{\psi} into ∣ψ⟩∣ψ⟩∣ψ⟩\ket{\psi}\ket{\psi}\ket{\psi}.
  2. We cannot look at it. A majority vote means reading the bits, and measuring a qubit destroys its amplitudes.
  3. Errors are not just flips. A qubit can be rotated by any small amount, so there seem to be infinitely many errors to fix.

Until the mid-1990s many physicists suspected these made quantum error correction impossible. Each one has a way around it, and the three-qubit code shows the first two.

We do not copy the state. We spread it across three qubits:

α∣0⟩+β∣1⟩  ⟼  α∣000⟩+β∣111⟩.\alpha\ket{0} + \beta\ket{1} \;\longmapsto\; \alpha\ket{000} + \beta\ket{111}.

Compare this with three copies, which would be (α∣0⟩+β∣1⟩)⊗3(\alpha\ket{0} + \beta\ket{1})^{\otimes 3} and contain terms like ∣010⟩\ket{010}. The encoded state has only two terms. It is one entangled state of three qubits, and no-cloning is not violated.

In the puzzle the top qubit holds the state to protect, here ∣+⟩\ket{+}, and the other two start in ∣0⟩\ket{0}.

PuzzleEncode

The input is 12(∣0⟩+∣1⟩)\tfrac{1}{\sqrt2}(\ket{0} + \ket{1}) on the top wire. Encode it as 12(∣000⟩+∣111⟩)\tfrac{1}{\sqrt2}(\ket{000} + \ket{111}).

This puzzle needs JavaScript.

Hint

You made a GHZ state in the entanglement lesson. Copy the top qubit's bit value onto each of the others.

The same two CNOTs encode every input state, because the circuit is linear: ∣0⟩∣00⟩\ket{0}\ket{00} goes to ∣000⟩\ket{000} and ∣1⟩∣00⟩\ket{1}\ket{00} goes to ∣111⟩\ket{111}.

Now suppose a bit flip, an XX gate, hits the middle qubit. The state becomes

α∣010⟩+β∣101⟩.\alpha\ket{010} + \beta\ket{101}.

We need to learn which qubit flipped without learning anything about α\alpha and β\beta. The trick is to ask only whether neighbouring qubits agree:

  • Do qubits 0 and 1 hold the same value?
  • Do qubits 1 and 2 hold the same value?

In the damaged state above, both terms give the same answers: no and no. Because the answers do not depend on which term we are in, measuring them does not disturb the superposition. These two answers are called the syndrome.

To measure a parity, add an extra qubit in ∣0⟩\ket{0}, called an ancilla, and CNOT both data qubits onto it. The ancilla ends up as 1 exactly when the two data qubits differ.

PuzzleExtract the syndrome

The three data wires hold an encoded state in which one qubit has been flipped. Make the fourth wire record whether data 0 and data 1 differ, and the fifth wire record whether data 1 and data 2 differ. You are shown one particular error, but your circuit is also tested with the flip on each other qubit and with no flip at all.

This puzzle needs JavaScript.

Hint

Each ancilla is the target of two CNOTs. The fourth wire needs data 0 and data 1 as controls.

Look at the final state. Both terms end in 11, so measuring the two ancillas gives 11 with certainty, and the three data qubits are left exactly as they were. The syndrome tells us what to fix:

Syndrome Meaning Correction
00 No flip Nothing
10 Qubit 0 differs from the others XX on qubit 0
11 Qubit 1 differs from both neighbours XX on qubit 1
01 Qubit 2 differs from the others XX on qubit 2
Check

An encoded state has become α∣001⟩+β∣110⟩\alpha\ket{001} + \beta\ket{110}. Which qubit was flipped?

PuzzleCorrect

Read the state, work out where the error is, and repair it.

This puzzle needs JavaScript.

The third objection was that errors come in a continuum. Suppose the middle qubit is not fully flipped but slightly rotated, so the state is mostly correct with a small amplitude for the flipped version:

1−ϵ (α∣000⟩+β∣111⟩)+ϵ (α∣010⟩+β∣101⟩).\sqrt{1-\epsilon}\,\bigl(\alpha\ket{000} + \beta\ket{111}\bigr) + \sqrt{\epsilon}\,\bigl(\alpha\ket{010} + \beta\ket{101}\bigr).

Measure the syndrome. With probability 1−ϵ1-\epsilon it reads 00 and the state collapses to the undamaged one. With probability ϵ\epsilon it reads 11 and the state collapses to the fully flipped one, which we know how to fix. The measurement forces the error to be all or nothing. A code that corrects a discrete set of errors therefore corrects small errors too. This is called the digitisation of errors, and it is the reason quantum error correction is possible at all.

The code handles one bit flip. It is defeated by two, which produce a syndrome pointing at the wrong qubit.

A deeper weakness is that qubits suffer a kind of error that classical bits do not. A phase flip, the ZZ gate, on any one qubit turns α∣000⟩+β∣111⟩\alpha\ket{000} + \beta\ket{111} into α∣000⟩−β∣111⟩\alpha\ket{000} - \beta\ket{111}. No qubit disagrees with its neighbours, so the syndrome is 00, yet the encoded information has changed. The next lesson repairs this by combining two repetition codes into the nine-qubit Shor code.

RecallAnswer from memory, then check
LessonFinish this lesson