Two-Qubit Gate Matrices

Just as the columns of a single-qubit gate matrix correspond to the idealized states, the columns of a matrix representing a two-qubit gate, such as the Controlled NOT (CNOT) Gate, correspond to the four idealized states—images/_pragprog/svg-71.png, images/_pragprog/svg-74.png, images/_pragprog/svg-318.png, and images/_pragprog/svg-319.png— for two qubits:

images/_pragprog/svg-block-270.png

The letters images/_pragprog/svg-329.png are complex numbers with the usual conjugates images/_pragprog/svg-330.png.

Each column is the action of the gate on the idealized state associated with that column. For example, look at the Controlled NOT (CNOT) Gate gate in which the control qubit is set to images/_pragprog/svg-18.png and its target to images/_pragprog/svg-17.png, as shown in the following figure:

images/multi_qubit_algebra/CNOT_Gate_1_Control_0_Target.png

Because the control is images/_pragprog/svg-18.png, the target qubit is switched to images/_pragprog/svg-18.png.

Or, the images/_pragprog/svg-318.png state is changed by the CNOT gate to the images/_pragprog/svg-319.png state. To express this operation as a matrix column, write the latter as a vector:

images/_pragprog/svg-block-271.png

Thus, the third column of the matrix images/_pragprog/svg-331.png for the CNOT gate is:

images/_pragprog/svg-block-272.png

Similarly, you can fill the other columns:

CNOT acts on images/_pragprog/svg-71.png

When the control qubit is images/_pragprog/svg-17.png, the target qubit continues to be images/_pragprog/svg-17.png. Thus, images/_pragprog/svg-332.png or:

images/_pragprog/svg-block-273.png
CNOT acts on images/_pragprog/svg-74.png

Since the control qubit is images/_pragprog/svg-17.png, the target qubit is unaffected and continues to images/_pragprog/svg-18.png. Thus, images/_pragprog/svg-333.png or:

images/_pragprog/svg-block-274.png
CNOT acts on images/_pragprog/svg-319.png

In this case, the control qubit is images/_pragprog/svg-18.png. So, the target qubit switches from images/_pragprog/svg-18.png to images/_pragprog/svg-17.png. Thus, images/_pragprog/svg-334.png or:

images/_pragprog/svg-block-275.png

Putting these vectors as the appropriate columns in the previous matrix, we’ll get the CNOT gate’s matrix images/_pragprog/svg-331.png:

images/_pragprog/svg-block-276.png

Notice that we’ve suppressed the column labels, but you should still associate each column with the corresponding idealized states.

Following the same line of reasoning, you can derive the gate matrix images/_pragprog/svg-335.png for the Controlled Z (CZ) Gate. The CZ gate only rotates the triangle images/_pragprog/svg-18.png qubelet on the target qubit when the control bit is images/_pragprog/svg-18.png, as shown in the following figure:

images/multi_qubit_algebra/CZ_Gate_1_Control_1_Target_Qubelets.png

That is, the state images/_pragprog/svg-319.png becomes images/_pragprog/svg-72.png. Writing the latter as a vector:

images/_pragprog/svg-block-277.png

The CZ gate leaves the other idealized states alone. Or, in terms of vectors:

images/_pragprog/svg-block-278.png

In the first two instances, the control qubit is images/_pragprog/svg-17.png. Thus, the target qubit is unchanged. In the last case, even though the control qubit is images/_pragprog/svg-18.png, the target qubit is images/_pragprog/svg-17.png and not affected by the CZ gate.

These vectors form the rest of the columns of the CZ gate’s matrix images/_pragprog/svg-335.png:

images/_pragprog/svg-block-279.png

With matrices for two-qubit gates, you can follow the procedure in Sequence of Gates as Matrix Multiplication, to work out how circuits with two-qubit gates modify quantum states. For example, see the following circuit:

images/multi_qubit_algebra/Control_1_Target_0_CNOT_CZ.png

Obtain the two-qubit quantum state images/_pragprog/svg-313.png as follows:

images/_pragprog/svg-block-280.png

