This is the same 3-qubit repetition code as the 3D Bloch-sphere version of this simulator, but computed and drawn a completely different way: instead of tracking two Bloch-sphere amplitude branches, this page runs a genuine 5-qubit statevector simulator (32 complex amplitudes: 3 data qubits q0,q1,q2 plus 2 syndrome ancillas a1,a2) and applies real gate matrices — CNOT and Pauli-X — exactly as a physical circuit would:
encode: CNOT(q0→q1), CNOT(q0→q2) |ψ⟩=α|0⟩+β|1⟩ on q0 → α|000⟩+β|111⟩
error: X on any subset of {q0,q1,q2} (the noise channel)
syndrome: CNOT(q0→a1), CNOT(q1→a1) a1 = q0⊕q1
CNOT(q1→a2), CNOT(q2→a2) a2 = q1⊕q2
measure: a1→s1, a2→s2 (projective, then reset to |0⟩)
correct: (s1,s2)=(1,0)→X q0 (1,1)→X q1 (0,1)→X q2 (0,0)→ none
decode: CNOT(q0→q2), CNOT(q0→q1) (inverse of encoding)
Because the two encoded branches |000⟩ and |111⟩ always have the same parity under Z₀Z₁ and Z₁Z₂, measuring a1 and a2 is provably non-destructive: it reveals which physical qubit flipped without collapsing the superposition α,β at all (verified below — fidelity stays exactly 1 after correcting any single error, for any α, β). If two or three qubits flip together, the syndrome misidentifies the culprit and the decoded logical qubit comes out flipped — the code's known failure mode. For independent per-qubit flip probability p, the chance of an uncorrectable (≥2-error) event is:
P(fail) = C(3,2)p²(1−p) + p³ = 3p² − 2p³
- Circuit diagram (top) — the actual gate sequence above, drawn wire-by-wire; red boxes mark qubits an X gate has hit, the ancilla meters show the measured syndrome once you run correction.
- Basis-state histogram (bottom-left) — |amplitude|² of each of the 8 data-register bitstrings 000…111, marginalized over the two ancillas, read directly off the live statevector.
- Failure-rate chart (bottom-right) — the analytic 3p²−2p³ curve versus p, with your current p and the running Monte-Carlo empirical rate plotted as a point.
- θ, φ sliders — choose the logical qubit's state and re-encode it.
- Apply Random Noise — each physical qubit flips independently with probability p.
- Flip Q0/Q1/Q2 — manually toggle a qubit to explore the syndrome table by hand (try flipping two at once).
- Run Syndrome + Correct — actually executes the ancilla CNOTs, measures them, and applies the indicated correction to the real statevector.
- Auto Trials — repeatedly re-encodes, injects noise at the current p, runs the full circuit and decodes, accumulating an empirical failure rate to compare against the 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.