# Shor 9 qubit code — how are the observables measured and eigenvalues obtained during syndrome measurement?

Say we have the Shor 9 qubit code

$$|\psi_L\rangle=\tfrac{1}{\sqrt{2^3}}((|000\rangle+|111\rangle)^{\otimes3}+(|000\rangle-|111\rangle)^{\otimes3}),$$

and we have a bit flip error. My lecture notes say that error syndromes are obtained by measuring the observables:

$$Z_1Z_2,Z_2Z_3,Z_4Z_5,Z_5Z_6, Z_7Z_8,Z_8Z_9.$$

Which will give eigenvalues +1 if the two adjacent qubits in the block are the same and -1 if they are different.

1. How does one measure the observables?

2. How are the eigenvalues obtained?

• Maybe it's not related on what is being asked, 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:26

Note that measuring an observable is equivalent to projecting the quantum state into a particular eigenspace of the operator, and the measurement result tells you which eigenspace. So, in the case of measuring an observable on an eigenstate of that observable, you just project the state onto itself, and the outcome tells you the eigenvalue. So, (2)is equivalent to (1).

In terms of how to actually measure an observable, there's a standard technique if the observable $$O$$ is such that $$O^2$$ is the identity (such as a tensor product of Pauli matrices, as is the case here). I described this in a previous answer, but add it here for completeness: Basically, you add an ancilla (the top qubit)for each observable, perform the circuit, and then measure the ancilla in the 0/1 basis. 0 corresponds to the +1 eigenvalue of the operator $$O$$, while 1 corresponds to the -1 eigenvalue.

• I added an answer below trying to follow you, I'm a little bit stuck at the end though would you mind having a look May 17, 2019 at 16:58
• I created a quirk circuit to show off the ZZ syndromes. You can move the X error (between the ...-s) around and see how they light up. Aug 11, 2020 at 19:30

So say we have the encoded single qubit

$$|\psi_L\rangle=\tfrac{c_0}{\sqrt{2^3}}(|000\rangle+|111\rangle)^{\otimes3}+\tfrac{c_1}{\sqrt{2^3}}(|000\rangle-|111\rangle)^{\otimes3},$$

And then say a bit flip occurs on the 4th qubit so now we have

$$|\psi_L \rangle=\tfrac{c_0}{\sqrt{2^3}}((|000\rangle+|111\rangle)\otimes(|100\rangle+|011\rangle)\otimes(|000\rangle+|111\rangle))+\tfrac{c_1}{\sqrt{2^3}}((|000\rangle-|111\rangle)\otimes (|100\rangle-|011\rangle)\otimes (|000\rangle-|111\rangle))$$

Then we add the ancilla qubit $$|0\rangle$$, giving

$$|\psi_i \rangle=\tfrac{c_0|0\rangle}{\sqrt{2^3}}((|000\rangle+|111\rangle)\otimes(|100\rangle+|011\rangle)\otimes(|000\rangle+|111\rangle))+\tfrac{c_1|0\rangle}{\sqrt{2^3}}((|000\rangle-|111\rangle)\otimes (|100\rangle-|011\rangle)\otimes (|000\rangle-|111\rangle))$$

Performing the first Hadamard gate in your diagram gives

$$|\psi_i \rangle=\tfrac{c_0(|0\rangle+|1\rangle)}{\sqrt{2}\sqrt{2^3}}((|000\rangle+|111\rangle)\otimes(|100\rangle+|011\rangle)\otimes(|000\rangle+|111\rangle))+\tfrac{c_1(|0\rangle+|1\rangle)}{\sqrt{2}\sqrt{2^3}}((|000\rangle-|111\rangle)\otimes (|100\rangle-|011\rangle)\otimes (|000\rangle-|111\rangle))$$

Performing $$Z_4Z_5$$ gives

$$|\psi_i \rangle=\tfrac{c_0(|0\rangle+|1\rangle)}{\sqrt{2}\sqrt{2^3}}((|000\rangle+|111\rangle)\otimes(-|100\rangle+|011\rangle)\otimes(|000\rangle+|111\rangle))+\tfrac{c_1(|0\rangle+|1\rangle)}{\sqrt{2}\sqrt{2^3}}((|000\rangle-|111\rangle)\otimes (-|100\rangle-|011\rangle)\otimes (|000\rangle-|111\rangle))$$

Performing the second Hadamard gate gives

$$|\psi_i \rangle=\tfrac{c_0|0\rangle}{\sqrt{2^3}}((|000\rangle+|111\rangle)\otimes(|100\rangle+|011\rangle)\otimes(|000\rangle+|111\rangle))+\tfrac{c_1|0\rangle}{\sqrt{2^3}}((|000\rangle-|111\rangle)\otimes (|100\rangle-|011\rangle)\otimes (|000\rangle-|111\rangle))$$

Now we take a measurement in the $$\{|0\rangle, |1\rangle\}$$ basis. At this point I'm confused. Does it mean that we use a projective operator, say for $$|1\rangle$$, $$P_1=|1\rangle \langle1|$$, then we see what the probability of this is using $$\langle\psi| P_1 |\psi\rangle$$? And if the probability is 1 then the eigenvalue is -1, and if its zero the eigenvalue is +1.

Note: When I understand it fully I'll edit this so it's a complete answer.

• @SanchayanDutta ah okay, I'll know for next time, on math stack exchange theyve berated me for asking too similar a question , even if it was a more fleshed out version with minor alterations to what I'm asking so I thought it'd be the same here. All the stack exchanges have little differences like that about what they like in can be tricky to keep up XD, but thanks for the friendly heads up May 17, 2019 at 18:52
• Np. Well, the optics is a bit different on Mathematics I guess. They're a large site with 500+ questions per day, and they've to deal with spam and duplicates swiftly. OTOH here we can afford to be a bit more lax (as long as the traffic is low); we hardly close questions as duplicates as long as they're not asking exactly the same thing. Nevertheless, I do agree that it can be hard to keep up with the different site cultures as a newcomer. If you're ever unsure about anything on Quantum Computing, feel free to drop by Quantum Computing Chat! May 17, 2019 at 18:57
• you don't perform $Z_4Z_5$. Instead, you perform $Z_4Z_5$ controlled off the extra qubit. This is equivalent to two controlled-phases, both controlled off the extra qubit, and targeting qubits 4 and 5 respectively. May 20, 2019 at 8:35