# 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?

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 – bhapi May 17 at 16:58

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))$$

$$|\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.

• In general, asking questions in an answer is bad form (it's better to ask it in a new question and then write up the answer when you understand it completely), but I appreciate your attempt at writing a complete answer. :) – Sanchayan Dutta May 17 at 18:49
• @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 – bhapi May 17 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! – Sanchayan Dutta May 17 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. – DaftWullie May 20 at 8:35