5.4.1 Circuits with multiple gates

Single-qubit gates and two-qubit gates can be combined in a structured sequence to give a quantum circuit containing multiple quantum gates. Consider as an example the circuit shown in Figure 11, which depicts a sequence of gates acting on two qubits, labelled vertical line q sub one mathematical right angle bracket and vertical line q sub two mathematical right angle bracket. Remember that each qubit enters its circuit from the left; first, a Hadamard gate is applied to qubit vertical line q sub one mathematical right angle bracket. Then a CNOT is applied to vertical line q sub one mathematical right angle bracket and vertical line q sub two mathematical right angle bracket, where the control C is vertical line q sub one mathematical right angle bracket and the target T is vertical line q sub two mathematical right angle bracket. Finally, a NOT gate is applied to vertical line q sub two mathematical right angle bracket.

Figure 11 An example of a quantum circuit with multiple quantum gates

The circuit in Figure 11 is a sequence of operations applied to qubits and can be analysed using the methods already introduced, with extra subscripts labelling the single-qubit gates and operations so that the qubit each operation is acting on is clear. Thus cap h hat sub one acts only on the qubit q sub one, leaving q sub two unchanged. Therefore, using vertical line zero times zero mathematical right angle bracket as a sample input the calculation becomes:

absolute value of q sub one times q sub two mathematical right angle bracket sub final equals cap x hat sub two times times times CX hat sub one comma two times cap h hat sub one times zero times zero mathematical right angle bracket full stop

Now cap h hat sub one acts only on q sub one, so

multiline equation row 1 cap h hat sub one vertical line zero times zero mathematical right angle bracket equals cap h hat sub one times absolute value of zero mathematical right angle bracket sub one times zero mathematical right angle bracket sub two row 2 equals one divided by Square root of two times left parenthesis vertical line one mathematical right angle bracket sub one plus absolute value of zero mathematical right angle bracket sub one right parenthesis times zero mathematical right angle bracket sub two row 3 equals one divided by Square root of two times left parenthesis vertical line 10 mathematical right angle bracket postfix plus vertical line 00 mathematical right angle bracket right parenthesis

This means that

absolute value of q sub one times q sub two mathematical right angle bracket sub final equals cap x hat sub two times times times CX hat sub one comma two times one divided by Square root of two times left parenthesis vertical line 10 mathematical right angle bracket postfix plus times 00 mathematical right angle bracket right parenthesis full stop

Next comes the effect of the CNOT gate, courtesy of times times CX hat sub one comma two and gives

absolute value of q sub one times q sub two mathematical right angle bracket sub final equals cap x hat sub two times one divided by Square root of two times left parenthesis vertical line 11 mathematical right angle bracket postfix plus times 00 mathematical right angle bracket right parenthesis full stop

Finally, observe that cap x hat sub two acts on q sub two only, so flip q sub two of each ket in the superposition:

absolute value of q sub one times q sub two mathematical right angle bracket sub final equals one divided by Square root of two times left parenthesis vertical line 10 mathematical right angle bracket postfix plus times 01 mathematical right angle bracket right parenthesis full stop