Notice the order of the multiplication of the images/_pragprog/svg-185.png and images/_pragprog/svg-331.png matrices is reverse that of the order in which the corresponding gates are applied to the input state images/_pragprog/svg-318.png in the quantum circuit. Also, in the previous equation, the input state images/_pragprog/svg-318.png is replaced with a vector which has a 1 in the third element, corresponding to images/_pragprog/svg-318.png.

The result of this multiplication is a vector whose last element is images/_pragprog/svg-336.png. The bottom element is associated with the quantum state images/_pragprog/svg-319.png. So, a images/_pragprog/svg-336.png value indicates that this sequence of gates changes the quantum state as follows:

images/_pragprog/svg-block-281.png

For this circuit, you can verify this result by manually working out the action of the gates on the qubits: the control qubit is 1, the CNOT gate switches the bottom qubit to images/_pragprog/svg-18.png, which the CZ gate then inverts to images/_pragprog/svg-337.png. This corresponds to the quantum state images/_pragprog/svg-72.png, as found earlier using matrices and vectors. As the number of gates increases, this sort of analysis becomes tedious and error-prone. But the matrix approach always works.

Matrix and Vector Multiplication Isn’t a Replacement for Quantum Computing

images/aside-icons/warning.png

You may get the idea that multiplying gate matrices with the vector for a quantum state is really all that it takes to do quantum computations. In fact, this principle drives many simulators in various computer languages. But as the number of qubits increases, classical computers would grind to a halt as they run out of resources trying to do matrix math. Quantum computers, on the other hand, are impervious to this excessive workload, as they work with the mega-qubit using quantum mechanical principles instead of using classical means.

Still, the matrix method is important to learn since it gives you a way to analyze small portions of a circuit and see how the qubelets are affected. If you try to use Measure gates instead, you won’t get a complete picture of how the rotations of the qubelets of different qubits interact.

You can apply this technique of multiplying quantum state vectors with gate matrices as long as your quantum circuit only has two-qubit gates. In the next section, you’ll learn to include single-qubit gates that switch, split, and rotate qubelets on one or both qubits in your quantum circuits.

Circuits with Single- and Two-Qubit Gates

When designing your own quantum programs you’ll frequently want to apply a single-qubit gate on one or both qubits in addition to the two-qubit gates. For example, consider the following circuit:

images/multi_qubit_algebra/1_Control_1_S_Target.png

A single-qubit S gate is applied on the bottom qubit before it’s fed to the target of the CZ gate. So, this circuit contains the single-qubit S gate coupled with the two-qubit CZ gate. In other words, you end up with a situation where you have to deal with the images/_pragprog/svg-186.png matrix for the S gate as well as the images/_pragprog/svg-338.png matrix for the CZ gate.

To apply the matrix method to calculate the quantum states of the qubits in this circuit, the matrices need to be compatible so that they can be multiplied. For square matrices, this means that the matrices must have the same dimensions.

Thus, the single-qubit S gate is “made” into a two-qubit gate by appending the second qubit, the top one in this case, as a pass-through, as shown in the following figure:[44][45]

images/multi_qubit_algebra/2_Qubit_S_Gate.png

Next, use the single-qubit S gate’s images/_pragprog/svg-186.png matrix as a guide to calculate the matrix for the two-qubit S gate. For reference, the matrix images/_pragprog/svg-240.png for the S Gate, is:

images/_pragprog/svg-block-282.png

Notice that this matrix implies that the pentagon images/_pragprog/svg-17.png qubelets are unaffected, while the triangle images/_pragprog/svg-18.png qubelets are rotated by images/_pragprog/svg-148.png radians, or 90° anticlockwise:

images/_pragprog/svg-block-283.png

The angle images/_pragprog/svg-245.png indicates the relative difference between the pentagon images/_pragprog/svg-17.png and triangle images/_pragprog/svg-18.png qubelets.

As we did for the CNOT gate earlier in this section, work out the columns of the images/_pragprog/svg-338.png matrix by seeing what this circuit does to each of the four idealized states, images/_pragprog/svg-71.png, images/_pragprog/svg-74.png, images/_pragprog/svg-318.png, and images/_pragprog/svg-319.png:

