# The statevector of the quantum circuit

I have tried to solve this problem many times. But I can't solve this. Please somebody help me.

(prep has no meaning)

$${O_1}$$ : $$O_2$$:

1. What is the state vector $$|\psi\rangle$$ (for qubits 1 and 2) after measuring $$O_1$$, the observable $$X\otimes X$$ (at the 2nd barrier)? Assume the outcome of the measurement is 0.
2. Assume the measurement is 1. what is the state vector?
3. What is the state vector $$|\psi\rangle$$ (for qubits 1 and 2) after measuring $$O_2$$, the observable $$Z\otimes Z$$ (at the 4th barrier)?

After the first Hadamard gate you have the state $$\frac{1}{\sqrt{2}}(|000\rangle+|100\rangle)$$ (qubit zero being the leftmost). After the controlled $$O_1$$ gate, you get $$\frac{1}{\sqrt{2}}(|000\rangle+|111\rangle)$$. And the next Hadamard leaves you with:
\begin{align} |\psi\rangle &= \frac{1}{\sqrt{2}}\left(\frac{1}{\sqrt{2}}(|000\rangle+|100\rangle)+\frac{1}{\sqrt{2}}(|011\rangle-|111\rangle)\right) \\ &= \frac{1}{2}(|000\rangle+|100\rangle+|011\rangle-|111\rangle). \end{align}
Now, for the measurement part, I assume you refer to the measurement depicted in the circuit you added to your question, as the measurement observable $$X \otimes X$$ has eigenvalues $$+1, -1$$, not $$0$$. Thus, if qubit zero is measured to be in the $$|0\rangle$$ state, that leaves $$|\psi\rangle=\frac{1}{\sqrt{2}}(|000\rangle+|011\rangle)$$. If it's measured to be in $$|1\rangle$$, the resulting state is $$|\psi\rangle = \frac{1}{\sqrt{2}}(|100\rangle-|111\rangle)$$. To get the state of qubits one and two, you can simply factor out qubit zero from the two previous expressions.
The operations after the second barrier would bring both cases back to $$|\psi\rangle=\frac{1}{\sqrt{2}}(|000\rangle+|011\rangle)$$ (check this by reseting qubit zero to $$|0\rangle$$ and applying $$Z$$ to the last qubit in the case that the measurement outcome was $$|1\rangle$$). Then, you can apply the gates in a similar fashion as above for the last question.