# "Bell state + x-measurement on qubit 0"

I am working through the IBM Quantum Composer -Learn quantum computing: a field guide.. I am in the section entitled Entanglement. My question concerns this circuit "Bell state + x-measurement on qubit 0"

I am confused because the output of qubit 0 changes. I thought it should not change because a) There are two H gates in a row after a |0>, and, b) I understand that a CNOT gate does not alter the state of the control qubit.

So what am I missing?

Regards, Peter

A CNOT gate does not alter the state of the control qubit when applied to one of the computational basis states $$\{|00\rangle, |01\rangle, |10\rangle, |11\rangle\}$$. But two qubits can also be in any superposition of the basis states (this is where things differ from the classical case), and, often (1), applying a $$CNOT$$ to such a superposition will "alter the state of the control qubit". Quotes because, more specifically, a $$CNOT$$ will often in such cases entangle the control and target qubits (altering the state of the whole system), after which the state cannot be fully described in terms of each of the two qubits in isolation, and it will not be true to say that the control qubit is still in the pure state it was prior to the $$CNOT$$.
So in the circuit in question we start with the control and target qubits in state $$|0\rangle|0\rangle$$, apply the $$H$$ to the control to get $$\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)|0\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)$$, then apply the $$CNOT$$ to get $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$. Note that the 2 qubits are now entangled - we cannot express this state as a product state of the qubits and it would not be correct to say the control is still in the state $$\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$ it was before the $$CNOT$$.
So applying a second $$H$$ to the control does not take the control qubit back to state $$|0\rangle$$, instead the entangled state changes to $$\frac{1}{2}(|00\rangle+|01\rangle+ |10\rangle-|11\rangle)$$ (still entangled - applying a unitary gate like the $$H$$ to one of the 2 qubits will not remove the entanglement). Finally a $$Z$$-basis measurement on the control will give you the final target qubit state $$\frac{1}{\sqrt{2}}(0\rangle+|1\rangle)$$ or $$\frac{1}{\sqrt{2}}(0\rangle-|1\rangle)$$ for control measurement outcomes 0 or 1 respectively.
(1) "Often" because, depending on the state it acts on, the $$CNOT$$ might entangle the 2 qubits, or disentangle them, or change them from 1 product state to another, or do nothing at all. But you certainly can't assume it will leave the control qubit entirely unaltered.