Reader small image

You're reading from  A Practical Guide to Quantum Machine Learning and Quantum Optimization

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804613832
Edition1st Edition
Right arrow
Authors (2):
Elías F. Combarro
Elías F. Combarro
author image
Elías F. Combarro

Elías F. Combarro holds degrees from the University of Oviedo (Spain) in both Mathematics (1997, award for second highest grades in the country) and Computer Science (2002, award for highest grades in the country). After some research stays at the Novosibirsk State University (Russia), he obtained a Ph.D. in Mathematics (Oviedo, 2001) with a dissertation on the properties of some computable predicates under the supervision of Prof. Andrey Morozov and Prof. Consuelo Martínez. Since 2009, Elías F. Combarro has been an associate professor at the Computer Science Department of the University of Oviedo. He has published more than 50 research papers in international journals on topics such as Computability Theory, Machine Learning, Fuzzy Measures and Computational Algebra. His current research focuses on the application Quantum Computing to algebraic, optimisation and machine learning problems. From July 2020 to January 2021, he was a Cooperation Associate at CERN openlab. Currently, he is the Spain representative in the Advisory Board of CERN Quantum Technology Initiative, a member of the Advisory Board of SheQuantum and one of the founders of the QSpain, a quantum computing think tank based in Spain.
Read more about Elías F. Combarro

Samuel González-Castillo
Samuel González-Castillo
author image
Samuel González-Castillo

Samuel González-Castillo holds degrees from the University of Oviedo (Spain) in both Mathematics and Physics (2021). He is currently a mathematics research student at the National University of Ireland, Maynooth, where he works as a graduate teaching assistant. He completed his physics bachelor thesis under the supervision of Prof. Elías F. Combarro and Prof. Ignacio F. Rúa (University of Oviedo), and Dr. Sofia Vallecorsa (CERN). In it, he worked alongside other researchers from ETH Zürich on the application of Quantum Machine Learning to classification problems in High Energy Physis. In 2021, he was a summer student at CERN developing a benchmarking framework for quantum simulators. He has contributed to several conferences on quantum computing.
Read more about Samuel González-Castillo

View More author details
Right arrow

1.4 Working with two qubits and entanglement

Now that we have mastered the inner workings of solitary qubits, we are ready to up the ante. In this section, we will learn about systems of two qubits and how they can become entangled. We will first define the mathematical representation of two-qubit systems and how we can measure them. After that, we will study different quantum gates that can act on two qubits at once and we will have a look at some of their very interesting and slightly puzzling properties. We will conclude with a simple but enlightening example of a two-qubit circuit. We promise that the ride is going to be amazing!

1.4.1 Two-qubit states

So far, we have worked with qubits in isolation. But the real power of quantum computing cannot be unleashed unless qubits can talk to each other. We will start by considering the simplest case of quantum systems in which there is qubit interaction: two-qubit systems.

Of course, in a two-qubit system, each of the qubits can be in state \left| 0 \right\rangle or in state \left| 1 \right\rangle. Thus, for the two qubits, we have four possible combinations: both are in state \left| 0 \right\rangle, the first one is in state \left| 0 \right\rangle and the second one in state \left| 1 \right\rangle, the first one is in state \left| 1 \right\rangle and the second one in state \left| 0 \right\rangle, or both are in state \left| 1 \right\rangle. These four possibilities form a basis (called the computational basis) of a 4-dimensional space and we denote them, respectively, by

\left| 0 \right\rangle \otimes \left| 0 \right\rangle,\,\left| 0 \right\rangle \otimes \left| 1 \right\rangle,\,\left| 1 \right\rangle \otimes \left| 0 \right\rangle,\,\left| 1 \right\rangle \otimes \left| 1 \right\rangle.

Here, \otimes is the symbol for the tensor product. The tensor product of two column vectors is defined by

