Quantum Computing
Program Next-Gen Computers for Hard, Real-World Applications
by Nihal Mehta, Ph.D.
Version: P1.0 (August 2020)
Copyright 2020 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/nmquantum, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Andy Hunt (Publisher) Janet Furlow (VP of Operations) Dave Rankin (Executive Editor) Brian MacDonald (Development Editor) L. Sakhi MacMillan (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2020, The Pragmatic Bookshelf.
Early Praise for Quantum Computing
Youll remember shaking your head when someone tries to win a metaphysical argument with recourse to quantum physics. I call it the countdown to quantum. While you wont win those arguments with this book, youll learn about what quantum computing really consists of and that its not the infinite speed classical computer of popular opinion. I know nothing of the technical challenges of building quantum hardware, but there will be a corresponding challenge finding programmers competent in these skills. This book excels at teaching the necessary concepts.
Nigel Lowry |
Director, Lemmata |
Truly scintillating. Professor Mehtas Quantum Computing opened my eyes to a beautiful new world of practical probabilistic programming.
Ross Henderson |
CEO, CAREM, a geospatial epidemiology company |
Quantum computing has a reputation for being tricky and often tangled up in complex maths; even its basic building blocks can run counter to our everyday understanding of the world. This book takes a different approach to describing quantum phenomena thats much easier to initially grasp and then goes into how we can use it to build programs, giving us an abstraction that is actually useful back in the real world. Starting from the basics of quantum states and working up to building real programs using quantum computers, this book covers it all. Its even got some maths if you miss that.
Tim Nugent |
Owner, Lonely.Coffee |
No other book teaches the fundamentals so clearly. I cant imagine beginning quantum programming without this book.
Nick Watts |
Software Engineer, CAS, a division of the American Chemical Society |
Preface
Richard Feynman, a Nobel Laureate, first postulated a computer rooted in the laws of quantum mechanics that govern the behavior of subatomic particles such as muons, gluons, quarks, and bosons. Its a theory that strains credulity at every turnits bizarre concepts jar against everyday experience. A long line of distinguished quantum physicists from Niels Bohr to Albert Einstein and Richard Feynman have been exasperated by the very theory they helped create. Yet, surprisingly, the theory has correctly predicted every phenomenon that physicists have thrown at it. These same principles now have their sights trained on digital computing. For the first time since Eniac, the modern computer built at the University of Pennsylvania in 1946, the underlying fabric of computing is threatened: bits, with their rigid and states, are replaced with fluid units that seemingly exist in both states simultaneously, giving us unprecedented ways to tackle challenging computational tasks. Quantum mechanics is the most spectacular theory ever put forth, and we are going to latch onto its coattails to learn about quantum computing and how its challenging the notions of conventional computing.
I first got interested in quantum computing years ago when I was exploring ways to squeeze better performance from the mathematical-based computer models that I was tasked with building for some of the worlds largest organizations. Time and again, though the computer models would return acceptable solutions, I couldnt get them to do even better. Its like the models hit a wall. Quantum mechanical concepts such as tunneling seemed to offer a way to punch through the barrier. But quantum mechanics is strange, and it was far from clear how to model computational tasks using subatomic particles. I created paper models to help make sense of the counter-intuitive quantum mechanics concepts. But, with no real quantum hardware to validate the models, they remained untested ideas that I filed away.