1.5 Working with multiple qubits and universality
Now that we have mastered working with two-qubit systems, it will be fairly straightforward to generalize all the notions that we have been studying to the case in which the number of qubits in our circuits is arbitrarily big. You know the drill: we will start by defining, mathematically, what a multi-qubit system is, we will then learn how to measure it and, finally, we will introduce quantum gates that act on many qubits at the same time.
1.5.1 Multi-qubit systems
With all that we have learned so far, it will now be very easy to understand how to work with multi-qubit systems.
As you may have already deduced, if we have qubits, the states that constitute the computational basis are
We usually omit the symbol to write
or
or simply
Important note
When using the notation for basis states, the total number of qubits must be clear from context. Otherwise, a state like, for example,
might mean either
,
,
, or any string with leading zeroes and ending in
…and that would be an intolerable ambiguity!
Of course, a generic state of the system will then be of the form
subject to the only condition that the amplitudes should be complex numbers such that
. Our dear old friend, the normalization condition!
To learn more…
Notice that the number of parameters describing the general state of an -qubit system is exponential in
. For highly entangled states, we do not know how to represent all this information in a more succinct way and it is strongly suspected that it is not possible. Part of the power of quantum computing comes from this possibility of implicitly working with
complex numbers by manipulating just
qubits.
Exercise 1.18
Check that the basis state is represented by a
-dimensional column vector whose
-th component is 1, while the rest are 0 (Hint: Use, repeatedly, the expression for the tensor product of column vectors that we discussed in Section 1.4.1 and the fact that the tensor product is associative). Deduce that any
-qubit state can be represented by a
-dimensional column vector with unit length.
If we decide to measure all the qubits of the system in the computational basis, we will obtain with probability
. If that is the case, then the state will collapse to
. But if we only measure one of the qubits, say the
-th one, then we will obtain
with probability
where is the set of numbers whose
-th bit is
. In this scenario, the state of the system after measuring
would be
Exercise 1.19
Derive the formulas for the case in which the result of the measurement is .
Exercise 1.20
What is the probability of getting when we measure the second qubit of
? What will the state be after the measurement if we indeed get
?
Computing inner products of -qubit systems in Dirac notation is very similar to doing it with two-qubit systems. The procedure is analogous to the one we showed in Section 1.4.1, but taking into account that
Exercise 1.21
Compute the inner product of and
, where
and
are both binary strings of length
. Use your result to prove that
is, indeed, an orthonormal basis.
Exercise 1.22
Compute the inner product of the states and
.
We can now turn to the question of how to operate on many qubits at once. Let's define multi-qubit gates!
1.5.2 Multi-qubit gates
Since -qubit states are represented by
-dimensional column vectors,
-qubit gates can be identified with
unitary matrices. Similar to the two-qubit case, we can construct
-qubit gates by taking the tensor product of gates on a smaller number of qubits. Namely, if
is an
-qubit gate and
is an
-qubit gate, then
is an
-qubit gate and its matrix is given by the tensor product of the matrices
and
.
To learn more…
The expression for the tensor product of two matrices and
is
However, there are -qubit gates that cannot be constructed as tensor products of smaller gates. One such example is the Toffoli or CCNOT gate, a three-qubit gate that acts on the computational basis as
where is the XOR function and
is the symbol for the AND Boolean function. Thus, CCNOT applies a doubly controlled (in this case, by the first two qubits) NOT gate to the third qubit — hence the name!
Exercise 1.23
Obtain the matrix for the CCNOT gate and verify that it is unitary.
The Toffoli gate is important because, using it and with the help of auxiliary qubits, we can construct any classical Boolean operator. For instance, (where
is the negation of
) and
. This shows that, with quantum circuits, we can simulate the behavior of any classical digital circuit at the cost of using some additional ancillary qubits, since any Boolean function can be built with just negations and conjunctions. This is somewhat surprising, because we know that all quantum gates are invertible, while not all Boolean functions are. It then follows that we could make all of our digital circuits reversible just by implementing a classical version of the Toffoli gate!
We will not be studying any other concrete examples of gates that act on three (or more!) qubits because, in fact, we can simulate their behavior with circuits that only use one- and two-qubit gates. Keep on reading to know how!
1.5.3 Universal gates in quantum computing
Current quantum computers can't implement every possible quantum gate. Instead, they rely on universality results that show how any unitary operation can be decomposed as a circuit that uses a reduced set of primitive gates. In previous sections, we mentioned, for instance, that any one-qubit gate can be obtained by using just and
rotations. It turns out that similar results exist for the general case of
-qubit quantum gates.
To us, it will be important to know that, for any unitary operation, we can construct a circuit that implements it using only one-qubit gates and the CNOT gate. For this reason, we say that those gates are universal — in the same sense that, for example, negation and conjunction are universal for Boolean logic. This fact will be crucial for our study of feature maps and variational forms in connection to quantum neural networks and other quantum machine learning models.
To learn more…
In addition to one-qubit gates plus CNOT, there are many other sets of universal gates. For instance, it can be shown that the three gates ,
, and CNOT can be used to approximate any unitary operation to any desired accuracy — and they are universal in that sense. See Section 4.5 of the book by Nielsen and Chuang [69] for proofs of these facts and for more examples of universal gate sets.
To illustrate how CNOT and one-qubit gates can be used to implement any other quantum gate, the following circuit shows a possible decomposition of the Toffoli gate targeting the top qubit:
.
Exercise 1.24
Verify that the preceding circuit implements the Toffoli gate by checking its action on the states of the computational basis.
This concludes our review of the fundamentals of quantum computing. We've come a long way since the beginning of this chapter, but by now we have mastered all the mathematics that we will need in order to study quantum machine learning and quantum optimization algorithms. Soon, we will see all these concepts in action!