Coherent syndrome extraction for the three-qubit repetition code (source code)

= Coherent syndrome extraction for the three-qubit repetition code
{title2=$(s_4,s_5)=(b_2\oplus b_3,b_1\oplus b_3)$}

Encode $u|0\rangle+v|1\rangle$ as $u|000\rangle+v|111\rangle$. Four <controlled-NOT gates> copy the displayed two data parities into initially zero <quantum ancillas>. No logical amplitude is measured. The <error syndromes> $00,01,10,11$ correspond respectively to no bit flip and bit flips on data qubits $1,2,3$. Conditional <Toffoli gates>, with temporary <Pauli X gates> implementing zero-valued controls, undo the indicated error. Inverse encoding yields the original logical state and a separate syndrome state. A phase flip has zero bit-flip syndrome and remains as a logical phase error; this three-qubit code is not a general single-qubit-error code.