|q⟩ Bad Qubits

advanced · Physics · Surface Codes & Topological Codes

Checkpoint: Toric-Code Logic

This checkpoint consolidates Module 8. You should be able to take an L×LL \times L toric code and, from first principles, state its parameters, identify its stabilizers and logical operators, and explain why each number is what it is. We work the bookkeeping end-to-end and then you reproduce it in code.

The parameter derivation, start to finish

Physical qubits. One qubit per edge of the square lattice on the torus. With L2L^2 vertices and L2L^2 faces, periodic boundary conditions give 2L22L^2 edges, so

n=2L2.n = 2L^2 .

Stabilizers and their redundancy. There are L2L^2 star operators and L2L^2 plaquette operators, but each family has exactly one relation:

vAv=I,pBp=I,\prod_v A_v = I, \qquad \prod_p B_p = I,

because every edge is counted twice. So there are L21L^2 - 1 independent stars and L21L^2 - 1 independent plaquettes, for

nk=2(L21)=2L22 independent stabilizers.n - k = 2(L^2 - 1) = 2L^2 - 2 \ \text{independent stabilizers}.

Encoded qubits. Subtracting,

k=n(nk)=2L2(2L22)=2.k = n - (n-k) = 2L^2 - (2L^2 - 2) = 2 .

Equivalently k=2gk = 2g for a genus-gg surface; the torus has g=1g = 1. The two logical qubits correspond to the two independent noncontractible cycles, with logical operators Zˉi\bar Z_i (ZZ-strings around direct cycles) and Xˉi\bar X_i (XX-strings around dual cycles) satisfying {Xˉi,Zˉi}=0\{\bar X_i, \bar Z_i\} = 0.

Distance. A logical operator is a noncontractible loop; the shortest such loop wraps one direction of the torus in a straight line of LL edges. Hence

d=L.d = L .

Putting it together, the L×LL \times L toric code is

[[n,k,d]]=[[2L2,  2,  L]].[[\,n, k, d\,]] = [[\,2L^2,\; 2,\; L\,]].

A concrete instance

For L=4L = 4: n=216=32n = 2 \cdot 16 = 32 qubits, k=2k = 2 logical qubits, d=4d = 4. The code is [[32,2,4]][[32, 2, 4]] and corrects (41)/2=1\lfloor (4-1)/2 \rfloor = 1 arbitrary error (even distance, so a weight-2 error can be ambiguous — another reason odd distances are preferred in practice).

Try it

Implement toricParams(L) returning {n,k,d}\{n, k, d\} for the L×LL \times L toric code from the derivation above, then return the sum n+k+dn + k + d for L=4L = 4. The grader checks the combined value.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.