= Solution
Number the physical wires $1,\ldots,5$ from top to bottom and write a <computational basis> ket in that order. The first four are <ancilla qubits> and the fifth carries the input. It is enough to follow the basis input $|b\rangle$, $b\in\{0,1\}$, because the encoding <quantum circuit> acts linearly.
The first fan-out consists of four <controlled-NOT gates> from wire 5 to wires 1–4. It sends $|0000b\rangle$ to $|bbbbb\rangle$. The three <Hadamard gates> then give
$$
\frac1{\sqrt8}\sum_{a,c,d\in\{0,1\}}(-1)^{b(a+c+d)}|acd\,bb\rangle.
$$
The two <Pauli X gates> on wires 2 and 3, followed by a <Controlled-Z gate> and the same two X gates, restore the bits but contribute $(-1)^{(1-c)(1-d)}$: the sign is negative exactly when the original bits on both wires were zero. Finally, the right-hand <controlled-NOT gates> are $3\to4$, $2\to5$, $1\to4$ and $1\to5$. They leave the first three bits unchanged and turn the last two into $b\oplus a\oplus d$ and $b\oplus a\oplus c$. Thus
$$
\boxed{|b_L\rangle=\frac1{\sqrt8}\sum_{a,c,d\in\{0,1\}}(-1)^{b(a+c+d)+(1-c)(1-d)}|a,c,d,b\oplus a\oplus d,b\oplus a\oplus c\rangle.}
$$
Explicitly, the logical basis <quantum states> produced by the printed gates are
$$
\begin{aligned}
|0_L\rangle=\frac1{\sqrt8}\bigl(&-|00000\rangle+|00110\rangle+|01001\rangle+|01111\rangle\\
&-|10011\rangle+|10101\rangle+|11010\rangle+|11100\rangle\bigr),\\
|1_L\rangle=\frac1{\sqrt8}\bigl(&-|00011\rangle-|00101\rangle-|01010\rangle+|01100\rangle\\
&+|10000\rangle+|10110\rangle+|11001\rangle-|11111\rangle\bigr).
\end{aligned}
$$
Each has eight orthogonal terms of equal magnitude, and their supports are disjoint, so they are normalized and mutually orthogonal. The arbitrary input is therefore encoded as
$$
\boxed{\alpha|0\rangle+\beta|1\rangle\longmapsto\alpha|0_L\rangle+\beta|1_L\rangle.}
$$
This is a realization of the <five-qubit error correcting code>. The input amplitudes and their relative <quantum phase> are preserved in the logical subspace; the encoding is an entangled-state <linear isometry>, not five independent copies of the unknown input. The explicit signs and bit ordering above are fixed by this circuit, rather than by a convention for a different encoder.
Back to article page