---
title: "Quantum Error Correction Interactive Lab | Sandbox Physics"
description: "Can you find an error without reading the encoded message? Yes."
canonical_url: "https://sandboxphysics.com/labs/quantum-error-correction/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/quantum-error-correction/"
last_modified: "2026-10-28"
---

Q045 · Detect, decode and repair

# Quantum Error Correction

**Can you find an error without reading the encoded message?** Yes. Auxiliary checks reveal how an error changed relations between encoded qubits, leaving the logical message unread. Their combined result, the syndrome, selects a repair for the errors the code can correct. Ideal repetition checks repair bit flips; the five-qubit code corrects any single-qubit error.

Move an error between encoded qubits, read the auxiliary checks and test the repair. Compare bit-flip protection with a five-qubit code.

> Interactive simulation: open this page in a web browser to change the parameters and run the model.

The small register is simulated exactly, with one auxiliary qubit that is reused. Pauli faults in memory, faults after controlled gates that hit only data qubits and classical flips of the syndrome readout are set separately. Encoding and the final verification are ideal. A single round of syndrome extraction is not fault tolerant and does not establish a threshold.

One message encoded in several data qubits

Inspect the check operators

Only the auxiliary qubit is read here

Ideal circuit protocol. The lines are registers, not atom trajectories. One auxiliary qubit is reset and reused for each check.

1. Encode + noise
2. Read checks
3. Decode
4. Correct
5. Verify

Ready. Nothing recorded yet.

02 / What the records say

## A quiet check can still miss an error.

Ideal target-state verification, with pointwise 95% Wilson intervals. The unencoded comparator is an independent qubit exposed to the same memory channel and forced error.

$\text{—}$

$\text{—}$

03 / The decoder sees only the checks

## The same syndrome always gets the same suggested repair.

Multiple errors can imitate one correctable error. A flipped syndrome can trigger the wrong repair. The final target projection consumes the encoded state and is kept separate from the syndrome measurement.

04 / Save the evidence

## Compare complete recorded samples.

Most recent twelve trials shown. Export keeps every zero and every failed outcome. Save up to six samples, then restore their settings and records.

Code, fault model & scientific sources

Generators are measured through a fresh auxiliary qubit: Hadamard, controlled Pauli factors, Hadamard, readout. After each controlled gate the touched data qubit may receive a uniform Pauli fault. Ancilla propagation faults, leakage, correlated noise, encoding faults and verification faults are omitted. Memory noise acts independently on each data qubit before extraction. Correction gates are ideal.

$\text{—}$

The repetition code protects against bit flips only. The five-qubit code corrects any single-qubit error when the checks are perfect. The random error rates belong to one assumed noise model; they are not a hardware error breakdown or a fault-tolerance threshold. Resource counts cover the checks only, not encoding or verification circuits.

