Article · Wikipedia archive · Last revised May 27, 2026

Shor code

In quantum computing, the Shor code or nine qubit Shor code is a foundational code in quantum error correction that protects quantum information against decoherence and operational errors. It was the first quantum error correcting code, introduced by Peter Shor in 1995. It encodes a single logical qubit into a system of nine physical qubits, allowing simultaneous correction of both bit-flip, phase-flip or a joint phase and bit flip errors on any single physical qubit. As the first quantum error-correcting code to demonstrate fault tolerant quantum computing in principle, the Shor code marked a critical step toward the development of reliable quantum computing systems.

Last revised
May 27, 2026
Read time
≈ 5 min
Length
1,109 w
Citations
15
Source
Quantum circuit to encode a single logical qubit with the Shor code. E indicates an error and the rest of the circuit to the right decodes the state. source ↗

In quantum computing, the Shor code or nine qubit Shor code is a foundational code in quantum error correction that protects quantum information against decoherence and operational errors. It was the first quantum error correcting code, introduced by Peter Shor in 1995.12 It encodes a single logical qubit into a system of nine physical qubits, allowing simultaneous correction of both bit-flip, phase-flip or a joint phase and bit flip errors on any single physical qubit.2 As the first quantum error-correcting code to demonstrate fault tolerant quantum computing in principle, the Shor code marked a critical step toward the development of reliable quantum computing systems.

The Shor code is a simple example of a Bacon–Shor code. These codes have the property that are constructed from local operations and repeating patterns, and introduce the ability to switching encoding dynamically (while the circuit is running) in a fault-tolerant manner.3

Description

Encoding states

Creation of each block. In this diagram, the Hadamard gate (H) creates a state | + {\displaystyle |+\rangle } and the other two qubits are concatenated using Controlled NOT gates. source ↗

The Shor code encodes one logical qubit in 9 physical qubits. To construct the code, we first transform encode a state α | 0 + β | 1 {\textstyle \alpha |0\rangle +\beta |1\rangle } to an encoding of three qubits, as4 | 0 | + + + {\displaystyle |0\rangle \to |+++\rangle } and | 1 | , {\displaystyle |1\rangle \to |---\rangle ,} where | ± = ( | 0 ± | 1 ) / 2 {\textstyle |\pm \rangle =(|0\rangle \pm |1\rangle )/{\sqrt {2}}} . In order to obtain the desirer Shor logical | 0 L {\textstyle |0_{\rm {L}}\rangle } and | 1 L {\textstyle |1_{\rm {L}}\rangle } we use concatenation, that is, each of the three qubits is multiplied into a three qubit block, given by4 | 0 L = 1 2 2 ( | 000 + | 111 ) ( | 000 + | 111 ) ( | 000 + | 111 ) {\displaystyle |0_{\rm {L}}\rangle ={\frac {1}{2{\sqrt {2}}}}(|000\rangle +|111\rangle )\otimes (|000\rangle +|111\rangle )\otimes (|000\rangle +|111\rangle )} and | 1 L = 1 2 2 ( | 000 | 111 ) ( | 000 | 111 ) ( | 000 | 111 ) . {\displaystyle |1_{\rm {L}}\rangle ={\frac {1}{2{\sqrt {2}}}}(|000\rangle -|111\rangle )\otimes (|000\rangle -|111\rangle )\otimes (|000\rangle -|111\rangle ).}

Detection and correction

Qubits for three blocks (0,1,2), (3,4,5) and (6,7,8), where each block is protected from bit-flips and the three blocks are protected together from a phase flip on any of the blocks. Thus the Shor code can correct any bit and/or phase flip errors in any single qubit. It can also correct two bit flips as long as the errors occur in separate blocks.4

Due to discretization of errors it can be shown that any unitary transformation on a single qubit can be corrected just by correcting bit flips and phase flips errors.4

Logical gates

One can define logical Pauli gates for the Shor code, where the logical Pauli Z gate is given by

