# Applying CNOT in series to ancilla qubit

$$\renewcommand{ket}{\left| #1 \right\rangle}$$ $$\renewcommand{bra}{\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?

Cross-posted on qc.SE

• The state after the first CNOT is not |+>|+>. It is what you've written before that, (|0>|0>+|1>|1>)/sqrt(2). These are not the same state! Nov 8, 2021 at 13:53
• State $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$ is entangled state while $|+\rangle|+\rangle$ is separable state $\frac{1}{2}(|00\rangle+|01\rangle+|10\rangle+|11\rangle)$. Nov 9, 2021 at 11:27