(1.39)
which creates a 4×4 matrix.
Suppose we wanted to construct a two-qubit circuit starting in the state |10⟩ with an X gate applied to the left qubit, and a Y gate applied to the other. Mathematically this would be written
(1.40)
Referring to (1.24) we see that the X gate will simply flip the left qubit, and referring to (1.25) we see that the Y gate will flip the right qubit and add the coefficient i. We conclude that
(1.41)
To see how this would be implemented using the matrix representation, we first construct the X⊗Y matrix:
Completing the calculation gives the expected result:
A particularly interesting two-qubit circuit is formed by applying a Hadamard gate to each qubit in the ground state: H ⊗ H|00⟩. Let us first compute H ⊗ H:
Completing the calculation gives:
Note that the resulting state vector can be decomposed into a sum of all of the two-qubit basis states:
or alternatively
We see that application of Hadamard gates to each qubit creates an equally weighted superposition of all possible basis states. This is often a very useful starting point for a quantum calculation.
Although the matrix representation can be helpful in understanding the operations, calculations can often be done more compactly once the effect of the gates are understood. For example, we could write H ⊗ H |00⟩ = H ⊗ H |0⟩ |0⟩, apply the Hadamard gates to each qubit, and simplify:
We conclude this section