Using gates on 2 qubits
Two-qubit gates such as controlled gates are slightly different from ordinary 1-qubit gates; they let you create interaction between your qubits. In general, this translates into using 1 qubit as the control qubit, and the other as the acted-on qubit. Mathematically, this is not super complex, but intuitively you might have to think once or twice about what is going on.
Getting ready
The first 2-qubit gate that we'll touch on is the Controlled-NOT gate that we saw in Chapter 4, Starting at the Ground Level with Terra. The CX gate is generally used to create entanglement between qubits if the control qubit is in a superposition.
A CX gate where the controlling qubit is the second qubit and the controlled qubit the first can be expressed as the following matrix:
This corresponds to the following circuit:
The way you interpret this is to run the first...