Hughes2021 Book QuantumComputingForTheQuantumC
Hughes2021 Book QuantumComputingForTheQuantumC
Quantum
Computing for
the Quantum
Curious
Quantum Computing for the Quantum
Curious
Ciaran Hughes • Joshua Isaacson
Anastasia Perry • Ranbel F. Sun
Jessica Turner
Jessica Turner
Batavia
IL, USA
© The Editor(s) (if applicable) and The Author(s) 2021. This book is an open access publication.
Open Access This book is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this book are included in the book’s Creative Commons
license, unless indicated otherwise in a credit line to the material. If material is not included in the book’s
Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the
permitted use, you will need to obtain permission directly from the copyright holder.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Acknowledgments
It is a pleasure to thank Marge Bardeen, Harry Cheung, and Spencer Pasero for their
helpful discussions on various aspects of this project, from inception to completion.
We are grateful to Daniel Carney, William Jay, Yin Lin, Jim Simone, Julia Stadler,
Liner de Souza Santos, and Anders Ellers Thomsen for reading and providing
feedback on the draft document. It is also a pleasure to thank LaMargo Gill for her
remarkably thorough proofreading of this document. We thank Heath O’Connell
and Aaron Sauers for their useful advice regarding information content. We thank
Olivia Vizcarra and the Fermilab Theory Group for facilitating this project.
This work would not be possible without funding from the Robert Noyce Teacher
Scholarship and the Fermilab Teacher Research Associates (TRAC) program. This
work was supported by the Fermi Research Alliance, LLC, under Contract No. DE-
AC02-07CH11359 with the U.S. Department of Energy, Office of Science, Office of
High Energy Physics, and partial support was received by an HEP-QIS QuantISED
award titled “Quantum Information Science for Applied Quantum Field Theory.”
Additionally, we are very appreciative of IBM for financially sponsoring the book,
with special thanks to Abraham Asfaw and Sebastian Hassinger, without which this
course would not have been open source.
Various sources were used as inspiration for building this course. We acknowl-
edge IBM Q experience1 for their useful web interface and note that specific figures
(as indicated in their captions) are owned by IBM as per their end-user license
agreement.2 We urge the reader to review this end-user license agreement before
using the IBM Q web interface. Additionally, we would like to acknowledge the
useful PhET Interactive Simulations3 supplied by the University of Colorado Boul-
der. Furthermore, we credit the Quantum Mechanics Visualization Project (QuVis),4
hosted by the University of St. Andrews, for useful interactive simulations. Finally,
1 https://quantum-computing.ibm.com.
2 https://quantum-computing.ibm.com/terms.
3 https://phet.colorado.edu.
4 https://www.st-andrews.ac.uk/physics/quvis/.
v
vi Acknowledgments
we thank Martin Laforest and the Communications and Strategic Initiatives Team
at the Institute for Quantum Computing, University of Waterloo’s outreach depart-
ment5 for supplying material that formed the inspiration for Chaps. 3, 5, and 9 of
this module.
5 https://uwaterloo.ca/institute-for-quantum-computing/outreach.
Contents
1 Introduction to Superposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Classical Superposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Quantum Superposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 What Is a Qubit? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Mathematical Representation of Qubits . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Dirac Bra-Ket Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Matrix Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Bloch Sphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4 Physical Realization of Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3 Creating Superposition: The Beam Splitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1 Beam Splitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Mach–Zehnder Interferometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.1 Particle Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Creating Superposition: Stern–Gerlach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1 Stern–Gerlach Apparatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Measurement Basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.3 Geometric Representation of a Basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4 Effect of Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.6 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.7 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
vii
viii Contents
5 Quantum Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.1 Cryptography Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.2 Classical Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.3 BB84 Quantum Key Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3.1 Before Sending the Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3.2 Quantum Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.3.4 Classical Post-processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4 Detecting an Eavesdropper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.5 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.7 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6 Quantum Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.1 Single Qubit Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.2 X (Also Called NOT) Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.3 Hadamard Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.4 Mathematics of the Hadamard Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6.4.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.5 Z Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.6 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.7 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.8 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7 Entanglement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.1 Entanglement Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.2 Hidden Variable Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.3 Multi-Qubit States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.3.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.4 Non-Entangled Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.4.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.5 Entangled Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.5.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.5.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.6 Entangling Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.7 CNOT Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7.8 Notation Convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.9 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.10 Big Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.11 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
7.12 Check Your Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8 Quantum Teleportation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.1 Scanning a Qubit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.2 Teleportation Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Contents ix
A Probability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
A.2 Combining Probabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
A.2.1 Key Words Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
A.2.2 Key Ideas Review. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
A.2.3 Check Your Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
A.3 Histograms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
A.4 Mean, Median, and Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
A.4.1 Key Word Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
A.4.2 Check Your Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
A.5 Variance and Standard Deviation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
A.5.1 Key Word Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
A.5.2 Check Your Understanding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
x Contents
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Course Description
About
Prerequisites
The material assumes knowledge of waves from high school physics. Introductory
modern physics (photoelectric effect, wave/particle duality, etc.) is helpful but not
required, and computer programming experience is not necessary.
The units are labeled by difficulty depending on the level of math and abstract
reasoning involved. It is possible to skip over intermediate and/or advanced topics
depending on the student’s background. For those who are rusty on probability and
linear algebra concepts, a refresher is provided in Appendices A and B.
xi
xii Course Description
Fundamental
• Grades: 9–10
• Math Prerequisites: probability of flipping one coin, histograms
Intermediate
• Grades: 11–12
• Math Prerequisites: trigonometry, matrix multiplication, probabilities of flipping
multiple coins
Advanced
• Grades: 12+
• Math Prerequisites: vectors, vector spaces, matrices as transformations
Learning Objectives
1. Introduction to Superposition
Key Terms: qubit, ket notation, state amplitude, normalization, Bloch sphere,
unitary matrix
3. Creating Superposition: The Beam Splitter
• Explain how light behaves like a particle in the single-photon beam splitter
experiment.
Course Description xiii
• Explain how entanglement is used to transmit the state of a qubit from one
place to another.
• Explain the limitations and paradoxes of quantum teleportation.
Alternative Pathways
The units are best studied in numerical order. However, for those with limited time,
Figure 1 shows the minimum recommended prerequisites for each unit. A few
references and examples may have to be skipped over, but the core content should
still be understandable.
Course Description xv
1. Introduction to Superposition
2. What is a Qubit?
8. Quantum Teleportation
Bell_test_experiments —showing that particles can actually be in two locations at the same time
https://www.quantamagazine.org/physicists-are-closing-the-bell-test-loophole-20170207/.
Fig. 1.1 Examples of constructive and destructive interference due to the classical superposition
principle
Fig. 1.2 A classical superposition is used to calculate the total electric force on a charge q2 due
to charges q1 and q3
phase, thereby canceling the sound wave. This destructive interference is illustrated
in the second figure of Fig. 1.1.
Another common application of classical superposition is finding the total
magnitude and direction of quantities such as force, electric field, magnetic field,
etc. For example, to calculate the total electric force Ftotal on a charge q2 produced
by other charges q1 and q3 , one would sum the forces produced by each individual
charge: Ftotal = F12 + F32 . The challenge here is that forces are vectors, so vector
addition is needed, as shown in Fig. 1.2.
Fig. 1.3 Quantum effects associated with energy quantization are important at the atomic and
subatomic distances. In this figure, the grey lines represent allowed energies. In quantum systems,
the energies are quantized. As we zoom out of the quantum system to see it through a classical lens
(represented by the downward arrow), the energies become more dense and appear continuous.
This is the reason quantization is not noticeable in everyday objects
A specific example of energy quantization is when energies can only have integer
values E = 0, 1, 2, 3, . . ., but not any numbers inbetween. This is counterintuitive,
as we cannot observe it with our classical eyes. The gaps in energy are too small to
be seen with the human eye and as such can be treated as continuous for classical
physics. However, the gaps are more pronounced at smaller sizes, as shown in
Fig. 1.3. For example the hydrogen atom is small enough that quantum effects are
important, and Bohr needed to quantize the energy levels to successfully model its
behavior.
One aspect of quantum superposition can be explained using a coin analogy. A
coin has a 50/50 probability of landing as either heads or tails, as shown in Fig. 1.4.
Question 1 What state is the coin in while it is in the air? Is it heads or tails?
We can say that the coin is in a superposition of both heads and tails. When it
lands, it has a definite state, either heads or tails. Generally, the word “state” means
any particular way that a system can possibly be described. For example, the coin
can be either heads, or tails, or a combination of heads or tails while flipped in the
4 1 Introduction to Superposition
air. All of these cases are called states of the coin system. While the coin is being
flipped it is in a state of superposition. When we observe the coin, we are making a
measurement which destroys the superposition.
At any given time, a system can be described as being in a particular state. The
state is related to its quantized values. For example, a tossed coin is either in a
heads state or a tails state. An electron orbiting a hydrogen atom could be in the
ground state or an excited state. A quantum system is special because it can be in a
superposition of these definite states, i.e., both heads and tails simultaneously. The
outcome of a measurement is to observe some definite state with a given probability.
In Schrödinger’s famous thought experiment, Schrödinger’s cat is placed in
a closed box with a single atom that has some probability of emitting deadly
radiation at any time. Since radioactive nuclear decay is a spontaneous process, it
is impossible to predict for certain when the nucleus decays. Therefore, you do not
know whether the cat is alive or dead unless you open and look in the box. (Watch
this video.)2 It can be said that the cat is both alive AND dead with some non-zero
probability. That is, the cat is in a quantum superposition state until you open the
box and measure its state. Upon measurement, the cat is obviously either alive OR
dead and the superposition has collapsed to a definite, non-superposition state.
Quantum systems can exist in a superposition state, and measuring the system
will collapse the superposition state into one definite classical state. This might be
hard to understand from a classical point of view, as we usually do not see quantum
superposition with our human eyes (i.e in macroscopic objects). Einstein was really
bothered by this feature of quantum systems. His friend, Abraham Pais, records:
“I recall that during one walk, Einstein suddenly stopped, turned to me, and asked
whether I really believed that the moon exists only when I look at it.”3
1.4 Activities
2 https://www.youtube.com/watch?v=uWMTOrux0LM.
3 Nielsen,
M. A. 1., & Chuang, I. L. (2000). Quantum computation and quantum information. New
York: Cambridge University Press, p. 212.
1.5 Check Your Understanding 5
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
4 https://en.wikipedia.org/wiki/The_dress.
What Is a Qubit?
2
In order to work with qubits, it is useful to know how one can express quantum
mechanical states with mathematical formulas. Dirac or “bra-ket” notation is
commonly used in quantum mechanics and quantum computing. The state of a qubit
is enclosed in the right half of an angled bracket, called the “ket”. A qubit, |,
could be in a |0 or |1 state or even a superposition of both |0 and |1. This is
written as
with α and β called the amplitudes of the states (Fig. 2.2). Amplitudes are generally
complex numbers (a special type of number used in mathematics and physics).
However, to understand the meaning of amplitudes, we can imagine the amplitudes
as being ordinary (real) numbers. Amplitudes allow us to mathematically represent
all of the possible superpositions.
Amplitudes are very important because they give us the probability of finding
the particle in that specific state when performing a measurement. The probability
of measuring the particle in state |0 is |α|2 , and the probability of measuring the
particle in state |1 is |β|2 . Why is it squared? The short answer is that it gives the
correct experimental predictions for this choice of representation.1 Squaring α and
β to find the probability is similar to squaring a wave’s amplitude to find the energy
of the wave. Since the total probability of observing all the states of the quantum
system must add up to 100%, the amplitudes must obey this rule:
This is called a normalization rule. The coefficients α and β can always be rescaled
by some factor to normalize the quantum state.
1 We know that quantum physics is probabilistic from experiments. The squared coefficients are
needed to make a quantity that behaves like a probability distribution, i.e., it is a real number and
positive. There cannot be a negative probability by definition.
2.1 Mathematical Representation of Qubits 9
2.1.2 Examples
1
|coin = √ (|1 + |0) . (2.3)
2
One common misconception is that the measurement of a single qubit will result
in a weighted average of the |0 and |1 states. It is important to note that after
you perform the measurement on a single qubit, the qubit is no longer in a
superposition but takes on a definite state of either |0 or |1.2 This means that
you would not be able to find α or β from a single qubit. Instead, we need to
create many qubits which are in the same quantum state, and then measure how
many of the qubits collapse into |0 (giving α) and how many collapse into |1
(giving β). Therefore, multiple identical particles are needed in order to count
how many collapse into |0 or |1.
Experimentally, a qubit’s state can be changed through some physical action such as
applying an electromagnetic laser or passing it through an optical device. Changing
a qubit’s state through a physical action mathematically corresponds to multiplying
the qubit vector |ψ by some unitary matrix U so that after the operation the state is
now |ψ = U |ψ. Unitary is a mathematical term which expresses that U can only
act on the qubit in such a way that the total probability |α|2 +|β|2 does not change. A
matrix U is unitary if the matrix product of U and its conjugate transpose U † (called
U -dagger) multiply to give the identity matrix: U U † = U † U = 1. This is very
important because, in all mathematical constructions of quantum mechanics, one
fundamental assumption is that each (matrix) operator must be unitary. This ensures
that after changing any state through an action, the total probability to observe all
possible states will still add up to 100%. If this did not happen, then we could not
interpret the results of quantum mechanics to be probabilistic, and the results would
disagree with the many experiments that have been performed to date. The physical
action of interacting with the state corresponds mathematically to applying a unitary
operator.
2.2.1 Examples
The conjugate transpose of a matrix is found using the following two steps. First,
we “conjugate” the complex numbers. The conjugate of a complex number is
found by switching the sign of the imaginary part. The complex conjugate of 1
is just 1, while the complex conjugate of +i is −i. Second, we transpose the
conjugated matrix. Transposing a matrix switches rows with columns, i.e., the
2.3 Bloch Sphere 11
first row turns into the first column, second row turns into the second column,
etc. Therefore,
1 1
A† = . (2.8)
−i −i
Multiplying A by its conjugate transpose does not produce the identity matrix,
so A is not unitary.
3. What is the result of applying the unitary operator X onto a |0 state qubit?
01 1
X= , |0 = . (2.11)
10 0
01 1 0
X|0 = = = |1. (2.12)
10 0 1
The X matrix changes the |0 qubit state to the |1 qubit state.
A single qubit can be visualized using the Bloch sphere. The Bloch sphere is a visual
representation of a qubit with similar geometric properties to the unit circle from
trigonometry. Each point on the Bloch sphere corresponds to a different possible
superposition of a single qubit. The top and bottom of the sphere correspond to the
two measurable states of the qubit, |0 and |1. An arrow on the Bloch sphere, which
can point to any of the different locations on the surface of the sphere, indicates
the current state of the qubit. Figure 2.3 shows four examples of how the Bloch
sphere can be used to visualize different qubit states. When the arrow is not pointing
directly to the top or bottom of the sphere, the qubit is in a superposition state. For
example, everywhere around the equator the qubit has a 50/50 chance of collapsing
into |0 or |1 upon measurement. The exact location on the equator corresponds to
a distinct state, where the amplitudes can have different signs and be either real or
imaginary numbers.
12 2 What Is a Qubit?
Fig. 2.3 The state of a qubit is represented by an arrow on the Bloch sphere
When the state of the qubit is changed, the arrow rotates to a different position on
the sphere. One analogy is to think of the qubit like Schrödinger’s cat traveling the
globe shown in Fig. 2.4. When the cat is at the North Pole, it will definitely be alive.
When the cat is at the South Pole, it will definitely be dead. As long as the cat’s
state is not measured, it can be anywhere else on the globe in a superposition state
of alive and dead. As coders of the quantum computer, it is our job to manipulate
the state of the qubit which gives the cat instructions on how to move around the
globe.
(a) Russia
(b) Australia
(c) North Pole
(d) all of the above
2.5 Big Ideas 13
The cat could have been anywhere on Earth except for the South Pole. Notice
that in Australia the cat has a smaller probability of being alive since it is further
away from the North Pole.
The Bloch sphere is a helpful visual aide for understanding how a qubit can have an
infinite number of possible quantum states. However, it only represents one qubit
and does not work for systems of two or more qubits.
In a classical computer, the 0- and 1-bit mathematically represent the two allowed
voltages across a wire in a classical circuit. Semiconductor devices called transistors
are used to control what happens to these voltages. A question frequently posed
by new students is “What is a qubit made out of?” As quantum computers are
based on fundamentally different concepts than classical computers, they must be
built from completely different technology, i.e. it is not possible to have a classical
current in a superposition of both flowing and not flowing through a wire. Quantum
computers are still in their infancy, and so there are many different candidates for the
technology to build them. Some technologies are based on optical systems, others
use superconductors,3 and there are others based on molecules. It is still unclear
if any of these are more beneficial than the others, and it is even more unclear if
all future quantum computers will be built from the same technology or if there
will be many different types of quantum computers available (in the same way
there exists both XBox and PlayStation game consoles, but both have the same
general purpose—interactive gaming). We will study two different experiments
which illustrate the properties of the qubits, but the engineering details of building
a quantum computer are well beyond the scope of this introduction.
1. A qubit can be in a superposition of |0 and |1 states. The Bloch sphere can be
used to visually represent a single qubit.
2. A qubit can be written in terms of amplitudes. Each squared amplitude corre-
sponds to the probability of measuring the qubit in |0 or |1.
3. A physical change to a qubit mathematically corresponds to unitary matrices
which multiply the qubit amplitudes.
Table 2.1 Table for message Character Binary code Character Binary code
A 01000001 N 01001110
B 01000010 O 01001111
C 01000011 P 01010000
D 01000100 Q 01010001
E 01000101 R 01010010
F 01000110 S 01010011
G 01000111 T 01010100
H 01001000 U 01010101
I 01001001 V 01010110
J 01001010 W 01010111
K 01001011 X 01011000
L 01001100 Y 01011001
M 01001101 Z 01011010
is unitary.
11. Show by example that applying a non-unitary matrix to a qubit results in
probabilities that no longer add up to 100%. (Hint: Start with any initial state,
e.g., |0. Measure the probabilities of finding either 0 or 1. Apply a non-unitary
matrix to the initial state. Then measure the probabilities of finding either a 0 or
1. Do the probabilities add up to 100%?)
12. If the qubit represented by Fig. 2.5 is measured, what are the possible
outcomes? Numerical values for the amplitudes are not needed, only conceptual
statements.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Creating Superposition: The Beam Splitter
3
Now that we have explored qubits and the phenomenon of superposition, we can
ask the question: how do we know that superposition actually happens? What is
the evidence that shows that a quantum particle really does exist in two different
locations at this same time while in a quantum superposition? The nature of science
means that experiments are constantly updating previous results, so are there other
interpretations of the experimental results that can explain the data without the
need for superposition? In this chapter we’ll explore the experimental evidence
that debunks interpretations other than quantum superposition. Further, while a
flipping coin is a simple model of a qubit, it is not very useful for building a
quantum computer because it does not exhibit all of the properties of a true quantum
superposition. For example, we cannot manipulate the superposition amplitudes. In
this chapter, we will study some real physical examples of quantum particles in a
superposition containing two states. These examples include a photon in a beam
splitter and the Mach–Zehnder interferometer.
In classical optics, a beam splitter acts like a partially reflective mirror that splits
a beam of light into two. In a 50/50 beam splitter, 50% of the light intensity is
transmitted and 50% is reflected, as shown in Fig. 3.1.
One way to visualize the beam splitter is to imagine a barrier with holes randomly
cut out like Swiss cheese, as shown in Fig. 3.2. Imagine this barrier is placed in a
pond, and a water wave moves toward the barrier. After the wave hits the barrier,
we would observe a smaller wave going through the barrier and another would be
reflected off the barrier.
Experiments demonstrate that light behaves both like a wave (Young’s double-slit
experiment) and a particle (photoelectric effect, Compton effect). Classically, light
is thought of as a wave consisting of continually oscillating electric and magnetic
fields. However, light can also be thought of as a stream of particles called photons.
Photons have no mass but carry the light’s energy from one point to another at the
speed of light. A laser beam is comprised of photons. If you turn down the intensity
of your laser, you can even send one photon at a time, as shown in Fig. 3.3. As
setting up a single photon source and detector requires specialized equipment, we
will instead run a simulator to explore the quantum effects of photons.
3.1 Beam Splitter 19
Question 2 Open the beam splitter simulator,1 go to the Controls screen, and fire a
single photon. The setup before the photon hits a beam splitter is shown in Fig. 3.4.
Which detectors are triggered when the photon passes through the 50/50 beam
splitter?
Question 3 Which detector(s) would trigger if a classical wave is sent through the
beam splitter?
1 https://www.st-andrews.ac.uk/physics/quvis/simulations_html5/sims/photons-particles-waves/
photons-particles-waves.html.
20 3 Creating Superposition: The Beam Splitter
Question 5 What does the photon do at the instance it encounters the 50/50 beam
splitter?
(a) Splits in half. Half the photon is transmitted and half is reflected
(b) The whole photon goes through with 50% probability and reflects with 50%
probability
(c) The whole photon is both transmitted and reflected, essentially in two places at
once
If the photon was split in half, both detectors in the beam splitter experiment
would be triggered at the same time. As only one detector goes off at a time, the
photon could not have split up. In this case, we see that light behaves more like the
soccer ball than the water wave.
At this point you may be thinking that the photon was either transmitted or
reflected at the beam splitter, and we simply didn’t have that information until it
hit Detector 1 or 2. Unfortunately, this would be the incorrect interpretation formed
by our classical animal brain. This would be like saying the coin was Heads all
along, and all we had to do was look at it to determine its state. Similarly to how
a spinning coin will land on heads 50% of the time and tails 50% of the time, the
single photon is in a superposition of both states all the way until the point when
it reaches the detectors. This distinction might seem like a matter of semantics,
but this is important as the distinction describes two different ways that the universe
operates at the smallest possible distances. Also, it will be important once the system
becomes more complicated. The experimental setup after the photon hits a beam
splitter is shown in Fig. 3.5.
If we let the transmitted path be |0 (detector 1), and the reflected path be |1
(detector 2), then the photon’s state after the beam splitter is
1 1
|photon = √ |0 + √ |1. (3.1)
2 2
Upon measurement, will the superposition collapse into either |0 or |1? Unfortu-
nately, it is not possible to predict which detector will be activated at any given time
as quantum mechanics is inherently probabilistic.
The phenomenon of superposition allows quantum computers to perform opera-
tions on two bits of information at once with a single qubit. In fact, it is possible to
create a general purpose (also called universal) quantum computer using photons as
qubits, beam splitters to create superposition, and pieces of glass that slow down the
photons along selected paths (phase shifters).2
2 Knill, E.; Laflamme, R.; Milburn, G. J. (2001). “A scheme for efficient quantum computation with
Fig. 3.5 The beam splitter puts the photon into a superposition state.
To convince ourselves that the photon really did take two paths at once, let’s see what
happens when a second beam splitter is added. This experimental setup is shown in
Fig. 3.6. The mirrors redirect the photons towards the second beam splitter. This
device configuration is known as a Mach–Zehnder interferometer. The set up is
very sensitive to the distances between the mirrors and detectors, which have to be
the same or differ by an integer number of the photon’s wavelength.
Question 6 If we assume that the photon was reflected by the first beam splitter,
which detectors would be triggered?
Question 7 If we assume that the photon was transmitted by the first beam splitter,
which detectors would be triggered?
If the photon was either transmitted or reflected by the first beam splitter, it would
have a 50/50 chance of transmission or reflection by the second beam splitter.
Thus, both detectors should trigger with equal probability. However, strangely
the experimental results do not agree with this hypothesis, as only one detector
is triggered with 100% probability. This weird phenomenon is more intuitively
understood from the wave perspective of light.
To understand the operation of the interferometer, it is important to note that the
beam splitters have a polarity. The beam splitter consists of a piece of glass coated
with a dielectric on one side. When light enters the beam splitter from the dielectric
side, the reflected light is phase shifted by π . Light entering from the glass side will
not experience any phase shift. The phase shift only occurs when the light travels
from a low to high index of refraction (nair < ndielectric < nglass ).
What does it mean for a photon to be phase shifted? In this case, it is more
intuitive to think about the wave nature of light. The phase shift would invert the
electric and magnetic field oscillations relative to the incoming wave. If a π -shifted
wave overlaps with the original wave, destructive interference occurs as is shown
in Fig. 3.7.
3 https://www.st-andrews.ac.uk/physics/quvis/simulations_html5/sims/Mach-Zehnder-
Interferometer/Mach_Zehnder_Interferometer.html.
3.2 Mach–Zehnder Interferometer 23
+π
+0
air
dielectric
glass +0 +p
0 π/2 π 3π/2 2π
+0 +0
Fig. 3.7 The light through a beam splitter is phase shifted if it is reflected from the dielectric side
but not phase shifted if it is reflected from the glass side.
The behavior of the interferometer can also be viewed from the particle perspective,
though it may be less intuitive. Recall from the single beam splitter experiment that
the photon did not split up or clone itself. It was in a superposition state, essentially
taking both paths. The second beam splitter treats the photon as if it came in from
both top and bottom simultaneously. As shown in Fig. 3.8, the top path enters the
second beam splitter from the glass side and experiences no phase shift, whereas the
bottom path enters from the dielectric side and is phase shifted upon reflection. The
+0 and +π states at Detector 2 interfere destructively, while the +0 and +0 states
at Detector 1 interfere constructively. Therefore, Detector 1 triggers with 100%
probability.
Question 10 If the photon is sent into the Mach–Zehnder interferometer from the
upper left instead of the bottom left, which detector(s) would be triggered and with
what probability?
24 3 Creating Superposition: The Beam Splitter
Fig. 3.8 The blue path shows the photon’s path if it is reflected by Beam Splitter 1. The red path
shows the path if the photon is transmitted. Because Beam Splitter 2 has the dielectric facing
downwards, blue is phase shifted upon reflection.
Fig. 3.9 Coin analogy for the interferometer. Sending a photon through one beam splitter puts
it in superposition, but adding a second beam splitter undoes the superposition and recovers the
original state.
Even though the output of the first beam splitter is 50/50, the second beam
splitter can distinguish whether the laser was fired from the top or the bottom. The
first beam splitter creates a superposition state, but adding a second one undoes the
superposition and recovers the original state. This is a non-classical operation. It
would be like starting with the coin heads up, flipping it, flipping it again while it
is still in the air, and then always getting heads when it lands! This is highlighted
in Fig. 3.9.
There is hidden information in the superposition state. In the Mach–Zehnder
photon qubit, the information is encoded in the form of the phase shift. In the
experiment shown in Fig. 3.8, we chose the phase shift to have a value of π .
However, we could have just as easily chosen the phase shift to have any value
between 0 and 2π (the angles of a circle). Each separate choice of phase shift
would produce a different type of superposition state that would still produce
the same measurable 50/50 outcome. This is represented on the Bloch sphere by
different locations along the equator.4 This phase shift information is present in
4A complex amplitude eiφ with infinite possible phase angles φ does not affect the probability
since |eiφ |2 = 1.
3.4 Check Your Understanding 25
the amplitudes but not the square of the amplitudes (and hence hidden from us in
the Mach–Zehnder experiment–though we could make another experiment to try to
determine this information). Here are two simple examples of distinct states that
can be created in two different experimental arrangements of the Mach–Zehnder
experiment which still have the same 50/50 probability:
1 1 1 1
√ |0 + √ |1 or √ |0 − √ |1. (3.2)
2 2 2 2
In these two states the plus or minus signs represents two of the many different phase
shifts that are possible. Each different choice of the phase shift depends on how
the experimental arrangement is chosen. As you can see, quantum superposition is
inextricably linked to wave-particle duality.
Furthermore, in the Mach–Zehnder experiment we created a superposition,
performed a phase shift and then observed wave interference. These experimental
operations are equivalent to mathematically applying matrix/gate operations on a
qubit, as we shall see later. As such, the Mach–Zehnder is an example of how we can
technologically implement qubits (the photon) and operations (superposition/phase
shift, etc) to build a quantum computer.5 In quantum computing, people talk about
the superposition of states rather than the wave behavior. Yet, as we have seen, both
frameworks lead to the same understanding of the Mach–Zehnder interferometer.
Later we will use the interferometer to implement a quantum algorithm.
1. A photon can be put into a superposition using a beam splitter. After passing
through the beam splitter, a photon takes both paths simultaneously.
2. The Mach–Zehnder interferometer shows how the photon really does take two
paths at once. This is conclusive experimental evidence of superposition of
photons.
5 It
should be noted that the technology has progressed so that most qubits are at present
implemented using superconducting transmons and not using a Mach–Zehnder.
26 3 Creating Superposition: The Beam Splitter
2. Only one detector is triggered if a single photon is sent through the beam
splitter experiment shown in Fig. 3.5. If the laser outputs two photons at the same
time, what is the probability that both detectors will be triggered simultaneously?
Now how about three photons? Ten photons? Note that this is why a higher power
beam of light appears to reach both detectors simultaneously.
3. In practice, it is difficult to place the detectors the exact same distance from
the beam splitter. The difference in distance is measured using the time delay t
between photons. The experiment is shown in Fig. 3.10 and the data in Fig. 3.11.
(a) Does the data shown in Fig. 3.11 at t = 0 support that light is a particle or
a wave?
400
Number of coincidences
300
200
100
0
-2 -1 0 1 2
Time delay(s)
Fig. 3.11 Data is shown above for light bursts sent from the laser every 0.4 μs. Figure reproduced
with permission of Martin Laforest and the Communications and Strategic Initiatives Team at the
Institute for Quantum Computing, University of Waterloo Outreach department.
3.4 Check Your Understanding 27
Fig. 3.13 A third detector (your eye) is added to the Mach–Zehnder apparatus.
(b) Why are there large coincidence counts when t = 0? (Hint: Look at the
spacing between the peaks.)
4. Using the matrices given in Fig. 3.12, show how the superposition state is
created by multiplying the beam splitter matrix by initial photon state.
5. Construct the matrix representation for a 30/70 beam splitter.
6. Unsettled by the Mach–Zehnder interferometer, you decide to determine
once and for all which path the photon takes after the first beam splitter. You
place another detector (indicated by the eyeball) on the upper path as shown in
Fig. 3.13. If the eyeball sees a photon, what would be seen at Detectors 1 and 2?
28 3 Creating Superposition: The Beam Splitter
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Creating Superposition: Stern–Gerlach
4
The Stern–Gerlach apparatus (SGA) showed that the electron spin is quantized to
only two values. This video2 explains the experimental apparatus used to measure
the electron’s spin. The key point here is that the vertically oriented apparatus (called
the z-direction by convention) only measures the spin as either up or down, not
randomly oriented at any angle. Since the spin of an electron has two measurable
states, it can represent a qubit with |0 as spin up and |1 as spin down (Fig. 4.1).
Question 1 Open up the PhET Stern–Gerlach simulator3 and try sending electrons
of various initial spins into the Stern–Gerlach apparatus (SGA).
Are the results what you would expect? The “up” and “down” directions are
defined by the orientation of the apparatus, as in Fig. 4.2. There is nothing inherently
special about the z-direction compared to the x- or y-direction. An SGA rotated
horizontally would measure either spin left or spin right. An SGA rotated by 45◦
would measure the spin to be either diagonally up or diagonally down. What is
particularly interesting is if we send a single spin up electron into a horizontally
oriented SGA.
Question 2 Where would you expect a spin up electron to land in Fig. 4.3 after
passing through a horizontal SGA?
Fig. 4.1 An electron can spin either up or down and produce a magnetic field.
Spins
Fig. 4.2 A cartoon picture of the Stern–Gerlach Apparatus. Electron spin produces a magnetic
field either in the up or down direction.
3 https://phet.colorado.edu/sims/stern-gerlach/stern-gerlach_en.html.
4.2 Measurement Basis 31
This is non-classical because you cannot add or subtract horizontal magnetic field
vectors to get a vertical magnetic field vector. One analogy might be to think about
a person looking at a coin vertically to determine its state. If they see heads or
tails, someone looking from the side would see a superposition. If they are forced to
make a choice via measurement, they would say heads or tails with 50% probability
(Fig. 4.4).
4 https://analyticsindiamag.com/top-applications-of-quantum-computing-everyone-should-know-
about/.
32 4 Creating Superposition: Stern–Gerlach
Heads for
sure.
Superposition of
Heads and Tails.
Fig. 4.4 Analogy for how a definite vertical spin is seen as a superposition in the horizontal
direction.
2
|0 + |1 = √ |+. (4.5)
2
Rearranging, we get
1 1
|+ = √ |0 + √ |1. (4.6)
2 2
1 1
|− = √ |0 − √ |1. (4.7)
2 2
These equations show that a horizontal spin is a superposition of spin up and spin
down. As we saw in the beam splitter example, the minus sign encodes information
about the original state of the particle before it is put in superposition. As described
and visually shown in Sect. 2.3, it is possible to choose other complex amplitudes
that give the same probability, but the details are mathematically beyond our scope.
Y
F
Y F
X
Y
F
Fig. 4.5 Rewriting quantum states in terms of a different basis is similar to decomposing a
classical vector into a different choice of coordinate system.
written in terms of a different choice of basis, similarly to how any vector can be
broken down into components along a different choice of axes.
1. The basis must describe all possible quantum states for the system.
2. The basis must be orthogonal.
Let us check these conditions for the z-basis, which consists of states |0 and |1:
5 Thesetwo properties can also be used to form a basis in a classical system, where states should
be swapped for vectors.
34 4 Creating Superposition: Stern–Gerlach
A linear combination of |0 and |1 completely describes the electron’s state.
2. If you measure the spin as |0, it is definitely not |1, therefore |0 and |1 are
orthogonal.
The same argument can be made for the x-basis or any other angle of the SGA
(Fig. 4.5).
In this geometric representation of the z-basis and x-basis, the orthogonal states are
drawn perpendicular to one another. If the electron√is in a particular
√ state |0 in the z-
basis, the state vector can be decomposed into 1/ 2|+ + 1/ 2|− in the x-basis.
Physically turning the SGA from vertical to horizontal√corresponds√to changing the
measurement from the z to the x-basis. Since |0 = 1/ 2|− + 1/ 2|−, the spin
up particle became a 50/50 superposition when the measurement device became
horizontal.
√ √
Question 3 Use Fig. 4.6 and trigonometry to show that |1 = 1/ 2|+−1/ 2|−.
Often, there is hidden information about the state that cannot be measured unless
we change to a different basis. In the x-basis, there is no measurable difference
between |0 and |1. Both the |0 qubit and the |1 qubit would have measurement
results of 50% left and 50% right in the x-basis. In the z-basis, |0 would have 100%
probability of being measured up in the Stern–Gerlach and 0% being measured
down, while |1 would have 0% probability being measured up and 100% down.
Fig. 4.6 Geometric representation of the z-basis and x-basis. The state of a spin up electron is
shown.
4.4 Effect of Measurement 35
You learned that measuring a qubit collapses its superposition state into one of
two possibilities. A spinning coin is in a superposition state, but once it lands, it
becomes either heads or tails. The photon is in a superposition state after passing
through a beam splitter, but once it reaches the detectors, we know for sure whether
it was reflected or transmitted. To appreciate the truly strange nature of quantum
measurement, let’s see what happens when electrons are sent through multiple
Stern–Gerlach devices in a row.
Question 4 Open the PhET Stern–Gerlach simulator6 and send electrons with
randomly oriented spins through a vertical SGA as in Fig. 4.7. What is the spin
of the electrons that pass through the hole?
(a) +z
(b) −z
(c) Superposition of +z and −z
Question 5 Add a second SGA, oriented horizontally as in Fig. 4.8. What is the spin
of the electrons before entering the second SGA?
(a) +x
(b) −x
(c) Superposition of +x and −x
Question 6 What is the spin of the electrons after passing through the second SGA?
(a) +x
(b) −x
(c) Superposition of +x and −x
Question 7 What is the z-spin of the electron coming out of the second SGA?
Design an experiment to confirm this in the simulation.
6 https://phet.colorado.edu/sims/stern-gerlach/stern-gerlach_en.html.
36 4 Creating Superposition: Stern–Gerlach
Spins
Fig. 4.9 The first SGA selects for +z spin and the second SGA selects for −x. The third SGA
shows that by measuring the −x in the z-basis then the electron is in a superposition of +z and −z.
(a) +z
(b) −z
(c) Superposition of +z and −z
Given that only spin up electrons passed through the first SGA, one would expect
that the electron is still spin up after the second SGA, no matter what is measured in
x. However, if you measure the z-spin with a third SGA as in Fig. 4.9, it has a 50%
chance of being up or down!
By measuring the electron, we fundamentally changed its state. Measuring the
x-spin of the qubit puts it into a superposition of up and down, even when it started
as up to begin with. When you measure the length of an object with a ruler, you
don’t expect the object’s length to change after you measure the it!
1. An electron has an intrinsic property called spin, which is quantized into two
values called spin-up and spin-down.
2. The measurement basis is important when interpreting results from experiments
on quantum states. Two common basis are the z-basis (|0 and |1) and the x-
basis (|+ and |−).
3. The Stern–Gerlach apparatus (SGA) can be used to put the electron into a
superposition state. The electron can be used as a qubit, and the SGA as a way to
operate on this qubit. Together, they are a simple model of a quantum computer.
4.6 Activities
(a) I only
(b) II only
(c) I or III
(d) II or III
(e) I, II, or III
5. An electron with random spin is sent through two vertical SGAs as shown
in Fig. 4.12. What would be the output of the second SGA?
6. An electron with random spin is sent through two vertical SGAs, where the
second SGA is rotated upside down, or 180◦ .
(a) If the second +z port is blocked as in Fig. 4.13, what would be the output of
the second SGA?
(b) If both ports on the second SGA are open as in Fig. 4.14, what would you
see at the output?
7. An electron with random spin is sent through a horizontal SGA followed by
a vertical SGA as in Fig. 4.15. What would be the output of the second SGA?
8. An electron with random spin is sent through three SGAs as shown in
Fig. 4.16. What would be the output of the third SGA?
4.7 Check Your Understanding 39
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Quantum Cryptography
5
The Internet can be thought of as a channel of information being sent from you to
everyone else connected to the Internet. If you wanted to transmit your sensitive
information (such as bank account numbers or military secrets) over the Internet,
then you have to ensure that only the persons you intend to read your information
have access to your sensitive data. Otherwise, everyone would be able to read your
information, e.g., access to your bank account details and transfer money out of your
account. Therefore, one needs to encrypt any data sent over the Internet. Encryption,
in this context, ensures that only the intended sender and receiver can understand any
message being sent over an Internet channel.
Encryption relies on the sender and receiver sharing a secret key (that no one else
has) and using that to encrypt and decrypt messages. In this way, since no one else
has the secret key, no one else can understand the shared information. Because no
one else understands the shared information, they cannot misuse it for their own
benefit.
The only type of encryption protocol known to be perfectly secure is the One-
Time Pad, also known as the Vernam Cipher.1 It is assumed that two people
exchange a shared key at least as long as the message in a completely secure way.
The shared key encrypts the message to create the cipher, and the cipher is decoded
by decrypting with the shared key. The protocol is best understood by trying it out
with the associated worksheets in Sect. 10.7. In practice, due to not having a secure
channel to share such a complicated key, despite being unbreakable, this method
1 Shannon, Claude (1949). “Communication Theory of Secrecy Systems.” Bell System Technical
Journal. 28 (4): 656–715. https://doi.org/10.1002/j.1538-7305.1949.tb00928.x.
is usually not employed.2 Here we see the fundamental caveat with encryption:
you require a secure channel to share the secret key (if you do not have a secure
channel then someone random can just take the secret key and encryption would
be pointless), but if you have a secure channel then why do you need to encrypt
your data? You need a way around this issue. How do you share a secret key in an
insecure channel, where anyone can be listening?
The way around sharing a secret key in an insecure channel in the majority of
online communications is called public key cryptography.3 A person called Alice
makes two keys such that each key knows that only the other key is related to it
(think of the keys as siblings). They are called the private and public key. Alice then
gives the public key to everyone in the world but importantly keeps the private key
for herself. Anybody else, say Bob, who wants to send a private message to Alice
has to encrypt their message with the public key that Alice generated. There are
many different types of encryption protocols that one can use. The special part of
public key cryptography is that only Alice’s private key can decrypt the message
that was encrypted using its sibling public key. In this way, only Alice can read the
message from Bob. As no one else has Alice’s private key, no one else can read
Bob’s message. However, if Bob did not use Alice’s public key but used a different
public key to encrypt his message, then Alice cannot decrypt that message, as her
private key is not a sibling key of the different public key. This whole cryptography
scheme relies on the fact that no one can break the encryption protocol. If they could
break it, then they could read Alice’s message even if they did not have Alice’s
private key.
The most commonly used modern Internet encryption protocol is RSA encryp-
tion. RSA encryption relies on encrypting messages with keys that are made out
of very large integers. To break the encryption protocol, an eavesdropper would
need to factorize this very large integer into its (prime) factors. Factorizing a large
integer into its (prime) factors is known to be a problem that classical computers
cannot solve in any reasonable amount of time.4 For example, given two large prime
numbers p and q, it takes just a fraction of a second to multiply these two prime
numbers together to produce a large integer c = pq. However, finding the two
prime numbers p and q given just the integer c would take a classical supercomputer
thousands of years.
RSA encryption works by encrypting the message with the public key. Decrypt-
ing the message by brute force requires factorizing a large integer in the public
2 https://en.wikipedia.org/wiki/One-time_pad.
3 https://en.wikipedia.org/wiki/Public-key_cryptography.
4 https://en.wikipedia.org/wiki/Integer_factorization.
5.3 BB84 Quantum Key Distribution 43
key, which would take thousands of years. However, the private key related to the
public key knows how to check the prime factors of the public key and can decrypt
the message easily. Because the encryption protocol is so difficult to break, no one
would even attempt to do so. Instead, the eavesdropper may attempt to steal your
private key by hacking into your computer, which Internet firewalls protect against.
As such, nearly all Internet encryption relies on a computer not being able to factor
large integers in a short amount of time.
However, in 1995, Peter Shor proposed a quantum computing algorithm, based
on superposition and interference, that drastically speeds up the factoring process. A
4000-digit number, which would take a classical computer longer than the lifetime
of the universe to factorize, would take less than a day on a large, stable quantum
computer. Shor’s Algorithm5 can theoretically break modern encryption schemes,
although quantum hardware is not sufficiently advanced yet to make this decryption
practical. If it were, all your bank details, military secrets, and industrial secrets
could be easily hacked. The details of Shor’s algorithm are beyond our scope, so we
will instead discuss how the same quantum computer could be used to ensure a key
is shared over a secure channel.
Together, the one-time pad and quantum key distribution (QKD) would be a
formidable combination. The BB84 QKD6 simulation demonstrates how one could
create a shared key using electrons and a Stern–Gerlach apparatus. The BB84
protocol is summarized below.
The sender (Alice) and receiver (Bob) publicly agree to the relationship between
spins and bit value shown in Table 5.1.
5 https://quantum-computing.ibm.com/docs/guide/q-algos/shor-s-algorithm.
6 https://www.st-andrews.ac.uk/physics/quvis/simulations_html5/sims/cryptography-bb84/
Quantum_Cryptography.html.
44 5 Quantum Cryptography
5.3.3 Example
Alice sends five electrons to Bob. When Alice sends an electron prepared in one
basis and Bob measures in the same basis, they measure the same spin. However,
if Bob measures in a different basis than Alice, then the electron will be in a
superposition state and there will be a 50% probability of the state collapsing into
0 or 1. Example values for the first three bits of a BB84 experiment are shown in
Fig. 5.1. Can you fill in the last two bits?
z z z x x
Basis
Spin
Bit
0 1 1
value
z x x x z
Basis
Spin
Bit
0 1 0
value
z z z x x
Basis
Spin
Bit
0 1 1 1 0
value
z x x x z
Basis
Spin
Bit
0 1 0 1 1
value
0
Key 0 1
Fig. 5.2 Alice and Bob’s measurements of the BB84 protocol completed from Fig. 5.1. The
discarded bits are grayed out, and the key is 01
1. Alice and Bob publicly share the basis used for each bit measurement without
revealing the actual bit value they measured.
2. If they measured in the same basis, they keep that bit. If they measured in
a different basis, they discard that bit. This is shown in Fig. 5.2. For the
measurements performed in the same basis, Alice and Bob are guaranteed to
have the same string of bits unless there was an eavesdropper.
3. They publicly compare a subset of the bits, say 20 out of 100 bits. If all 20 are
the same, then it is unlikely that there was an eavesdropper. The remaining 80
become the shared key.
If an eavesdropper (Eve) overhears the post-processing part where Alice and Bob
share the basis used for each bit measurement, Eve has no information about
whether any bit was either a 0 or 1. As Eve has no information, public post-
processing sharing is not a dangerous action for Alice and Bob to take. The only
46 5 Quantum Cryptography
way for Eve to determine the spin value of the qubits, and as a consequence acquire
important information, is to measure the qubit with her own Stern–Gerlach before
it gets to Bob. This can be potentially dangerous for Alice and Bob. However, as
the basis is not shared during the transmission, Eve must randomly pick a basis
to measure the qubit intercepted from Alice. If Alice and Bob randomly choose to
measure in a different basis, they throw away all the bits and it does not matter
which basis Eve chooses. If Alice and Bob randomly choose to measure in the same
basis then there are two outcomes depending on what Eve does: (1) If Eve randomly
chooses the same basis as Alice, then she does not alter the state. This is bad, as Eve
has successfully eavesdropped information without Alice and Bob knowing. (2) If
Eve randomly chooses a different basis than Alice, then she alters the state and puts
it into a superposition. Even though Bob is using the same basis as Alice, due to
Eve altering the state, Alice and Bob can have a different spin measurement. This is
how they can catch an eavesdropper.
5.4.1 Example
The eavesdropping situation is shown in Fig. 5.3. If Eve chooses the same basis as
Alice, the spin is unchanged when it gets to Bob (bit #1). If Eve chooses a different
basis than Alice, the spin could be different when it gets to Bob (bits #2 and #3).
Eve could get lucky and Bob’s bit could agree with Alice (bit #2). However, Bob
is equally likely to measure something different from Alice (bit #3). Can you fill in
what might happen with bits #4 and #5?
When Alice and Bob compare a portion of their key bits, a discrepancy would
indicate the presence of an eavesdropper. If they compare a sufficient number of key
bits and all of them match, they can be reasonably sure that the rest of it is secure.
This statement will be quantified shortly in the questions.
1. Classical RSA encryption assumes that factoring a large integer into its prime
factors is prohibitively difficult. This assumption is true for classical computers,
ensuring your information can be safe.
2. Shor’s algorithm on a large and stable quantum computer could factor a large
integer into prime factors, making classical encryption vulnerable.
3. New quantum encryption protocols are developed to keep information safe in the
quantum era. The BB84 protocol is one way to share a secret key in a secure
channel, that can then be used for encryption.
5.7 Check Your Understanding 47
z z z x x
Basis
Spin
Bit
0 1 1
value
z x x z z
Basis
Spin
Bit
0 1 0
value
z z z x x
Basis
Spin
Bit
0 1 0
value
Fig. 5.3 An example of how to catch an eavesdropper using the BB84 protocol
5.6 Activities
1. If Alice and Bob exchange 1 million bits in order to use the BB84 quantum
cryptography protocol, approximately how long will their bit-key string be?
Assume they do not check for eavesdropping.
2. Alice and Bob share their lists of measurement basis, but do not share any
more information about the bits. What is the probability that Eve will guess the
correct bit for a single bit-key?
7 https://www.qutools.com/quantenkoffer_science-kit/.
48 5 Quantum Cryptography
3. Alice and Bob perform 20 bit-key measurements but do not share any
information about the bits. What is the probability that Eve will guess the correct
20-bit key?
4. If Eve tries all possible key combinations with the one-time pad, can she crack
the one-time pad?
5. If Eve uses a Stern–Gerlach to measure the spin in between Alice and Bob’s
measurements, what percentage of the time will she be lucky and get the correct
key-bit value without detection?
6. If Alice and Bob measure in the same basis and compare 20 bits of their key,
what is the probability that Eve could have eavesdropped all 20 bits without being
detected?
7. Suppose that Eve discovers that the no-cloning theorem is wrong and finds a
way to clone the state of each photon. How could she use a cloning machine to
learn about the entire key without leaving any trace?
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Quantum Gates
6
Classical computers manipulate bits using classical logic gates such as OR, AND,
NOT and NAND. This link1 provides a basic review of classical logic gates.
Similarly, quantum computers manipulate qubits using quantum gates. The gates
are applied to qubits and the states of the qubits change depending on which
gate is applied. In the Bloch sphere representation, the gate provides instructions
for rotating the qubit’s arrow around the sphere. A quantum algorithm has to be
implemented on a quantum computer using quantum gates. After running a quantum
algorithm, the result is retrieved by measuring the qubit’s state. The hardware
implementation of quantum gates depends on how the qubit and quantum computer
has been implemented technologically.2 As an example, one could have a qubit
based on spin. Then gates could be implemented using an external magnetic field to
1 https://whatis.techtarget.com/definition/logic-gate-AND-OR-XOR-NOT-NAND-NOR-and-
XNOR.
2 E.g., topological qubits and superconducting qubits have very different hardware implementations
change the spin and hence the qubit state. This chapter will focus on gates from the
computing perspective rather than the engineering perspective. You will learn about
several important gates that act on a single qubit, interpret histograms produced by
a quantum computer simulator, and use matrices to describe the operation of these
gates.
In classical computers, the NOT gate takes one input and reverses its value. For
example, it changes the 0 bit to a 1 bit or changes a 1 bit to a 0 bit. This is like a
light-switch flipping a light from ON to OFF, or from OFF to ON. A quantum X
gate is similar in that a qubit in a definite state |0 will become |1 and vice versa.
When the qubit is in a superposition of all basis states, then the superposition also
flips:
(6.1)
To see how this works, you can try out the IBM Q simulator.3 Traditionally,
all qubits on the IBM Q machine (or any other quantum simulator) start with the
incoming qubits in the |0 state. To run this simple gate, drag the X gate onto any
qubit. To find the results, add the measurement operation at the end, as shown in
Fig. 6.1. Figure 6.1 is known as a quantum circuit, the quantum analog to classical
circuits. A circuit describes how a qubit changes through a computation depending
on which gates act on it. The circuit is read from left to right. As an example, in
Fig. 6.1 the single qubit on the left is initialized to |0. An X gate is then applied
to that specific qubit, and the last symbol on the qubit line denotes that the qubit is
measured. The double line underneath is used to illustrate the measurement.
After running the quantum circuit and opening the results, you should see a
histogram showing the measurements of the qubit’s final state for 1,024 independent
trial runs. As the qubit always starts as the |0 state, applying the X gate produces
the |1 state and so the measurement outcome is |1 100% of the time as shown in
Fig. 6.2.
3 https://quantum-computing.ibm.com. It can also be run on IBM’s real quantum computer, but you
It is worth noting that any computer will have hardware errors. In a classical
computer, this could be an electrical short of the motherboard, or degradation of the
hard drive which corrupts the stored classical bits. A real quantum computer will
also have hardware errors. The quantum state of a qubit can change accidentally
because of these hardware errors. Such errors may arise from the lack of full control
of the interference between electromagnetic fields, variations in temperature, or
energy dissipation. The accidental and incorrect change of a qubit state gives rise
to the wrong answer which is called “noise”.4 As quantum computers only measure
the state of a qubit, they cannot easily tell if the measurement is correct or incorrect.
When we humans interpret these results, noise can cause confusion as to which
answer is actually correct. Minimizing noise error is the greatest obstacle to building
quantum computers.5 For example, noise will cause the histogram in Fig. 6.2 to not
Histogram
100.000%
100
90
80
Probabilities (%)
70
60
50
40
30
20
10
0
00001
State
Fig. 6.2 Histogram showing that the qubit is measured in the |1 state with a probability of
1. Reprint Courtesy of International Business Machines Corporation. ©International Business
Machines Corporation
have the perfect 100% outcome. Instead, noise will cause the qubit to be in the |0
state incorrectly some of the time, and the measurement histogram will incorrectly
be x% in the |0 state and (100 − x)% in the |1 state. If the noise is large, then
x = 50% and the measurement will be completely random. It should be understood
that noise is an effect that occurs in both classical and quantum computers but
because quantum computing technology is in its infancy, the noise is not as well
under control.
The Hadamard gate is very important in quantum computing. If the qubit starts in a
definite |0 or |1 state, the Hadamard gate puts each into a superposition of |0 and
|1 states. In Fig. 6.3, we apply a Hadamard gate to the |0 state qubit on the IBM Q
simulator and measure the output.
The result of running the circuit 100 times is a histogram shown in Fig. 6.4.
Note that each run is independent: before each measurement, the qubit has to
be reset to the |0 state and passed through the gate, and then the measurement
happens. We repeat this process 1024 times. Each bin in the histogram shows the
frequency/probability of measuring |0 or |1. You can clearly see that applying the
Hadamard gate to a single qubit creates a superposition state of both |0 and |1. The
probabilities are not exactly 50/50 because of statistical error. The more data you
collect, the closer the result converges to 50/50. This is similar to flipping a coin
and counting the number of heads or tails; the greater the number of flips, the more
likely you are to observe 50/50 probability of seeing heads/tails.
Recall that measurement collapses the superposition. Only one classical state
can be observed, and all of the other quantum information is lost. Measurement
collapse is the reason why a qubit’s state cannot be duplicated, known as the no-
cloning theorem of quantum computing. Once a superposition state is measured, it
fundamentally changes into one of the basis states, and hence cannot be duplicated.
Still, it is not known how or whether measurement collapse happens.6
6 https://en.wikipedia.org/wiki/Measurement_problem.
6.4 Mathematics of the Hadamard Gate 53
Histogram
55
49.316% 50.684%
50
45
Probabilities (%)
40
35
30
25
20
15
10
5
0
00000 00001
State
Fig. 6.4 Measurement histogram after running the Hadamard gate circuit in Fig. 6.3 1024
times. Reprint courtesy of International Business Machines Corporation, ©International Business
Machines Corporation
Fig. 6.5 Applying two Hadamard gates to the |0 state or |1 state
Question 1 Create a qubit in the |1 state and pass it through a Hadamard gate.
From the measurement histogram, can you tell whether the qubit started in a |0 or
|1 initial state?
The measurement histogram should look identical whether |0 or |1 was the
initial state. Then how can we tell what the initial state was after a Hadamard
operation? In the beam splitter, we determined where the photon came from by
adding a second beam splitter to create interference. The way to measure and
distinguish between them is to add a second Hadamard gate.
Question 2 Build a circuit that applies two Hadamard gates to a qubit in the |0
initial state as shown in Fig. 6.5. What is the output? Repeat this experiment for the
|1 initial state.
Using matrix multiplication we can show that √ application of the Hadamard gate
to an |0 initial state puts the qubit into the (1/ 2)(|0 + |1) state, also called the
|+ state:
(6.4)
√ initial state is |1, the Hadamard gate will create the superposition
If the
(1/ 2)(|0 − |1) state, called the |−:
(6.5)
In the Stern–Gerlach experiment, you learned that the |0 and |1 states make
up the z-basis and are associated with spin up and spin down. The |+ and |−
states comprise the x-basis and are associated with spin right and spin left. While
the Stern–Gerlach could be rotated to measure at any angle, a quantum computer
√ is
physically built to only
√ measure in the z-basis. Therefore, the spin right 1/ 2(|0 +
|1) and spin left 1/ 2(|0 − |1) look the same when measured by a quantum
computer. However, the two states have hidden information that can be recovered
by using a second Hadamard gate to change back into the z-basis.
6.4.1 Examples
√
1. A spin right 1/ 2(|0 + |1) is sent through
√ a Hadamard gate, creating a
superposition of |+ and |− given by 1/ 2(|+ + |−). By performing a basis
change, show that this is equivalent to producing a |0 state.
1 1 1 1 1 1 1
√ |+ + |− = √ √ |0 + √ |1 + √ √ |0 − √ |1 ,
2 2 2 2 2 2 2
(6.6)
1 1 1 1
= |0 + |1 + |0 − |1, (6.7)
2 2 2 2
= |0. (6.8)
2. Use matrix multiplication to show how applying the Hadamard gate twice to a
|0 state qubit recovers its original state.
1 1 1 1 1 1
H |0 = √ =√ , (6.9)
2 1 −1 0 2 1
6.5 Z Gate 55
1 1 1 1 1
H H |0 = = . (6.10)
2 1 −1 1 0
In fact, all quantum gates are reversible as a consequence of the unitary matrix
condition. Recall that the gates must be unitary so that the probabilities always
add up to 1. Multiplying any unitary matrix by its conjugate transpose will return
the identity matrix, i.e., reverses the gate to get the original state by U U † =
U † U = 1. The Hadamard matrix is self-unitary, i.e., it is its own conjugate
transpose, U = U † .
6.5 Z Gate
The Z gate leaves a |0 state unchanged but flips the sign of the |1 state to −|1
by
(6.12)
This is equivalent to changing the qubit from a |+ state to a |− state. The effects
of the X, H , and Z gates are summarized in Fig. 6.6.
6.7 Activities
8. Which of the quantum circuits in the Fig. 6.7 would NOT produce the
histogram shown in Fig. 6.4?
9. Use matrix multiplication to show how applying the Z gate to |+ changes
it to |−.
10. Using only Hadamard and Z gates, design a quantum circuit that outputs the
same result as an X gate.
11. Using the IBM Q simulator, apply the Z gate to a qubit in the following
initial states and interpret the measurement histogram.
(a) |0
(b) |1 (Hint: You need to first flip the |0 state using the X gate.)
(c) |+ (Hint: You need to first create the |+ state using the H gate.)
(d) |− (Hint: You need to first create the |− state using the X and H gates.)
12. What is the expected measurement histogram produced by the circuit in
Fig. 6.8?
13. Show that the Hadamard gate is unitary and therefore reversible.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Entanglement
7
Fig. 7.1 Two coins that are entangled in such a way that they either both land on HH or both land
on TT.
know to land on the same side as the other even though there can be no classical
communication between them.
How does the other coin instantaneously “know” what was measured on the
other? Is information somehow being transmitted faster than the speed of light?
Einstein called this behavior a “spooky action at a distance.”1 It has since been
shown that no information is being transmitted from one place to the other, and
so no information is being transmitted faster than the speed of light. Rather, the
particles share non-classical information at the time of entanglement, which is then
observed in the measurement process. The correlation between entangled qubits is
the key that allows quantum computers to perform certain computations much faster
than classical computers.
1 “Bounding the speed of spooky action at a distance.” Physical Review Letters. 110: 260407. 2013.
arXiv:1303.0614.
7.3 Multi-Qubit States 61
It is tempting to think that there may be some classical explanation for entanglement.
Did the entanglement change the fair coins by adding extra mass to the heads side
or the tails side, thereby making them unfair? To provide a more realistic example
in a classical system, consider a particle that decays into two lighter particles. The
momenta of these three particles are related by the conservation of momentum:
pi = pf 1 + pf 2 . Given a known total initial momentum, then by measuring the
momentum of one of the final state particles, we can determine the momentum of
the other final state particle. In summary, by measuring one particle’s momentum,
we know the other. Momentum is the hidden classical variable that is encoded when
the two particles are created. This is shown in Fig. 7.3. Naturally, the question arises:
is there a conceptually similar hidden variable in the quantum mechanical situation?
However, Bell’s theorem2 demonstrated that the correlation between entangled
quantum particles is more than what is possible classically, disproving the idea of
a hidden variable. All other potential loopholes have been resolved as of 2016.3 As
such, entanglement is a purely quantum phenomenon with no classical explanation.
Given multiple qubits, the total state of the system can be written together in a
single ket. For example, if coin #1 is heads and coin #2 is tails, the two-coin state is
expressed as |H T . In general, a system of two qubits can be in a superposition of
four classical states, and written as
2 https://brilliant.org/wiki/bells-theorem/.
3 TheBIG Bell Test Collaboration (9 May 2018). “Challenging local realism with human choices.”
Nature. 557: 212–216. doi:10.1038/s41586-018-0085-3.
62 7 Entanglement
Fig. 7.4 A two-qubit system can collapse into one of four states with probability αij2 .
As we saw for the single qubit states, the coefficients αij are called the amplitudes
and are generally complex numbers. Measuring the two qubits will collapse the
system into one of the four basis states with probability given by αij2 . This is shown
in Fig. 7.4.
7.3.1 Example
It is possible to have a system of particles that are not entangled with each other. In
this case, changing one particle will not cause any change in the other particle. For
7.5 Entangled Systems 63
example, in a classical system, flipping two coins and measuring one coin as heads
does not tell you any information about whether or not the other coin will land on
heads or tails. These events are said to be independent. If you wanted to calculate
the probability of |H T , you would simply multiply the probability of getting H on
coin #1 by the probability of getting T on coin #2. This is given by
1 1 1
Prob (|H T ) = = .
2 2 4
Non-entangled states are also called product states or separable states because
they can be factored into a product of single-qubit states.4 The two single-qubit
probabilities multiply to produce the two-qubit probabilities.
7.4.1 Example
One qubit is in a α0 |0 + α1 |1 state, while another is in a β0 |0 + β1 |1 state. What
is the state of the non-interacting two-qubit system?
(α0 |0 + α1 |1) (β0 |0 + β1 |1) = α0 β0 |00 + α0 β1 |01 + α1 β0 |10 + α1 β1 |11.
Intuitively, any interaction between two or more qubits will cause the qubits to share
some information between each other. This sharing of information from interactions
causes emergent phenomena that we call entanglement. Mathematically, a multi-
qubit state is entangled only if it cannot be expressed as a product state. However,
determining if a general multi-qubit state can be expressed as a product state can
be difficult. Instead, an easier test to determine if a system is entangled or not is
to check if measuring the value of one qubit changes the probability distribution
of the second qubit. We will use this test extensively.5 If this test is true, then the
system is definitely entangled. However, if the probability distribution of the second
qubit does not change in this test, then the system could still be entangled. In this
case, the entanglement arises from the sharing of hidden information in the signs
(or complex components) of the probability amplitudes of a general state. While
the probabilities may not change (due to the amplitudes being squared), the relative
4 More recently, it has been shown that there can exist quantum correlations in separable states
that are not due to entanglement. These are called quantum discord: https://en.wikipedia.org/wiki/
Quantum_discord.
5 There are ways to test for entanglement without the need to factorise a multi-qubit state into single
qubit states. Namely, whether the trace of the density matrix for the subsystem squared is equal to
1. However, the mathematical necessities for this test are outside the scope of this course.
64 7 Entanglement
7.5.1 Example
7.5.2 Example
Show that |ψ = √1 |00 + √1 |11 cannot be written as a product of two single
2 2
qubits.
Assume that the state can be written as the product of two states.
1 1 ?
√ |00 + √ |11 = (α0 |0 + α1 |1) (β0 |0 + β1 |1) , (7.1)
2 2
?
= α0 β0 |00 + α0 β1 |01 + α1 β0 |10 + α1 β1 |11. (7.2)
Comparing the amplitudes on the left vs. the right, the αi ’s and βj ’s must satisfy:
1 1
α0 β0 = √ , α0 β1 = 0, α1 β0 = 0, α1 β1 = √ . (7.3)
2 2
However, this is not possible. For example, take α0 β1 = 0. This means that either
α0 = 0 or β1 = 0. If α0 = 0, then α0 β0 = 0, but α0 β0 = √1 in the above
2
equation. A similar contradiction occurs with β1 = 0. So the initial assumption
must be incorrect and this entangled state cannot be written as the product of two
separate states.
As there are many different ways of building a quantum computer, there are many
different ways of physically entangling particles. One method called “spontaneous
parametric down-conversion” shines a laser at a special nonlinear crystal. The
7.7 CNOT Gate 65
crystal splits the incoming photon into two photons with correlated polarizations.
For example, one could produce a pair of photons that always have perpendicular
polarizations (see Fig. 7.5). Just as the engineering aspect of building a quantum
computer is outside the scope of this course, so is the technological aspect of
how qubits are physically entangled. We will focus more on how entanglement is
represented in a quantum computer and the uses of this.
You have already learned about the X, Hadamard, and Z gates. These act on a single
qubit. There are also quantum gates that perform a logic operation on multiple
qubits. The most important multi-qubit gate is the controlled NOT (CNOT) gate.
The CNOT is used to entangle two qubits together and is essential in quantum
computing/algorithms. The CNOT takes in two qubits, a control qubit and a target
qubit, and outputs two qubits. The control qubit stays the same, while the target
obeys the following rule.
• If the control qubit is |0, then leave the target qubit alone.
• If the control qubit is |1, then on the target qubit flip |0 → |1 and |1 → |0.
The truth table for the CNOT gate is shown in Table 7.1.6 From this one can deduce
the matrix form of the CNOT gate as
6 https://en.wikipedia.org/wiki/Controlled_NOT_gate.
66 7 Entanglement
⎛ ⎞
1000
⎜0 1 0 0 ⎟
CNOT = ⎜ ⎟
⎝0 0 0 1 ⎠ . (7.4)
0010
Figure 7.6 is the circuit for the CNOT gate. Plugging in the “Before” values from
Table 7.1 into this circuit will produce the “After” values.
When converting between bra-ket notation and circuit notation, there are two
different conventions. Since we will be using the IBM quantum computer, we will
adopt the IBM convention. This is shown in Fig. 7.7. In the IBM notation, the
topmost qubit in the circuit corresponds to the rightmost qubit in the bra-ket notation
(| . . . q). IBM shorthand is top-down in circuit notation, which corresponds to right-
left in bra-ket notation.
The other convention, which we will not use going forward but provide in case it
is seen in other resources, is shown in Fig. 7.7. Here, the topmost qubit corresponds
to the leftmost qubit in bra-ket notation (|q . . .). Top-down in circuit notation
corresponds to left-right in bra-ket notation. We will not use this going forward.
7.9 Examples
1. Figure 7.8 shows the quantum circuit sending |01 through a CNOT gate. What
is the output?
Fig. 7.7 The two conventions for mapping circuit notation to the bra-ket notation, IBM (left) and
Other (right). Note in this book we adopt the IBM convention as we run code on the IBM quantum
computers.
7.9 Examples 67
Fig. 7.8 The quantum circuit that sends a multi-qubit in the |01 state through a CNOT gate.
The figure shows that, in IBM notation, the control qubit is on top and the
target is on the bottom. Since the control is in the |1 state, the target qubit is
flipped to |1. So measurement will always result in |11.
2. Examine Fig. 7.9. The control qubit is in a superposition of |0 and |1. What is
the effect of a CNOT gate?
Before the CNOT operation, in ket notation, the control qubit is in the √1 |0+
2
√1 |1 state, while the target qubit is in the |0 state. The two-qubit input state is
2
therefore √1 |00 + √1 |01. Applying the rules for the CNOT, the first state |00
2 2
does not change as the control qubit is |0. However, for the second state |01,
the control qubit is |1 and so the target qubit is flipped from |0 to |1. The result
of the CNOT gate is the state √1 |00 + √1 |11. The histogram from measuring
2 2
this state is shown in Fig. 7.10. This is a special state called the Bell state.
The two qubits are entangled after the CNOT! As illustrated in the previous
example, this state cannot be written as the product of two separate qubits.
As with the single-qubit gates, the CNOT gate operates on ALL states in the
superposition, e.g., the CNOT gate acts on the four basis states of a two qubit
system simultaneously. Quantum algorithms leverage this parallelism to ensure
speed improvements over classical computers. In addition, as with all quantum
gates, the CNOT is reversible, meaning the operation can be undone (which can
be used to figure out the original qubit states).
68 7 Entanglement
Histogram
55
49.805% 50.195%
50
45
40
Probabilities (%)
35
30
25
20
15
10
5
0
00000 00011
State
Fig. 7.10 The measurement histogram produced by running the circuit in Fig. 7.9. Reprint
courtesy of International Business Machines Corporation, ©International Business Machines
Corporation.
7.11 Activities
1. For each of the questions below, assume that two-qubits start in the state
1 1 1
|ψ = √ |00 + |10 − |11. (7.5)
2 2 2
7 In fact, three single qubit gates (the Hadamard, phase, and π/8 phase-rotation) in combination
with the CNOT form a universal set of gates, i.e., all other gates can be made up from them.
8 https://www.qutools.com/quantum-physics-education-science-kits/.
7.12 Check Your Understanding 69
(a)
What is the probability of measuring both qubits as 0?
(b)
What is the probability of measuring the first qubit as 1?
(c)
What is the probability of measuring the second qubit as 0?
(d)
What is the new state of the system after measuring the first qubit as 0?
(e)
What is the new state of the system after measuring the first qubit as 1?
2. Two fair coins are flipped. What is the state of the two-coin system while the
coins are in the air?
3. Is √1 |00 + √1 |01 an entangled state? If so, show that it cannot be written
2 2
as a product. If not, what is the individual state of the two qubits?
4. Are the following two-qubit states entangled?
(a) √1 |01 + √1 |10
2 2
(b) √1 |01 − √1 |10
√2 2
(c) 2
3
|00 + 1
2 |11
(d) √1 |10 + √1 |11
2 2
(e) 1
2 |00 + 1
2 |01 + 12 |10 − 12 |11
(f) √ |00 + |10 − 1 |11
1 1
2 2 2
5. Two qubits are passed through a CNOT. In IBM notation, the qubit on the
right is the control qubit. What is the output for the following initial states?
(a) |00
(b) |01
(c) |11
(d) √1 |01 + √1 |10
2 2
(e) √1 |00 + 1 |10 − 1 |11
2 2 2
6. The output of a CNOT gate is shown in Fig. 7.11. What were the inputs?
7. Can you predict the state produced by these quantum circuits? Try them out
on the IBM quantum computer.
70 7 Entanglement
8. Can you predict which states will be produced by these quantum circuits?
|0 H •
|0
b)
|0 • H
|0
d)
9. Can you predict the state produced by these quantum circuits? Note: to
put the circuit in a) on the IBM quantum computer, you need to use the code
(rather than the click-and-drag interface) to put the second CNOT control on
the bottom qubit.
7.12 Check Your Understanding 71
10. Use the IBM Q9 simulator to create the entangled state √1 |01 + √1 |10.
2 2
11. Suppose Alice has one half of an entangled pair and Bob has the other half.
When Alice makes a measurement on her qubit, Bob’s qubit instantaneously
changes its state. Can Alice and Bob use entanglement to transmit information
faster than the speed of light? Why or why not?
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
9 https://quantum-computing.ibm.com/
Quantum Teleportation
8
Question 1 Create a qubit in the |1 state and pass it through a Hadamard gate.
From the measurement histogram, can you tell whether the qubit started as a |0 or
|1 initial state?
The measurement histogram should look identical if either of the |0 or |1 states
is used initially. Then how can we tell what the initial state was after performing a
Hadamard operation? In the beam splitter, we determined where the photon came
from by adding a second beam splitter to create interference. The way to measure
and distinguish between them is to add a second Hadamard gate. As we have seen in
Sect. 2.2, all gates must be unitary to conserve probabilities. The unitary condition
ensures that all gates are reversible: we can undo the action of any gate by applying
1 The
no-cloning theorem poses a big problem for correcting errors that happen on quantum
computers: https://en.wikipedia.org/wiki/Quantum_error_correction.
its conjugate transpose. This is easily seen in matrix form as unitary matrices as
defined as U U † = 1. As the Hadamard gate is its own conjugate transpose, applying
a second Hadamard gate is equivalent to undoing the first. This is how the original
state is recovered.
Question 2 If a qubit is in the unknown state a|0 + b|1, what is the result of a
single measurement?
(A) 0
(B) 1
(C) 0 with probability a 2 and 1 with probability b2
(D) A number between 0 and 1
Question 3 What is the result of a second measurement after the first from
Question 2?
The way to get around the problem of not being able to measure the qubit (and avoid
collapsing the unknown state onto a basis state) is to “scan” the qubit indirectly with
the help of entangled particles. This comic2 illustrates the basic idea. The protocol
is as follows:
1. Alice and Bob meet up and make a qubit each (which we will call qubit #2 and
#3). At this point, the two qubits are completely independent and we can think
of the qubits as two different balls that do not contain any information about
the other. Then, Alice and Bob decide to entangle their qubits by causing an
interaction between the qubits, for example by applying a CNOT gate. Think
2 https://www.jpl.nasa.gov/news/news.php?feature=4384.
8.2 Teleportation Protocol 75
of entanglement as Alice writing some information on Bob’s ball that only she
knows how to read, and Bob writing information on Alice’s ball that only he
knows how to read. For Bob to read Alice’s information on his ball, Alice needs
to send him a (classical) message describing how to understand it, and vice-
versa. They do not tell each other how to read the information yet. One possible
entangled state (called the Bell-state) that they decide to create is
1 1
√ |00 + √ |11. (8.1)
2 2
Alice takes her qubit and walks away, and Bob takes his and walks in a different
direction as shown in Fig. 8.1.
2. Now Alice obtains a third qubit in an unknown state (qubit #1) that she wants
to transfer to Bob. She can only communicate with him classically by email or
phone, and it would take too long to physically bring the qubit to Bob. The current
situation is shown in Fig. 8.2.
3. Alice interacts her two qubits using a CNOT gate (qubits #1 and #2) and mea-
sures the qubit she originally had (qubit #2). She then sends the unknown qubit
to be teleported (qubit #1) through a Hadamard gate and afterwards measures the
output. Recall that the Hadamard gate is used to create a superposition of states.
The current situation is shown in Fig. 8.3.
Because Alice’s original qubit (qubit #2) was entangled with Bob’s, the
CNOT interaction with qubit #1 immediately changes the state of Bob’s qubit.
Fig. 8.3 Alice passes her two qubits through a CNOT gate
long as the order of the qubits is kept unchanged. For example, if qubit #1 = |0,
qubit #2 = |1, and qubit #3 = |1, they can be written as |0|1|1 = |011 =
|0|11 = |01|1. Sometimes it is easier to split up the multi-qubit state like this
to explicitly show if a gate is acting on a single qubit.
Now, from steps (1) and (2) we have Alice and Bob’s qubits in the Bell state
√1 (|00 + |11). Qubit #1 is in an unknown state a|0 + b|1. At the start of step
2
(3), the three qubits need to be written together in ket notation by multiplying the
qubit to be teleported by the entangled Bell state. The product is:
1 1 1
[a|0 + b|1] √ |00 + √ |11 = √ a|000+a|011+b|100+b|111 .
2 2 2
(8.2)
Next, we apply a CNOT gate using the first qubit in Eq. (8.2) as the control
and the second as the target. Recall that the target (qubit #2) changes state only
if the control is |1. After applying the CNOT gate the three-qubit state is
1
√ a|000 + a|011 + b|110 + b|101 . (8.3)
2
After this, we apply a Hadamard gate to qubit√#1 in Eq. (8.3). Recall that
Hadamard gate changes the state |0 → (1/ 2)(|0 + |1), and |1 →
the √
(1/ 2)(|0 − |1). The three-qubit state is
1
a (|0 + |1) |00+a (|0 + |1) |11+b (|0 − |1) |10+b (|0 − |1) |01 .
2
(8.4)
Next, distribute the product of qubits throughout Eq. (8.4) to find
1
a|000 + a|100 + a|011 + a|111 + b|010 − b|110 + b|001 − b|101 .
2
(8.5)
8.2 Teleportation Protocol 77
Finally, combine like-terms of Eq. (8.5) based on the first two qubits to get
1
|00(a|0 + b|1) + |10(a|0 − b|1) + |01(a|1 + b|0) + |11(a|1 − b|0)
2
(8.6)
Remember that qubit #1 and qubit #2 are the ones that belong to Alice. We
see that the state of Bob’s qubit #3 has changed by applying the CNOT and
Hadamard gates to Alice’s qubits. As can be seen in Eq. (8.6), Bob’s qubit is
currently in one of four possible superposition states. This is shown in Fig. 8.4.
The four possible superposition states of Bob’s qubit depend on Alice’s
original qubit #2 through the initial entanglement in Step 1, as well as depending
on the unknown qubit #1 to be teleported from the CNOT gate in Step 3. The
reason we need to measure the state of Alice’s qubit #2 and qubit #1 is to figure
out the way Bob’s qubit depends on these two. The current status is shown in
Fig. 8.4. Note that Bob has not done anything with his qubit at this stage.
4. Alice now sends the two classical bits of information from the measurements to
Bob by email or phone. According to Eq. (8.6), her measurements can be 00, 10,
01 or 11, each with 25% probability.
Depending on the measurement obtained by Alice, Bob can recover the original
state of the teleported qubit (i.e., a|0 + b|1) by using a combination of X or Z
gates. The specific combination of X/Z gates to use will be explored as a question
in Sect. 8.4. This situation is illustrated in Fig. 8.5. At this stage, the qubit has been
successfully teleported from Alice to Bob, and thus ends the teleportation protocol.
Throughout the teleportation process, the original qubit #1 that has to be
teleported does not remain in its original quantum state: a|0 + b|1. This is because
Alice performs a measurement on it during the teleportation protocol. As a result,
there is no copy of qubit #1 existing at any time, and so teleportation does not
Fig. 8.5 The final result of teleportation between Bob and Alice
78 8 Quantum Teleportation
Fig. 8.6 The full quantum circuit for quantum teleportation. The dashed box entangles Alice’s
and Bob’s qubits to make the Bell state. Afterwards, the quantum teleportation protocol described
in the text is performed.
1. If Alice and Bob have a single qubit each, which they entangle, it is possible for
Alice to teleport the information encoded in a third unknown qubit into Bob’s
qubit.
2. Quantum teleportation sends quantum information by using the entanglement
and measurement properties of quantum mechanics.
3. Quantum teleportation does not destroy the qubit to be teleported (like in science
fiction). It only transfers the information contained within the qubit without ever
needing to know that information.
3 Fermi National Accelerator Laboratory is building a quantum teleportation experiment which will
extend over large distances, helping to develop a future quantum internet, e.g., https://qis.fnal.gov/
quantum-teleportation-experiment/.
8.4 Check Your Understanding 79
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Quantum Algorithms
9
We have come a long way from Chap. 1. To recap on what we have learnt, we have
understood important quantum mechanical phenomena such as superposition and
measurement (through the Stern-Gerlach and Mach-Zehnder experiments). We have
also learnt that while quantum computers can in principle break classical encryption
protocols, they can also be used to make new secure channels of communication.
Furthermore, we have applied quantum logic gates to qubits to perform quantum
computations. With entanglement, we teleported the information in an unknown
qubit to another qubit. This is quite a substantial achievement.
However, we have not yet learned about a fundamental aspect of quantum
computing: quantum algorithms. Simply put, given a task that we want the quantum
computer to perform, a quantum algorithm is how the quantum computer performs
this task on some input qubits. One typical example of an algorithm on a classical
computer is the search algorithm, e.g., searching a database to find a friend in
your friends list. In fact, quantum computers can also implement search algorithms.
Grover’s algorithm, one of the two most famous quantum computing algorithms (the
other being Shor’s algorithm which we learnt about in Chap. 5), uses entanglement
to search a database faster than any classical computer can. While studying Grover’s
algorithm is outside the scope of this course, we will study the Deutsch-Jozsa
Algorithm that shows how quantum computers can perform calculations faster than
classical computers. After studying this algorithm, you will have a basis to learn
more complicated algorithms.
The main advantage that quantum computers have over classical computers is
parallelism. Because qubits can be in a superposition of states, a quantum computer
can perform an operation on all of the states simultaneously. Let’s say we want to
know the result of applying some function f (x) to some number x. Two classical
computations are needed to find the result for x = 0 and for x = 1, whereas a
quantum computer can evaluate both answers in parallel as displayed in Fig. 9.1.
If we wanted to compute f (x) for x = 2 (represented as 10 in binary) and x = 3
(represented as 11), we would need to add a second qubit. The two-qubit quantum
computer can then evaluate all four possibilities at once as shown in Fig. 9.2.
|000, |001, |010, |100, |011, |110, |101, |111 → 8 pieces of information.
(9.1)
Adding a qubit to a quantum computer doubles its processing power! For a classical
computer, you need to double the number of wires in the processor to get double
Fig. 9.1 It takes a classical computer two operations to operate on two pieces of information. A
quantum computer with one qubit can operate on two classical pieces of information at once.
Fig. 9.2 It takes a classical computer four operations to operate on four pieces of information. A
quantum computer with two-qubits can operate on four classical pieces of information at once.
9.2 Limitations 83
the processing power.1 However, with a quantum computer, you only need to add a
single qubit to double the processing power! Further, an n-qubit system can perform
certain 2n operations at once!
Separate from the issue of processing power is a concept known as memory.
In a classical computer, on a standard 64-bit laptop, each number can be repre-
sented in the 64-bit binary representation (a simple extension of the 8-bit binary
representation you already learned about). If you wanted four numbers on a 64-bit
machine at the same time, then you need to have 4 × 64 = 256-bits of memory
on your hard drive to store them. On a 64 bit classical computer, for M different
numbers, you need M × 64-bits of memory; i.e., the bits needed for the memory
is linear as a function of the number of numbers required. However, on an n-qubit
quantum computer, there can be 2n different coefficients of the quantum state that
could in principle hold the numbers and therefore can be used as memory; i.e., the
qubits needed for memory is logarithmic as a function of the number of numbers
you want.
Because classical computers are very advanced and have large processing
power and terabytes of memory, classical computers can simulate small quantum
computers. As the addition of a single qubit would double the memory required,
the largest supercomputer in the U.S.2 would only be able to simulate a 46-qubit
quantum computer. As of 2018, Google has a quantum computer with a quantum
chip (called the Bristlecone) which has 72-qubits.
9.2 Limitations
While parallelism sounds amazing in theory, it is not immediately useful on its own.
A quantum computation can calculate a superposition of the 2n numbers, however
a measurement still needs to be performed in order to extract information from
the quantum computer. One measurement will only show one of those answers
and afterwards collapse the superposition into a basis state. Think about it as
if the 2n numbers are all on a secret scratchpad that we cannot see, and nature
shows you one random page at a time, then burns the scratchpad. You would need
to run the quantum computer at least 2n times to get all the numbers, therefore
negating any advantage over classical computers. As an example of this, the two-
qubit quantum computer can calculate the superposition a|f (00) + b|f (01) +
c|f (10) + d|f (11), but measuring this state will result in either f (00), f (01),
f (10), OR f (11). If you are unlucky, due to the randomness of quantum physics,
you could repeat the computation four times and still not see all of the possibilities.
Quantum computers are therefore only practical for certain types of problems.
Since quantum computers are built on quantum physics principles, we intuitively
1 Itis an observation that classical computers double their processing power roughly every 18
months. This is known as Moore’s law.
2 The Titan at Oak Ridge Laboratory as of 2018.
84 9 Quantum Algorithms
expect that they would be best suited for simulating quantum phenomena directly.
Generally, these types of problems look for correlations between different outputs.
Due to this, it is generally accepted that quantum computers will not replace
classical computers but will be able to perform different calculations that classical
computers simply cannot. We will study an example problem which the quantum
computer can solve more efficiently than a classical computer.
Here we provide a proof that quantum computers can be faster than classical
computers by explicit construction of a problem.
Let f (x) be an unknown function that operates on a single qubit. There can only be
four different functions that satisfy this requirement, and the four different functions
are shown in Table 9.1.
A function is called constant if it always outputs the same result for all values of x.
A function is called balanced if it outputs 1 for half of all the possible values of x
and 0 for the other half. The question posed to the computer is this:
For this single qubit case, the question is answered by checking if f (0) = f (1).
It also turns out in this single qubit case that there are only constant and balanced
functions. However, in multiple qubit systems, there exist functions that are neither
constant nor balanced. In the multiple qubit scenario, it is important that in the
problem statement the function given to the quantum computer is either constant or
balanced, and not something else.
Question 2 Which of the functions in Table 9.1 are constant and which are
balanced?
Question 3 If you run the classical algorithm and see that f (0) = 1, could you tell
whether the function is constant or balanced?
Fig. 9.3 The Mach-Zehnder interferometer altered to implement the cartoon version of the
Deutsch-Jozsa algorithm. The function implementations are shown in Fig. 9.5.
86 9 Quantum Algorithms
1. The two inputs x = 0 and x = 1 are represented by the two possible photon paths
as shown in Fig. 9.4. A photon taking the yellow path is x = 0, while a photon
taking the red path is x = 1. Beam splitter 1 therefore creates a superposition
of 0 and 1 since the photon takes both paths. Due to the orientation of the beam
splitter, the red transmitted path will have no phase shift whereas the yellow
reflected path will have a phase shift of π .
2. Each of the four functions in Table 9.1 can be modelled by a different experimen-
tal setup as shown in Fig. 9.5. For example, if we wanted to test f1 , we would
place a piece of glass along the red path but nothing along the yellow path. A
photon passing through the glass will experience an additional phase shift of π .
The reason that this is only a cartoon demonstration is that the phase shifters do
not actually implement the function, as we will see in the next section.
Question 4 If f1 is being tested, what is the phase of the yellow path upon
reaching the second beamsplitter? The red path photon?
The yellow path was phase-shifted by Beam Splitter 1 and unaffected by the
blue function box f (0). The red path was unaffected by Beam Splitter 1 and
phase-shifted by the blue function box f (1). Therefore, they both have a phase
shift of π .
3. The second beam splitter creates the interference necessary to ensure that
measurement happens only in one detector. Depending on which detector is
measured, this is interpreted as the function being constant or balanced.
Fig. 9.5 The four different functions from Table 9.1 experimentally implemented by four different
configurations. In this cartoon, we have denoted the function changing the bit by an X-gate,
however in reality as described in Eq. (9.2) two qubits are needed to implement these functions.
At Detector 1, the yellow path and red path photons both have a phase shift of π .
At Detector 2, the yellow path photon has a phase shift of π while the red path
photon has a phase shift of 2π .
4. Measure which detector is activated.
After working through the exercises, you should see that thanks to superposition and
interference, only one quantum measurement is needed in this cartoon picture of the
Deutsch-Jozsa problem. The general algorithm is presented in the next section.
88 9 Quantum Algorithms
Before we describe the full quantum solution, we need to setup some useful
tools. For example, in the quantum computing literature, it is common to use the
mathematical tool called modular arithmetic. For this algorithm, we will not need
to understand modular arithmetic more than basic notation. In quantum computing,
modular arithmetic with “mod 2” is defined to be f (0)⊕f (1) = 0 if f (0)+f (1) =
0, 2, 4, 6, . . .. However, f (0) ⊕ f (1) = 1 if f (0) + f (1) = 1, 3, 5, . . .. Note the
circle with a plus inside ⊕ denotes this modular arithmetic “mod 2” operation. The
⊕ operation outputs the remainder of dividing a number x by the number 2. As an
example, if f (0) = 0 and f (1) = 1 then f (0) ⊕ f (1) = 1, whereas if f (0) = 1
and f (1) = 1 then f (0) ⊕ f (1) = 0.
Also, we will need a second qubit for this algorithm, and will shortly see why. In
the quantum computing world, the function f (x) is implemented by
f
|x|y −
→ |x|y ⊕ f (x). (9.2)
f
As an example, assume f (0) = 1, then |0|1 − → |0|1 ⊕ f (0) = |0|0. Although
the implementation of functions as in Eq. (9.2) looks strange, this is needed to ensure
that the function operation is unitary.3 The circuit that implements the Deutsch-
Jozsa algorithm is shown in Fig. 9.6. We will now give a walk-through of the
algorithm and the circuit.
Deutsch-Jozsa Procedure:
1. As the first step of the algorithm shown in Fig. 9.6, get two qubits, and put them
into a |0|1 product state. In the modified Mach-Zehnder experiment above, only
the first qubit from Fig. 9.6 was shown. The second qubit was hidden in the blue
function boxes.
2. Operate on each qubit with the Hadamard gate. Following the rules of the
Hadamard gate, the two qubit state is now
Fig. 9.6 The quantum circuit for the one qubit Deutsch-Jozsa algorithm. The generic function
f (x) is represented by the box with f inside, and the labels below/above the lines indicate how
the function is implemented.
3 Taking the function f1 and representing its action on a single qubit as a matrix, this matrix is not
unitary. Non-unitarity violates the laws of quantum mechanics.
9.3 Deutsch-Jozsa Algorithm 89
1
(|0 + |1)(|0 − |1). (9.3)
2
In the Mach-Zehnder cartoon in Fig. 9.3, Beam splitter 1 performs the first
Hadamard gate on the first qubit in Fig. 9.6.
3. Apply the function f (x) using the rule in Eq. (9.2) to the state in Eq. (9.3). After
performing the arithmetic, the two qubit state can be organised as
1
|0 |0 ⊕ f (0) − |1 ⊕ f (0) + |1 |0 ⊕ f (1) − |1 ⊕ f (1) . (9.4)
2
In order to get a clearer picture of the effect of f (x) on the state, it is useful to
notice that if f (0) = 0 then |0 ⊕ f (0) − |1 ⊕ f (0) = |0 − |1. Additionally,
if f (0) = 1 then |0 ⊕ f (0) − |1 ⊕ f (0) = −|0 + |1. We can combine these
two by writing |0 ⊕ f (0) − |1 ⊕ f (0) = (−1)f (0) (|0 − |1). A similar formula
is needed for the f (1) case also, and we leave this as an exercise for the reader.
Applying this formula to Eq. (9.4) gives
1
(−1)f (0) |0 |0 − |1 + (−1)f (1) |1 |0 − |1 (9.5)
2
f (0) 1
= (−1) |0 + (−1) (f (0)+f (1))
|1 (|0 − |1). (9.6)
2
In the Mach-Zehnder cartoon in Fig. 9.3, the interaction between the two qubits
was modeled by the photon passing through the blue function boxes.
4. We now throw away the second qubit. We only keep the first qubit and make sure
it is normalized correctly. The first qubit is
1
√ (|0 + (−1)(f (0)+f (1)) |1). (9.7)
2
The reason we need the second qubit is to perform the gate operations and collect
the like-terms which ensures the algorithm works. This second qubit is called an
ancilla qubit because it is not measured. This is shown in the circuit in Fig. 9.6 as
the lack of the measurement operator in the second qubit line.
5. Apply a Hadamard gate to the qubit state in Eq. (9.7) to produce
1
1 + (−1)(f (0)+f (1)) |0 + 1 − (−1)(f (0)+f (1)) )|1) . (9.8)
2
In the Mach-Zehnder cartoon in Fig. 9.3, the second Hadamard gate operation
was implemented by Beam Splitter 2.
6. Measure the qubit. If f (x) is constant, then the state in Eq. (9.8) reduces to |0,
while if f (x) is balanced then the state reduces to |1. In the Mach-Zehnder
cartoon in Fig. 9.3, the detector measured the final state of the photon.
90 9 Quantum Algorithms
4 https://www.nature.com/articles/s41586-019-1666-5.
5 https://www.sciencenews.org/article/google-quantum-supremacy-claim-controversy-top-
science-stories-2019-yir.
6 https://arxiv.org/abs/1910.09534.
7A laser is a source of photons which have the same wavelength and are in phase.
9.7 Check Your Understanding 91
9.6 Activities
1.
(a) How many different classical pieces of information can be represented by
eight classical bits (1 byte)?
(b) What about a quantum computer with eight qubits?
(c) What advantage does the quantum computer have over the classical com-
puter?
2. This problem refers to the experimental setup in Fig. 9.3. Which detector(s)
go off for the function
(a) f1 ?
8 Theoretical physicists and computational scientists at Fermi National Accelerator Laboratory are
working on improving algorithms and the foundations of quantum science in order to expand
the problems that (near term) quantum devices can solve, e.g., https://qis.fnal.gov/quantum-
computing-for-hep/.
9 https://qiskit.org/textbook/ch-algorithms/index.html.
92 9 Quantum Algorithms
Fig. 9.7 The gate implementation for testing the different possible three-qubit functions.
(b) f2 ?
(c) f3 ?
(d) f4 ?
3.
(a) Which detector(s) go off if the function is constant?
(b) Which detector(s) go off if the function is balanced?
(c) How many photons would you need to send to determine whether the
function was constant or balanced?
4. Explain how superposition and interference allows the Deutsch-Jozsa algo-
rithm to beat the classical algorithm.
5. Figure 9.7 shows the gate implementation for testing a three-qubit function
f (x). A constant function will always result in |000 or |111.
(a) How many evaluations would be needed on a classical computer to tell
whether this function is constant or balanced?
(b) By running this algorithm on IBM Q, can you determine whether this
function is constant or balanced?
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Worksheets
10
Objectives:
Questions
Alice and Bob each measure one of two qubits with a Stern-Gerlach apparatus. Start
with both SGAs along the z-axis (Fig. 10.1)
1. Try sending pairs of particles in a product state |↑A |↓B . What do Alice and
Bob measure individually?
2. Try sending pairs of particles in an entangled state: √1 (|↑A |↓B − |↓A |↑B ).
2
What do Alice and Bob measure individually?
3. If Alice measures her spin, would you be able to predict Bob’s result:
(a) In the product state?
(b) In the entangled state?
4. Try sending pairs of particles in a product state |↑A |↓B . What do Alice and
Bob measure individually?
1 https://www.st-andrews.ac.uk/physics/quvis/simulations_html5/sims/entanglement/
entanglement.html.
Fig. 10.1 Figure reproduced from the QuVis website, licensed under creative commons CC-BY-
NC-SA.
Fig. 10.2 Figure reproduced from the QuVis website, licensed under creative commons CC-BY-
NC-SA.
5. Try sending pairs of particles in an entangled state √1 (|↑A |↓B − |↓A |↑B ).
2
What do Alice and Bob measure individually?
6. If Alice measures her spin, would you be able to predict Bob’s result:
(a) In the product state?
(b) In the entangled state?
7. Convert the product state |↑A |↓B into the x-basis and use it to explain the
observations in the x-basis. Recall that |↑ = √1 (|+ + |−) and |↓ =
2
√1 (|+ − |−).
2
8. Convert the entangled state √1 (|↑A |↓B − |↓A |↑B ) into the x-basis and use
2
it to explain the measurements in the x-basis.
9. Suppose that there are two possible sources of particles. Source #1
randomly emits two particles in either the state |↑A |↓B or |↓A |↑B
with equal probability. Source #2 emits two particles in the entangled state
√1 (|↑A |↓B − |↓A |↑B ). How can Alice and Bob tell whether the source is
2
#1 or #2?
10.2 Polarizer Demo 95
For students who have learned about polarization, the creation of superposition
states can be demonstrated using three polarizing filters. When unpolarized light
is sent through a vertical filter, only vertically polarized light is able to pass
through. Sending vertically polarized light through a horizontal filter results in no
light passing through, since the vertical and horizontal polarizations are mutually
exclusive. Surprisingly, adding a diagonal filter in between recovers the light!
The diagonal polarizer introduced a horizontally polarized component, similar to
how passing a spin-up electron through a horizontal SGA created a horizontal
superposition.
Question Relate the behavior of the polarizers to what you saw in the SGAs. Hint:
think of the top two polarizers in Fig. 10.3 as the z-basis, and diagonal polarizers as
the x-basis.
No light
Unpolarized
light
light
1. The X player goes first. We note that keeping indices helps to track the game. The
markers can be placed in any of the two spaces on the game board (Fig. 10.4).
2. The O player goes next. The markers can be placed in any two squares, even
ones that are already occupied by other X or O markers. Notice in Fig. 10.5 that
the index for the O player also starts with 1, representing its first move placing
markers in squares 1 and 6.
3. Player X goes again and can place their spooky markers at any two squares, even
ones occupied by other Xs or Os. The game goes on until the players create a
“cyclic loop” as seen in Fig. 10.6.
4. Collapsing the quantum state. When a loop is created, the players have to
collapse their state. There are three options for who makes the decision on how
7 8 9
2 Hoehn R, et al. (2014). “Using Quantum Games to teacher quantum mechanics, Part 1.” Journal
of Chemical Education 91 (3), 417–422. Retrieved from https://pubs.acs.org/doi/ipdf/10.1021/
ed400385k.
3 Einstein, Podolsky, and Rosen (1935) “Can quantum-mechanical description of physical reality
x1
o1 o1
x1
x2 o1 o1
x2 x1
o1 x1 x2 o1
Fig. 10.7 The two collapse outcomes due to player O’s decision.
the markers will be collapsed. The fair choice would be by the player who did
not create the cycle (in this case, player O). When the markers are forced to
collapse, only one of the two squares for each move can be chosen, so player O
can choose either square 4 or 6. Depending on their choice, the outcome would be
different (Fig. 10.7). Once the states are collapsed, the “spooky markers” change
into classical markers and they fully occupy the state of one particular square.
98 10 Worksheets
x2 o3 o1
x3 x5 o4
5. The next player can place his or her spooky markers in any two squares except
the ones that are occupied by the collapsed markers. The game goes on until
another cycle is created and the players are forced to collapse the state.
6. Winning the game. In some cases both players will create three in a row after
collapsing their spooky markers. In this case, the player with the smallest sum
of indexes wins. For example, in Fig. 10.8 player X wins because they have the
smaller sum.
Some Other Rules Can Be Added or Modified One of the requirements could
be that players cannot place both markers in the same square like the one shown
in Fig. 10.9. Another way to make the collapse more quantum (or more random) is
using a coin flip to decide which player chooses the collapse.
Other modifications may include assigning different point values for three in a
row, such as the winner with lowest sum of the indexes gets 1 point, while the other
player gets 1/2 point.
One of the main challenges of playing the game is to observe when a cycle has
been created so the state of the spooky markers can be collapsed at the right time.
10.3 Quantum Tic-Tac-Toe 99
A computer-simulated game will automatically keep track of this and will force
students to collapse their markers, such as this game simulator.4
We found that using color codes and connecting lines helps visually track loops.
Another way is to create a model of the game where students can see the connections
and collapse the states using physical pieces. It would be interesting to see students’
responses as to which medium helps them understand the game principle better.
How are the game rules and principles connected to the real applications of quantum
mechanics? There are three major themes that can be drawn from the game:
superposition, the effect of measurement, and entanglement.
Superposition
In classical physics all objects have defined states. However, quantum systems can
exist in a superposition of several classical states at the same time. The example
could be an electron with a spin that is in superposition of up and down, or a photon
in a superposition of vertical and horizontal polarization. QTTT spooky markers
exist in two separate locations on the game board, representing their state as a
superposition state of two classical TTT markers.
Measurement
When measuring the state of a quantum system, the quantum state of a system
collapses and only one classical state is observed with some probability. In QTTT,
the rule of creating the loop forces players to collapse their markers (measure their
quantum state). In this case the player decides how to collapse the markers, which
corresponds to the scientist choosing the way of measuring quantum system, such
as axis orientation. The rule of forcing the measurement when the loop is created
does not have an exact corresponding physical meaning. Quantum systems can exist
in a superposition state for an extended time, and the measurement is not forced, but
chosen by the observer.
Entanglement
Entanglement is the quantum phenomenon of creating two or more particles, whose
states cannot be described separately, but have some correlation even when they are
separated by a significant distance. When measuring the state of one of the entangled
particles, the state of the other particle can be known even without measurement.
Einstein called it “spooky action at a distance.” When the players collapse their
states after creating a loop in QTTT, they know for sure in which state each marker
would collapse into.
4 http://qttt.rohanp.xyz/.
100 10 Worksheets
Objectives
Design, build, and test quantum circuits that model systems in superposition and
entanglement.
Setup
Open the IBM Q simulator5 and start a new circuit in the Circuit Composer
(Fig. 10.10).
The default is 5-qubits initialized to the |0 state. Gates can be applied by
dragging and dropping them onto the appropriate qubit(s). Don’t forget to add the
measurement gate at the end to see the results. When you are satisfied with your
circuit, save the experiment and click Run (Fig. 10.11).
By default, the circuit will be evaluated 1024 times using the simulator backend.
You may also run the circuit on a real quantum computer, subject to a waiting period.
Increasing the number of shots will increase the statistical accuracy of the results at
the expense of run-time. After you have run the circuit, the results will appear in a
link at the bottom of the page.
Fig. 10.10 A new experiment on the IBM Q Circuit Composer. Reprint courtesy of International
Business Machines Corporation, ©International Business Machines Corporation.
5 https://quantum-computing.ibm.com.
10.4 Schrödinger’s Worm Using Five Qubits 101
Fig. 10.11 Options for running the IBM Q experiment. Reprint courtesy of International Business
Machines Corporation, ©International Business Machines Corporation.
Alive
Dead
Part I: Superposition
The worm is alive when all five squares are black and dead when only four are black.
Use a 0 to represent a white square and 1 to represent a black square (Fig. 10.12).
Alive
Very Dead
Further Resources
• The Qiskit webpage6 has resources for YouTube videos and other educational
links.
• IBM quantum offers a (virtual) summer school7 with minimal prerequisites
required.
6 https://qiskit.org/.
7 https://qiskit.org/events/summer-school/.
10.5 Superposition vs. Mixed States Lab 103
Objectives
• Experimentally determine the difference between particles in a superposition
state and a mixed state using the superposition states and mixed states simula-
tor.8
• Apply the idea of basis changing to explain the experimental results.
• Compute the probability amplitudes given measurement results.
Questions
1. We send 100 electrons of unknown spin into a Stern-Gerlach apparatus. We
measure that 50 are spin up and 50 are spin down. We can conclude that:
(a) 100 electrons were in a 50/50 superposition state of up and down (superpo-
sition state).
(b) The electrons were a classical mixture of 50 electrons spin up and 50 spin
down (mixed state).
(c) Not enough information
2. Use the simulator (Fig. 10.14) to compare the measurement outcomes of the
mixed particles vs. the superposition particles. What are the similarities and
differences?
3. By making a basis change with |0 = √1 |++ √1 |− and |1 = √1 |+− √1 |−,
2 2 2 2
can you explain the similarities and differences mathematically?
4. Which of the two inputs labelled “Superposition or mixture?” and “Superposition
or mixture??” is a random mixture and which is a superposition?
5. The mixture consists of a fraction A of spin up particles and a fraction B of spin
down particles. Find these fractions, A and B.
6. The superposition state can be written as α|0 + β|1. Find the amplitudes α and
β assuming they are real and positive.
7. Use a basis change to show that the amplitudes α and β give the correct
probabilities in both the x- and z- basis.
8 https://www.st-andrews.ac.uk/physics/quvis/simulations_html5/sims/superposition/
superposition-mixed-states.html.
104 10 Worksheets
Fig. 10.14 Figure reproduced from the QuVis website, licensed under creative commons CC-BY-
NC-SA.
10.6 Measurement Basis Lab 105
Objectives
• Use the PHET Stern-Gerlach Simulator9 to see how changing the orientation of
the Stern-Gerlach Apparatus (SGA) affects the spin measurement.
• Perform calculations to write the spin in a different measurement basis
(Fig. 10.15).
Fig. 10.15 Figure reproduced from the PHET Stern-Gerlach Simulator website, licensed under
creative commons CC-BY.
9 https://phet.colorado.edu/sims/stern-gerlach/stern-gerlach_en.html.
106 10 Worksheets
Questions
1. Send spin up electrons through a single SGA and record the measurement
probabilities for different SGA angles (see above table).
2. Generate a scatter plot of the data.
3. What function describes the shape of the graph?
4. Write the state of the spin up electron as a superposition for an arbitrary SGA
angle (θSGA ). In other words, find α and β in |electron = α|goes through +
β|blocked. The diagram below may help, but note that θ = θSGA .
Before parting ways, you and Bob agree on a key. Using a coin with heads = 0 and
tails = 1, randomly generate a key of the same length as the message. Make sure
that you and Bob have the same key.
• Shared Key:
• Encoding:
1. Choose a secret letter to send to Bob in binary using Table 10.1. Message:
2. Add the key to your message, bit by bit, to encode the message. In binary,
0 + 0 = 0, 0 + 1 = 1 + 0 = 1, and 1 + 1 = 0. For example, if the key = 0110
and the message = 1101, then the cipher text = 1011, as 0110+1101 = 1011.
– Cipher Text:
• Decoding
Cipher
from Bob
Shared
Key
2. Add the key to Bob’s message, bit by bit, to decode the message.
Decoded
message
• Eavesdropping
1. Swap cipher texts with another group. How could you recover the original
message?
2. How many different keys would you need to try?
3. If the original message had five letters instead of one letter, how many
different keys would you need to try?
4. You intercept a five letter message and, by chance, find a key that decrypts it
to read HELLO. What other words could it possibly be?
10.7 One-Time Pad 109
• Questions
1. Why does adding the key to the cipher recover the original message?
2. Why is the one-time pad theoretically unbreakable?
3. What is the practical security flaw in the one-time pad?
110 10 Worksheets
Before parting ways, you and Alice agree on a key. Using a coin with heads = 0 and
tails = 1, randomly generate a key of the same length as the message. Make sure
that you and Alice have the same key.
• Shared Key:
• Encoding:
2. Add the key to your message, bit by bit, to encode the message. In binary,
0 + 0 = 0, 0 + 1 = 1 + 0 = 1, and 1 + 1 = 0. For example, if the key = 0110
and the message = 1101, then the cipher text = 1011. 0110 + 1101 = 1011.
– Cipher Text:
10.7 One-Time Pad 111
• Decoding
Cipher
from
Alice
Shared
Key
112 10 Worksheets
2. Add the key to Alice’s message, bit by bit, to decode the message.
Decoded
message
• Eavesdropping
1. Swap cipher texts with another group. How could you recover the original
message?
2. How many different keys would you need to try?
3. If the original message had five letters instead of one letter, how many
different keys would you need to try?
4. You intercept a five-letter message and, by chance, find a key that decrypts it
to read HELLO. What other words could it possibly be?
• Questions
1. Why does adding the key to the cipher recover the original message?
2. Why is the one-time pad theoretically unbreakable?
3. What is the practical security flaw in the one-time pad?
10.8 BB84 Quantum Key Distribution 113
• No Eavesdropper
=0 = 1
= 0 = 1
4. Once you have filled up the chart, tell Bob the basis used for each bit. If Bob
tells you to “discard” the bit, cross it out on your chart.
5. Check to see that you and Bob end up with the same sifted key.
Basis: x
or z
Bit value:
0 or 1
114 10 Worksheets
• SIFTED KEY:
• With Eavesdropper
1. Repeat the procedure, but instead of passing the spin card directly to Bob, it
will first pass through Eve.
2. Compare the sifted key bits one at a time. How can you tell if Eve intercepted
the message?
• SIFTED KEY:
Basis: x
or z
Bit value:
0 or 1
10.8 BB84 Quantum Key Distribution 115
• No Eavesdropper
=0 = 1
= 0 = 1
3. Once you have filled up the chart, Alice will tell you the basis used for each
bit. If you measured in a different basis, tell Alice to “discard” the bit and
cross it out on your chart.
4. Check to see that you and Alice end up with the same sifted key.
Basis: x
or z
Bit value:
0 or 1
116 10 Worksheets
• SIFTED KEY:
• With Eavesdropper
1. Repeat the procedure, but instead of getting the spin card directly from Alice,
it will first pass through Eve.
2. Compare the sifted key bits one at a time. How can you tell if Eve intercepted
the message?
• SIFTED KEY:
Basis: x
or z
Bit value:
0 or 1
10.8 BB84 Quantum Key Distribution 117
• SIFTED KEY:
Basis: x
or z
Bit value:
0 or 1
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0
International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing,
adaptation, distribution and reproduction in any medium or format, as long as you give appropriate
credit to the original author(s) and the source, provide a link to the Creative Commons license and
indicate if changes were made.
The images or other third party material in this chapter are included in the chapter’s Creative
Commons license, unless indicated otherwise in a credit line to the material. If material is not
included in the chapter’s Creative Commons license and your intended use is not permitted by
statutory regulation or exceeds the permitted use, you will need to obtain permission directly from
the copyright holder.
Probability
A
A.1 Introduction
With the above knowledge, we can now calculate the probabilities for more
complicated scenarios. For example, by the end of this section, we will be able
to find the probabilities for a specific number of heads to occur after we flip 5 coins.
When combining the probability for a specific event with that for another event,
we can start by listing all the possible outcomes. For example, consider rolling a die
Fig. A.1 The chances of flipping a specific number of heads when there are a total of 10 coin flips
and flipping a coin; the possible outcomes are shown in Fig. A.2. The total number of
unique outcomes is 12, and all of the different outcomes occur exactly once. From
this, we can concluded that the probability of any one of the events listed above
1
is 12 . We can also find this result mathematically from the probability of rolling
a given number on a die, and separately the probability of getting heads or tails
when flipping a coin. To find the combined probability for a given number on the
dice (lets say a 4) and flipping a heads on a coin, we can multiply the two separate
probabilities together to obtain the probability for both to occur (i.e., 16 × 12 = 12
1
),
which is the same result we found from counting the different scenarios.
The total number of combinations for the outcomes of two independent events is
the product of the number of outcomes for each event individually. An independent
event is one in which the outcome is not changed by the outcome of another event.
For example, each flip of a coin is an independent event. Whether the coin lands on
heads or tails does not depend on whether it previously landed on heads or tails in
the past flips. To understand if an event is not independent, consider a bag of six
blue and six red marbles. If we remove one marble from the bag at random, and do
not replace it, the next marble that is removed is no longer independent from the
previous action. The probability for a blue marble to be removed in the second draw
depends on whether the first marble was blue or red.
When combining two or more independent events, the total number of outcomes
is simply the product of the probabilities of each individual event. This means, that
if we roll 2 dice, we have 36 possible outcomes, and if we roll 3 dice, we have
216 possible outcomes, etc. The probability for each of the outcomes to occur in
A.2 Combining Probabilities 121
H H H H H H
T T T T T T
Fig. A.2 All twelve possible outcomes when both rolling a die and flipping a coin
Fig. A.3 All possible outcomes of rolling two dice. One die is colored white and the other red to
help distinguish the possible combinations for each die
this case is also the product of the probability for each individual outcome to occur.
For example given a red, green, and white die, the probability of rolling a 2 on the
red die, a 6 on the green die, and a 1 on the white die is simply the product of the
1
probability for each individual die, or in this case 216 .
However, this is not the same when the two events are made to be dependent on
each other. Take the situation when we want to find the probability that the sum of
two dice adds up to a specific number. All possible outcomes of rolling two dice
are shown in Fig. A.3. Here we see that there are at least two ways for the dice to
come out so that result in the same number, with the exception of 2 and 12. When
we count up the total number of unique sums of the two dice, we get the numbers 2
through 12. The count of the ways each sum can occur is given in Table A.1. In this
case, the total number of outcomes is still the product of the number of outcomes
for each die, but the probability is not the product of the individual probabilities.
• The number of outcomes for a set of independent events is the product of the
number of outcomes for each event.
• The probability for a unique event from independent events is the product of the
probability for each independent event
• When considering dependent events, the probability can be calculated by divid-
ing the number of events of interest by the total number of outcomes.
1. Given two dice, what is the probability that when rolled they
(a) have different numbers?
(b) sum to a number greater than 8? sum to a number less than 8?
(c) are both an even number? both an odd number? one even and one odd?
2. Write out all possible outcomes of flipping 5 coins. Calculate the probability for
0, 1, 2, 3, 4, and 5 heads to come out. Plot these probabilities as a histogram.
3. Given a deck of cards, and a die. Calculate the total number of outcomes.
Calculate the probabilities for
(a) Drawing a red card and rolling an even number.
(b) Drawing a face card and rolling a one.
(c) Drawing the ace of spades and rolling 4 or higher.
A.4 Mean, Median, and Mode 123
A.3 Histograms
There are many different ways to represent the data collected from a series of events.
First, one can represent data as a frequency table. A frequency table contains two
columns, where the first column is the possible categories that the event can fall into,
and the second column is the number of times that event has occurred. It is possible
to represent a frequency table as a plot by having the x-axis represent the different
categories, and the y-axis representing the frequency of those events. This graphical
representation of the frequency table is known as a histogram.
To make these concepts more concrete, consider the following example. After
flipping five coins, we count the number of heads and find that we have three heads.
Now we repeat this trail 29 more times, and at the end we have the following counts
for the number of heads for the 30 trials:
3, 4, 2, 1, 1, 1, 4, 1, 4, 3,
2, 3, 2, 2, 3, 2, 2, 1, 3, 3,
2, 3, 4, 4, 3, 2, 1, 3, 3, 2.
Fig. A.4 Histogram for the number of heads from 30 sets of 5 coin flips
The second method is known as the median. The median of a set of events is the
middle number when the events are ordered from the smallest value to the largest
value. If there happen to be two numbers in the middle, the median is the average of
those two values.
The last method is known as the mode. The mode is simply the result in a set of
events that occurs the most often.
To help make these definitions more clear, let us consider an example. A teacher
gave a test to a class of 15 students, and the scores that the students achieved were
78, 100, 81, 89, 91, 88, 93, 99, 85, 75, 95, 94, 84, 81, and 87. First, we will calculate
the mean (which is often represented by the symbol μ). Recall, the mean is found
by taking the sum of the scores and dividing by the number of scores. The mean for
these scores is:
78+100+81+89+91+88+93+99+85+75+95+94+84+81+87
μ=
15
1320
= (A.1)
15
= 88 .
The mean or average score for this test is 88. Now, to calculate the median, we first
sort the data from smallest to largest, and then find the value in the middle. In the
example it is given by
A.4 Mean, Median, and Mode 125
75, 78, 81, 81, 84, 85, 87, 88 , 89, 91, 93, 94, 95, 99, 100 (A.2)
⏐
7 numbers ⏐ 7 numbers
⏐
⏐
median
Therefore, the median is also given by the number 88. Finally, the mode is the
number that occurs the most often. Table A.3 shows the counts for each of the
different test scores, and from that we can see that the mode is the score 81.
Putting together the results for these tests, we find that both the mean score and
the median score are 88 and the mode score was 81. These calculations can be
extended to arbitrarily large data sets, and the techniques discussed above will still
work to calculate the mean, median, and mode. In our example above, the mean
and median turn out to be the exact same number. However, this is not always the
case. When these two numbers are far away from each other, it could indicate that
there is an outlier in the data set. An outlier is a point in the data set that drastically
differs from the rest of the data. An example of an outlier would be to consider the
test scores again. If we were to add in a test score of 5, this would be considered an
outlier. Consider the impact this outlier would have on the mean, median, and mode.
The mean would now be 82.8 instead of 88, while the median would be 87.5 and the
mode would still be 81. From this, we can see that by combining the mean, median,
and mode we learn more information about the data than by any one individual
measure.
For all of the problems below, consider the 30 test scores found in Table A.4.
2. What happens to the mean, median, and mode if 5 new test scores are added with
the values of: 6, 12, 20, 14, and 5
(xi − μ)2 = 100, 144, 49, 1, 9, 0, 25, 121, 9, 169, 49, 36, 16, 49, 1
(xi − μ)2 = 778
778
σ2 = = 51.9 (A.4)
15
σ = σ 2 = 7.2
A.5 Variance and Standard Deviation 127
The standard deviation is 7.2, and this means that most of the scores are within 7.2
points of 88.
For all the problems below, again consider the 30 test scores found in Table A.4.
B.1 Introduction
Linear algebra is the field of mathematics underlying the topics of vectors and
matrices. It is the backbone of mathematics used for solving systems of linear
equations. You may be familiar with static physics problems, whose solution utilize
linear algebra. An example of a set of linear equations is
x1 + 4x2 + 3x3 = −7
5x1 + 2x2 = 11 (B.1)
9x2 − 8x3 = 0
This appendix supplies a basic introduction to some key aspects of the field of linear
algebra. We will cover the topics of scalars, vectors, and matrices.
B.2.1 Scalars
a + bi, with both a and b as real numbers. Addition and subtraction of complex
numbers is straightforward, we simply add or subtract the real components from
each other and add or subtract the imaginary components from each other. Some
examples are:
(3 + 4i) + (5 + 3i) = 8 + 7i
(3 + 4i) − (1 + 3i) = 2 + i
(3 + i) + (1 − 3i) = 4 − 2i
(9 − 6i) − (4 + i) = 5 − 7i
On the other hand, multiplication and division are slightly more complicated.
When performing multiplication and division, it is helpful to know the powers of i:
x × y = (a + bi) × (c + di) = (ac + adi + bci + bdi 2 ) = (ac − bd) + (ad + bc)i.
(B.3)
Before covering division, let us introduce the idea of a complex conjugate.
A complex conjugate is the complex number where the real component is the
same, but the imaginary component has the opposite sign. The complex conjugate
is denoted with an ∗ symbol. For example, the complex conjugate of a + bi is
a − bi. When multiplying a complex number by its complex conjugate we get a
real number, and refer to it as the magnitude squared of a complex number and is
represented by |x|2 , i.e. |a + bi|2 = (a + bi) × (a + bi)∗ = a 2 + b2 .
In order to divide two complex numbers, first you multiply the numerator
and denominator by the complex conjugate of the denominator and then perform
multiplication of complex numbers, e.g.,
B.2.2 Vectors
A vector is a mathematical object that is defined to have both size and direction.
One can imagine a vector as a directed line segment as seen in Fig. B.1. The size
or magnitude of a vector is the length of the line segment. The tail of a vector is
the starting point, and the head of a vector is the ending point. The direction of a
B.2 Scalars, Vectors, and Matrices 131
e
i t ud
g n
Tail Ma
Fig. B.2 Depiction of a 5 y
vector on a coordinate system
in 2 dimensions 4 a = (2, 4)
3
2
1
x
−5 −4 −3 −2 −1
−1 1 2 3 4 5
−2
−3
−4
−5
vector is from the tail to the head. Two vectors are considered equal to each other
when they both have the same magnitude and the same direction.
Some common vectors that you may be familiar with are force, velocity, and
acceleration. For example, a car’s velocity is the speed the car is going combined
with the direction the car is driving in. Typically, vectors are denoted by either a or
a, and the magnitude of a vector is denoted by | a |. The magnitude is a scalar value
(see Sect. B.2.1 for details). Additionally, we can describe a vector by imagining
a coordinate system, where the origin is located at the tail of the vector (in two
dimensions this would correspond to the point (0, 0)), and the head of the vector
would be its coordinate (e.g., (x, y) in two dimensions). For example, given a as a
two dimensional vector as shown in Fig. B.2, we can define the vector as a = (2, 4).
The magnitude of a vector can be calculated by using the distance formula
between two points. Recall that the distance formula between the origin of a
coordinate system in two dimensions is given by
d= x2 + y2. (B.5)
The formula for the distance from the origin of a vector to its endpoint can be
generalized to higher dimensions in a straightforward manner. For example, given a
ten dimensional vector a = (x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9 , x10 ), the magnitude is
132 B Linear Algebra
given by
|
a| = x12 + x22 + x32 + x42 + x52 + x62 + x72 + x82 + x92 + x10
2 . (B.6)
• Vector addition is commutative, or in words the order does not matter (i.e.
a + b = b + a ). This is often referred to as the parallelogram law, and can
be pictorially shown to be true in Fig. B.4.
• Vector addition is associative, or in words when summing three vectors it does
+ c = a + (b + c)).
a + b)
not matter which pair is added together first (i.e. (
b
a +
Fig. B.4 The parallelogram b
law
a + b
a
b + a
a
b
B.2 Scalars, Vectors, and Matrices 133
Subtraction of two vectors works in the same way as addition, but instead of
adding the components, we subtract them. This can also be thought of taking a
vector a , and flipping the direction of the vector. This will change a = (x, y)
to − a = (−x, −y). All of the rules for addition described above also apply to
subtraction.
If we have a vector and a scalar, the only thing we can do is to multiply the
two together. When multiplying a vector and a scalar, we simply multiply every
component of the vector by the scalar. For example, given the three dimensional
vector a = (4, 6, 2) and the scalar s = 5, then b = s × a = (20, 30, 10). It is
important to notice here that the result b is also a vector. The direction of the vector
b is unchanged if s > 0, but is in the opposite direction if s < 0. The magnitude of
the vector b is scaled by the value of the scalar, and thus it is stretched if |s| > 1 and
compressed if |s| < 1.
Finally, we have the multiplication of two vectors. There are actually two
different ways that we can multiply vectors together. The first way is known as
the dot product. The dot product takes two vectors, and multiplies them together to
produce a scalar. We denote the dot product of two vectors by a · b. The dot product
is calculated by taking the product of all the components of the vector, and summing
them up. In other words, given the vector a = (xa , ya ) and the vector b = (xb , yb ),
the dot product is given as: a · b = xa × xb + ya × yb . While this example is in two
dimensions, the dot product can be extended to an arbitrary number of dimensions.
We can also think about the dot product geometrically. Let us take two vectors
with the magnitude of b larger than that of a . We can then relate the dot
a and b,
or what portion of a is pointing
product to the projection of a onto the direction of b,
in the direction of b. The projection can be thought of as imagining what the shadow
of a would look like when cast by a light source perpendicular to b (see Fig. B.5). In
other words, the dot product can be represented by multiplying the magnitudes of the
two vectors, and taking the cosine of the angle between them ( a · b = | cos θ ).
a ||b|
Below are some properties that are related to dot products, where a , b, and c are
vectors, and s is a scalar:
• a · b = b · a
• (a + b) · c = a · c + b · c
• (s a ) · b = s(
a · b)
The other method of multiplying two vectors is known as the cross product. The
Note that the notation for the cross product looks
cross product is written as a × b.
the same as multiplication. However, multiplication operates on scalars while the
cross products acts on vectors. The cross product takes two vectors, and produces a
third vector that is perpendicular to the other two. From this definition, it can easily
be seen that this will not work for two dimensional vectors, so we will focus on
three dimensions for this discussion. The magnitude of the resulting vector from the
cross product is equal to the area of the parallelogram formed by the vectors (i.e.
| = |
a × b| sin θ and as shown in Fig. B.6).
a ||b|
134 B Linear Algebra
The direction of the resulting vector from a cross product can be determined by
the right-hand rule. To use the right-hand rule given the cross product c = a × b,
first point the fingers of the right hand in the direction of a , and curl them towards
The direction the thumb points is the direction of c. Using the right-hand rule,
b.
we can make an observation that a × b = −b × a . From this, we can also see that
a × a = −a × a , which is only possible if the result is the 0 vector (i.e. c = (0, 0, 0)).
Given the vectors a = (x1 , y1 , z1 ) and b = (x2 , y2 , z2 ), the cross product can be
calculated using:
c = a × b = (y1 z2 − y2 z1 , x2 z1 − x1 z2 , x1 y2 − x2 y1 ). (B.7)
B.2.3 Matrices
then
⎛ ⎞ ⎛ ⎞
9 + (−4) 5+7 −6 + (−5) 5 12 −11
A + B = ⎝1 + (−9) −10 + (−9) −8 + 5 ⎠ = ⎝−8 −19 −3 ⎠ , (B.10)
1+9 5 + (−1) −3 + 8 10 4 5
and
⎛ ⎞ ⎛ ⎞
9 − (−4) 5−7 −6 − (−5) 13 −2 −1
A − B = ⎝1 − (−9) −10 − (−9) −8 − 5 ⎠ = ⎝ 10 −1 −13⎠ . (B.11)
1−9 5 − (−1) −3 − 8 −8 6 −11
then
B × A = (3 × 2) + (5 × 9) = (51). (B.14)
n
ci,j = ai,k × bk,j , (B.15)
k=1
where the nk=1 symbol means we sum all indices k from 1 to n. As an example,
let us calculate A × B = C and B × A = D for the 2 × 2 matrices given by
32 26
A= , B= . (B.16)
56 87
First, let us calculate the matrix C by treating the ith row of A and the j th column
of B as if they were vectors as done above:
2
c1,1 = 3 2 = (3 × 2 + 2 × 8) = 22
8
6
c1,2 = 3 2 = (3 × 6 + 2 × 7) = 32
7
2
c2,1 = 5 6 = (5 × 2 + 6 × 8) = 58
8
6
c2,2 = 5 6 = (5 × 6 + 6 × 7) = 72
7
B.2 Scalars, Vectors, and Matrices 137
Taken together,
22 32
C= . (B.17)
58 72
Now, by following similar steps we can calculate B × A by taking the ith row of
B and the j th column of A to produce
3
d1,1 = 26 = (2 × 3 + 6 × 5) = 36
5
2
d1,2 = 26 = (2 × 2 + 6 × 6) = 40
6
3
d2,1 = 87 = (8 × 3 + 7 × 5) = 59
5
2
d2,2 = 87 = (8 × 2 + 7 × 6) = 58
6
Transposition
There also exists operations on a single matrix. For this textbook, the only one that
is important to cover is matrix transposition. The operation of the matrix transpose
simply turns the rows into columns and the columns into rows. Mathematically, the
transpose is represented by AT and can be represented using the index notation for
a matrix A as
Chapter 1 Solutions
Chapter 2 Solutions
1. With the 8-bit representation, this would require eight coins arranged as TTTTT-
THT.
3. (a) 9/10 or 90%. The probability is the square of the amplitude.
(b) No, 1/9 + 4/9 = 1. Normalization means the total probabilities add up to 1.
(c) 75 coins.
(d) Measurement collapses the superposition onto either |H or |T .
5. (a) All of them are possible as they all can produce |0 after measurement.
(b) After measurement, the state in the question is in |0, since the superposition
collapsed. Since it is in the |0 state after measurement, if you try to measure
the same state again you will always measure |0. No new information is
provided about the state after the collapse to |0.
(c) If |0 is measured from the unknown state, and a second identical state is
prepared and is measured in the |1 state, then you know the unknown state
contains some nonzero superposition of both |0 and |1, e.g., it is |ψ =
α|0 + β|1 with α = 0 and β = 0. So you can rule out |ψ = |0 as
the initial state, but all of the other three states given in (a) are still possible.
11. Take |ψ = |0. The probability of measuring |ψ in the |0 state is 100%, and
the probability of measuring |ψ in the |1 state is 0%. Here the probabilities add
up to 100%. Now take any random non-unitary matrix, for example,
01
N= . (2)
00
This new state after non-unitary evolution has 0% probability of being in the |0
state, and 0% probability of being in the |1 state. The total probability does not
add up to 100%.
Chapter 3 Solutions
1. All parts of the statement are false. The particle is in both states the entire time
before measurement and has a 50% chance of being measured as 0 or 1.
3. a. The coincidence counts are low when the detectors are an equal distance from
the beam splitter. This points to light behaving like a particle entering only
one detector at a time.
b. Photons from different 0.4 μs bursts can arrive at the detectors simultaneously.
5. A 30/70 superposition state would take the form:
3 7
|0 + |1. (4)
10 10
⎛ ⎞ ⎛ ⎞
3
0 1 3
M = ⎝ 10 ⎠ ⇒ M = ⎝ 10 ⎠ (5)
1 7
1 7
10 10
would give the correct probabilities, but it is not unitary. And all quantum
matrices must be unitary. Using the 50/50 beamsplitter as a reference, the unitary
30/70 beam splitter matrix is
⎛ ⎞
7 3
M= ⎝ 10 10 ⎠ . (6)
− 103 7
10
Chapter 4 Solutions
1. Z
X
3. (a) cos(π/6)|0 + sin(π/6)|1
(b) α 2 = cos2 (π/6) = 0.75
(c) sin(π/6 + π/4)|+ + cos(π/6 + π/4)|−
(d) cos2 (π/6 + π/4) ≈ 0.067
5. 100% +z
7. 50% up, 50% down
9. 50% + x, 50% − x
Chapter 5 Solutions
1. Their basis will match approximately half of the time, so their key will be
approximately 500,000 bits long. The number of matching bits will not be exactly
500,000 due to the probabilistic nature of measuring up and down randomly
in a finite sample size, i.e., think of flipping a coin. However, the margin of
error at the 95% confidence interval is ≈ 0.03%, meaning that with one million
measurements of qubits in a 50-50 superposition, we would expect the margin of
error to be 300 bits.
3. (1/2)20 ≈ 10−6 .
5. If Alice and Bob both use the z-basis, the different cases are:
(a) Alice sends +z, Eve measures in z, Bob measures +z.
142 Answers to Odds
Chapter 6 Solutions
1. (a)
01 1 0
X|0 = = = |1. (7)
10 0 1
(b)
01 α β
X|ψ = = = β|0 + α|1. (8)
10 β α
(b)
1 1 1 1 0
H H |1 = = = |1. (10)
2 1 −1 −1 1
Answers to Odds 143
(c)
1 1 1 1 1 α α
H H |ψ = = . (11)
2 1 −1 1 −1 β β
9.
1 1 0 1 1 1
Z|+ = √ =√ = |−. (12)
2 0 −1 1 2 −1
11. (a) The Z gate does not affect the |0 state.
(b) The sign on the |1 state is changed, but this does not affect probabilities and
so cannot be seen in the histogram.
(c) The |+ is changed to a |−, which shows up as 50% |0 and |1.
(d) The |− is changed to a |+, which shows up as 50% |0 and |1.
13.
1 1 1 1 1 1 20 10
H H =
†
= = . (13)
2 1 −1 1 −1 2 0 2 01
Chapter 7 Solutions
We get this by taking the coefficient of the |00 term and then squaring it.
(b) The probability of measuring the first qubit as 1, Prob(first qubit |1), is the
sum of all outcomes which have the first qubit in the |1 state. In this example,
this is Prob(first qubit |1) = Prob(|10) + Prob(|11), which is equal to
2
1 1 2 1
+ − = . (15)
2 2 2
144 Answers to Odds
(c) The probability of measuring the second qubit as 0, Prob(second qubit |0),
is the sum of all outcomes which have the second qubit in the |0 state. In this
example, this is Prob(second qubit |0) = Prob(|00) + Prob(|10), which is
equal to
1 1 3
+ = . (16)
2 4 4
(d) After measuring the first qubit as√0, then we know that the only part of |ψ
that has the first qubit as 0 is (1/ 2)|00. However, we need to renormalize
the state to make sure it has a probability of one. So the new state of the
system after the measuring the first qubit as 0 is |ψ = |00.
(e) After measuring the first qubit as 1, then we know that the only parts of
|ψ that have the first qubit as 1 are (1/2)|10 − (1/2)|11. However, we
need to renormalize the state to make sure it has a probability of one. So
the new state of the system after the measuring the first qubit as 1 is |ψ =
√1 |10 − √1 |11.
2 2
3. Not entangled. Knowing that the first qubit is 0 does not narrow down whether
the second qubit is 0 or 1. Qubit 1 is |0 and Qubit 2 is √1 (|0 + |1). The
2
combination of the two qubits to form a multi-qubit state gives the state in the
question.
5. (a) |00
(b) |11
(c) |01
(d) √1 |11 + √1 |10
2 2
(e) √1 |00 + 12 |10 − 12 |01
2
7. Note which qubit is the control qubit in IBM convention.
(a) |01
(b) |10
(c) |11
(d) |01
9. (a) The states change from the start to the end after every gate as: |00 →
|01 → |11 → |10.
(b) |00 → |0( √1 |0 + √1 |1) → √1 (|00 + |11) → √1 |0( √1 |0 + √1 |1)
2 2 2 2 2 2
+ √1 |1( √1 |0 − √1 |1) = 12 (|00 + |01 + |10 − |11).
2 2 2
11. No. Alice measures a random value. This automatically changes Bob’s state.
However, Alice would need to send a classical message to Bob to find out which
state Bob measured; therefore information is still bounded by the classical speed
of light. This scenario is consistent with Bell’s theorem.
Answers to Odds 145
Chapter 8 Solutions
1. No, the qubits stay in place. Teleportation only changes the state of an existing
qubit.
3. Once it is measured after the Hadamard gate.
5. The X gate flips the |0 into |1 and |1 into |0.
7. The X gate changes the state into a|0 − b|1 and the Z gate flips the sign on the
|1 to produce the desired state.
Chapter 9 Solutions
1. (a) Both the classical and quantum computer can represent 28 = 256 classical
pieces of information.
(b) Both the classical and quantum computer can represent 28 = 256 classical
pieces of information.
(c) The quantum computer can create a superposition of up to 256 possibilities
and do a computation on all of them. However, a measurement will be only
one classical value.
3. (a) Detector 1 only
(b) Detector 2 only
(c) Only one photon is needed.
5. (a) The most naive classical algorithm is one where you evaluate every function
value and make a list of the results. In this case there are 23 = 8 different
function values that would need to be evaluated separately. If each element
in the list is identical then the function is constant.
(b) Since there are results other than |000 and |111, the function is not constant
(Fig. 1).
Histogram
28 26.4655
26 24.512% 24.805% 24.219%
24
22
20
Probability(%)
18
16
14
12
10
8
6
4
2
0
00001 00011 00101 00111
State
Chapter 10 Solutions
10.1
All four possible states are observed. The middle two terms do not cancel out
because they are different states: Alice measures + and Bob measures −, or
Alice measures − and Bob measures +.
9. They cannot tell them apart in the z-basis, but they could measure the particles
in the x-basis. If Alice and Bob always get opposite results, the source emits
entangled particles. If there is no correlation, the particles are not entangled.
10.4
1. |11111
3. There are two ways to make the superposition: start with an alive worm (left) or
start with a dead worm (right) (Fig. 2).
5. All quantum gates are reversible. Since a Hadamard gate made the superposition,
its conjugate transpose can undo this. The Hadamard is its own conjugate
transpose, so applying a second will undo the superposition.
7. |11010
Answers to Odds 147
10.5
10.6
Appendix A Solutions
A.2
5
1. (a) 6, first die can be any number, second die can be any number but what the
first die lands on.
Sum to greater than 8: 10 36 = 18
5
(b)
Sum to less than 8: 21 36 = 12
7
Both odd: 36 9
= 14
One even, one odd: 18 36 = 2
1
2 × 3 = 6
1 1 1
3. (a)
52 × 6 = 39
(Face cards: Jack, Queen, King, Ace) 16 1 2
(b)
52 × 6 = 104
1 3 1
(c)
A.4
1. Mean = 76.233
Median = 73.5
Mode = 72
A.5
1. Variance = 140.25
Standard deviation = 11.843
Appendix B Solutions
1. 1 × (−3)
+ 4 × 2 + 3 × 5 = 18
i 0
3.
0 −i
Index
A I
Algorithm, 81 IBMQ, 66
Amplitudes, 8 Interference, 85
B L
BB84, 43 Logic gate, 49
Beam splitter, 17
Bell state, 59, 75
Bloch sphere, 11 M
Bra-Ket notation, 7 Mach-Zehnder interferometer, 21
Matrix representation, 10
Measurement, 4, 9, 35, 50
C Measurement basis, 31
Classical superposition, 2 Measurement collapse, 52
CNOT gate, 65, 75 Measurement error, 51
Cryptography, 42 Memory, 83
Modular arithmetic, 88
Multi-qubit state, 61, 75
D
Decoherence, 91
Deutsch-Jozsa algorithm, 84 N
No-cloning theorem, 36, 52, 78
Noise, 51, 90
E Normalization, 8
Eavesdropper, 45 NOT gate, 50
Electron, 29
Encryption, 41
Entanglement, 59 O
Error correction, 73 Orthogonal, 33
G P
Grover’s algorithm, 81 Parallelism, 67, 81
Photon, 18
Product state, 63
H
Hadamard gate, 52, 76
Hidden variable theory, 61 Q
Histogram, 52 Quantized, 2
U
R
Unitary, 10, 55, 73
RSA encryption, 42
W
S Wave-particle duality, 18
Schrödinger’s cat, 4, 12
Shor’s algorithm, 43
Spin, 29 Z
State, 3 Z gate, 55