# Can Shor's 9 Qubit Code Correct for a measurement on the first qubit?

Start with Shor's codeword for $$|0 \rangle$$:

$$|\psi\rangle = \frac{1}{\sqrt{8}}(|000\rangle + |111\rangle)\otimes(|000\rangle + |111\rangle)\otimes(|000\rangle + |111\rangle)$$.

Now, assume that instead of an $$X$$ flip or a $$Z$$ flip, the first qubit is measured. Can Shor's error correction algorithm correct for this error and recover the original $$|0\rangle$$? Show the calculations to justify your answer.

My guess is that it can succesfully correct, because of the Deferred Measurement Principle.

My attempt at a solution: Let's say that the result of the measurement of the first qubit is $$|0\rangle$$. Thus the entire state collapses to:

$$|\psi_0\rangle = \frac{1}{\sqrt{4}}(|000\rangle)\otimes(|000\rangle + |111\rangle)\otimes(|000\rangle + |111\rangle)$$.

In step 1 we detect and correct for $$X$$ errors. Since there is no bit flip, this step doesn't change the state.

In step 2 we look for $$Z$$ errors. My question is, how to calculate a phase-flip check on $$|\psi_0\rangle$$, and how do I interpret the result to correct the error? Same question for the state after measuring $$|1\rangle$$.

Thanks!

You can think of this measurement as an 'error' on the (encoded) state that needs to be corrected. Quantum error correction is all about subspaces of the Hilbert space, and during QECC we are always trying achieve information in what subspace our state lies.

The state lies in some subspace, which is either the codespace or some orthogonal space. With every space we identify an error (with the codespace it is the trivial 'error' - $$I$$). There are many other errors that map to a specific codespace, but we cannot always* correct for these errors.

For the $$9$$-bit Shor code, the subspaces are those associated with all the single-qubit bit flips $$X_{i}$$, and furthermore with all the single qubit phase flips $$Z_{i}$$. There is some degeneracy in the code where there are cases that sometimes you can correct mulitple (correlated!) $$Z$$-flips, but we'll disregard that in our discussion.

Now we are ready to investigate our measurement: after measureing, the state $$|\psi_{0}\rangle$$ does not lie in any of the subspaces associated with the $$9$$-bit Shor code, but it is rather a specific superposition:

$$\begin{equation} \begin{split} |\psi_{0}\rangle = &\frac{1}{2}|000\rangle \otimes \big(|000\rangle+|111\rangle\big) \otimes \big(|000\rangle+|111\rangle\big) \\ = &\frac{1}{4}\big(|000\rangle+|111\rangle\big) \otimes \big(|000\rangle+|111\rangle\big) \otimes \big(|000\rangle+|111\rangle\big) \\ +& \frac{1}{4}\big(|000\rangle-|111\rangle\big) \otimes \big(|000\rangle|111\rangle\big) \otimes \big(|000\rangle+|111\rangle\big) \\ = & \frac{1}{\sqrt{2}}\big(|\psi\rangle + Z_{1}|\psi\rangle\big) = \frac{1}{\sqrt{2}}\big(|\psi\rangle + Z_{2}|\psi\rangle\big) = \frac{1}{\sqrt{2}}\big(|\psi\rangle + Z_{3}|\psi\rangle\big), \end{split} \end{equation}$$

We thus see that the state $$|\psi_{0}\rangle$$ is a superposition of no error having happened, and of a phase flip on either the first, second or third having happened.

Measuring out stabilizers will not only collapse this superposition to either of the two (so either no error or a phase flip), the measurement outcome (the error syndrome) will also indicate what subspace we have projected to. The correction is then straightforward.

If the measurement on qubit $$1$$ resulted in the state $$|1\rangle$$, we obtain a different 'superposition of subpsaces'. It is not that different though (the $$+$$ in the beginning of the third line changes to a $$-$$), and the code doesn't really 'care': it projects all the same, to the same kind of subspaces. The correction process is therefore (in this particular case) exactly the same.

*I say not always, because it depends if the error acts the same as the correctable error on the codespace or not - if it acts the same (then it only differs from the correctable error by a stabilizer) then it is correctable.