Logical Operations on Encoded Qubits
Error correction would be pointless if we had to decode a logical qubit every time we wanted to compute with it — decoding exposes it to noise. The goal is to manipulate the encoded qubit while it stays protected. The operators that do this are the logical gates, and they live in the same multi-qubit space as the codewords.
What makes an operator "logical"
A logical operator must satisfy two conditions:
- It maps the code space to itself — codewords go to codewords. Equivalently, it commutes with every stabilizer, so it never changes the syndrome.
- It acts as the intended single-qubit gate on the logical labels: , , .
A physical on one qubit fails condition 1: is outside the code space (it has a nonzero syndrome). We need an operator built so the net effect lands back inside the code.
Logical X and Z for the bit-flip code
For , :
Check : and — it swaps the two codewords, the logical bit flip. It commutes with and (each anticommutes with two 's, an even number), so the syndrome is untouched.
Check : and — it applies the logical phase. A single suffices here because all three qubits carry the same logical bit; any one of them reads it out.
Logical operators are not unique
Because and differ only by a stabilizer, they act identically on the code space. In general a logical operator is defined only up to multiplication by stabilizers — any representative in the same coset is equally valid. We usually pick the lowest-weight one; its weight is the code distance, here 3 for and 1 for (the bit-flip code is asymmetric: strong against , weak against ).
Try it
Encode , then apply the logical to flip it to . The
grader checks the statevector: the only nonzero amplitude must sit at index 7 (111).
After running, the statevector panel shows a single bar at 111 with amplitude 1 — the encoded
qubit has been flipped from logical 0 to logical 1 without ever leaving the protected code space.
Sign in on the full site to ask questions and join the discussion.