# 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 :

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 is applied to qubit to give an intermediate qubit, say , and then gate is applied to to give the final resultant . Alternatively, if calculating the outcome of on qubit , the matrices representing and can be multiplied together to give a resultant matrix, which can be considered a new operator, . Then operator, can be thought to act on to give the resultant .

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 , show that the sequence of gates in Equation 14 produces the final state

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:

Using matrix multiplication to combine gates: First, calculate the product of the matrices :

then apply this matrix to the column vector for :

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

OpenLearn - Introduction to quantum computing
Except for third party materials and otherwise, this content is made available under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Licence, full copyright detail can be found in the acknowledgements section. Please see full copyright statement for details.