21,59 €
Quantum computing is an exciting subject that offers hope to solve the world’s most complex problems at a quicker pace. It is being used quite widely in different spheres of technology, including cybersecurity, finance, and many more, but its concepts, such as superposition, are often misunderstood because engineers may not know the math to understand them. This book will teach the requisite math concepts in an intuitive way and connect them to principles in quantum computing.
Starting with the most basic of concepts, 2D vectors that are just line segments in space, you'll move on to tackle matrix multiplication using an instinctive method. Linearity is the major theme throughout the book and since quantum mechanics is a linear theory, you'll see how they go hand in hand. As you advance, you'll understand intrinsically what a vector is and how to transform vectors with matrices and operators. You'll also see how complex numbers make their voices heard and understand the probability behind it all.
It’s all here, in writing you can understand. This is not a stuffy math book with definitions, axioms, theorems, and so on. This book meets you where you’re at and guides you to where you need to be for quantum computing. Already know some of this stuff? No problem! The book is componentized, so you can learn just the parts you want. And with tons of exercises and their answers, you'll get all the practice you need.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 192
Veröffentlichungsjahr: 2022
A beginner's guide to just the math you need without needless complexities
Leonard S. Woody III
BIRMINGHAM—MUMBAI
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Publishing Product Manager: Sunith Shetty
Senior Editor: Nathanya Dias
Content Development Editor: Sean Lobo
Technical Editor: Rahul Limbachiya
Copy Editor: Safis Editing
Project Coordinator: Aishwarya Mohan
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Nilesh Mohite
Marketing Coordinator: Abeer Dawe
First published: April 2022
Production reference: 1170322
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80107-314-1
www.packt.com
To my wife Jeanette, I owe you a debt of gratitude that I can only repay by loving you every day for the rest of my life, and fortunately for us, that will be easy.
I dedicate this book to my mom, Georgia Chandler Mapes, and my dad, Leonard Spencer Woody, Jr.
You raised me right!
And to my grammy, Patricia Dana Woody. You were my second mother and I love you and miss you terribly.
I would first like to acknowledge my technical reviewer, Emmanuel Knafo, Ph.D. He spent tireless hours reviewing this text and it would not be the book it is without him. Secondly, I would like to thank my close friend Sam Smith, who reviewed many chapters quickly and eagerly. Sam, Robin Smith, Rory Woods, and I came up together at Microsoft. Thank you for your friendship, our many happy hours, and help with the book. My first manager at Microsoft, my friend and mentor Omar Kouatly, allowed me to get started in this venture of quantum computing, encouraged me, and helped with the book as well. Thank you. Delbert Murphy, Darius Zakrzewski, and Jon Skerrett have been my "partners in crime" in exploring, learning, and sharing a passion for quantum computing. Thank you for your inspiration. Finally, my friend Matthew A. Kirsch helped with early copies of this text and earlier parts of my life. I thank you for those immeasurable contributions as well.
In the one year plus that it took to write this book, I needed support and advice. My great friend and spiritual mentor, Art Thompson, provided that in spades. Other close friends such as Graham Eddy, Carmel Maddox, Heather Downey, Patrick Sweet, Eli Rosenblatt, Rich Chetelat, Paul Varela, Benjamin Maddox, Nacho Dave, and Andy Brown have been there every step of the way during this tumultuous year.
No book is written alone and I would like to thank the people at Packt for working with me to make this book a reality. I would especially like to thank Sean Lobo, my editor, for sticking with me all the way through and his many hours spent reviewing this text.
Finally, I would like to thank my family, which includes Brandi Zahir and her children Zachary, Benjamin, and Caitlyn. To my children, you allowed me to write this book and gave up many hours with daddy so that I could finish it. I will always love you and you are the reason I exist. Thank you, Eva-Maria, Sophia, Johnny, and Alex. To my wife Jeanette of 17 years, you are the love of my life, my rock, my person. We have built quite a family together and I can't wait to live the rest of my life with you. And to who made this all possible, thank you, God.
Leonard S. Woody III is a senior consultant with 20 years of experience explaining complex subjects to software development clients. For the last 3 years, he has worked at Microsoft, most currently as a program manager for Azure Quantum. He was awarded a BS in computer science and a BS in physics from the University of Virginia. He attained his MS in software engineering from George Mason University. Woody lives in Northern Virginia with his wife and four children. His biggest love is spending time with his family.
Emmanuel Knafo, focusing on DevOps innovation and cloud architecture, helps organizations transform how to ideate, plan, execute, and learn from their technology investments. He obtained his Ph.D. in mathematics in number theory at the University of Toronto. He is a published author in various mathematical journals. He has published IT articles on the Microsoft Premier Developer Blog.
I would like to thank the author for this opportunity to re-ignite my passion for mathematics and physics by making me the technical reviewer for this book. It has been a thoroughly enjoyable experience! My passion for math was instilled by my father, Emile, and nurtured by my mother, Evelyne. Finally, I'm grateful to Audrey and the lights of our lives: Ethan and Adam.
Devika Mehra started her programming journey when she was 15 years old, which led to her never-ending zest to explore the boundless field of technology. She has an immense interest in the fields of security and quantum computing. She initially flexed her muscles in different programming languages and then focused on the development of Android applications. She is currently working with Microsoft Sentinel as a software engineer and develops security integration and analysis content for the end customer. She wishes to make the world a better place to live in and believes that technology can be a great catalyst to achieve this.
Srinjoy Ganguly works as a quantum AI research scientist at Fractal Analytics. He has 4+ years of experience in quantum computing, and is an IBM Qiskit advocate and educator. He also teaches quantum computing at Woxsen University as a visiting professor. His research interests include QNLP, category theory with compositionality, variational quantum algorithms and their applications, and machine learning.
This book is written for software developers and tech enthusiasts that have not learned the math required for quantum computing either in many years or possibly not at all. Quantum computing is based on a combination of quantum mechanics and computer science. These two subjects, quantum mechanics and computer science, are built on a foundation of math, as the following diagram illustrates:
Figure 1 – Diagram of relationship of math to quantum computing
Making sure your foundation is well built as you dive into quantum computing is paramount to your long-term success in the field. Notice that I said "as you dive" instead of "before you dive," because you should do cool quantum computing stuff as you are learning the relevant math. We do that in the very first chapter, Chapter 1, Superposition with Euclid, and almost every chapter after that. It's important that you see how the math connects to actual quantum computing.
Let's answer the question of how you should learn the math of quantum computing using this book. Everyone is different, but the steps we used in school work really well (with a few tweaks):
**READ THIS AWESOME BOOK!**Watch YouTube videos – here are a couple of playlists to get you started:Essence of linear algebra by 3Blue1Brown (https://tinyurl.com/233ruczb)Linear Algebra: An In-Depth Introduction by MathTheBeautiful (https://tinyurl.com/464dvc4b)Exercise – do actual math problems. You don't learn a sport by just reading a book and watching some videos. You have to do it! This book has you covered with exercises in every chapter.I'd like to add three more steps to make sure you don't lose enthusiasm:
Go do some cool quantum computing stuff with your newfound knowledge.Get stuck.Come back to the book and start again at Step 1 to get unstuck.Now I'd like to quickly talk about who this book is for.
I don't assume much in terms of mathematical training. A general high school study of math is all you need and even then, I include appendices to review subjects such as trigonometry if you need it. The most important prerequisite is an enthusiasm for quantum computing.
I'll quickly say this book is not for graduate students, mathematicians, physicists, and rocket scientists in general. You probably know all this stuff already. But it might show you a new way to teach it.
This is not an overall introduction to quantum computing. We will most certainly connect the math to quantum computing and do some actual quantum computing. But in the end, this is a math book. There are great books out there that give a general introduction to quantum computing. A personal favorite of mine is Quantum Computing Explained by David McMahon and there are more included in the appendix of references I have used for the book.
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801073141_ColorImages.pdf.
There are a number of text conventions used throughout this book.
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "Select System info from the Administration panel."
Tips or Important Notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
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.packtpub.com/support/errata and fill in the form.
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.
Once you've read Essential Mathematics for Quantum Computing, we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.
This section starts the book off with easy concepts such as vectors and matrices.
The following chapters are included in this section:
Chapter 1, Superposition with EuclidChapter 2, The MatrixMathematics is the language of physics and the foundation of computer science. Since quantum computing evolved from these two disciplines, it is essential to understand the mathematics behind it. The math you need is linear in nature, and that is where we will start. By the time we are done, you will have the mathematical foundation to fundamentally understand quantum computing. Let's get started!
In this chapter, we are going to cover the following main topics:
VectorsLinear combinationsSuperpositionA long time ago in a country far, far away, there lived an ancient Greek mathematician named Euclid. He wrote a book that defined space using only three dimensions. We will use his vector space to define superposition in quantum computing. Don't be fooled—vector spaces have evolved tremendously since Euclid's days, and our definition of them will evolve too as the book progresses. But for now, we will stick to real numbers, and we'll actually only need two out of the three dimensions Euclid proposed.
To start, we will define a Euclidean vector as being a line segment with a length or magnitude and pointing in a certain direction, as shown in the following screenshot:
Figure 1.1 – Euclidean vector
Two vectors are equal if they have the same length and direction, so the following vectors are all equal:
Figure 1.2 – Equal vectors
Vectors can be represented algebraically by their components. The simplest way to do this is to have them start at the origin (the point (0,0)) and use their x and y coordinates, as shown in the following screenshot:
Figure 1.3 – Vectors represented geometrically and algebraically
You should note that I am using a special notation to label the vectors. It is called bra-ket notation. The appendix has more information on this notation, but for now, we will use a vertical bar or pipe, |, followed by the variable name for the vector and then an angle bracket, ⟩, to denote a vector (for example, |a⟩). The coordinates of our vectors will be enclosed in brackets [ ]. The x coordinate will be on top and the y coordinate on the bottom. Vectors are also called "kets" in this notation—for example, ket a, but for now, we will stick with the name vector.
So, it ends up that we can add vectors together both geometrically and algebraically, as shown in the following screenshot:
Figure 1.4 – Vector addition
As you can see, we can take vectors and move them in the XY-plane as long as we preserve their length and direction. We have taken the vector |b⟩ from our first graph and moved its start position to the end of vector |a⟩. Once we do that, we can draw a third vector |c⟩ that connects the start of |a⟩ and the end of |b⟩ to form their sum. If we look at the coordinates of |c⟩, it is four units in the x direction and zero units in the y direction. This corresponds to the answer we see on the right of Figure 1.4.
We can also do this addition without the help of a graph, as shown on the right of Figure 1.4. Just adding the first components (3 and 1) gives 4, and adding the second components of the vectors (2 and -2) gives 0. Thus, vector addition works both geometrically and algebraically in two dimensions. So, let's look at an example.
What is the sum of |m⟩ and |n⟩ here?
The solution is:
Now, you try. The answers are at the end of this chapter:
What is |m⟩ - |n⟩?What is |n⟩ - |m⟩?Solve the following expression (notice we use three-dimensional (3D) vectors, but everything works the same):We can also multiply our vectors by numbers or scalars. They are called scalars because they "scale" a vector, as we will see. The following screenshot shows a vector that is multiplied by a number on the left and the same thing algebraically on the right:
Figure 1.5 – Scalar multiplication
The vector |b⟩ is doubled or multiplied by two. Geometrically, we take the vector |b⟩ and scale its length by two while preserving its direction. Algebraically, we can just multiply the components of the vector by the number or scalar two.
What is triple the vector |x⟩ shown here?
The solution is:
Once we have established that we can add our vectors and multiply them by scalars, we can start to talk about linear combinations. Linear combinations are just the scaling and addition of vectors to form new vectors. Let's start with our two vectors we have been working with the whole time, |a⟩ and |b⟩. I want to scale my vector |a⟩ by two to get a new vector |c⟩, as shown in the following screenshot:
Figure 1.6 – |a⟩ scaled by two to produce |c⟩
As we have said, we can do this algebraically as well, as the following equation shows:
Then, I want to take my vector |b⟩ and scale it by two to get a new vector, |d⟩, as shown in the following screenshot:
Figure 1.7 – |b⟩ scaled by two to produce |d⟩
So, now, we have a vector |c⟩ that is two times |a⟩, and a vector |d⟩ that is two times |b⟩:
Can I add these two new vectors, |c⟩ and |d⟩? Certainly! I will do that, but I will express |e⟩ as a linear combination of |a⟩ and |b⟩ in the following way:
Vector |e⟩ is a linear combination of vectors |a⟩ and |b⟩! Now, I can show this all geometrically, as follows:
Figure 1.8 – Linear combination
This can also be represented in the following equation:
So, we now have a firm grasp on Euclidean vectors, the algebra you can perform with them, and the concept of a linear combination. We will use that in this next section to describe a quantum phenomenon called superposition.
Superposition can be a very imposing term, so before we delve into it, let's take a step back and talk about the computers we use today. In quantum computing, we call these computers "classical computers" to distinguish them from quantum computers. Classical computers use binary digits—or bits, for short—to store ones and zeros. These ones and zeros can represent anything, from truth values to characters to pixel values on a screen! They are physically implemented using any two-state device such as an electrical switch that is either on or off.
A quantum bit, or qubit for short, is the analogous building block of quantum computers. They are implemented by anything that demonstrates quantum phenomena, which means they are very, very small. In the following screenshot, we show how a property of an electron—namely spin—can be used to represent a one or zero of a qubit:
Figure 1.9 – Pair of electrons with a spin labeled 1 and 0
Physicists use mathematics to model quantum phenomena, and guess what they use to model the state of a quantum particle? That's right! Vectors! Quantum computer scientists have taken two of these states and labeled them as the canonical one and zero for qubits. They are shown in the following screenshot:
Figure 1.10 – Zero and one states
As you can see, the zero and one states are just vectors on the x and y axes with a length of one unit each. When you combine a lot of ones and zeros in classical computing, wonderful, complex things can be done. The same is true of the zero and one state of qubits in quantum computing.
Greek Letters
Mathematicians and physicists love Greek letters, and they have found their way into quantum computing in several places. The Greek letter "Psi", ψ, is often used to represent the state of a qubit. The Greek letters "alpha", α, and "beta", β, are used to represent numbers or scalars.
While qubits can represent a one or a zero, they have a superpower in that they can represent a combination of a zero and one as well! "How?" you might ask. Well, this is where superposition comes in. Understanding it is actually quite simple from a mathematical standpoint. In fact, you already know what it is! It's just a fancy way of saying that a qubit is in a linear combination of states.
If you recall, we defined the vector |e⟩ as a linear combination of the aforementioned |a⟩ and |b⟩
