Learn Quantum Computing with Python and Q#
eBook - ePub

Learn Quantum Computing with Python and Q#

A hands-on approach

  1. 384 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learn Quantum Computing with Python and Q#

A hands-on approach

About this book

Learn Quantum Computing with Python and Q# introduces quantum computing from a practical perspective. Summary Learn Quantum Computing with Python and Q# demystifies quantum computing. Using Python and the new quantum programming language Q#, you'll build your own quantum simulator and apply quantum programming techniques to real-world examples including cryptography and chemical analysis. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the technology Quantum computers present a radical leap in speed and computing power. Improved scientific simulations and new frontiers in cryptography that are impossible with classical computing may soon be in reach. Microsoft's Quantum Development Kit and the Q# language give you the tools to experiment with quantum computing without knowing advanced math or theoretical physics. About the book Learn Quantum Computing with Python and Q# introduces quantum computing from a practical perspective. Use Python to build your own quantum simulator and take advantage of Microsoft's open source tools to fine-tune quantum algorithms. The authors explain complex math and theory through stories, visuals, and games. You'll learn to apply quantum to real-world applications, such as sending secret messages and solving chemistry problems. What's inside The underlying mechanics of quantum computers
Simulating qubits in Python
Exploring quantum algorithms with Q#
Applying quantum computing to chemistry, arithmetic, and data About the reader For software developers. No prior experience with quantum computing required. About the author Dr. Sarah Kaiser works at the Unitary Fund, a non-profit organization supporting the quantum open-source ecosystem, and is an expert in building quantum tech in the lab. Dr. Christopher Granade works in the Quantum Systems group at Microsoft, and is an expert in characterizing quantum devices. Table of Contents PART 1 GETTING STARTED WITH QUANTUM
1 Introducing quantum computing
2 Qubits: The building blocks
3 Sharing secrets with quantum key distribution
4 Nonlocal games: Working with multiple qubits
5 Nonlocal games: Implementing a multi-qubit simulator
6 Teleportation and entanglement: Moving quantum data around
PART 2 PROGRAMMING QUANTUM ALGORITHMS IN Q#
7 Changing the odds: An introduction to Q#
8 What is a quantum algorithm?
9 Quantum sensing: It's not just a phase
PART 3 APPLIED QUANTUM COMPUTING
10 Solving chemistry problems with quantum computers
11 Searching with quantum computers
12 Arithmetic with quantum computers

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Learn Quantum Computing with Python and Q# by Sarah C. Kaiser,Christopher Grenade in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation en Python. We have over one million books available in our catalogue for you to explore.

Information

Part 1. Getting started with quantum

This part of the book helps set the stage for the rest of our quantum journey. In chapter 1, we gain more context about quantum computing, the approach to learning quantum computing in this book, and where we can expect to use this to apply the skills we learn. In chapter 2, we start getting into writing code by developing a quantum simulator in Python. We then use the simulator to program a quantum random number generator. Next, in chapter 3, we extend the simulator to program cryptographic applications of quantum technology, such as the BB84 quantum key exchange protocol. In chapter 4, we use nonlocal games to learn about entanglement and extend the simulator once again to support multiple qubits. In chapter 5, we learn how to use a new Python package to help implement quantum strategies for playing the nonlocal games from chapter 4. Finally, in chapter 6, we extend the simulator one last time, adding new quantum operations so that we can simulate techniques like quantum teleportation and practice moving data in our quantum devices.

1 Introducing quantum computing

This chapter covers
  • Why people are excited about quantum computing
  • What a quantum computer is
  • What a quantum computer can and cannot do
  • How quantum computers relate to classical programming
Quantum computing has been an increasingly popular research field and source of hype over the last few years. By using quantum physics to perform computation in new and wonderful ways, quantum computers can impact society, making it an exciting time to get involved and learn how to program quantum computers and apply quantum resources to solve problems that matter.
In all the buzz about the advantages quantum computing offers, however, it is easy to lose sight of the real scope of those benefits. We have some interesting historical precedent for what can happen when promises about a technology outpace reality. In the 1970s, machine learning and artificial intelligence suffered from dramatically reduced funding, as the hype and excitement around AI outstripped its results; this would later be called the “AI winter.” Similarly, internet companies faced the same danger when trying to overcome the dot-com bust.
One way forward is to critically understand the promise offered by quantum computing, how quantum computers work, and what is and is not in scope for quantum computing. In this chapter, we help you develop that understanding so that you can get hands-on and write your own quantum programs in the rest of the book.
All that aside, though, it’s just really cool to learn about an entirely new computing model! As you read this book, you’ll learn how quantum computers work by programming simulations that you can run on your laptop today. These simulations will show many essential elements of what we expect real commercial quantum programming to be like while useful commercial hardware is coming online. This book is intended for folks who have some basic programming and linear algebra experience but no prior knowledge about quantum physics or computing. If you have some quantum familiarity, you can jump into parts 2 and 3, where we get into quantum programming and algorithms.

1.1 Why does quantum computing matter?

