# Quantum circuit for a three-qubit bit-flip code

I know a three-qubit bit-flip code has a common encoding circuit as follows,

Further, as in page 35 in Gottesman's paper, the encoding circuit can also be constructed through stabilizer generators. He illustrated the encoding circuit of the $$[5,1,3]$$ code, whose stabilizer generators are $$g_1=Y_1Z_2Z_4Y_5$$, $$g_2=X_2Z_3Z_4X_5$$, $$g_3=Z_1Z_2X_3X_5$$, $$g_4=Z_1Z_3Y_4Y_5$$.

So I think the encoding circuit of three-qubit bit-flip code can also be constructed by its stabilizer generators $$Z_1Z_2$$ and $$Z_2Z_3$$ as shown below.

But in this way the circuit is different from the one in the first picture and I do not think this is right.

You can actually, most of the time, prepare an encoded qubit state by using the stabilizers; you can also do this for the bit-flip code.

I have intentionally left the above sentence a little vague, because there are some very important subtleties. To really understand these subtleties, a good understanding of stabilizer codes is strongly preferred. If you don't feel comfortable enough with the subject, I advice you to read the first half of Gottesman's updated introduction on the subject instead of his thesis, which has outdated terminology and symbols and might feel a little more convoluted.

## Preparing code states through stabilizer measurement

The general idea behind 'using' the stabilizers to encode a codestate into a set of (data) qubits is that you perform the stabilizer measurements to project the state of said data qubits to the eigenspaces of the stabilizer generators. To perform these stabilizer measurements, one makes use of an ancilla qubit. In your second picture (on the $$[5,1,3]$$ code), this is the qubit labeled $$|c\rangle$$. It is not a data qubit. Actually, in that picture, only four of the five data qubits are depicted.

The text that I linked has a clear explanation on how to perform these measurements. The general idea behind these measurements is that we measure only the ancilla; the measurement outcomes are then associated with the $$+1$$ and $$-1$$ eigenspaces of the stabilizer generators.

In your last picture, you show three qubits, which I expect you to mean to be the three data qubits of the bit-flip code. Therefore, there is no ancilla in play here, and this is not a correct picture. You should add one extra qubit, prepare that in the $$|+\rangle$$ state, and then perform a controlled $$Z$$ operation to the first and second data qubit. Upon measurement of the ancilla in the $$X$$ basis, you will have mapped to either subspace of the $$Z_{1}Z_{2}I_{3}$$ generator. I refer to the aforementioned text for further explanation (I can repeat that here but I think you can really benefit from reading that text).

## Does this process, in general, give us any encoded state?

Another subtlety lies in the fact that this method of 'mapping to the codespace' does not give us any way of knowing which codestate we end up with. All we have done is map to the codespace. There even is a minute probability that the original state on our data qubits was perfectly orthogonal to the codespace; mathematically speaking we then end up with the null vector. In general, this will not happen often if the initial state of the qubits is $$|0\rangle^{\otimes n}$$, because for most codes that state is part of some codestate. (Of course, for the bit-flip code it exactly is a codestate, usually labeled as the logical $$|0\rangle$$ state).

The important thing to realize is that if we want to encode some single-quibit state $$|\psi\rangle$$ of only one of the data qubits into the corresponding codestate on all data qubits, stabilizer measurements are not the way to go to perform this for general states $$|\psi\rangle$$.

• Thank you so much. I think Gottesman's updated introduction describes the error correction process rather than the encoding process of a three-qubit bit-flip code among nine-qubit code, as shown in page $8$. So I did understand it wrong before. I thought $|c\rangle$ acts like a controlled logical qubit. If it is $|0\rangle$, then all five qubits would span a logical state $|0\rangle_L$; similarly $|1\rangle\rightarrow |1\rangle_L$. Dec 13 '19 at 2:11
• If I understand correctly this time that encoding by stabilizers could only generate a codespace without knowing the specific state, then is there a unified way to encode a known single qubit state into a $n$-qubit logical state? Dec 13 '19 at 2:12
• I will try and answer these questions tomorrow. I will update the above answer
– JSdJ
Dec 13 '19 at 2:27

I think this circuit performed by generators $$Z_1Z_2$$ and $$Z_1Z_3$$ works.

When $$|\psi\rangle=|0\rangle$$, it can have the logical state $$|000\rangle$$; and when $$|\psi\rangle=|1\rangle$$ the logical state is $$|111\rangle$$.