\begin{pmatrix} a_{1} \\ a_{2} \\ {\vdots} \\ a_{n} \\ \end{pmatrix} \otimes \begin{pmatrix} b_{1} \\ b_{2} \\ {\vdots} \\ b_{m} \\ \end{pmatrix} = \begin{pmatrix} {a_{1}\begin{pmatrix} b_{1} \\ b_{2} \\ {\vdots} \\ b_{m} \\ \end{pmatrix}} \\ {a_{2}\begin{pmatrix} b_{1} \\ b_{2} \\ {\vdots} \\ b_{m} \\ \end{pmatrix}} \\ {\vdots} \\ {a_{n}\begin{pmatrix} b_{1} \\ b_{2} \\ {\vdots} \\ b_{m} \\ \end{pmatrix}} \\ \end{pmatrix} = \begin{pmatrix} {a_{1}b_{1}} \\ {a_{1}b_{2}} \\ {\vdots} \\ {a_{1}b_{m}} \\ {a_{2}b_{1}} \\ {a_{2}b_{2}} \\ {\vdots} \\ {a_{2}b_{m}} \\ {\vdots} \\ {a_{n}b_{1}} \\ {a_{n}b_{2}} \\ {\vdots} \\ {a_{n}b_{m}} \\ \end{pmatrix}.

Hence, the four basis states can be represented by four-dimensional column vectors given by

\left| 0 \right\rangle \otimes \left| 0 \right\rangle = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \\ \end{pmatrix},\qquad\left| 0 \right\rangle \otimes \left| 1 \right\rangle = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ \end{pmatrix},\qquad\left| 1 \right\rangle \otimes \left| 0 \right\rangle = \begin{pmatrix} 0 \\ 0 \\ 1 \\ 0 \\ \end{pmatrix},\qquad\left| 1 \right\rangle \otimes \left| 1 \right\rangle = \begin{pmatrix} 0 \\ 0 \\ 0 \\ 1 \\ \end{pmatrix}.

Usually, we omit the \otimes symbol and just write

\left| 0 \right\rangle\left| 0 \right\rangle,\,\left| 0 \right\rangle\left| 1 \right\rangle,\,\left| 1 \right\rangle\left| 0 \right\rangle,\,\left| 1 \right\rangle\left| 1 \right\rangle

or

\left| {00} \right\rangle,\,\left| {01} \right\rangle,\,\left| {10} \right\rangle,\,\left| {11} \right\rangle

or even

\left| 0 \right\rangle,\,\left| 1 \right\rangle,\,\left| 2 \right\rangle,\,\left| 3 \right\rangle.

Obviously, in this last case, the number of qubits that we are using must be clear from the context in order not to mistake the state \left| 0 \right\rangle of a one-qubit system with the state \left| 0 \right\rangle of a two-qubit system — or, as we will see soon, any other multi-qubit system!

As we have mentioned, these four states constitute a basis of the vector space of possible states for a two-qubit system. The general expression for the state of such a system is

\left| \psi \right\rangle = a_{00}\left| {00} \right\rangle + a_{01}\left| {01} \right\rangle + a_{10}\left| {10} \right\rangle + a_{11}\left| {11} \right\rangle

where a_{00}, a_{01}, a_{10}, and a_{11} are complex numbers (called amplitudes, remember?) such that {\sum}_{x,y = 0}^{1}\left| a_{xy} \right|^{2} = 1.

If we measure in the computational basis both qubits at this generic state that we are considering, we will obtain 00 with probability \left| a_{00} \right|^{2}, 01 with probability \left| a_{01} \right|^{2}, 10 with probability \left| a_{10} \right|^{2}, and 11 with probability \left| a_{11} \right|^{2}. In all those cases, the state will collapse to the state corresponding to the outcome of the measurement, just as with one-qubit systems.

Let's now say that we only measure one of the qubits. What happens then? Suppose that we measure the first qubit. Then, the probability of obtaining 0 will be \left| a_{00} \right|^{2} + \left| a_{01} \right|^{2}, which is the sum of the probabilities of all the outcomes in which the first qubit can be 0. If we measure the first qubit and the result turns out to be 0, the system will not collapse completely, but it will remain in the state

\frac{a_{00}\left| {00} \right\rangle + a_{01}\left| {01} \right\rangle}{\sqrt{\left| a_{00} \right|^{2} + \left| a_{01} \right|^{2}}},

where we have divided by \sqrt{\left| a_{00} \right|^{2} + \left| a_{01} \right|^{2}} to keep the state normalized. The situation in which the result of the measurement is 1 is analogous.

Exercise 1.10

Derive the formulas for the probability of measuring 1 on the first qubit in a general two-qubit state and for the state of the system after the measurement.

Dirac notation is also useful to compute inner products of two-qubit states. We only need to notice that