[IBM · Stabilizer codes](https://quantum.cloud.ibm.com/learning/en/courses/foundations-of-quantum-error-correction/stabilizer-formalism/stabilizer-codes) · [Laflamme et al. · Perfect quantum code](https://arxiv.org/abs/quant-ph/9602019)

Physics tutorial

## Quantum Error Correction

**Background** Move an error between encoded qubits, read the auxiliary checks and test the repair. Compare bit-flip protection with a five-qubit code.

**Why it matters** Predict from what you can actually observe, then check the prediction separately.

Start with the essentials

- **Focus question**: Can you find an error without reading the encoded message?
- **One-sentence intuition**: A stabilizer check reveals the error syndrome and leaves the logical superposition intact. The final target measurement asks a different question, and it destroys the state.

### Core mathematical model

#### The encoded message stays a superposition

$$
|\psi_L\rangle=\alpha|0_L\rangle+\beta|1_L\rangle,\qquad S_j|\psi_L\rangle=|\psi_L\rangle
$$

Encoding spreads the superposition over the code space. It does not clone the input into independent copies.

#### Syndrome check with an auxiliary qubit

$$
M_b=\frac{I+(-1)^b S_j}{2}
$$

A Hadamard on the auxiliary qubit, a controlled stabilizer and a final Hadamard carry out these projectors. The syndrome on screen is the classical readout, including any readout flips you selected.

#### When the repetition code fails

$$
P_{\rm fail}=3p^2(1-p)+p^3
$$

For an encoded zero state with independent bit-flip errors in memory and perfect syndrome extraction, the code fails only when two or three bits flip. It does not protect against phase errors, and it does not establish a fault-tolerant threshold.

#### Final check against the known state

$$
P_{\rm pass}=|\langle\psi_L|\psi_{\rm recovered}\rangle|^2
$$

The ideal projection onto the target state is sampled into pass or fail records. It is not a syndrome measurement, and it is not a general measure of logical error.

### Common difficulties

#### What was measured?

**Typical misconception** The syndrome is the logical message.

**Better mental model** The decoder sees only the auxiliary check bits. The final projection onto the known target is a separate test that destroys the state.

#### What a simulation can show

**Typical misconception** A successful simulated run certifies a device.

**Better mental model** The small register is simulated exactly, with one auxiliary qubit that is reused. Pauli faults in memory, faults after controlled gates that hit only data qubits and classical flips of the syndrome readout are set separately. Encoding and the final verification are ideal. A single round of syndrome extraction is not fault tolerant and does not establish a threshold.

### Run the experiment

1. 01

   #### Choose a comparison

   Repair a bit flip with the repetition code. Then keep the code and switch to a phase-sensitive input with a phase error.

   **What to observe:** The phase error can leave every check silent and still fail the final verification.

2. 02

   #### Run the full protocol

   Repeat the phase-error experiment with the five-qubit code. Follow syndrome extraction, decoding, correction and final verification one step at a time.

   **What to observe:** The syndrome from the auxiliary qubit picks the repair without reading the logical amplitudes.

3. 03

   #### Push the assumptions

   Remove the forced error and raise the gate or readout errors. Compare how often encoded and unencoded qubits survive, alongside the resources the checks use.

   **What to observe:** Noisy correction can make things worse. One round of these unprotected checks is not fault tolerant.

Physical conclusion

The small register is simulated exactly, with one auxiliary qubit that is reused. Pauli faults in memory, faults after controlled gates that hit only data qubits and classical flips of the syndrome readout are set separately. Encoding and the final verification are ideal. A single round of syndrome extraction is not fault tolerant and does not establish a threshold.

## Related experiments and articles

Quantum evidence · Reading path

### Clocks, traps and single-quantum control

Articles on this path that use this experiment, followed by the other experiments they suggest.

1. [Article **Keeping a chosen number of photons in a cavity**](https://sandboxphysics.com/stories/quantum-evidence/quantum-feedback-photon-number-verification/)
2. [Lab **Cavity Photon Counting & Feedback** Compare a limited feedback model with fresh verification data](https://sandboxphysics.com/labs/cavity-photon-qnd-feedback/)
3. [Lab **Decoherence Channels & Information Loss** Compare loss and dephasing](https://sandboxphysics.com/labs/decoherence-channels/)
4. [Lab **Quantum State & Process Tomography** Distinguish an estimated state from verification data](https://sandboxphysics.com/labs/quantum-state-process-tomography/)

Quantum evidence · Reading path

### Bell tests and photon information

Articles on this path that use this experiment, followed by the other experiments they suggest.

1. [Article **How Bell tests distinguish quantum correlations**](https://sandboxphysics.com/stories/quantum-evidence/bell-tests-correlations-loopholes/)
2. [Lab **Bell Correlations & CHSH** See how sampling and detector efficiency affect a Bell test](https://sandboxphysics.com/labs/bell-chsh/)
3. [Lab **Quantum State & Process Tomography** Reconstruct a quantum state from measurements](https://sandboxphysics.com/labs/quantum-state-process-tomography/)

Quantum & fields · Starter path

## Start from a single measurement

Predict an outcome, then count what the measurements actually give. The path starts with one qubit and moves on to wave packets, bound states and two-photon interference.

[Start here → **Quantum State & Born Measurement** Predict a probability, turn the analyzer, then compare your prediction with the measured frequency over many shots. Observe · 15 min](https://sandboxphysics.com/labs/qubit-state/)

1. [1 Quantum State & Born Measurement](https://sandboxphysics.com/labs/qubit-state/)
2. [2 Stern–Gerlach Sequence](https://sandboxphysics.com/labs/stern-gerlach-sequence/)
3. [3 Wave Packet & Uncertainty](https://sandboxphysics.com/labs/wave-packet-uncertainty/)
4. [4 Quantum Harmonic Oscillator](https://sandboxphysics.com/labs/quantum-harmonic-oscillator/)
5. [5 Which Path & Quantum Eraser](https://sandboxphysics.com/labs/quantum-eraser/)
6. [6 Hong–Ou–Mandel Two-Photon Interference](https://sandboxphysics.com/labs/hong-ou-mandel/)

[View the full path →](https://sandboxphysics.com/topics/quantum/#starter-path)
