# Quantum circuit, two control not gates

Consider the quantum circuit in the picture below:

We have a Hadamard gate followed by a CNOT gate, this puts the 2nd & 3rd state in the bell state $\beta_{00}=\frac{1}{\sqrt2}(\mid 00\rangle +\mid 11\rangle$

This occurs because the CNOT gate flips the target qubit iff the control qubit is $\mid 1 \rangle$. The two qubits are now entangled.

When we proceed to the second CNOT gate we only care about what state the second wire is in? Would someone be able to help explain how we can compute how the top wire acts in this situation?

Or if someone would be able to explain in general how we treat qubits entangled such as this if we want to say something about them separately? At the end of the circuit we have two detectors $x$ and $y$, these will collapse wave function, two two lower qubits will carry on unchanged in their bell state, how would we describe the middle wire being measured by $x$?

-

Calculating the effect of the second CNOT gate works pretty much as the first one; you just have to carry the state of the third qubit along (this you actually do in case of the first gate with the first qubit). Recall that everything here is linear – if you feel uncomfortable with such a manipulation of an entangled state, consider the effect of the gate on each term in the state and add them up.

Now, the calculation in some detail. After the first CNOT gate (i.e., at place 2) you have $$(\alpha|0\rangle+\beta|1\rangle)\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle).$$ When the first qubit is in the state $|0\rangle$ nothing happens, when it is in the state $|1\rangle$, the second qubit is flipped, so that we have $$\frac{\beta}{\sqrt{2}}(|110\rangle+|101\rangle).$$ Combining the two terms gives the state at 3 $$\frac{1}{\sqrt{2}}[\alpha(|000\rangle+|011\rangle)+\beta(|110\rangle+|101\rangle)].$$

If you want to look at the state of just a single qubit which is entangled with other qubits, you have to trace out all the other qubits. You can look at the Wikipedia article on partial trace for more detail.

Finally, when you have a detector placed at the end you can see what happens by taking the scalar product of the state after the last Hadamard gate (i.e., the state at 4 that I will denote for now by $|\psi_4\rangle$) and the eigenstates of the measured observable. For example, when measuring $x$ [with the eigenstates $(|0\rangle\pm|1\rangle)/\sqrt{2}$] of the first qubit you calculate $\frac{1}{\sqrt{2}}(\langle 0|\pm\langle 1|)_1|\psi_4\rangle$ to see what state you get after detection of $(|0\rangle\pm|1\rangle)/\sqrt{2}$. (The subscript 1 means that the bra represents a state of the first qubit.) Similarly, you can proceed for any state and any measurement. Note that the state obtained in this way is not normalized; $|\frac{1}{\sqrt{2}}(\langle 0|\pm\langle 1|)_1|\psi_4\rangle|^2$ gives the probability of measuring $(|0\rangle\pm|1\rangle)/\sqrt{2}$.

-
Thanks so much for explaining this! So when you apply an operation to a qubit in place i you apply the operation to each basis element in position i? – Freeman Feb 18 '13 at 8:15
Yep, it works exactly like that. You look at individual basis states and how they transform and then you just add them together in a linear superposition. – Ondřej Černotík Feb 18 '13 at 9:26