\left( {\left\langle \psi_{1} \right| \otimes \left\langle \psi_{2} \right|} \right)\left( {\left| \varphi_{1} \right\rangle \otimes \left| \varphi_{2} \right\rangle} \right) = \left\langle \psi_{1} \middle| \varphi_{1} \right\rangle\left\langle \psi_{2} \middle| \varphi_{2} \right\rangle,

apply distributivity and remember to conjugate the complex coefficients when obtaining a bra from a ket.

Then, for instance, we can notice that the inner product of \frac{4}{5}\left| {01} \right\rangle + \frac{3i}{5}\left| {11} \right\rangle and \frac{1}{\sqrt{2}}\left| {00} \right\rangle + \frac{1}{\sqrt{2}}\left| {11} \right\rangle is

\begin{array}{rlrl} & {\left( {\frac{4}{5}\left\langle {01} \right| - \frac{3i}{5}\left\langle {11} \right|} \right)\left( {\frac{1}{\sqrt{2}}\left| {00} \right\rangle + \frac{1}{\sqrt{2}}\left| {11} \right\rangle} \right) = \qquad} & & \qquad \\ & {\quad\frac{4}{5\sqrt{2}}\left\langle 01 \middle| 00 \right\rangle + \frac{4}{5\sqrt{2}}\left\langle 01 \middle| 11 \right\rangle - \frac{3i}{5\sqrt{2}}\left\langle 11 \middle| 00 \right\rangle - \frac{3i}{5\sqrt{2}}\left\langle 11 \middle| 11 \right\rangle = \qquad} & & \qquad \\ & {\quad\frac{4}{5\sqrt{2}}\left\langle 0 \middle| 0 \right\rangle\left\langle 1 \middle| 0 \right\rangle + \frac{4}{5\sqrt{2}}\left\langle 0 \middle| 1 \right\rangle\left\langle 1 \middle| 1 \right\rangle - \frac{3i}{5\sqrt{2}}\left\langle 1 \middle| 0 \right\rangle\left\langle 1 \middle| 0 \right\rangle - \frac{3i}{5\sqrt{2}}\left\langle 1 \middle| 1 \right\rangle\left\langle 1 \middle| 1 \right\rangle = - \frac{3i}{5\sqrt{2}},\qquad} & & \qquad \\ \end{array}

since \left\langle 0 \middle| 1 \right\rangle = \left\langle 1 \middle| 0 \right\rangle = 0 and \left\langle 0 \middle| 0 \right\rangle = \left\langle 1 \middle| 1 \right\rangle = 1.

1.4.2 Two-qubit gates: tensor products

Of course, the operations that we can conduct on two-qubit systems need to be unitary. Thus, two-qubit quantum gates are 4 \times 4 unitary matrices that act on 4-dimensional column vectors. The simplest way to construct such matrices is by taking the tensor product of two one-qubit quantum gates. Namely, if we consider two one-qubit gates U_{1} and U_{2} and two one-qubit states \left| \psi_{1} \right\rangle and \left| \psi_{2} \right\rangle, we can form a two-qubit gate U_{1} \otimes U_{2} that acts on \left| \psi_{1} \right\rangle \otimes \left| \psi_{2} \right\rangle as

\left( {U_{1} \otimes U_{2}} \right)\left( {\left| \psi_{1} \right\rangle \otimes \left| \psi_{2} \right\rangle} \right) = \left( {U_{1}\left| \psi_{1} \right\rangle} \right) \otimes \left( {U_{2}\left| \psi_{2} \right\rangle} \right).

By linearity, we can extend U_{1} \otimes U_{2} to any combination of two-qubit states and we can associate a matrix to U_{1} \otimes U_{2}. In fact, said matrix is given by the tensor product of the matrices associated to U_{1} and U_{2}. More concretely, the expression for the tensor product, A \otimes B, of the 2 \times 2 matrices A and B is

