The 3-qubit bit-flip code protects one logical qubit from an X (bit-flip) error by spreading it across three physical qubits:
|0⟩_L = |000⟩, |1⟩_L = |111⟩
|ψ⟩_L = cos(θ/2)|000⟩ + e^(iφ)sin(θ/2)|111⟩
Because the two branches always differ in every qubit, tracing out any two qubits leaves the third in a diagonal (mixed) state with Bloch vector (0,0,cosθ) — no single physical qubit carries the phase φ. That is the whole point: information about |ψ⟩ is stored only in the correlations between qubits, so a local error on one qubit cannot destroy it.
A bit-flip error is a Pauli-X applied to one physical qubit. Two parity checks (measured via ancillas in a real device, computed directly here) reveal which qubit flipped without ever measuring — and hence without collapsing — the encoded state:
s1 = Z0Z1, s2 = Z1Z2
(0,0) → no error (1,0) → error on Q0
(1,1) → error on Q1 (0,1) → error on Q2
Correction applies X to the flagged qubit, undoing a single error exactly. If two or three qubits flip at once, the syndrome misidentifies the culprit (or sees none), the "correction" can make things worse, and the logical qubit comes out bit-flipped. For independent per-qubit error probability p, the probability of an uncorrectable (≥2-error) event is:
P(fail) = C(3,2)p²(1−p) + p³ = 3p² − 2p³
- θ, φ sliders — choose the logical qubit's state and re-encode it into |000⟩/|111⟩.
- Apply Random Noise — each of the three physical qubits flips independently with probability p.
- Flip Q0/Q1/Q2 — manually toggle a specific qubit to explore the syndrome table by hand (try flipping two at once).
- Correct — applies the syndrome-indicated fix.
- Auto Trials — repeatedly encodes, injects noise, corrects and re-encodes, accumulating an empirical failure rate to compare against the 3p²−2p³ formula.
This exact code — and its dual, the phase-flip code obtained by conjugating with Hadamards — is the building block Shor's 9-qubit code combines to correct arbitrary single-qubit errors, and the same syndrome-extraction idea underlies the surface codes used in today's real superconducting quantum processors.