Conventions as in the notes: qubits are numbered from , Pauli strings omit identities, , and syndrome bit is iff the error anticommutes with check .
Problem 1
Problem 1.1 (Repetition codes and their threshold).
Each bit of an -bit repetition code flips independently with probability , and we decode by majority vote.
Derive as a polynomial in .
Show that if and only if .
At , what is the smallest odd with ?
Explain in one or two sentences why measuring the parities is enough to decode, and why this matters for the quantum version.
Solution
Majority vote fails iff at least of the bits flip:
, so . For this is positive iff , i.e. .
Evaluating the sum at : gives , gives , gives . So .
The parities form the syndrome: a flip of bit changes exactly the parities that contain , so the set of lit parities determines the most likely error pattern (one lit parity at an end, or two adjacent lit parities in the middle, for a single flip). The parities are identical for and , so they reveal nothing about the stored value. In the quantum case this is what allows us to diagnose errors without measuring, and thereby destroying, the encoded superposition.
Problem 2
Problem 1.2 (Pauli expansions and digitization).
Using for , show that every matrix equals with .
Expand the Hadamard gate and the rotation in the Pauli basis. (Hint: .)
The error hits qubit 1 of an encoded state of Shor’s code. List the possible syndromes, the probability of each, and the state after the measurement.
Solution
The four matrices are linearly independent (by the trace identity, implies ), and there are four of them in the four-dimensional space of matrices, so they form a basis. Writing and multiplying by and taking the trace, .
. Since , , so
with no component.
. The three terms have different syndromes (trivial; flipped; first -check flipped), so they lie in mutually orthogonal eigenspaces of the checks. Measuring the checks gives
trivial syndrome with probability , state ;
the syndrome with probability , state , corrected by ;
the syndrome with probability , state , corrected by (or , ; they act identically).
The probabilities add to and every branch is corrected exactly. (We checked these probabilities numerically for .)
Problem 3
Problem 1.3 (No-cloning for two states).
Let and be two single-qubit states. Suppose a unitary satisfies and .
Show that up to a phase, i.e. the two states are either orthogonal or equal (up to phase).
Explain why the encoder of the bit-flip code does not contradict this.
Solution
Unitaries preserve inner products. Taking the inner product of the two equations,
so satisfies , hence . (If we allow the clones to pick up phases, the same argument gives .) A cloner can therefore only copy states from a fixed orthonormal set, which is the classical case.
The encoder copies only the basis states and , which are orthogonal, so part 1 allows it. On a superposition it produces the entangled state , not . Error correction never needs copies of ; it needs the information to be spread out non-locally so that no single qubit carries it.
Problem 4
Problem 1.4 (The phase-flip code).
The phase-flip code has , and checks , .
Show that the circuit “CNOT from qubit 1 to qubit 2, CNOT from qubit 1 to qubit 3, then on all three qubits” maps to .
Give the syndrome table for .
Verify the Knill-Laflamme condition for and compute .
Compute where is the codespace projector. What does this say about errors on this code?
Solution
The CNOTs produce ; then maps and , giving .
anticommutes with an -check iff the check acts on qubit :
error
0
0
1
0
1
1
0
1
For , and . For , is or (); each anticommutes with at least one check , so for code states , , which is therefore . Hence and : the code is nondegenerate for this error set.
on qubit 1, so and . Thus
which is not proportional to . An error is undetectable and acts as the logical on the code: the phase-flip code has distance against errors.
Problem 5
Problem 1.5 (Shor's code in action).
Order the eight Shor checks as , then , .
Compute the syndrome of and give a correction.
Phase flips hit qubits 1 and 4 (). Which single-qubit error has the same syndrome? What is the net effect of applying that correction?
Show that and have the same syndrome and act identically on the codespace. Which check product relates them?
Solution
. The part anticommutes with and ; the part anticommutes with both -checks (qubit 5 lies in both). The syndrome is . Correct with (or equivalently followed by any in block 2, since , , act identically).
flips the first -check only, flips both, so , the syndrome of a single in block 3, e.g. . The decoder applies , leaving : a logical bit flip. Two phase flips in different blocks defeat the distance-3 code, as expected.
and both commute with all checks and anticommute with only, so they share the syndrome . Their product is , a product of two checks; every codeword is a eigenvector of it, so . This is degeneracy.
Problem 6
Problem 1.6 (Detecting versus correcting).
An error is detectable by a code with projector if for a number .
Show that for the bit-flip code every -type error of weight or is detectable, but is not.
Show that the bit-flip code nevertheless cannot correct the set , using the Knill-Laflamme condition (Theorem 1.2 in the notes).
Deduce, in your own words, the general rule “distance detects errors but corrects only ”.
Solution
Any -string of weight or maps and to strings with one or two s, outside the codespace, so (). But swaps , so , which is not a multiple of .
The condition must hold for the pair , : , and by part 1 is not proportional to . So the set is not correctable: and give the same syndrome but require different corrections.
Detection of needs only itself to be harmless-or-visible. Correction of a set needs every product to be harmless-or-visible. With distance , every error of weight below is detectable, so errors of weight up to are detected; for correction we need , i.e. .
Problem 7
Problem 1.7 (Simulating the bit-flip code with Stim).
Write a Stim circuit for one round of the three-qubit bit-flip code: data qubits start in , each suffers X_ERROR(p), two ancillas collect the parities of and , and finally all qubits are measured. Decode with the lookup table from the notes and estimate the logical error rate for with shots. Compare with .
Solution
One possible solution (this exact script is in the course repository under research/checks/01-why-qec/hw01_rep_code_stim.py):
import numpy as np, stimdef circuit(p): c = stim.Circuit() c.append("R", range(5)) c.append("X_ERROR", [0, 1, 2], p) c.append("CNOT", [0, 3, 1, 3, 1, 4, 2, 4]) c.append("M", [3, 4]) # syndrome bits s1, s2 c.append("M", [0, 1, 2]) # data return cLOOKUP = {(1, 0): 0, (1, 1): 1, (0, 1): 2}def logical_error_rate(p, shots=200_000): s = circuit(p).compile_sampler(seed=7).sample(shots).astype(np.uint8) syn, data = s[:, :2], s[:, 2:].copy() for (a, b), q in LOOKUP.items(): data[(syn[:, 0] == a) & (syn[:, 1] == b), q] ^= 1 return data[:, 0].mean() # corrected data is 000 or 111for p in (0.05, 0.1, 0.2, 0.3): print(p, logical_error_rate(p), 3 * p**2 - 2 * p**3)
Our run gave
simulated
All four agree with the formula to within two standard errors. Because the parity measurements here are perfect, the lookup decoder is exactly majority vote, which is why the classical formula applies. In Module 9 we will make the measurements noisy too.