\begin{array}{rlrl} {\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{pmatrix} \otimes \begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ \end{pmatrix}} & {= \begin{pmatrix} {a_{11}\begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ \end{pmatrix}} & {a_{12}\begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ \end{pmatrix}} \\ {a_{21}\begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ \end{pmatrix}} & {a_{22}\begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ \end{pmatrix}} \\ \end{pmatrix}\qquad} & & \qquad \\ & {= \begin{pmatrix} {a_{11}b_{11}} & {a_{11}b_{12}} & {a_{12}b_{11}} & {a_{12}b_{12}} \\ {a_{11}b_{21}} & {a_{11}b_{22}} & {a_{12}b_{21}} & {a_{12}b_{22}} \\ {a_{21}b_{11}} & {a_{21}b_{12}} & {a_{22}b_{11}} & {a_{22}b_{12}} \\ {a_{21}b_{21}} & {a_{21}b_{22}} & {a_{22}b_{21}} & {a_{22}b_{22}} \\ \end{pmatrix}.\qquad} & & \qquad \\ \end{array}

Now it is easy to verify that this operation is indeed unitary and, hence, deserves the name of quantum gate.

Exercise 1.11

Check that, given any pair of unitary matrices U_{1} and U_{2}, the inverse of U_{1} \otimes U_{2} is U_{1}^{\dagger} \otimes U_{2}^{\dagger} and that {(U_{1} \otimes U_{2})}^{\dagger} = U_{1}^{\dagger} \otimes U_{2}^{\dagger}.

Tensor products of gates occur naturally when we have circuits with two qubits and pairs of individual one-qubit gates are acting on each of them. For instance, in the following circuit, the gate X \otimes X acts on the two qubits and then it is followed by the gate H \otimes I, where I is the identity gate:

XHX

Exercise 1.12

Explicitly compute the matrices for the gates X \otimes X and H \otimes I.

You may complain that we haven't done anything new so far. And you would be right! In fact, quantum gates that are obtained as the tensor product of one-qubit gates can be seen as operations on isolated qubits that just happen to be applied at the same time. But wait and see! In the next subsection, we will introduce a completely different way of acting on two-qubit systems.

1.4.3 The CNOT gate

By taking tensor products of one-qubit gates, we can only obtain operations that act on each qubit individually. But this just leaves us with a (rather boring) subset of all the possible two-qubit gates. There are many unitary matrices that cannot be written as the tensor product of other simple matrices. In the two-qubit case, probably the most important one is the controlled-NOT (or controlled-\mathbf{X}) gate, usually called the CNOT gate, given by the unitary matrix

\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{pmatrix}.

It is illuminating to see how this gate acts on the elements of the two-qubit computational basis. As you can easily check, we get

\text{CNOT}\left| {00} \right\rangle = \left| {00} \right\rangle,\qquad\text{CNOT}\left| {01} \right\rangle = \left| {01} \right\rangle,\qquad\text{CNOT}\left| {10} \right\rangle = \left| {11} \right\rangle,\qquad\text{CNOT}\left| {11} \right\rangle = \left| {10} \right\rangle.

This means that the value of the second qubit is flipped if and only if the value of the first qubit is 1. Or, to put it in other words, the application of a NOT gate on the second qubit (that we call the target) is controlled by the first qubit. Now the name of this gate makes much more sense, doesn't it?

In a quantum circuit, the CNOT gate is represented as follows:

Notice that the control qubit is indicated by a solid black circle and the target qubit is indicated by the \oplus symbol (the symbol for an X gate can also be used instead of \oplus).

Sometimes, technical difficulties restrict the number of CNOT gates that can be actually implemented on a quantum computer. For instance, on a certain quantum chip you may have the possibility of applying a CNOT gate targeting qubit 1 and controlled by qubit 0, but not the other way around. If you find yourself in such a situation, there's no need to panic. If you use the circuit

HHHH

you are effectively applying a CNOT gate with target in the top qubit and control in the bottom one. And that's how you can save the day!

The CNOT gate can also be used to interchange or swap the states of two qubits, by using the following circuit:

Exercise 1.13

Check these equivalences in two different ways: by computing the matrices of the circuits and by obtaining the result of using them with qubits in states \left| {00} \right\rangle, \left| {01} \right\rangle, \left| {10} \right\rangle, and \left| {11} \right\rangle.

In any case, the most prominent use of the CNOT gate is, without a doubt, the ability to create entanglement, an intriguing property of quantum systems that we will study next.

1.4.4 Entanglement

Oddly enough, in order to define when a quantum system is entangled, we first need to define when it is not entangled. We say that a state \left| \psi \right\rangle is a product state if it can be written as the tensor product of two other states \left| \psi_{1} \right\rangle and \left| \psi_{2} \right\rangle, each of at least one qubit,
as in