images/_pragprog/svg-71.png Idealized State:

The top qubit, images/_pragprog/svg-339.png, is a pass-through. So it’s unchanged by the gate.

The bottom qubit, images/_pragprog/svg-340.png, is fed to the S gate. From this gate’s matrix, images/_pragprog/svg-240.png, the bottom images/_pragprog/svg-17.png qubit, is also unaffected.

Thus, images/_pragprog/svg-341.png. Write the latter state as a vector:

images/_pragprog/svg-block-284.png

Note that the first element of this vector is associated with images/_pragprog/svg-71.png.

images/_pragprog/svg-74.png Idealized State:

The top qubit, images/_pragprog/svg-342.png, is a pass-through. So, it’s unchanged by the gate.

The bottom qubit, images/_pragprog/svg-343.png, becomes images/_pragprog/svg-344.png when acted on by the S gate in accordance with the gate matrix images/_pragprog/svg-240.png. Thus, images/_pragprog/svg-345.png. Write the latter state as a vector:

images/_pragprog/svg-block-285.png

The second element, associated with images/_pragprog/svg-74.png, is images/_pragprog/svg-106.png.

images/_pragprog/svg-318.png Idealized State:

The top qubit, images/_pragprog/svg-346.png, is a pass-through. So it’s unchanged by the gate.

The bottom qubit, images/_pragprog/svg-340.png, is fed to the S gate and is unchanged in accordance with the gate matrix images/_pragprog/svg-240.png. Thus, images/_pragprog/svg-347.png. Write the latter state as a vector:

images/_pragprog/svg-block-286.png

The third element is associated with images/_pragprog/svg-318.png.

images/_pragprog/svg-319.png Idealized State:

The top qubit, images/_pragprog/svg-346.png, is a pass-through. So it’s unchanged by the gate.

The bottom qubit, images/_pragprog/svg-343.png, becomes images/_pragprog/svg-344.png when acted on by the S gate in accordance with the gate matrix images/_pragprog/svg-240.png. Thus, images/_pragprog/svg-348.png. Write the latter state as a vector:

images/_pragprog/svg-block-287.png

These vectors then form the columns of the images/_pragprog/svg-338.png matrix for the pass-through two-qubit S gate:

images/_pragprog/svg-block-288.png

Now, the matrices for both the pass-through S gate and the CZ gate are the same size. Thus, you can multiply their matrices to get how these gates act on images/_pragprog/svg-319.png:

images/_pragprog/svg-block-289.png

Notice that the order of multiplying the matrices images/_pragprog/svg-185.png and images/_pragprog/svg-240.png is opposite to the order in which the corresponding gates are applied to the input state images/_pragprog/svg-319.png. Also, the input state images/_pragprog/svg-319.png is replaced with its vector in the previous equation.

 

The multiplication of the matrices with the vector for images/_pragprog/svg-319.png results in the quantum state images/_pragprog/svg-351.png:

images/_pragprog/svg-block-297.png

Once again, to convince yourself that the matrix procedure gives the correct result, you can reason this circuit out manually: the S gate on the bottom qubit, images/_pragprog/svg-18.png, rotates its triangle images/_pragprog/svg-18.png qubelet by images/_pragprog/svg-148.png radians, or a quarter turn anticlockwise. Since, the control qubit to the CZ gate is images/_pragprog/svg-18.png, the CZ gate will rotate the triangle images/_pragprog/svg-18.png qubelet on the target qubit on the bottom by a half turn. So, the triangle images/_pragprog/svg-18.png qubelet will end up rotated a quarter turn clockwise, or images/_pragprog/svg-352.png radians, as shown in the figure.

images/multi_qubit_algebra/CZ_Gate_1_Control_1_90_Target_Qubelets.png

Analyzing existing circuit designs is useful to pick up ways to work with qubits. But eventually you’ll want to twist qubelets in ways unique to your application. So in the next section, you’ll learn how matrices also help to identify the gates you’ll need in your own designs.

The circuits in this section were initialized with idealized states. In the next section, you’ll learn to work with circuits seeded with blended states obtained as a result of a previous computation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.201