Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Dancing with Python

You're reading from   Dancing with Python Learn to code with Python and Quantum Computing

Arrow left icon
Product type Paperback
Published in Aug 2021
Publisher Packt
ISBN-13 9781801077859
Length 744 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Robert S. Sutor Robert S. Sutor
Author Profile Icon Robert S. Sutor
Robert S. Sutor
Arrow right icon
View More author details
Toc

Table of Contents (29) Chapters Close

Preface 1. Chapter 1: Doing the Things That Coders Do 2. Part I: Getting to Know Python FREE CHAPTER
3. Chapter 2: Working with Expressions 4. Chapter 3: Collecting Things Together 5. Chapter 4: Stringing You Along 6. Chapter 5: Computing and Calculating 7. Chapter 6: Defining and Using Functions 8. Chapter 7: Organizing Objects into Classes 9. Chapter 8: Working with Files 10. PART II: Algorithms and Circuits
11. Chapter 9: Understanding Gates and Circuits 12. Chapter 10: Optimizing and Testing Your Code 13. Chapter 11: Searching for the Quantum Improvement 14. PART III: Advanced Features and Libraries
15. Chapter 12: Searching and Changing Text 16. Chapter 13: Creating Plots and Charts 17. Chapter 14: Analyzing Data 18. Chapter 15: Learning, Briefly 19. References
20. Other Books You May Enjoy
21. Index
Appendices
1. Appendix A: Tools 2. Appendix B: Staying Current 3. Appendix C: The Complete UniPoly Class
4. Appendix D: The Complete Guitar Class Hierarchy
5. Appendix E: Notices 6. Appendix F: Production Notes

1.11 Qubits

In the first section of this chapter, we looked at data. Starting with the bits 0 and 1, we built integers, and I indicated that we could also represent floating-point numbers. Let’s switch from the arithmetic and algebra of numbers to geometry.

A single point is 0-dimensional. Two points are just two 0-dimensional objects. Let’s label these points 0 and 1. When we draw an infinite line through the two points and consider all the points on the line, we get a 1-dimensional object. We can represent each such point as (x), or just x, where x is a real number. If we have another line drawn vertically and perpendicular to the first, we get a plane. A plane is 2-dimensional, and we can represent every point in it with coordinates (x, y). The point (0, 0) is the origin.

Points in 0, 1, and 2 dimensions
Figure 1.7: Points in 0, 1, and 2 dimensions

This is the Cartesian geometry you learned in school. As we move from zero dimensions to two in Figure 1.7, we can represent more information. In an imprecise sense, we have more room in which to work. We can even link together the geometry of the plane with complex numbers, which extend the real numbers. We see those in section 5.5.

Now I want you to think about taking the standard 2-dimensional plane and wrapping it completely around a sphere. If that request strikes you as bizarre, consider this: start with a sphere and balance the plane on top. Make the origin of the plane sit right on the north pole of the sphere. Now start uniformly bending the plane down over the sphere, compressing it together as you move out from the origin.

Plane balanced on a sphere
Figure 1.8: A plane balanced on a sphere

Carry this to its completion, and the “infinity” ∞ of the plane sits at the south pole. In mathematical terms, this is a stereographic projection of the plane onto the sphere.

That was mind-warping as well as plane-warping! The sphere sits in three dimensions, but we can think about its surface as two-dimensional.

Exercise 1.12

We use longitude and latitude measured in degrees to locate any location on our planet. Those are the two coordinates for the “dimensions” of the surface of the Earth. Look at an image of the planet with longitude lines drawn and see how they get closer as you approach the poles. This is very different from the usual xy-plane, where the lines stay equally spaced.

With that geometric discussion as the warm-up, I am now ready to introduce the qubit, which is short for “quantum bit.” While a bit can only be 0 or 1, a qubit can exist in more states. Qubits are surprising, fascinating, and powerful. They follow strange rules which may not initially seem natural to you. According to physics, these rules may be how nature itself works at the level of electrons and photons.

A qubit starts in an initial state. We use the notation |0⟩ and |1⟩ when we are talking about a qubit instead of the 0 and 1 for a bit. For a bit, the only non-trivial operation you can perform is switching 0 to 1 and vice versa. We can move a qubit’s state to any point on the sphere shown in the center of Figure 1.9. We can represent more information and have more room in which to work.

A quantum Bloch sphere
Figure 1.9: A quantum Bloch sphere

This sphere is called the Bloch sphere, named after physicist Felix Bloch.

Things get even better when we have multiple qubits. One qubit holds two pieces of information, and two qubits hold four. That’s not surprising, but if we add a third qubit, we can represent eight pieces of information. Every time we add a qubit, we double its capacity. For 10 qubits, that’s 1,024. For 100 qubits, we can represent 1,267,650,600,228,229,401,496,703,205,376 pieces of information. This illustrates exponential behavior since we are looking at 2the number of qubits.

You’re going to see how to use bits, numbers, qubits, strings, and many other useful objects and structures as we progress through this book. Before we leave this section, let me point out several weird yet intriguing qubit features.

  • While we can perform operations and change the state of a qubit, the moment we look at the qubit, the state collapses to 0 or 1. We call the operation that moves the qubit state to one of the two bit states “measurement.”
  • Just as we saw that bits have meaning when they are parts of numbers and strings, presumably the measured qubit values 0 and 1 have meaning as data.
  • Probability is involved in determining whether we get 0 or 1 at the end.
  • We use qubits in algorithms to take advantage of their exponential scaling and other underlying mathematics. With these, we hope eventually to solve some significant but currently intractable problems. These are problems for which classical systems alone will never have enough processing power, memory, or accuracy.

Scientists and developers are now creating quantum algorithms for use cases in financial services and artificial intelligence (AI). They are also looking at precisely simulating physical systems involving chemistry. These may have future applications in materials science, agriculture, energy, and healthcare.

lock icon The rest of the chapter is locked
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.
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 $19.99/month. Cancel anytime