Math of Two-Qubit Circuits
As in the previous article, single qubit circuits may be simple to use and manipulate, but many interesting quantum protocols and algorithms use multi-qubit circuits, including Grover’s Search and Shor’s Algorithm.
To understand how to represent multi-qubit circuits’ states, here’s a refresher of single-qubit states, represented in their ket, vector, and Bloch sphere:
However, since it is not ideal to draw a Bloch sphere for every qubit, it is best to stick with the ket and vector representation for multi-qubit states and circuits.
Just like in the binary system, qubits use right indexing in the ket notation. This means that the first qubit is on the right and the last qubit is on the left.
Back to vectors, if you recall that the top number of a single qubit vector is the contribution to the 0 state and the bottom number is the contribution to the 1 state, two qubits are quite similar. For two qubits, four total contributions need to be taken into account because there are four possibilities of what the different states can be: 00, 01, 10, and 11. To know which contribution will be represented where in the vector, you start with the state with the smallest decimal value at the top and gradually increase going down. Since 00 converts to 0 in decimal, it goes at the top. 01 just converts to 1 in decimal, so it goes next. 10 converts to 2 in decimal, so it goes next. Lastly, 11 is placed at the bottom because it is 3 in decimal.
Predicting the Output of Two-Qubit Circuits
Figuring out the output of a two-qubit circuit only takes two steps. First, find the ket representation of the final state. Let’s use this circuit for example:
领英推荐
Each qubit starts in the 0 state, then the qubit 0 gets flipped by the X gate to the 1 state. In the end, the circuit is in the state 01. The second step is to find the vector representation of the state from the ket representation. Looking back to the contribution vector above helps to see that the vector will turn out as the following.
Now, instead of being an X gate, predict what the output ket and vector would be if it were an H gate. Since qubit 0 will be put into superposition and nothing will happen to qubit 1, the output state will be 0+, or 00 for half of measurements and 01 for half of measurements. This means that the vector will look like the following.
The Controlled-X Gate
Controlled gates are two-qubit circuits. The first qubit is the control and the second is the target. Depending on the state of the control qubit, the target qubit may or may not be changed. If the state of the control qubit is 0, nothing will happen to the target qubit, however, if the state of the control qubit is 1, then a gate will be applied to the target qubit. For the Controlled-X gate, or the CX gate, that gate will be the X gate. Let’s predict the output of this circuit based on this.
Each of the qubits first start out in the 0 state, but then qubit 0 flips to a 1 from the X gate. In a controlled gate, the control qubit is the small circle. In this circuit, the control is qubit 0 and the target is qubit 1. Since the control qubit is in the 1 state, the target qubit, qubit 1, has the X gate applied to it. As a result, qubit 1 changes to a 1 state. In the end, the state for this circuit is 11. This can also be represented in vector notation.