5.2.3 Sequences of gates

The next step towards quantum computing is to combine gates sequentially to give a quantum circuit. In a circuit, successive operations are applied to a single qubit.

If you first apply the NOT gate, and then apply the Hadamard gate, the mathematical expression representing this is written as a sequence of operators, operating from right to left on the qubit vertical line psi mathematical right angle bracket:

absolute value of phi mathematical right angle bracket equals cap h hat times cap x hat times psi mathematical right angle bracket
Equation label:(14)

This ordering of operators should not come as a surprise; reading the expression on the right hand side of Equation 14, first gate cap x hat is applied to qubit vertical line psi mathematical right angle bracket to give an intermediate qubit, say vertical line alpha mathematical right angle bracket, and then gate cap h hat is applied to vertical line alpha mathematical right angle bracket to give the final resultant vertical line phi mathematical right angle bracket. Alternatively, if calculating the outcome of cap h hat times cap x hat on qubit vertical line psi mathematical right angle bracket, the matrices representing cap h hat and cap x hat can be multiplied together to give a resultant matrix, which can be considered a new operator, cap w hat equals cap h hat times cap x hat. Then operator, cap w hat can be thought to act on vertical line psi mathematical right angle bracket to give the resultant vertical line phi mathematical right angle bracket.

The diagram representing this sequence is shown in Figure 9.

Figure 9 A circuit for applying a NOT gate and a Hadamard gate in sequence

A circuit diagram represents the logical flow of the circuit from the left (the initial state) to the right (the final state) of the diagram. Therefore, in the circuit shown in Figure 8, the elements are ordered from left to right: the NOT, which acts first, is on the left.

Note that the ordering of gates in the circuit diagram is the opposite to the ordering of gates when the circuit is written as a sequence of operators acting on a ket.

By matrix multiplication, any sequence of single-qubit gates can be represented by a single 2 × 2 matrix found by forming an ordered product of the matrices representing the gates. You have to be careful because, in general, the single-qubit operators do not commute. In the next exercise you will see that the method using matrix multiplication to combine gates is equivalent to applying the gates sequentially.

Exercise 14

Given the initial qubit state vertical line zero mathematical right angle bracket, show that the sequence of gates in Equation 14 produces the final state

absolute value of psi mathematical right angle bracket equals one divided by Square root of two times left parenthesis vertical line zero mathematical right angle bracket postfix minus times one mathematical right angle bracket right parenthesis full stop

Show that you get the same result by applying either the gates in sequence or by using matrix multiplication to combine gates.

Answer

Applying the gates in sequence from right to left:

multiline equation row 1 vertical line psi mathematical right angle bracket equals cap h hat times cap x hat vertical line zero mathematical right angle bracket row 2 equals cap h hat vertical line one mathematical right angle bracket by definition of a NOT gate row 3 equals one divided by Square root of two times left parenthesis vertical line zero mathematical right angle bracket postfix minus vertical line one mathematical right angle bracket right parenthesis using row two of Table four

Using matrix multiplication to combine gates: First, calculate the product of the matrices cap h hat times cap x hat:

equation sequence part 1 cap h hat times cap x hat equals part 2 one divided by Square root of two times matrix row 1column 1 11 row 2column 1 one minus minus one times matrix row 1column 1 01 row 2column 1 10 equals part 3 one divided by Square root of two times matrix row 1column 1 11 row 2column 1 minus minus 11

then apply this matrix to the column vector for vertical line zero mathematical right angle bracket:

multiline equation row 1 vertical line psi mathematical right angle bracket equals cap h hat times cap x hat vertical line zero mathematical right angle bracket row 2 equals one divided by Square root of two times matrix row 1column 1 11 row 2column 1 minus minus 11 times vector element 1 one element 2 zero row 3 equals one divided by Square root of two times vector element 1 one element 2 negative one row 4 equals one divided by Square root of two times left parenthesis vertical line zero mathematical right angle bracket postfix minus vertical line one mathematical right angle bracket right parenthesis

which is the same final state as applying the gates in sequence, as expected.