# Applying CNOT in series to ancilla qubit


I tried computing:

$$CNOT\ket{+0} = \frac{1}{\sqrt{2}}(CNOT\ket{00}+CNOT\ket{10}) = \frac{1}{\sqrt{2}}(\ket{00}+\ket{11})$$

This was the first CNOT gate, followed by the next one. The ancilla qubit is now also in the state $$\ket{+}$$:

$$CNOT\ket{+}\ket{+} = \frac{1}{2}(CNOT\ket{00}+CNOT\ket{01}+CNOT\ket{10}+CNOT\ket{11}) = \frac{1}{2}(\ket{00}+\ket{01}+\ket{11}+\ket{10})$$

It seems to me the ancilla qubit is thus still in the state $$\ket{+}$$ and when measured in the standard basis, it gives $$0$$ or $$1$$ with equal chance. However, applying these gates is used in quantum error correction codes, and apparently you should get the outcome $$0$$ always when measuring the ancilla qubit. What am i doing wrong?

Cross-posted on physics.SE

We have the initial state $$|+\rangle|+\rangle|0\rangle$$. The ordering I will be using is $$q_2q_1a$$. So, the first $$\rm CNOT$$ between $$q_1$$ and $$a$$ gives us the state

\begin{align} |+\rangle\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle) &= \frac{1}{2}(|0\rangle+|1\rangle)(|00\rangle+|11\rangle) \\ &= \frac{1}{2}(|000\rangle+|011\rangle+|100\rangle+|111\rangle) \end{align}

Now, it is easy to apply the second $$\rm CNOT$$ gate between $$q_2$$ and $$a$$. The state we end up with is

$$\frac{1}{2}(|000\rangle+|011\rangle+|101\rangle+|110\rangle)$$

Now, there is something wrong that you stated on your question.

This was the first $$\rm CNOT$$ gate, followed by the next one. The ancilla qubit is now also in the state $$|+\rangle$$.

This is not true. By expanding the tensor product, you can easily see that $$|+\rangle|+\rangle$$ is not equal to the Bell state $$|00\rangle+|11\rangle$$ (normalized).