$\renewcommand{ket}[1]{\left| #1 \right\rangle}$ $\renewcommand{bra}[1]{\left\langle #1 \right|}$Suppose we have to qubits both in the state $\ket{+ }= \frac{1}{\sqrt{2}}(\ket{0}+\ket{1})$, and we have an ancilla qubit in the state $\ket{0}$. What will the final state of the ancilla qubit be if we apply in series first a CNOT gate with qubit 1 as the control qubit and the ancilla qubit as the target, and then another CNOT gate this time with qubit 2 as the control qubit and the ancilla qubit as the target?
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?