Book Image

Mastering Quantum Computing with IBM QX

By : Dr. Christine Corbett Moran
Book Image

Mastering Quantum Computing with IBM QX

By: Dr. Christine Corbett Moran

Overview of this book

<p>Quantum computing is set to disrupt the industry. IBM Research has made quantum computing available to the public for the first time, providing cloud access to IBM QX from any desktop or mobile device. Complete with cutting-edge practical examples, this book will help you understand the power of quantum computing in the real world.</p> <p>Mastering Quantum Computing with IBM QX begins with the principles of quantum computing and the areas in which they can be applied. You'll explore the IBM Ecosystem, which enables quantum development with Quantum Composer and Qiskit. As you progress through the chapters, you'll implement algorithms on the quantum processor and learn how quantum computations are actually performed.</p> <p>By the end of the book, you will completely understand how to create quantum programs of your own, the impact of quantum computing on your business, and how to future-proof your programming career.</p>
Table of Contents (22 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Qubits, states, and gates in terms of matrices


This section repeats part of earlier chapters, using more mathematical language and notation instead of Python code. This section of the Appendix is based upon my paper Moran CC (2018) Quintuple: A Tool for Introducing Quantum Computing Into the Classroom (https://www.frontiersin.org/articles/10.3389/fphy.2018.00069/full). 

Qubits

A qubit is the quantum generalization of a classic bit. Unlike a classic bit, it can take any value corresponding to a linear superposition of its constituents: formally, two orthonormal eigenstates. In the course of the book, to prevent confusion as to when a number, for example 1, was used as a number, and when it was used as merely a label of a state, we always put "1" in quotes when it was used as a label of a state, for example, |"1">. However, in the general mathematical literature it is recognized that whatever lies between | and > or < and | is a label of a state, so here we will drop the quotation marks consistent with the literature.

Our default choice of basis throughout this appendix is the following:

 

This multi-purpose notation (<| or |>), used throughout this manuscript to represent a quantum state, is called bra-ket or Dirac notation and is standard in quantum mechanics. Without getting into a detailed discussion of the mathematics, one can, simplistically, think of the symbol lying between the |> notation as being a label for the state. Whether the notation is |> versus <| indicates whether it is represented as a column or a row vector, respectively, where <| is the conjugate transpose of |> and vice versa. Thus, a generic one-qubit state |ψ> is |ψ> = a|0> + b|1>.

The coefficients a and b are complex numbers and these complex coefficients provide the representation of

 in the {|0>, |1>} basis. The probability of finding |ψ> in state |0> is |a|2 = aa*, where a* is the complex conjugate of a; similarly, the probability of finding |ψ> in state |1> is |b|2 = bb*. These two probabilities normalize to one: |a|2 + |b|2 = 1. A single qubit state |ψ> can be physically realized by a variety of mechanisms that correspond to a quantum mechanical two-state systems, for example a two spin system, or a two level system, among many others. The Bloch sphere is a useful way to visualize the state of a single qubit on a unit sphere. Formally, in the Bloch sphere representation the qubit state is written as follows:

Where θ and Φ are the polar coordinates to describe a vector on the unit sphere.

To make use of the power of quantum computation, we will in general want more than one qubit. In a classic n-bit register, we can initialize each bit to 0 or 1. For example, to represent the base 10 number 19 in a classic five-bit register, we can set its elements to 10011. For n qubits, to create an analogous state, a so-called quantum register, we prepare the state |10011> = |1> 

|0> 
 |0> 
|1> 
|1>
. Here, 
 corresponds to the tensor product (also known as the direct or Kronecker product). Generically, an n-bit quantum register can hold any superposition of n-qubit states.

For an n-qubit state, there are 2n possible values the n-qubit state can, in general, be a superposition of. For example, for a 2-qubit state we have 2= 4 possible states, {|00>, |01>, |10>, |11>}. For a 3-qubit state, we have 2= 8 possible states or {|000>, |001>, |010>, |011>, |100>, |101>, |110>, |111>}.

Numbering the states from 0 to 2n-1, the canonical ordering used throughout this section is

, where the number of summations corresponds to the total number of qubits. Thus, if we incorporate the amplitudes, the complex coefficients of these states, we can compute the probability of finding 

 in state |ij...m> as the squared absolute value of cij...m, |cij...m|2 = cij..mc*ij...m. If we can represent an n-qubit state as the tensor product of the states of individual qubits |q0q1...qn> = |q0

|q1> 
...
|qn>,
 the state is called separable. However, due to the nature of superposition, it may be that a multi-qubit state is non-separable and individual qubit states are not well defined independent of other qubits. This non-local correlation phenomenon known as entanglement is a necessary resource to achieve the exponential speedup of quantum compared to classic computation. As such, the concept of quantum registers, necessary to store multi-qubit non-separable states, will play a primary role in quantum computation simulation.

Gates

We have outlined the analogy to the classic n-bit register, the n-qubit quantum register, for keeping track of quantum data. Here, we will do the same with a classic gate and a quantum gate, which evolve classic and quantum states respectively. In classic computation, a classic gate operates on a classic register to evolve its state. In quantum computation, a quantum gate operates on a quantum register to evolve its state. Quantum states can be represented by matrices; the mathematics of the evolution of quantum states can unsurprisingly be represented by matrices as well. To represent quantum gates, these matrices must conform to the postulates of quantum mechanics as they multiply a state to produce an evolved state. Specifically, we know that the evolution of states must conserve probability (preserve norms); we cannot produce a state that is a superposition of states with a probability greater than one.

Matrices that ensure the conservation of probability when they multiply states are called unitary. Formally, this corresponds to any matrix U that satisfies the property that its conjugate transpose U is also its inverse, that is, UU = UU = I, where I is the identity matrix. In quantum computation, a quantum gate corresponds to a unitary matrix, and any unitary matrix corresponds to a valid quantum gate. Since unitary matrices are always invertible, quantum gates and thus computation is reversible; any operation we can do, we can undo. As a qubit state can be realized physically by a variety of quantum mechanical systems, so can quantum gates be physically realized by a variety of quantum mechanical mechanisms, which must necessarily depend on the system's representation of the qubit. For example, in a system where qubits are represented by ions in a quantum trap, a laser tuned to a particular frequency can induce a unitary transformation, effectively acting as a quantum gate.

Gates acting on a single qubit can be applied to a quantum register of an arbitrary qubit number. For example, for a gate X, if the desired qubit to act on is the 3rd qubit in a 4-qubit quantum register, X is a gate which flips the qubit it acts on from |0> to |1> or from |1> to |0>. The appropriate gate is formed via X3of4 = I 

 X 
I
, where I is the 2 x 2 identity matrix. In general, to create a gate Gm of n to operate on the mth qubit of a register of n qubits from a gate G that operates on a single qubit, one may use the following:

Here,

is the analog of

 corresponding to the tensor product, instead of the summation operation. We can see that the application of a gate on a single qubit in this fashion doesn't generate entanglement, as it never results in the expansion of the size of the quantum register it is acting on.

The gates we will work with are defined as follows.

Gate definitions in terms of matrices

Specific sets of classic gates, for example the the NOT and AND gates, can be used to construct all other classic logic gates and thus form a set of universal classic gates. Other such sets exist; in fact, the NAND, negative and, gate alone is a universal classic gate. In quantum computation, to obtain a universal gate set we will need a multi-qubit gate, which is applied on 2-qubits of an n-qubit register. The CNOT gate is one such gate. CNOT is the 2-qubit controlled not gate. Its first input is known as the control qubit, the second as the target qubit, and the state of the target qubit is flipped on output if and only if the control qubit is |1>. The application of CNOT can under many scenarios generate entanglement. CNOT combined with single qubit gates can approximate, arbitrarily well, any (unitary) operation on a quantum computer. Quantum gates can be combined to form quantum circuits, the analog to classic circuits composed of logic gates connected by wires. The full set of gates that the IBM QX supports forms a (non-minimal) universal quantum gate set, such that we can combine the gates in a quantum circuit to create any multi-qubit logic gate we desire.

The H gate is also known as a Hadamard  gate and is defined as follows:

The X, Y, and Z gates are also known as Pauli gates and are defined as follows:

 

 

The I gate is also known as an Identity gate and is defined as follows:

The S gate is also known as a Phase gate and is defined as follows: 

  

The T gate is also known as a π/8 gate and is defined as follows:

 

The CNOT gate is also known as a quantum NOT gate and is defined as follows:

Additional gates

The quantum experience defines three additional gates, which correspond to being able to more easily navigate to different areas of the Bloch sphere. These gates aren't needed for the universal quantum gate set, but can help to minimize the total number of gates, and thus decrease the errors of a computation and/or make the computation easier to follow. These gates are as follows:

 

Quantum measurement

We'll need to understand how measurement functions in quantum mechanics to understand the constraints of extracting information from a quantum register. Measurement in quantum mechanics is something that engenders a lot of discussion, but its properties are straightforward to state in mathematics, if not in philosophy. It is possible to perform a measurement of a single qubit with respect to any basis {|a>, |b>} (not just the default {|0>, |1>} basis), so long as this basis is orthonormal, that is, that the total probability is 1. It is likewise possible to measure a multi-qubit system with respect to any orthonormal basis. Earlier, we stated that the probability of finding the following:

,

In state |ij...m> is the squared absolute value of cij..m, which is |cij..m|2 = cij..mc*ij..m. Here, when we perform a measurement, we actually do find the system in one of these states |ij...m> with the appropriate probability |cij..m|2. After the measurement is performed, the state is collapsed and all further measurements return the same result, state |ij...m> with probability 1.