Z L = X X X X X X X X X , {\displaystyle Z_{\mathrm {L} }=X\otimes X\otimes X\otimes X\otimes X\otimes X\otimes X\otimes X\otimes X,}

where X {\textstyle X} is the single qubit Pauli X gate. In the same manner a logical Pauli X is given by

X L = Z Z Z Z Z Z Z Z Z , {\displaystyle X_{\mathrm {L} }=Z\otimes Z\otimes Z\otimes Z\otimes Z\otimes Z\otimes Z\otimes Z\otimes Z,} where Z {\textstyle Z} is the single qubit Pauli Z gate.4

Random error threshold

According to the threshold theorem a quantum error correction code can correct physical error if the error rate is below a certain threshold. If p is the probability of a random error happening on a single qubit, the Shor code fail if two qubits are affected, this happens with probability56 P 2 ( p ) = 1 ( 1 p ) 9 9 p ( 1 p ) 8 36 p 2 , {\displaystyle P_{2}(p)=1-(1-p)^{9}-9p(1-p)^{8}\approx 36p^{2},} When P 2 ( p ) {\textstyle P_{2}(p)} is larger than p itself (where we neglected terms with power larger than p3), it is better to not use Shor code at all. In this case the threshold is approximately p=1/36=2.78%. However including errors in the error correction itself this value can drop to 10−4.5

Stabilizer formalism

The Shor code is a [[9,1,3]] code (9 qubits, 1 logical qubit, distance 3), the later number indicates that it can correct at most a single qubit error.2 In the stabilizer formalism, the Shor code has 8 generators (6 bit flip and 2 phase flip parity checks):4

1 2 3 4 5 6 7 8 9 g 1 Z Z I I I I I I I g 2 I Z Z I I I I I I g 3 I I I Z Z I I I I g 4 I I I I Z Z I I I g 5 I I I I I I Z Z I g 6 I I I I I I I Z Z g 7 X X X X X X I I I g 8 I I I X X X X X X {\displaystyle {\begin{array}{c|ccccccccc}&1&2&3&4&5&6&7&8&9\\\hline g_{1}&Z&Z&I&I&I&I&I&I&I\\g_{2}&I&Z&Z&I&I&I&I&I&I\\g_{3}&I&I&I&Z&Z&I&I&I&I\\g_{4}&I&I&I&I&Z&Z&I&I&I\\g_{5}&I&I&I&I&I&I&Z&Z&I\\g_{6}&I&I&I&I&I&I&I&Z&Z\\g_{7}&X&X&X&X&X&X&I&I&I\\g_{8}&I&I&I&X&X&X&X&X&X\\\end{array}}}

As the Shor code has only X stabilizers and Z stabilizers (does not mix X and Z in the stabilizer), it is then considered a CSS code.2

See also

See also

References

References

  1. Shor, Peter W. (1995-10-01). "Scheme for reducing decoherence in quantum computer memory". Physical Review A. 52 (4): R2493–R2496. doi:10.1103/physreva.52.r2493. ISSN 1050-2947.
  2. Williams, Colin P. (2010-12-07). Explorations in Quantum Computing. Springer Science & Business Media. ISBN 978-1-84628-887-6.
  3. Devitt, Simon J; Munro, William J; Nemoto, Kae (2013-07-01). "Quantum error correction for beginners". Reports on Progress in Physics. 76 (7) 076001. arXiv:0905.2794. doi:10.1088/0034-4885/76/7/076001. ISSN 0034-4885.
  4. Nielsen, Michael A.; Chuang, Isaac L. (2010-12-09). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press. ISBN 978-1-139-49548-6.
  5. Herbert, Steven (2026-01-04). Quantum Computing: Foundations and Practice. Oxford University Press. ISBN 978-0-19-269469-0.
  6. Nakahara, Mikio; Ohmi, Tetsuo (2008-03-11). Quantum Computing: From Linear Algebra to Physical Realizations. CRC Press. ISBN 978-1-040-06974-5.