---
title: "Boundary Quantum Error Correction Interactive Lab | Sandbox Physics"
description: "How much of an encoded quantum state can be erased and still recovered? This five-qubit code recovers an arbitrary input after any two known erasures."
canonical_url: "https://sandboxphysics.com/labs/boundary-quantum-code/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/boundary-quantum-code/"
last_modified: "2026-10-28"
---

FR09-C · A state spread over five sites

# Boundary Quantum Error Correction

**How much of an encoded quantum state can be erased and still recovered?** This five-qubit code recovers an arbitrary input after any two known erasures. The surviving three sites preserve both populations and relative phase. If only two sites survive, their state carries no information about the input.

Erase sites around a five-qubit encoding and compare the recovered state with the input. Change the input phase to test whether the quantum information survives.

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

Model assumptions

An exact five-qubit stabilizer code encodes one logical qubit. Erasure means tracing out a known set of sites. Recovery uses the Petz transpose channel with a maximally mixed logical prior. The diagram represents one finite perfect tensor, with no spatial metric or gravitational dynamics.

Exact finite-code calculation

## Compare all three state components

Gold is the input; teal is the recovered state. The three Pauli expectation values specify a qubit, including its relative phase.

Recovered density matrix and recovery condition

$\rho_{\rm recovered}=\begin{pmatrix}0.704&0.343-0.301i\\0.343+0.301i&0.296\end{pmatrix}$

$A_e^\dagger A_f=c_{ef}I$

The residual measures the largest failure of this erasure-correction condition for the displayed channel. Zero allows one recovery map to preserve every logical state, including entanglement with an external reference.

Physics tutorial

## Boundary Quantum Error Correction

**Background** An unknown qubit has both populations and a relative phase. Encoding spreads that information over a larger state. A small part can reveal nothing even when the larger state remembers everything.

**Why it matters** This five-qubit code is the building block of a finite tensor-network model of holographic encoding. Losing a known site gives a precise test of what the remaining sites contain.

Start with the essentials

- **Focus question**: How much of an encoded quantum state can be erased and still recovered?
- **One-sentence intuition**: Three surviving sites jointly preserve the logical qubit, although any pair alone contains no information about it.

### Core mathematical model

#### An isometric encoding

$$
\begin{aligned}V|\psi\rangle&=\cos\frac{\vartheta}{2}|0_L\rangle\\&\quad+e^{i\varphi}\sin\frac{\vartheta}{2}|1_L\rangle\\V^\dagger V&=I\end{aligned}
$$

The two logical codewords are orthonormal five-qubit states. The polar angle sets the populations; the azimuth sets the relative phase.

#### Erase by tracing out a site

$$
\begin{aligned}\mathcal N_E(\rho)&=\operatorname{Tr}_E(V\rho V^\dagger)\\&=\sum_e A_e\rho A_e^\dagger\end{aligned}
$$

The erased outcomes are summed over without conditioning on a measurement. Recovery receives only this reduced density matrix and the list of lost positions.

#### Test the whole logical subspace

$$
\begin{aligned}A_e^\dagger A_f&=c_{ef}I\\\rho_{\rm out}&=\mathcal R_E(\mathcal N_E(|\psi\rangle\langle\psi|))\\F&=\langle\psi|\rho_{\rm out}|\psi\rangle\end{aligned}
$$

The first condition tests whether the erased subsystem can distinguish logical states. When it holds, a recovery channel preserves every input and its entanglement with a reference. Fidelity compares the displayed recovered state with the chosen pure input.

### Common difficulties

#### The information is shared across sites

**Typical misconception** Each site holds a spare copy of the input.

**Better mental model** Any one or two sites have an input-independent state. The logical information is in joint correlations. Two disjoint groups of three sites cannot fit into a five-site code, so the recovery regions cannot make two independent copies.

#### Known erasure differs from unknown damage

**Typical misconception** Recovering two erased sites means any two unknown errors can also be corrected.

**Better mental model** Erasure tells the decoder which positions are missing. This distance-three code corrects two known erasures or one arbitrary unknown single-qubit error.

### Run the experiment

1. 01

   #### Start with two lost sites

   Predict whether the relative phase survives. Choose Two sites lost, then drag the gold dial.

   **What to observe:** All three recovered components follow the input. The survivors preserve a superposition as well as a basis state.

2. 02

   #### Lose one more

   Choose Too little survives, then move both input sliders.

   **What to observe:** The input bars move, but every recovered component stays zero. With only two sites, the recovery returns the maximally mixed logical state and fidelity is one half.

3. 03

   #### Try another erased pair

   Reset. Click the erased sites to restore them, then erase a different pair. Save a simulation record.

   **What to observe:** Every pair gives exact recovery. The file contains the encoded complex amplitudes, surviving density matrix and recovered result for that input.

Physical conclusion

Test an encoding with phase-sensitive inputs and an explicit recovery channel; basis-state agreement alone leaves quantum information untested.

## Related experiments and articles

Holography and quantum gravity · Reading path

### From AdS signals to entanglement geometry and quantum recovery

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

1. [Article **Why half of a pure quantum state can look random**](https://sandboxphysics.com/stories/holography/entanglement-and-heat/)
2. [Article **Recovering a superposition after two qubits are lost**](https://sandboxphysics.com/stories/holography/encoding-and-recovery/)
3. [Article **Read a holography paper through a small calculable model**](https://sandboxphysics.com/stories/holography/reading-the-models/)
4. [Lab **AdS Interval Entanglement** Recalculate an analytic slice](https://sandboxphysics.com/labs/ads-interval-entanglement/)

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)