\left| \psi \right\rangle = \left| \psi_{1} \right\rangle \otimes \left| \psi_{2} \right\rangle.

If \left| \psi \right\rangle is not a product state, we say that it is entangled.

For example, \left| {01} \right\rangle is a product state, because we know that it is just another way of writing \left| 0 \right\rangle \otimes \left| 1 \right\rangle. Also, \sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {10} \right\rangle) is a product state, because we can factor \left| 0 \right\rangle on the second qubit to obtain

\frac{1}{\sqrt{2}}(\left| {00} \right\rangle + \left| {10} \right\rangle) = \left( {\frac{1}{\sqrt{2}}\left( {\left| 0 \right\rangle + \left| 1 \right\rangle} \right)} \right)\left| 0 \right\rangle.

On the other hand, \sqrt{\left. 1\slash 2 \right.}\left( {\left| {00} \right\rangle + \left| {11} \right\rangle} \right) is an entangled state. No matter how hard you try, it is impossible to write it as a product of two one-qubit states. Suppose, for sake of contradiction, that it were possible. Then, you would have

\begin{array}{rlrl} {\frac{1}{\sqrt{2}}\left( {\left| {00} \right\rangle + \left| {11} \right\rangle} \right)} & {= \left( {a\left| 0 \right\rangle + b\left| 1 \right\rangle} \right)\left( {c\left| 0 \right\rangle + d\left| 1 \right\rangle} \right)\qquad} & & \qquad \\ & {= ac\left| {00} \right\rangle + ad\left| {01} \right\rangle + bc\left| {01} \right\rangle + bd\left| {11} \right\rangle.\qquad} & & \qquad \\ \end{array}

But this forces ad to be 0, because we have no \left| {01} \right\rangle component in \sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {11} \right\rangle). Then, either a = 0, in which case ac is 0, or d = 0, from which bd = 0 follows. In both cases, it is impossible to reach the equality that we needed. Thus, it follows that the state is entangled.

Exercise 1.14

Is \sqrt{\left. 1\slash 3 \right.}(\left| {00} \right\rangle + \left| {01} \right\rangle + \left| {11} \right\rangle) entangled? And what about \frac{1}{2}(\left| {00} \right\rangle + \left| {01} \right\rangle + \left| {10} \right\rangle + \left| {11} \right\rangle)?

When measured, entangled states can show correlations that go beyond what can be explained with classical physics. For instance, if we have the entangled state \sqrt{\left. 1\slash 2 \right.}\left( {\left| {00} \right\rangle + \left| {11} \right\rangle} \right) and we measure the first qubit, we can obtain 0 or 1, each with probability \left. 1\slash 2 \right.. However, if we measure the second qubit afterwards, the result will be completely determined by the value obtained when measuring the first qubit and, in fact, will be exactly the same. If we invert the order and measure first the second qubit, then the result will be 0 or 1, with equal probability. But, in this case, the result of a subsequent measurement of the first qubit will be completely determined!

This still happens even if we separate the two qubits thousands of light years apart, as if one qubit could somehow know what the result of measuring the other qubit was. This curious behavior haunted many physicists during the 20th century, including Albert Einstein, who called it a "spooky action at a distance" (see [34]). Nevertheless, the effects of entanglement have been repeatedly demonstrated in uncountable experiments (in fact, the Nobel Prize in Physics 2022 was awarded to Alain Aspect, John F. Clauser, and Anton Zeilinger, pioneers in studying and testing this phenomenon in practice [10, 25, 41, 19]). And, very importantly for us, entanglement is one of the most powerful resources available in quantum computing.

But entanglement is, by no means, the only puzzling feature of qubit systems. In the next subsection, we are going to mathematically prove that copying quantum information, an operation that you may have taken for granted, is not possible in general. These qubits are, indeed, full of surprises!

1.4.5 The no-cloning theorem

Another peculiar property of quantum systems is that, in general, they don't allow us to copy information. Surprising as this may seem, it is just an easy consequence of the linearity of quantum gates. To show why, let us be more precise about what we would need in order to copy information, for instance with just two qubits. We would like to have a two-qubit quantum gate U that will be able to copy the first qubit into the second. That is, for any given quantum state \left| \psi \right\rangle, we would need

U\left| \psi \right\rangle\left| 0 \right\rangle = \left| \psi \right\rangle\left| \psi \right\rangle.

