Bit-flip repetition code Created 2026-09-28 Updated 2026-10-14
The -qubit bit-flip repetition code stores one logical qubit in and . Its stabilizer generators are for , and its logical operators are and . Interchanging the Pauli X gate and Pauli Z gate gives the phase-flip repetition code. For odd , majority-vote decoding of a repetition code corrects up to physical Pauli X gate errors, assuming ideal operations and a noise family containing only these bit flips.
For , prepare two quantum ancillas in and apply controlled-NOT gates from the input qubit to each of them. By linearity, encoding sends
This does not produce , which would contain cross terms. For example, encoding produces , whereas three independent copies would have eight equal computational basis amplitudes. The encoding creates quantum entanglement when both coefficients are nonzero and respects the no-cloning theorem.
The three-qubit bit-flip syndrome table corrects the family and its entire linear span, as specified by the Knill--Laflamme condition. It cannot correct arbitrary errors on one physical qubit: the phase flip
commutes with both checks and acts as logical . In particular, it takes the encoded to the orthogonal encoded with error syndrome . Thus its full quantum code distance is one, despite correcting one error of the restricted Pauli X gate type. The Shor code, Steane code and five-qubit error correcting code provide protection against arbitrary one-qubit errors.
Replacing every qubit of an -qubit phase-flip repetition code by an -qubit bit-flip repetition code gives a code with logical - and -operator weights and , respectively, and hence distance .
The phase-flip repetition code with codewords corrects any one physical Pauli Z gate error. Its two adjacent-pair error syndromes cannot distinguish an error pattern from its three-bit complement. Minimum-weight recovery therefore leaves no residual error at weight zero or one, and leaves at weight two or three. This residual operator exchanges the codewords, so inverse encoding gives a logical Pauli X gate. For independent physical phase errors of probability , the decoded quantum channel is , where . For , .
Use the normalized three-qubit states . The Shor code has logical basis
It encodes as , preserving the unknown amplitudes by a linear isometry. It concatenates a three-block phase-flip repetition code with the three-qubit bit-flip repetition code inside each block. Six stabilizer generators, , test bit errors inside the blocks. The other two stabilizer generators are
All eight commute and have eigenvalue on both logical basis states. They define the stabilizer code. The inner checks identify single bit flips, and the outer checks identify a block phase flip; combined they also correct a Pauli Y gate error, since .
For the requested phase flip, a on any one qubit interchanges and in its block. It commutes with the six -pair checks. It anticommutes with or exactly when its block is contained in that check. The Shor-code phase-flip syndrome is therefore
A projective measurement of the two commuting checks yields the displayed error syndrome without learning or : both logical components have the same check eigenvalues after the error. Applying the indicated Pauli Z gate restores every encoded quantum state.
The correction is genuinely degenerate. For in the same block, fixes both and , so and consequently . In particular and are distinct physical errors but have identical action on every code state; their image subspaces coincide, not merely their observed syndrome labels. In the Knill--Laflamme condition for , the error Gram matrix has , , and
The zero overlaps between different blocks follow because a phase flip changes a different pattern of orthogonal factors; cross-logical overlaps also vanish. Thus consists of one block and three all-ones blocks and has rank four, not ten. This both proves correctability of the entire single-phase-error span and exhibits its degeneracy. A coherent sum of phase errors in one block has the same logical action with its coefficients summed, so inability to locate the individual qubit loses no logical information. The two block checks suffice to correct every single phase flip, even though the within-block errors are indistinguishable.
Use the Hilbert-Schmidt inner product normalized by the dimension: . The identity and the three Pauli matrices are Hermitian, each has square , and each nonidentity Pauli matrix has zero trace. For distinct nonidentity indices, the Pauli matrix multiplication law gives , which is traceless. Therefore
There are four such orthonormal operators, and the complex vector space of two-by-two matrices has dimension four. Hence they form an orthonormal basis. Taking the inner product of any with each basis element proves, for arbitrary complex and not just Hermitian ones,
For example, if , its four coefficients are , , , and , respectively.
For the joint error, regard the two prescribed basis outputs as the columns of an environment-valued linear map. Its coefficient array in the usual output-row, input-column convention is
The source's other array is arranged as a column of the images of basis kets; it must not be mistaken for this coefficient array acting on an amplitude column. Applying the just-proved Pauli matrix expansion componentwise in any environment orthonormal basis gives the Pauli decomposition of a qubit-environment isometry:
To check the potentially delicate sign of the Pauli Y gate coefficient, use and . The four terms then give
Linearity proves the expansion for every input pure state. The environment coefficient vectors need not be normalized or mutually orthogonal. Consequently this expansion includes coherent combinations of Pauli errors, rather than asserting that every quantum channel is a probabilistic Pauli channel.
For the recovery probability, use the usual independent-use interpretation of the given phase-flip channel: each of the three transmitted qubits has a Pauli Z gate error independently with probability . The phase-flip repetition code uses logical codewords and . The decoding Hadamard gates convert physical phase flips to bit flips because . We can then analyze the two decoding controlled-NOT gates and the final Toffoli gate directly, rather than assuming a recovery rule.
Let be the error bits after this basis conversion. For a logical basis input , the three data bits before inverse encoding are . The two controlled-NOT gates produce
The Toffoli gate flips the first wire when both of the last two bits are one. Its residual error is
The last two wires carry an error syndrome independent of . Thus this transformation preserves the amplitudes of an arbitrary superposition: zero or one phase error returns the original unknown qubit, while two or three phase errors leave the logical Pauli X gate applied to it. The probability of universally successful recovery is therefore
Equivalently, the decoded quantum channel is , with logical failure of the three-qubit phase-flip repetition code . For , the failure probability is below , since . A special input that is a Pauli X eigenstate is unchanged even by the residual logical error; this does not make the code correct that error on an unknown input. Its squared quantum fidelity with a particular pure input is . If the errors on different channel uses are correlated, the marginal probability alone is insufficient: the general universal success probability is the probability of at most one error.
Assume the three physical phase-flip channels act independently, with the same probability on each qubit, and encoding, recovery and decoding are ideal. Zero or one physical error is corrected. Hence
The probability of an uncorrectable two- or three-site error is .
One must also choose the logical convention consistently with the output phase error specified here. The usual phase-flip repetition code with codewords and has residual operator after two or three physical errors: their error syndrome equals that of the complementary zero- or one-error pattern. This operator exchanges those codewords, so plain inverse encoding would give logical , not .
To obtain the stated logical phase-flip convention, use the logical Hadamard convention for a phase-flip repetition code. Put a logical Hadamard gate before that encoding and after its decoding. The encoded state is
where the plus and minus states in these codewords are the real Hadamard basis states. The uncorrectable exchange is now conjugated to . With that convention the decoded density operator and its trace distance are exactly
For , , so coding reduces the trace distance. The displayed recovery probability means success of correction as a quantum operation on an arbitrary unknown input. If the particular input is a eigenstate, even the logical phase-error branch represents the same physical state, and the probability of recovering that particular state is one.
Independence is an extra noise assumption needed for the numerical probability. If all three physical qubits flip together with probability , each marginal still has the given phase-flip channel, but the logical failure probability is , not . More generally, for a classical joint phase-error distribution with a random number of flips, and ; the same decoded mixture holds in the stated logical convention. Thus marginal error probabilities alone do not determine the requested recovery probability. A complex environment overlap likewise requires the coherent rotation to be retained or separately compensated before this stochastic phase-error analysis applies.
Number the three data qubits from top to bottom. It suffices initially to follow a pure input ; linearity will extend the result to every density operator. The first two controlled-NOT gates create . The first layer of Hadamard gates then encodes this as
the three-qubit phase-flip repetition code. Let indicate whether a Pauli Z gate occurred on data qubit during storage. The next layer of Hadamard gates uses and gives
The two initially zero syndrome quantum ancillas receive the adjacent parities. In the diagram's top-to-bottom order, their error syndrome is
Both terms of the logical superposition have these same parities, so the syndrome is independent of . Measuring it reveals no logical-state information.
At the marked position of in the printed circuit, there has already been another layer of Hadamard gates on the data. There is also a layer immediately after . Thus a desired correction in the parity-extraction frame must be implemented as at the actual recovery location, since . Choose the recovery according to
The two patterns on each row share a syndrome because complementing all three bits does not change either parity. For a weight-zero or one error, the recovery removes the entire error in the parity-extraction frame. The remaining state is , and the two final controlled-NOT gates give .
For a weight-two or three error, minimum-weight recovery instead leaves all three bits flipped, giving . The final controlled-NOT gates send this to . Consequently, for every input density operator,
The logical failure is a Pauli X gate after decoding, even though the stored physical errors were Pauli Z gates: exchanges the two encoded codewords. This is the logical failure of the three-qubit phase-flip repetition code.
Independent applications of the phase-flip channel are a classical mixture of the eight physical Pauli Z gate error patterns. A specified weight- pattern has probability . The recovery from the preceding part succeeds on weight zero and one, and yields the logical Pauli X gate on weight two and three. There are three weight-two patterns and one weight-three pattern, so the logical failure probability is
Averaging the corrected branches gives the complete decoded quantum channel
In particular, the leading logical error is , rather than an error of first order in . For the stated range,
Thus the failure probability is smaller than the physical error probability. The decoded channel is a bit-flip channel; it is not , whose error operator would be . This distinction follows from the logical codeword exchange in the phase-flip repetition code.
Use phase-flip protection by Hadamard conjugation. Insert a Hadamard gate on each of the three data wires immediately after the two encoding CNOTs and before the physical error. Insert another Hadamard on each data wire immediately after the error and before syndrome detection. Leave the two syndrome ancillas and every detection, recovery and decoding gate unchanged.
The first layer changes the encoded state to , the three-qubit phase-flip repetition code. The two layers surrounding the error turn the effective error seen by the old circuit into
Since and , the four physical cases become respectively . The original coherent syndrome and recovery circuit corrects all four, as its syndrome table shows. Thus two Hadamard layers on the three data wires, straddling the error, give the required phase-flip protection. The final top wire is the original , not , because the second layer returns the data to the original coding basis before recovery and decoding.
The commuting terms
are independent stabilizer generators. Since , every ground state has . The resulting two-dimensional stabilizer subspace is
the phase-flip repetition code. A convenient pair of logical Pauli operators is
Indeed, they commute with every stabilizer, anticommute with each other, and are not stabilizers.
For phase-flip errors and , the operator entering the Knill--Laflamme condition is and has weight at most . Every nonempty proper product of anticommutes with some unless it is the full logical operator . The Knill--Laflamme conditions therefore hold whenever , and fail once two allowed errors can differ by . Thus
Each physical commutes with all stabilizers, and is a product of stabilizers. Hence every acts on the code as the undetectable logical operator . The code cannot detect, and therefore cannot correct, even a single bit flip.