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

Preface

Quantum computers offer a potential sea change in computing power. IBM Research has made quantum computing available to the public for the first time, providing access to IBM QX from any desktop or mobile device via the cloud. Complete with cutting-edge practical scenarios, this book will help you understand the power of quantum computing by programming for the real-world.

Mastering Quantum Computing with IBM QX begins with an introduction to the concept and principles of quantum computing and the areas in which they can be applied. You'll see how quantum computing can be used to improve the classical methods of computer processing and convert a classical algorithm into a quantum algorithm. You'll then explore the IBM ecosystem, which facilitates quantum development with the help of the Quantum Composer and Qiskit. As you progress through the chapters, you'll learn how to implement algorithms on the quantum processor and how quantum computations are actually performed.

By the end of the book, you'll have learned how to create quantum programs of your own, explored the impact of quantum computing on your business and career, and future-proofed your programming career.

Who this book is for

If you're a developer or data scientist interested in learning quantum computing, this book is for you. You're expected to have basic understanding of the Python language, but knowledge of physics, quantum mechanics, or advanced mathematics is not required.

What this book covers

Chapter 1, What is Quantum Computing?, gives an overview of what quantum computing is in contrast to classical computing, focusing on its potential advantages over classical computers. We then go over the history of classical and quantum computing and get an overview of the state-of-the-art in computation.

Chapter 2, Qubits, gives us an overview of why qubits are the cornerstones of quantum computation along with code to simulate it in Python. It discusses superposition and uses Python code to explore three different representations of a single qubit. The chapter then introduces the Bloch sphere and describes the superposition and measurement of single qubits.

Chapter 3, Quantum States, Quantum Registers, and Measurement, is about the quantum version of classic registers, quantum registers, which hold quantum states. We will discuss separable states and entanglement, which leads to a focus on quantum measurement and a Python implementation of quantum measurement for multiple, possibly entangled, qubits.

Chapter 4, Evolving Quantum States with Quantum Gates, gives an overview of the most commonly-used gates in quantum computing: I, X, Y, Z, H, S, S, T, T, and CNOT, which form a universal gate set that can be combined to perform any quantum computation. It provides a Python implementation of these commonly used quantum gates, and goes over examples within Python of these gates being applied to the states we have examined so far.

Chapter 5, Quantum Circuits, expands on the idea of quantum gates to introduce quantum circuits, the quantum analogue of classical circuits. It goes over how classical gates can be reproduced by quantum circuits and proceeds to introduce a visual representation of quantum circuits that can be used to easily define a quantum circuit without reference to mathematics or use of a programming language.

Chapter 6, The Quantum Composer, is all about the interactive interface in IBM QX used to create quantum circuits via quantum scores, the graphical manner of representing circuits introduced earlier. Via the Quantum Composer, you can define your own circuits for implementation on the IBM QX hardware or software simulator. The chapter proceeds to translate the examples previously coded in Python to the Quantum Composer representation and gives you the opportunity to run them on IBM QX hardware.

Chapter 7, Working with OpenQASM, describes the Open Quantum Assembly Language (pronounced open kazm). This language can be used within IBM QX. The chapter revisits some of the quantum circuits defined in previous chapters and redefines them within the OpenQASM language. It then provides you with the opportunity to rerun these circuits on the IBM QX, using OpenQASM.

Chapter 8, Qiskit and Quantum Computer Simulation, introduces Qiskit (Quantum Information Software Kit), focusing on how it can be used to run programs in IBM QX via the cloud, as well as its capabilities for quantum simulation.  The chapter then moves on to a capstone project using Qiskit to illustrate, in one project, the concepts of quantum circuits, measurement, and Qiskit usage, while producing a useful demo of using a quantum computer to represent musical chords.

Chapter 9, Quantum AND (Toffoli) Gates and Quantum OR Gates, explores some of the quantum equivalents of classic Boolean logical gates in order to specify logic problems to be solved by a quantum computer for use with Grover's algorithm and other algorithms.

Chapter 10, Grover's Algorithm, goes over the classical implementation compared to the quantum implementation as given by Grover's algorithm. Finally, the chapter provides an implementation of Grover's algorithm in OpenQASM, Qiskit, and quantum score. 

Chapter 11, Quantum Fourier Transform, describes the Quantum Fourier Transform, which is a sub-routine of many important quantum algorithms, including Shor's algorithm. The chapter next shows the use a classical algorithm to compute the discrete Fourier transform, that is a Fourier transform of a signal represented on a classical computer. Finally, a Quantum Fourier Transform algorithm is given in OpenQASM, Qiskit, and quantum score.

Chapter 12, Shor's Algorithm, explores Shor's algorithm. It goes over what prime factorization is, the classical implementation of an algorithm to perform prime factorization as compared to the quantum implementation as given by Shor's algorithm. Finally, the chapter provides an implementation of Shor's algorithm in Qiskit.

Chapter 13, Quantum Error Correction, describes the problem of quantum error propagation and illustrates the need for quantum error correction. Next, an overview of quantum error correction (QEC) is given, and finally, the chapter provides an implementation of a simple QEC algorithm.

Chapter 14, Conclusion – The Future of Quantum Computing, reviews what we have learned and places it in the context of areas where quantum computing is poised to disrupt, and those understanding quantum computation and quantum programming are likely to be in high demand. In addition, the book discusses why an executive, a programmer, or a technically minded person who doesn't happen to be a quantum physicist might care about quantum computing.

The solutions to practice questions at the end of each chapter are available at https://www.packtpub.com/sites/default/files/downloads/Assessments.pdf.

To get the most out of this book

This book assumes you are familiar with the Python programming language. Python 3.4+ is used. You won't need knowledge of quantum mechanics, physics, or advanced mathematics, but should have an understanding of algebra at a high-school level. To get the most out of the book, go through the exercises in the Jupyter Notebooks provided and answer the questions posed at the end of each chapter.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Quantum-Computing-with-IBM-QX. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789136432_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Now open theHello Quantum World.ipynb notebook by navigating to it from the Jupyter Notebook GUI."

A block of code is set as follows:

from qiskit.tools.visualization import plot_histogram
plot_histogram(job_exp.result().get_counts(qc))

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

import time
q = qiskit.QuantumRegister(5)
c = qiskit.ClassicalRegister(5)
qc = qiskit.QuantumCircuit(q, c)

Any command-line input or output is written as follows:

cd Mastering-Quantum-Computing-with-IBM-QX

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Now, click Simulate, then click OK, and within seconds you will get the output."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.