Then, U\left| {00} \right\rangle = \left| {00} \right\rangle and U\left| {10} \right\rangle = \left| {11} \right\rangle and, by linearity,

U\left( {\frac{1}{\sqrt{2}}(\left| {00} \right\rangle + \left| {10} \right\rangle)} \right) = \frac{1}{\sqrt{2}}\left( {U\left| {00} \right\rangle + U\left| {10} \right\rangle} \right) = \frac{1}{\sqrt{2}}\left( {\left| {00} \right\rangle + \left| {11} \right\rangle} \right).

We should highlight that the state that we have obtained is entangled, as we proved in the previous subsection.

Nevertheless, notice that, in our original state, we can factor the second \left| 0 \right\rangle out to obtain

\frac{1}{\sqrt{2}}(\left| {00} \right\rangle + \left| {10} \right\rangle) = \left( \frac{\left| 0 \right\rangle + \left| 1 \right\rangle}{\sqrt{2}} \right)\left| 0 \right\rangle.

Then, in virtue of the action of U, we should have

U\left( {\frac{1}{\sqrt{2}}(\left| {00} \right\rangle + \left| {10} \right\rangle)} \right) = U\left( {\left( \frac{\left| 0 \right\rangle + \left| 1 \right\rangle}{\sqrt{2}} \right)\left| 0 \right\rangle} \right) = \frac{(\left| 0 \right\rangle + \left| 1 \right\rangle)}{\sqrt{2}}\frac{(\left| 0 \right\rangle + \left| 1 \right\rangle)}{\sqrt{2}},

which is a product state. However, we had obtained earlier that U(\sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {10} \right\rangle)) = \sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {11} \right\rangle), which is entangled! This contradiction implies that, alas, no such U exists.

This remarkable result is called the no-cloning theorem and we should explain its meaning in a little more detail. On the one hand, notice that this does not imply that we cannot copy classical information. In fact, if \left| \psi \right\rangle is just \left| 0 \right\rangle or \left| 1 \right\rangle, we can easily achieve U\left| \psi \right\rangle\left| 0 \right\rangle = \left| \psi \right\rangle\left| \psi \right\rangle by taking U to be the CNOT gate. On the other hand, the theorem applies to unknown states \left| \psi \right\rangle. If we know what \left| \psi \right\rangle is — that is, if we know a circuit that prepares \left| \psi \right\rangle starting from \left| 0 \right\rangle — then, of course, we can create as many independent copies of it as we want. However, if \left| \psi \right\rangle is handed to us without any additional information about its state, the no-cloning theorem shows that we cannot replicate its state in general.

To learn more

The no-cloning theorem plays an important role in the security of quantum key distribution protocols such as the famous BB84, introduced in 1984 by Bennett and Brassard [13].

After this brief detour, let's return to our study of two-qubit quantum gates. In the next subsection, we will show how to construct many interesting two-qubit unitary operations whose action is controlled by one of their inputs.

1.4.6 Controlled gates

You may be wondering if, in addition to a controlled-X (or CNOT) gate, there are also controlled-\mathbf{Y}, controlled-\mathbf{Z}, or controlled-\mathbf{H} gates. The answer is a resounding yes and, in fact, for any quantum gate U, it is possible to define a controlled-U (or, simply, \text{C}\mathbf{U}) gate whose action on the computational basis is

\text{C}U\left| {00} \right\rangle = \left| {00} \right\rangle,\qquad\text{C}U\left| {01} \right\rangle = \left| {01} \right\rangle,\qquad\text{C}U\left| {10} \right\rangle = \left| 1 \right\rangle U\left| 0 \right\rangle,\qquad\text{C}U\left| {11} \right\rangle = \left| 1 \right\rangle U\left| 1 \right\rangle.

Exercise 1.15

Check that the matrix of \text{C}U is

\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & u_{11} & u_{12} \\ 0 & 0 & u_{21} & u_{22} \\ \end{pmatrix},

where {(u_{ij})}_{i,j = 1}^{2} is the matrix of U. Check also that \text{C}U is unitary. What is the adjoint of \text{C}U?

The circuit representation of a \text{C}U gate is similar to the one that we use for the CNOT gate, namely

U ,

where the solid black circle indicates the control and the box with U inside indicates the target.