Computing technology is advancing at a truly stunning pace. Three decades ago, the 80486 processor allowed users to execute 50 MIPS (million instructions per second). Today, small computers like the Raspberry Pi can reach 5,000 MIPS, while desktop processors can easily reach 50,000 to 300,000 MIPS. If we have an exceptionally difficult computational problem we’d like to solve, a very reasonable strategy is to simply wait for the next generation of processors to make our lives easier, our videos stream faster, and our games more colorful.
For many problems that we care about, however, we’re not so lucky. We might hope that getting a CPU that’s twice as fast will let us solve problems that are twice as big, but as with so much in life, “more is different.” Suppose we sort a list of 10 million numbers and find that it takes about 1 second. Later, if we want to sort a list of 1 billion numbers in 1 second, we’ll need a CPU that’s 130 times faster, not just 100 times. When solving some kinds of problems, this gets even worse: for some graphics problems, going from 10 million to 1 billion points would take 13,000 times longer.
Problems as widely varied as routing traffic in a city and predicting chemical reactions become more difficult much more quickly. If quantum computing was about making a computer that runs 1,000 times as fast, we would barely make a dent in the daunting challenges that we want to solve. Fortunately, quantum computers are much more interesting. We expect that quantum computers will be much slower than classical computers but that the resources required to solve many problems will scale differently, such that if we look at the right kinds of problems, we can break through “more is different.” At the same time, quantum computers aren’t a magic bullet—some problems will remain hard. For example, while it is likely that quantum computers can help us immensely with predicting chemical reactions, they may not be much help with other difficult problems.
Investigating exactly which problems we can obtain such an advantage in and developing quantum algorithms to do so has been a large focus of quantum computing research. Up until this point, it has been very difficult to assess quantum approaches this way, as doing so required extensive mathematical skill to write out quantum algorithms and understand all the subtleties of quantum mechanics.
As industry has started developing platforms to help connect developers to quantum computing, however, this situation has begun to change. By using Microsoft’s entire Quantum Development Kit, we can abstract away most of the mathematical complexities of quantum computing and begin actually understanding and using quantum computers. The tools and techniques taught in this book allow developers to explore and understand what writing programs for this new hardware platform will be like.
Put differently, quantum computing is not going away, so understanding what problems we can solve with it matters quite a lot indeed! Independent of whether a quantum “revolution” happens, quantum computing has factored—and will continue to factor—heavily into decisions about how to develop computing resources over the next several decades. Decisions like these are strongly impacted by quantum computing:
  • What assumptions are reasonable in information security?
  • What skills are useful in degree programs?
  • How can we evaluate the market for computing solutions?
For those of us working in tech or related fields, we increasingly must make such decisions or provide input for them. We have a responsibility to understand what quantum computing is and, perhaps more important, what it is not. That way, we will be best prepared to step up and contribute to these new efforts and decisions.
All that aside, another reason quantum computing is such a fascinating topic is that it is both similar to and very different from classical computing. Understanding both the similarities and differences between classical and quantum computing helps us understand what is fundamental about computing in general. Both classical and quantum computation arise from different descriptions of physical laws such that understanding computation can help us understand the universe in a new way.
What’s absolutely critical, though, is that there is no one right or even best reason to be interested in quantum computing. Whatever brings you to quantum computing research or applications, you’ll learn something interesting along the way.

1.2 What is a quantum computer?

Let’s talk a bit about what actually makes up a quantum computer. To facilitate this discussion, let’s briefly talk about what the term computer means.
Definition A computer is a device that takes data as input and does some sort of operations on that data.
There are many examples of what we have called a computer; see figure 1.1 for some examples.
Figure 1.1 Several examples of different kinds of computers, including the UNIVAC mainframe operated by Rear Admiral Hopper, a room of “human computers” working to solve flight calculations, a mechanical calculator, and a LEGO-based Turing machine. Each computer can be described by the same mathematical model as computers like cell phones, laptops, and servers. Sources: Photo of “human computers” by NASA. Photo of LEGO Turning machine by Projet Rubens, used under CC BY 3.0 (https://creativecommons.org/licenses/by/3.0/).
All of these have in common that we can model them with classical physics—that is, in terms of Newton’s laws of motion, Newtonian gravity, and electromagnetism. This will help us tell apart the kinds of computers we’re used to (e.g., laptops, phones, bread machines, houses, cars, and pacemakers) and the computers we’re learning about in this book. To tell the two apart, we’ll call computers that can be described using ...

Table of contents

  1. inside front cover
  2. Learn Quantum Computing with Python and Q#
  3. Copyright
  4. dedication
  5. contents
  6. front matter
  7. Part 1. Getting started with quantum
  8. 1 Introducing quantum computing
  9. 2 Qubits: The building blocks
  10. 3 Sharing secrets with quantum key distribution
  11. 4 Nonlocal games: Working with multiple qubits
  12. 5 Nonlocal games: Implementing a multi-qubit simulator
  13. 6 Teleportation and entanglement: Moving quantum data around
  14. Part 2. Programming quantum algorithms in Q#
  15. 7 Changing the odds: An introduction to Q#
  16. 8 What is a quantum algorithm?
  17. 9 Quantum sensing: It’s not just a phase
  18. Part 3. Applied quantum computing
  19. 10 Solving chemistry problems with quantum computers
  20. 11 Searching with quantum computers
  21. 12 Arithmetic with quantum computers
  22. appendix A. Installing required software
  23. appendix B. Glossary and quick reference
  24. appendix C. Linear algebra refresher
  25. appendix D. Exploring the Deutsch–Jozsa algorithm by example
  26. index