# How to measure syndromes in QEC

Shor's $$9$$ Qubit code. Imagine that we encode the state $$|\psi \rangle =α|0\rangle+β|1\rangle$$ using Shor's $$9$$ qubit code, then an $$X$$ error occurs on the 8th qubit of the encoded state $$|E(\psi) \rangle$$

This is

$$\frac{1}{2 \sqrt2}( \alpha (| 000 \rangle + | 111 \rangle) ( | 000 \rangle + | 111 \rangle) ( | 010 \rangle + | 101 \rangle) \\ + \beta ( | 000 \rangle - | 111 \rangle)( | 000 \rangle - | 111 \rangle)( | 010 \rangle - | 101 \rangle))$$

We now decode the encoded state, starting by applying the bit-flip code decoding algorithm.

How do you find the syndromes measured by the algorithm, see https://people.maths.bris.ac.uk/~csxam/teaching/qc2020/lecturenotes.pdf?

• For sure I'm late, but you can play around with this code and check step by step what is being done in the Shor's 9-qubit algorithm for correcting quantum errors: github.com/sebastianvromero/qecc_shor9q . Cheers! Apr 5, 2021 at 23:47

Is it clear how the syndrome measurement for $$3$$ qubit bit-flip code is done that is described in the same source with this circuit? If yes then is it clear how this can be done for $$9$$ qubit code with this circuit for bit-flip error? If no here are some ideas that might help.

A toy model example about what is happening in these codes. Imagine we have a Bell state $$|\psi \rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$. Imagine there is a probability that we will have an $$X$$ error (bit-flip error) on one of the qubits and we want to know if we had an error. Here is the circuit constructed with help of IBM quantum experience:

This is not an error-correcting code, this is a toy model on which one can see how syndrome measurement can be done. In the error detection part if we will not have an error (we assume the possibility of only one error) then the measurement will yield $$0$$, otherwise, if we will have an error then we will measure $$1$$. If we had an error, then applying an $$X$$ gate on one of the qubits will recreate the initial $$|\psi \rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$.

The bit-flip error detecting part here (and in $$3$$ qubit bit-flip code or $$9$$ qubit code) is a parity check: checks if there are even number of $$1$$s in the $$2$$ controlling qubits. So if we have $$|00 \rangle$$ or $$|11\rangle$$ (or $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle$$)) the parity is even and the output qubit will be in $$|0\rangle$$ state. If we have $$|01 \rangle$$ or $$|01\rangle$$ (or $$\frac{1}{\sqrt{2}}(|01\rangle + |01\rangle$$)) the parity is odd and the output qubit will be in $$|1\rangle$$ state. If this part is clear I suggest looking at two circuit links (created with quirk) provided at the beginning of the answer.

For the error on the $$8$$th qubit. For $$9$$ qubit code there are $$6$$ parity check measurements for $$6$$ pairs of qubits that can be seen in the mentioned circuit. The parity between all $$6$$ pairs of qubits is even when we don't have an error and the measured syndrome is $$00,00,00$$. If an $$X$$ error is acquired, one or two parities will be odd and we will notice it in sydrome measurement procedure. For the example mentioned in the question ($$8$$th qubit got an error) the parity is odd for last two pairs of qubits that is why we will measure $$00,00,11$$ syndrome. If $$9$$th qubit has an error the parity will be odd only for the last pair of qubits (last two qubits) and the syndrome will be $$00,00,01$$. If the error has acquired on the $$7$$th qubit then the syndrome will be $$00,00,10$$, because the parity is odd only for the penultimate pair of qubits (pair that consists of $$6$$th and $$7$$th qubits). If we know on which qubit an $$X$$ error has acquired we can apply on that qubit an $$X$$ gate that will correct the acquired error.

The parity checks for Shore's $$9$$ qubit code can also be done with this circuit by using an operator measurement technique.

• This is difficult stuff, thanks Dec 15, 2020 at 14:31
• @Trajan, you are welcome. Dec 18, 2020 at 8:52