Constructing a controlled gate is simpler than it seems, provided your quantum computer already implements rotation gates and the two-qubit CNOT gate. In fact, from the decomposition in rotations that we mentioned at the end of Section 1.3.4, it can be proved (see the book by Nielsen and Chuang [69, Corollary 4.2]) that any one-qubit quantum gate U can be written in the form

U = e^{i\theta}AXBXC

for some angle \theta and gates A, B, and C such that ABC = I. Then, the following circuit implements \text{C}U:

RCBA (𝜃) Z

Sometimes, though, constructing a controlled gate is much easier. For instance, it can be shown that a controlled-Z gate can be obtained from a controlled-X and two H gates, as shown in the identity of the following circuits:

Z \qquad = \qquad HH

Exercise 1.16

Prove the preceding equivalence.

We now have everything we need in order to construct our first two-qubit quantum circuit. Let's get those qubits entangled!

1.4.7 Hello, entangled world!

To finish up with our study of two-qubit systems, let us show how to create entangled states with the help of the CNOT gate. Consider the following circuit:

|H|00⟩⟩

Initially, the state of the system is \left| {00} \right\rangle. After we apply the H gate, we get into the state \sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {10} \right\rangle). Finally, when we apply the CNOT gate, the state changes to \sqrt{\left. 1\slash 2 \right.}(\left| {00} \right\rangle + \left| {11} \right\rangle), which, as we proved in Section 1.4.4, is indeed an entangled state.

The state \sqrt{\left. 1\slash 2 \right.}\left( {\left| {00} \right\rangle + \left| {11} \right\rangle} \right) is known as a Bell state, of which there are four. The other three are \sqrt{\left. 1\slash 2 \right.}\left( {\left| {00} \right\rangle - \left| {11} \right\rangle} \right), \sqrt{\left. 1\slash 2 \right.}(\left| {10} \right\rangle + \left| {01} \right\rangle), and \sqrt{\left. 1\slash 2 \right.}(\left| {10} \right\rangle - \left| {01} \right\rangle). All of them are entangled, and they can be prepared with circuits similar to the preceding one.

Exercise 1.17

Show that all four Bell states are entangled. Obtain circuits to prepare them. Hint: you can use Z and X gates after the CNOT in the preceding circuit.

We are now ready for the big moment. In the next section, we will finally learn how to work with not just one or two qubits, but with as many as we can get in our quantum computers.

Previous PageNext Page
You have been reading a chapter from
A Practical Guide to Quantum Machine Learning and Quantum Optimization
Published in: Mar 2023Publisher: PacktISBN-13: 9781804613832
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Elías F. Combarro

Elías F. Combarro holds degrees from the University of Oviedo (Spain) in both Mathematics (1997, award for second highest grades in the country) and Computer Science (2002, award for highest grades in the country). After some research stays at the Novosibirsk State University (Russia), he obtained a Ph.D. in Mathematics (Oviedo, 2001) with a dissertation on the properties of some computable predicates under the supervision of Prof. Andrey Morozov and Prof. Consuelo Martínez. Since 2009, Elías F. Combarro has been an associate professor at the Computer Science Department of the University of Oviedo. He has published more than 50 research papers in international journals on topics such as Computability Theory, Machine Learning, Fuzzy Measures and Computational Algebra. His current research focuses on the application Quantum Computing to algebraic, optimisation and machine learning problems. From July 2020 to January 2021, he was a Cooperation Associate at CERN openlab. Currently, he is the Spain representative in the Advisory Board of CERN Quantum Technology Initiative, a member of the Advisory Board of SheQuantum and one of the founders of the QSpain, a quantum computing think tank based in Spain.
Read more about Elías F. Combarro

author image
Samuel González-Castillo

Samuel González-Castillo holds degrees from the University of Oviedo (Spain) in both Mathematics and Physics (2021). He is currently a mathematics research student at the National University of Ireland, Maynooth, where he works as a graduate teaching assistant. He completed his physics bachelor thesis under the supervision of Prof. Elías F. Combarro and Prof. Ignacio F. Rúa (University of Oviedo), and Dr. Sofia Vallecorsa (CERN). In it, he worked alongside other researchers from ETH Zürich on the application of Quantum Machine Learning to classification problems in High Energy Physis. In 2021, he was a summer student at CERN developing a benchmarking framework for quantum simulators. He has contributed to several conferences on quantum computing.
Read more about Samuel González-Castillo