---
title: "Recovering a superposition after two qubits are lost"
description: "Construct the five-qubit code, calculate erasure and recovery, and see why several boundary regions can represent one logical operator."
canonical_url: "https://sandboxphysics.com/stories/holography/encoding-and-recovery/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/holography/encoding-and-recovery/"
last_modified: "2026-10-28"
---

[Holography and quantum gravity](https://sandboxphysics.com/stories/holography/)

L3 · Chapter 6

# Recovering a superposition after two qubits are lost

Sandbox Physics · 2026-10-28

A five-qubit code can recover an unknown quantum state after any two known sites are erased. It preserves the relative phase as well as the populations. The information resides in joint correlations. Constructing a small code gives boundary reconstruction a meaning that we can calculate and test one step at a time.

## Before you begin

Read the earlier density-matrix and entanglement chapter first. Two-by-two matrix multiplication is needed. Tensor products, stabilizers, isometries and recovery channels are introduced here. Five qubits have thirty-two basis states, but the encoding uses only two orthonormal codewords.

- Construct a two-dimensional code subspace from four stabilizers and explain why its encoding preserves inner products.
- Recover a complex superposition after erasure and distinguish state recovery, operator representation and copying.

## Store the information in joint correlations

To distribute an unknown quantum state, making several spare copies might seem natural. Perfect copying of arbitrary unknown states is forbidden. An encoding instead embeds the input in a larger joint state. One site can look completely random even though a suitable group of sites retains everything.

Call the encoding $V$. It maps the two-dimensional logical space into the thirty-two-dimensional space of five physical qubits. Its basis states become $|0_L\rangle$ and $|1_L\rangle$. Orthogonal normalized codewords preserve the inner product of every superposition. Such a map is an isometry. The allowed encoded states occupy a two-dimensional subspace inside the larger physical space.

$$
\begin{aligned}V|0\rangle&=|0_L\rangle,\quad V|1\rangle=|1_L\rangle\\V^\dagger V&=I\end{aligned}
$$

An isometry can increase dimension. A decoder only needs to invert it on the code subspace.

Source: Fernando Pastawski · Ahmed Almheiri

## Select two codewords with four conditions

Pauli $X$ exchanges zero and one. Pauli $Z$ leaves the zero amplitude unchanged and reverses the sign of the one amplitude. A tensor product of five such operators acts on five separate sites. The following four stabilizer generators commute and square to the identity.

A code state is unchanged by every stabilizer: it lies in their common positive-one eigenspace. The projector $(I+S_j)/2$ keeps the positive part of a state and removes the negative part. These four independent conditions each halve the dimension, leaving $32/2^4=2$ dimensions.

Begin with the all-zero basis state, apply all four projectors and normalize. This produces $|0_L\rangle$. Flip all five sites to obtain $|1_L\rangle$. The first has positive eigenvalue under the product of five $Z$ operators; the second has negative eigenvalue, so they are orthogonal. This procedure constructs the encoding without guessing a list of thirty-two amplitudes.

$$
\begin{aligned}S_1&=X\otimes Z\otimes Z\otimes X\otimes I\\S_2&=I\otimes X\otimes Z\otimes Z\otimes X\\S_3&=X\otimes I\otimes X\otimes Z\otimes Z\\S_4&=Z\otimes X\otimes I\otimes X\otimes Z\end{aligned}
$$

Sites run from one through five, left to right. Each row describes one five-qubit operation.

$$
\begin{aligned}P&=\prod_{j=1}^4\frac{I+S_j}{2}\\|0_L\rangle&=\frac{P|00000\rangle}{\|P|00000\rangle\|}\\|1_L\rangle&=X^{\otimes5}|0_L\rangle\end{aligned}
$$

The projected vector is nonzero. Flipping the logical input corresponds to flipping all five physical qubits.

Source: Fernando Pastawski

## Recover a superposition with an imaginary phase

For a complete worked example, choose $|\psi\rangle=(|0\rangle+i|1\rangle)/\sqrt2$. Its zero and one probabilities are equal, but its relative phase distinguishes it from the equal real superposition. Its Pauli expectation values are $(0,1,0)$. Erase sites one and three, called region $E$. Sites two, four and five form the surviving region $A$.

Erasure traces out $E$. It sums over all four erased basis states without selecting a measurement outcome. Define $A_e=\langle e|_E V$. The channel below computes the surviving state. Only that reduced density matrix and the known erased positions enter the decoder. The decoder receives no copy of the input.

The code obeys $A_e^\dagger A_f=\delta_{ef}I/4$. Consequently the eight vectors $2A_e|i\rangle$ are orthonormal: two choices of $i$ times four choices of $e$. They define a unitary change of basis $U_A$ on the three surviving qubits. In this basis, their state factors into the logical input and a four-dimensional maximally mixed auxiliary state.

Apply $U_A^\dagger$ and discard the auxiliary factor. The recovered matrix is exactly the input matrix, including its imaginary off-diagonal entries. The recovered $Y$ expectation remains one, and the fidelity is one. Agreement of the zero and one probabilities alone would miss this phase-sensitive test.

$$
\mathcal N_E(\rho)=\sum_{e=0}^3 A_e\rho A_e^\dagger
$$

Each Kraus matrix has eight rows and two columns. It maps the logical input into the surviving three-qubit space.

$$
\begin{aligned}\rho_A&=U_A\left(\rho\otimes\frac{I_4}{4}\right)U_A^\dagger\\\mathcal R_A(\rho_A)&=\operatorname{Tr}_{\rm aux}(U_A^\dagger\rho_AU_A)\\&=\frac12\begin{pmatrix}1&-i\\i&1\end{pmatrix}\end{aligned}
$$

This is an explicit decoder for the correctable erasure. The Lab uses the Petz transpose channel, which gives the same recovery on encoded outputs, and evaluates it on the actual reduced matrix.

Source: Fernando Pastawski · Ahmed Almheiri

## Represent one logical operation on different regions

A decoder also tells us how to perform a logical operation using only the surviving region. Change basis on $A$, apply the desired operation to the logical factor, then change back. The resulting physical operator $O_A$ acts on every encoded state as though we had operated on the input before encoding.

Changing the erased pair can produce another physical operator on a different region. These operators agree on the code subspace. Their action on other physical states may differ. Multiple boundary representations are therefore a precise statement about a specified set of states.

$$
(O_A\otimes I_E)V=VO
$$

The final encoding map specifies the subspace on which the equality holds. Removing it would assert an equality on a larger space that recovery does not provide.

Source: Ahmed Almheiri

## Erase one more site

Any three sites suffice, but any two alone contain no input information. Erase site five as well. The density matrix of sites two and four is always maximally mixed, independent of input phase or population. Their decoder cannot distinguish the possible inputs.

The implemented recovery returns $I_2/2$, with fidelity $1/2$ against every pure input. This also clarifies why recovery does not clone. Five sites cannot contain two disjoint three-site recovery regions. The regions overlap and cannot be handed to two separate decoders as independent registers.

Known erasure also gives the decoder useful location information. This distance-three code corrects two known erasures or one arbitrary unknown single-qubit error. These are different tasks with different information available to the decoder.

## Use one tensor as a building block

Draw the logical input as one more leg and the encoding becomes a six-leg tensor. Entangle the logical input maximally with a reference qubit. The resulting six-qubit state is maximally entangled across any three-against-three partition. Such a tensor can be read as an isometry in several directions, up to normalization, and is called perfect.

The HaPPY model places these tensors on a pentagon tiling of hyperbolic space and contracts neighboring legs. Larger networks connect subregion recovery with minimal cuts. Our single building block makes the distribution of quantum information explicit. Continuum field operators, dynamics and geometry require further structure. The next chapter returns to continuous geometry and asks how quantum entanglement corrects an area-only entropy formula.

Source: Fernando Pastawski

## Try the reasoning

### [Test recovery with phase, then make it fail](https://sandboxphysics.com/labs/boundary-quantum-code/)

1. Choose Protect a relative phase and predict the three components. Turn Input relative phase from $\pi/2$ to $-\pi/2$, a positive to negative quarter-turn, and compare input and recovery.
2. Choose Two sites lost and erase another pair. Explain why success for one input is weaker than preserving the whole code subspace.
3. Choose Too little survives and vary the population angle. Save a simulation record and use the actual surviving and decoded matrices to explain where the information was lost.

## Exercises and explanations

1. Equal real and imaginary superpositions both give zero and one probabilities of $1/2$. Why is agreement of those probabilities insufficient?

   Read the explanation

   Their off-diagonal matrix entries differ. The real superposition has $X=1$; the imaginary superposition has $Y=1$. Complete dephasing preserves both populations but removes both expectation values. Test phase-sensitive components or the full density matrix.

2. Why does checking all four logical matrix units test preservation of arbitrary entanglement with a reference?

   Read the explanation

   The four units $|i\rangle\langle j|$ span every two-by-two matrix. Expand any joint state in them, with reference operators as coefficients. A linear channel that preserves each unit also preserves the entire joint state.

3. Why do two three-site recovery regions not yield two independent copies?

   Read the explanation

   They overlap and both require control of shared physical sites. Decoding one region acts on those shared systems and changes the state and correlations needed by another independent attempt.

[Previous: How two intervals can share a bulk region](https://sandboxphysics.com/stories/holography/intervals-and-wedges/) [Next: How quantum corrections move an extremal surface](https://sandboxphysics.com/stories/holography/quantum-extremal-surfaces/)

## Sources and recalculated scope

The course derives its worked examples and draws its own schematics. The numerical references recalculate specified analytic geometry and a finite five-qubit encoding. The source locations below distinguish those calculations from theoretical reading topics.

1. [Fernando Pastawski, Beni Yoshida, Daniel Harlow and John Preskill, Holographic quantum error-correcting codes, arXiv:1503.06237v2; JHEP 06 (2015) 149](https://arxiv.org/html/1503.06237v2)

   Section 2 defines perfect tensors; Appendix A.1, equations (30)–(32), supplies the five-qubit code. We construct one tensor from its stabilizers and recalculate known-erasure recovery. The browser does not build the many-pentagon network or reproduce its greedy thresholds.

2. [Ahmed Almheiri, Xi Dong and Daniel Harlow, Bulk Locality and Quantum Error Correction in AdS/CFT, arXiv:1411.7041v3; JHEP 04 (2015) 163](https://arxiv.org/html/1411.7041v3)

   Sections 3–4: the code-subspace interpretation of bulk reconstruction and quantum secret sharing. Used for the conceptual operator discussion, not claimed as a numerical reproduction of a CFT.
