Fundamentals of Quantum Computing (2021) (9783030636890) (2021)
Fundamentals of Quantum Computing (2021) (9783030636890) (2021)
Fundamentals
of Quantum
Computing
Theory and Practice
Fundamentals of Quantum Computing
Venkateswaran Kasirajan
Fundamentals of Quantum
Computing
Theory and Practice
Venkateswaran Kasirajan
Trimble, Inc.
Superior, CO, USA
# The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2021
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on
microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer
software, or by similar or dissimilar methodology now known or hereafter developed.
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
This book is dedicated to my parents Meenalosani and Kasirajan.
Acknowledgments
The Ph.D. thesis of Laurens Willems starts with the quote from Sir Isaac Newton, “If I have
seen further than others, it is by standing upon the shoulders of giants.” How true indeed!
I was quite humbled by those noble words. The ninth-century Tamil epic Cı̄vaka Cintāmaṇi
compares the posture of the learned with the bowing stalk of a mature rice plant,
“ .” Education should never make one haughty. So, the
second-century BCE Tamil poet Avvaiyar warns, “ , ,” meaning –
what one has learned is equivalent to a handful of sand, and what one is yet to learn is as big as the
world. Even if one has gained only a handful of knowledge, as Thiruvalluvar said,
“ ,” the learned will long (for more learning) when
they see that while it gives pleasure to themselves, the world also derives pleasure from it.
Whenever I doubted whether I would finish this work or not, the wisdom of the sages kept telling
me that I am on the right path. Getting back to the roots, to the things lying at the bottom of my heart,
was soul-fulfilling and enchanting. I felt as though I was given a new life.
I have probably read hundreds of books. However, I never knew what it takes to write one. That
too on a heavy topic such as quantum computing. What was originally thought of as a 200-page
edition in four or five chapters kept expanding, and I had to stop at some point. It came at the expense
of family time, and I must thank my family for understanding and support. Without them, this would
not be possible. While working at my desk, my daughter Mehala would often stop by to look at which
chapter I’m working on. She then would shrug her shoulders, saying, “hmm, still in Chap. 4?” and
walk away disappointed as I’m not making significant progress. My wife Vanadurga saw me only at
dinnertime. My son Aparajithan reviewed the book despite his busy schedule, identified errors, and
pointed out several improvements. His summa cum laude skills readily helped. So, what started as a
single man’s effort, became a family affair at the end!
There is a famous saying that reminds us not to forget where we came from. I firmly believe that in
life, no one can succeed alone. Successful people are mentored and helped all along the way.
Forgetting those who contributed to one’s success is like kicking the ladder after climbing up, rather
than sending the elevator down. I think there will be no better opportunity than this to thank those who
helped, influenced, and changed my life. Among those are four personalities I should never forget and
be thankful forever – Prof. Parangiri, Mr. Ramprakash, Mr. S. Selvaraj, and Shankar Narayanan. I
hope all of them will be delighted to see this publication.
None of this in my life could have been possible without the generous hearts of my parents and the
countless sacrifices they made. Words of gratitude or remembrance are insufficient in expression.
Mother and father, I am sure you will be proud of this work, and this book is dedicated to your
memories.
vii
viii Acknowledgments
I am also grateful to all my undergraduate and graduate teachers – Prof. KRB, Prof. Sankaran,
Prof. Raman, Prof. Alwan, Prof. Krishnamoorthy, Prof. Sivakumar, Prof. Raju, Prof. TND, Prof.
Natarajan, and Prof. Edison – your courses on core physics subjects are still echoing and fresh in my
memory as if the lectures given were today.
I am grateful to my management at the office of the Digital Transformation and Horizontal
Engineering at Trimble Inc. for giving me space, recognition, and support. My thanks are due to
Joy Day and Ulrich Vollath for the time they spent reviewing this book. I also thank Kirk Waiblinger
for reviewing the book and pointing out several corrections. I thank my team members – the Trimble
Spime team – for their continued journey with me and their confidence. You are my best! I would also
like to thank the editorial and production teams at Springer for their excellent work on this book.
My special thanks go to Dr. Laurens Willems for reviewing this book, despite his tight schedule.
In Tim McGraw’s words, “When the work put in is realized, one can feel the pride, but must
always be humble and kind.” I hope this book helps software developers and undergraduate students
learn this subject in some small ways. May I remind my readers to study the references cited at the end
of each chapter and enhance their knowledge.
Venkateswaran Kasirajan,
Superior, Colorado.
September 2020.
1. The author acknowledges the use of the IBM Q for this work. The views expressed are those of
the author and do not reflect the official policy or position of IBM or the IBM Q team.
2. 15-qubit backend: IBM Q team, “ibmq_16_melbourne backend specification V2.0.6,” (2018).
Retrieved from https://quantum-computing.ibm.com
3. 32-qubit simulator: IBM Q team, “ibmq_qasm_simulator simulator specification v0.1.547,”
(2019). Retrieved from https://quantum-computing.ibm.com
4. 5-qubit backend: IBM Q team, “ibmq_london backend specification V1.1.0,” (2019). Retrieved
from https://quantum-computing.ibm.com
5. Qiskit: An opensource framework for quantum computing, 2019, H’ector Abraham et al., https://
doi.org/10.5281/zenodo.2562110
6. Qiskit/openqasm is released under Apache License 2.0 https://github.com/Qiskit/openqasm/blob/
master/LICENSE
7. qiskit-terra/Quantum is released under Apache License 2.0 https://github.com/Qiskit/qiskit-terra/
blob/master/LICENSE.txt
8. Microsoft Quantum Development Kit, License Terms. https://marketplace.visualstudio.com/
items/quantum.DevKit/license
9. Microsoft Quantum, released under MIT license https://github.com/microsoft/Quantum/blob/
master/LICENSE.txt
10. The author of this book acknowledges the research & work of the pioneers in quantum comput-
ing, upon their work this book is based. References to the publications from many of these
scholars are provided at the end of each chapter. Readers are requested to refer to them for more
information on this subject.
Contents
Part I Foundations
1 Foundations of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1 States of Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Atoms, Elementary Particles, and Molecules . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.1 Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 The Periodic Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.3 Bohr’s Model of the Atom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.4 Elementary Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.5 Molecules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3 Light and Quantization of Energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.1 Blackbody Radiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.2 Photoelectric Effect and the Concept of Photons . . . . . . . . . . . . . . . . . . 13
1.3.3 What Happens When Light Hits an Atom? . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Electron Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.1 Pauli’s Exclusion Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.2 Principal Quantum Number n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4.3 Orbital Angular Momentum Quantum Number l . . . . . . . . . . . . . . . . . . 16
1.5 Wave-Particle Duality and Probabilistic Nature . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.5.1 Maxwell’s Electromagnetic Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.5.2 De Broglie Waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5.3 Young’s Double-Slit Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.6 Wavefunctions and Probability Amplitudes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.6.1 Realism in Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.6.2 What Happens When We Measure a Quantum System? . . . . . . . . . . . . . 25
1.6.3 Heisenberg’s Uncertainty Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.6.4 Weak Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.7 Some Exotic States of Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.7.1 Quasiparticles and Collective Excitations . . . . . . . . . . . . . . . . . . . . . . . 27
1.7.2 Phonons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.7.3 Cooper Pairs (or the BCS Pairs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.7.4 Superconductors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.7.5 s-Wave, d-Wave, and p-Wave Superconductors . . . . . . . . . . . . . . . . . . . 31
ix
x Contents
1.7.6 Anyons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
1.7.7 Majorana Fermions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
1.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Practice Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2 Dirac’s Bra-ket Notation and Hermitian Operators . . . . . . . . . . . . . . . . . . . . . 35
2.1 Scalars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2.1 Complex Conjugate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.2.2 Norm of a Complex Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.3 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.3.1 Magnitude of Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.3.2 Unit Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.3.3 Addition and Subtraction of Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.3.4 Multiplication of Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.4 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.4.1 Properties of Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.4.2 Permutation Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.4.3 Hermitian Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.4.4 Unitary Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.4.5 Pauli Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5 Linear Vector Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5.1 Linear Independence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.5.2 The Dimensionality of the Vector Space . . . . . . . . . . . . . . . . . . . . . . . . 48
2.5.3 Inner Product or the Scalar Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.6 Using Dirac’s Bra-ket Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.6.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.6.2 Properties of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.6.3 Linear Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2.6.4 Hermitian Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.6.5 Outer Product or the Projection Operators . . . . . . . . . . . . . . . . . . . . . . . 59
2.7 Expectation Values and Variances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2.8 Eigenstates, Eigenvalues, and Eigenfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.9 Characteristic Polynomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.10 Definite Symmetric Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.10.1 Positive Semidefinite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.10.2 Negative Semidefinite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.11 Tensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.11.1 Direct Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.11.2 Tensor Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.12 Statistics and Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.12.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.12.2 Measures of Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.12.3 Measures of Dispersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.12.4 Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.12.5 Permutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
2.12.6 Combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Contents xi
2.13 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Practice Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3 The Quantum Superposition Principle and Bloch Sphere
Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.1 Euclidian Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.2 Metric Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.2.1 Completeness and Cauchy Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.3 Hilbert Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.4 Schr€odinger Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.4.1 Schr€odinger’s Cat Thought Experiment
(Do Not Try This at Home!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.5 Postulates of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.5.1 Postulate 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.5.2 Postulate 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.5.3 Postulate 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.5.4 Postulate 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.5.5 Postulate 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.5.6 Symmetric and Antisymmetric Wavefunctions . . . . . . . . . . . . . . . . . . . . 83
3.6 Quantum Tunneling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.7 Stern and Gerlach Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.7.1 Ladder Operators (or Raising/Lowering Operators) . . . . . . . . . . . . . . . . 92
3.8 Bloch Sphere Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.8.1 Qubit Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.9 Projective Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.9.1 Projection Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.9.2 Measuring Multi-Qubit Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.9.3 Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.9.4 Positive Operator Valued Measure (POVM) . . . . . . . . . . . . . . . . . . . . . 103
3.10 Qudits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Practice Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Part II Essentials
4 Qubit Modalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.1 The Vocabulary of Quantum Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
4.2 Classical Computers—A Recap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.2.1 Fundamental Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.3 Qubits and Usability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.4 Noisy Intermediate Scale Quantum Technology . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.5 Qubit Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
4.5.1 Spin or Energy Relaxation Time (T1) . . . . . . . . . . . . . . . . . . . . . . . . . . 112
4.5.2 Dephasing Time (T∅) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.5.3 Decoherence Time (T2) [10, 11] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.5.4 Hann Echo (T2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
xii Contents
4.5.5 Ramsay Experiment T 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.5.6 Gate Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.5.7 Gate Fidelity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.6 Leading Qubit Modalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.6.1 Trapped Ion Qubit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.6.2 Superconducting Transmons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.6.3 Topological Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.6.4 Anyon Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
4.6.5 Electron Spin/Quantum Dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
4.7 A Note on the Dilution Refrigerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4.7.1 How Does the Dilution Fridge Cool the Qubits? . . . . . . . . . . . . . . . . . . 143
4.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Practice Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5 Quantum Circuits and DiVincenzo Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.1 Setting Up the Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.1.1 Setting Up IBM Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.1.2 Installing Microsoft Quantum Development Kit . . . . . . . . . . . . . . . . . . . 151
5.1.3 Verifying the Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5.1.4 Keeping the Installation Updated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
5.2 Learning Quantum Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
5.2.1 Programming for OpenQASM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
5.2.2 QDK Using Q# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
5.2.3 Qiskit Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
5.2.4 Comparing the Development Platforms . . . . . . . . . . . . . . . . . . . . . . . . . 161
5.3 Introducing Quantum Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
5.3.1 On Quantum Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
5.3.2 On the Compute Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
5.4 Quantum Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
5.4.1 Clifford Group Gates for Single Qubits . . . . . . . . . . . . . . . . . . . . . . . . . 165
5.4.2 Arbitrary Rotation of the Qubit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
5.4.3 Physical Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
5.4.4 Multiqubit Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.4.5 Representing a Multi Qubit State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.4.6 Controlled U Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.4.7 Extended Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
5.4.8 Universality of Quantum Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.4.9 Circuit Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.4.10 State Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
5.4.11 Gottesman–Knill Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
5.5 The Compute Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5.5.1 Experimenting with the CNOT Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5.5.2 Implementing Digital Logic Gates Using Quantum Circuits . . . . . . . . . . 203
pffiffiffiffiffiffiffiffiffiffiffiffiffi
5.5.3 Implementing a CNOT Gate with a SWAP gate . . . . . . . . . . . . . . . . . 211
Contents xiii
Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Image Credits
xvii
xviii Image Credits
The following map shall help readers from varied backgrounds and learning needs. Solving the
chapter-end exercises is optional; however, it may provide additional learning experiences.
Linear vector spaces, Hilbert space, Quantum EPR Paradox, Bell’s Quantum Fourier How many qubits are
Dirac’s bra-ket , principle , Density matrix Transform, Oracle based needed ?, Classical
, , formalism, von Neumann algorithms, Shor’s , Available
opertors, Quantum tunneling, entropy, Entangled algorithm, amplitude backends, Future state
, development of two state photons, Quantum , quantum k-
eigenstates, tensors, systems and qubits means,
. and RSA security and HHL.
3.6 Quantum Tunneling Quantum Vocabulary Quantum gate model and theorem, Quantum ,
3.7 Stern and Gerlach Trapped Ion qubits, universal quantum gates. , Stabilizer formalism, Shor’s
Experiment entanglement, quantum annealing 9-qubt code, CSS codes,
3.8 Bloch sphere transmons, , no-cloning Stean’s code, fault-tolerant
Topological qubits, and theorem, interference, ,
3.9 Quantum dots, phase-kickback. surface codes, protected
Measurements Fridge DiVincenzo’s criteria qubits
xix
xx Introduction
2.2 Complex Numbers Quantum gate model and Quantum Fourier Quantum , How many qubits are
2.3 Vectors 2.4 Matrices universal quantum gates. Transform, Oracle based Stabilizer formalism, Shor’s needed ?, Classical
2.5 Linear Vector Spaces entanglement, algorithms, Shor’s 9-qubt code, CSS codes, , Available
2.6 Dirac’s bra-ket , no-cloning algorithm, amplitude Stean’s code, fault-tolerant backends, Future state
2.7 theorem, interference, , quantum k- ,
2.8 Eigenstates phase-kickback. means,
2.11 Tensors DiVincenzo’s criteria and HHL.
Qubit physics
1.7 3.7 Stern and Gerlach 4.6.1 Trapped Ion qubits, 9.2 Quantum error
Experiment 4.6.2
3.8 Bloch sphere transmons 9.3 Stabilizer formalism
4.6.3 Topological qubits 9.5 Surface codes
4.6.5 Quantum dots 9.6 Protected qubits
4.7 Fridge
Perhaps quantum computing does not need any introduction these days. Whether it is a claim for
quantum supremacy/quantum volume or a generous funding a startup received, not a day goes by
without a newspaper article on quantum computing. It looks as if the whole world has changed
suddenly, and everyone wants to do quantum.
The fact is, the foundational principles of quantum computing were established long ago when
personal computers did not exist. The first versions of the no-cloning theorem (it was reinvented in
1982), Holevo’s bound, and the first research paper on quantum information theory were all published
in the 1970s.
Significant progress was made in the early 1980s when Paul Benioff proposed the quantum Turing
machine. Around this time, Richard Feynman and Yuri Manin proposed the basic model of a quantum
computer. In 1985, David Deutsch published the concept of the universal quantum computer. In the
late 1980s, Bikas K. Chakrabarti established the effectiveness of quantum annealing over classical
annealing.
The next decade was buzzing with inventions – Artur Ekert’s communication protocol, Deutsch-
Jozsa algorithm, Simon’s algorithm, Peter Shor’s prime number factorization algorithm, Grover’s
algorithm, and quantum error correction were all invented in the 1990s. In the same period,
controlled-NOT gate operations were performed using cold trapped ions. Deutsch and Grover’s
algorithms were proved using 2 or 3 qubit NMR technology. Experimental proof of quantum
annealing was established in the late 1990s. Furthermore, DiVincenzo laid down the minimum
requirements of a quantum computer. Alexei Kitaev published his first papers on topological quantum
computing, and the first superconducting qubits were reported.
In the last two decades, researchers primarily focused on creating reliable qubit technology.
Remarkable progress on quantum communications and experimental proof of Shor’s algorithm
using NMR were established in research labs. What follows research is commercialization, and
quantum computing is no exception!
D-Wave Systems announced the 28-qubit quantum annealer in 2007, which probably was the first
usable quantum computer. The landscape changed significantly when IBM announced Quantum
Experience for the public in 2016. In the 1980s, IBM brought personal computers to our homes.
Nearly 35 years later, IBM took the lead in bringing quantum computing to the public for experimen-
tation! Now, it is a highly competitive space with money pouring in, with many players trying to gain
the edge and the claim for quantum supremacy.
The advantage of this competition is that we now have reliable platforms to experiment with. In
the last two decades, significant improvements have been made to the qubit designs minimizing the
qubit’s coupling to unwanted environmental noise sources. The current superconducting circuits have
xxi
xxii Introduction
a long coherence time in the order of milliseconds with gate periods close to tens of nanoseconds,
providing us the opportunity to experiment quantum algorithms on real quantum devices.
In the last four decades, classical computing has grown exponentially and probably reaching its
physical limits. With billions of connected devices, social networking, and digital transformation of
the governments and industries, we live in an era where the information overload breaches classical
computing limits. So, it is natural for investors and technologists to explore new avenues. Because of
the promise of the exponential speedup, quantum supremacy sets in very well in the vacuum building
up. It is in this background that this book is published.
Quantum computing will open new job opportunities and job upgrades for software developers and
physicists. While physicists research the core of quantum computing, that is, inventing new materials,
qubit designs, quantum error correction, and quantum algorithms, system engineers work on control
systems, cryogenics, and qubit fabrication. Not to ignore support systems personnel and managerial
staff required to keep the systems working. There are many overlapping areas where software
developers fit in – programming the control systems, inventing new quantum algorithms, developing
transpilers, applying statistical machine learning methods in correcting quantum errors, creating
cloud infrastructure, and consuming APIs. They play a critical role at all layers of quantum
computing.
Introduction xxiii
A fundamental course in computer science is well structured. It begins with the basics – introducing
binary digits and digital gates. The course then proceeds into computer system architecture and then
into data structures, algorithms, compilers, operating system principles, and application development.
Besides, the essence of software development is learned with rigorous lab work by typing code and
learning from numerous books of great authors.
This book follows a similar method. The prerequisites are high school level math and physics, with
a bit of programming experience. The rest are taught from the beginning.
Throughout the book, theory and practice are intermixed. Source code listings are provided for
Qiskit and QDK. The algorithms are explained with illustrations and step by step math. With this
level of detailing, readers must be able to port the code on any platform.
Part I
The first part of the book provides the necessary foundations. This part starts with the definition of
matter and rapidly takes the reader through the foundational concepts of quantum mechanics and the
required math. The concept of quantum mechanical two-state systems is developed in this part and
applied to qubits. This part also introduces quantum measurements and Bloch sphere representation
of qubits.
The first chapter starts by building the necessary foundations of quantum mechanics. This chapter
begins by explaining the concept of matter and its composition. It then progresses rapidly into
explaining the concept of photons, quantization of energy, electron configuration, wave-particle
duality, and probabilistic nature and describes the concept of “wavefunction” to the reader. This
chapter then introduces quantum measurement and provides a short description of Heisenberg’s
Uncertainty Principle. The first chapter ends with a description of some exotic states of matter.
Knowledge of the exotic states may be helpful in Chap. 4.
The second chapter refreshes linear algebra and introduces Dirac’s bra-ket notation. Short tutorials
explaining the concepts of linear operators, Hermitian matrices, expectation values, eigenvalues,
eigenfunctions, tensors, and statistics are made with few examples.
The third chapter introduces some advanced topics in quantum mechanics. This chapter introduces
the Hilbert space and the Schr€odinger equation. The key concepts developed in this chapter are the
quantum superposition principle, quantum tunneling, and spin angular momentum. This chapter then
builds the concept of qubits as two-state quantum systems. The last section of this chapter introduces
the Bloch sphere representation and qubit rotations using Pauli matrices.
xxiv Introduction
Part II
The second part of the book dives into the advanced topics and begins with qubit physics. Once the
qubit modalities are explained, this part then briefs quantum gate operations and the quantum circuit
model. Elements of quantum computation, quantum algorithms, basic concepts of quantum commu-
nication, and quantum error correction are touched upon in the second part.
The fourth chapter is devoted to describing the leading qubit modalities. This chapter starts by
introducing the quantum computing vocabulary and the Noisy Intermediate Scale Quantum technol-
ogy available today. Four leading qubit modalities – trapped ion qubits, superconducting transmons,
topological qubits, and quantum dots are explained in detail. This chapter ends with a note on the
dilution refrigerators.
The fifth chapter focuses on the gate model of universal quantum computing. Concepts such as
quantum entanglement, no-cloning theorem, quantum teleportation, superdense coding, quantum
interference, quantum parallelism, and phase kickback are explained in detail. While studying this
chapter, readers shall set up their computers with IBM Q and Microsoft Quantum Development Kit
and experiment with some basic circuits. The final section of this chapter talks about DiVincenzo’s
criteria for quantum computation.
The sixth chapter focuses on quantum communication and revisits the EPR paradox. The density
matrix formalism and von Neumann entropy are two new concepts introduced in this chapter. This
chapter also explains how entangled photons can be created in the labs and briefs quantum commu-
nication. Two quantum communication protocols – BB84 and Ekert 91 – are introduced to the
readers. Before concluding, this chapter examines the premises of RSA security.
The seventh chapter of this book explains some of the well-known quantum algorithms that the reader
can try either on IBM Q or Microsoft QDK. The algorithms discussed in this chapter broadly fall
under four categories. Deutsch-Jozsa, Bernstein-Vazirani, and Simon’s algorithm are oracle-based
algorithms. Shor’s algorithm, quantum phase estimation, and HHL are algorithms that work on a
Fourier basis. Grover’s algorithm uses a new method called amplitude magnification. A new category
of algorithms that use basic quantum computation principles is evolving. The quantum k-means
algorithm uses a swap-test to determine Euclidean distances. This chapter provides a step-by-step
derivation of the math and source code for the algorithms discussed.
Introduction xxv
The eighth chapter introduces the adiabatic theorem and provides a simple proof. Adiabatic optimi-
zation and quantum annealing methods are discussed in this chapter.
The ninth chapter focuses on quantum errors and correction mechanisms. The stabilizer formalism is
introduced in this chapter. Shor’s 9-qubit error correction code, CSS codes, and Steane’s 7-qubit error
correction codes are introduced in this chapter. After introducing these stabilizer circuits, this chapter
examines the premise of fault-tolerant quantum computation. The concluding sections of this chapter
discuss surface codes and protected qubits as means of fault-tolerant quantum computation.
Chapter 10 – Conclusion
The final chapter of this book attempts to look at the promise of quantum supremacy. This chapter
discusses how many qubits do we need to perform certain quantum computations, comparison with
classical simulations, availability of backends, and the future state.
One important point is there is no source code repository. Readers shall learn quantum computing
by typing code from the source code listings in the book, like the old days. Worked-out examples and
problems are provided at appropriate places to reinforce the concepts. Each chapter contains a
summary, key learning objectives, and a list of sections that can be skipped wherever possible. At
the end of each chapter, practice problems and a list of references are provided for further reading.
This method shall undoubtedly help the readers retain knowledge, read advanced textbooks, and
study research papers.
Reading Guide
An accompanying reading guide helps readers with various backgrounds identify their starting point
and fulfill their journey through the book. This mapping shall help readers get quickly onboard and
connect with the content important to them.
Wherever a section or the equations can be skipped, a text box highlights the options.
Note:
Readers can skip the equations and continue to read the text, without compromising the
understanding.
If a section has prerequisites, a text box highlights the requirements. This information helps
readers who skipped some sections to read the missed topics and get prepared.
xxvi Introduction
Note:
Reading section 1.7 on exotic states of matter may be helpful to read the following sections in this
chapter.
Conventions
Indexing Qubits
This book uses a zero-based index for labeling qubits. This indexing scheme is in line with quantum
programming languages. In a given quantum circuit, the topmost qubit is labeled q[0]. The indexing
proceeds from the top of the circuit to the bottom. The classical bits are also indexed in the same
fashion. The topmost classical bit is c[0].
Bloch spheres are used to illustrate the state vector of the qubits. The starting position of the state
vector is shown in a lighter shaded green color. The final position of the state vector is shown in a dark
shaded green color. The direction in which the state vector is rotated is shown using a dotted line.
The arrow of the dotted line shows the direction of rotation. Please see Fig. 5.6 for an example
illustration.
Source code listings are provided at appropriate places in a highlighted box. Each of the listings is
indexed and may be referenced within the body text of the book.
Introduction xxvii
I plan to keep this book updated with new materials, error corrections, and additional volumes. Those
who wish to connect with me shall do so through the Good Reads platform.
Venkateswaran Kasirajan,
Superior, Colorado.
September 2020.
About the Author
Venkateswaran Kasirajan (Venkat) was a student of physics before studying computer science and
taking up a software engineering career. Being a part of two startups, Venkat had the opportunity to
work on several core technologies and booted the career of hundreds of engineers. He was also
involved in several patents.
Venkat is currently working for Trimble Inc. as an engineering director overseeing a high-profile
engineering team.
Venkat’s interests are in condensed matter physics. He also researches quantum algorithms and
topology and serves as an internal champion for quantum computing at Trimble Inc.
When not working, Venkat is either listening to country music or teaching his daughter. Venkat
lives with his family in Colorado.
xxix
Part I - Foundations
1
Foundations of Quantum Mechanics
1
“It proves nothing of the sort!” said Alice. “Why, you don’t even know what they’re
about!”
“Read them,” said the King.
The White Rabbit put on his spectacles. “Where shall I begin, please your Majesty?” he
asked.
“Begin at the beginning,” the King said gravely, “and go on till you come to the end: then
stop.”
― Lewis Carroll, Alice’s Adventures in Wonderland
1.1 Matter
The night sky is fascinating. The beauty of the timeless twinkling stars and the gracious magic of the moon
have inspired poets and authors for thousands of years. Yet, we still wonder at its mystery. Who or What
created this expanse? Where did it come from, and where is it going? Why was this created? These are
some questions we have been asking ourselves since our childhood, and there are no definite answers yet.
Theologists and scientists are attempting to explain creation with their theories—theories that are
often are far apart—but still serving as the fundamental point of interaction between religion and
science. As we research and learn more, we can someday expect a convergence of these theories.
We can, however, answer some simple questions within our current knowledge of the universe.
For example, if one were to ask, what is the universe made of? We know the answer readily, and we
learned this in middle school that “matter is the stuff that makes the universe.”
In our quest to learn about the fundamentals of quantum computing, this is where we shall start. In
the next few sections of this chapter, we shall learn about the stuff that makes the universe. Basic
knowledge of this microcosm is essential to understand the foundations of quantum mechanics, which
form the basis for quantum computing.
We also learned in middle school that matter takes up space and has mass. Ordinary matter exists
in four distinct states we can observe today: solid, liquid, gas, and plasma.
In a solid, the constituent particles are densely packed. The particles are held together by strong
forces, so they cannot move freely but can only vibrate around their current positions. Thus, solids
have a definite shape and volume that can be changed only by breaking or slicing (Fig. 1.2).
Fig. 1.1 The splendor of the Milky Way galaxy, rising in the backdrop of the Nankoweap Trail, Grand Canyon
National Park, Arizona. (Photo: Rich Rudow)
In a liquid, the constituent particles have enough energy to move relative to each other. The ability
of the constituent particles to move relative to each other makes the liquids “flow.” Hence, the liquids
take the shape of the container but retain its volume at a given temperature and pressure (Fig. 1.3).
In a gas, the constituent particles are loosely bound. The particles are free to move about and
expand to occupy the space of the container. We can compress gases by applying pressure. When
1.1 Matter 5
Fig. 1.3 Simplicity. Boats on a blue water. (Image courtesy of Tiket2.com, CC BY)
Fig. 1.4 Water evaporates as lava flows into the ocean. (Source: Vlad Butsky, https://www.flickr.com/photos/butsky/
357672637/, CC BY 2.0)
cooled, the gases turn into liquids and then into solids. Some gases, like carbon dioxide, may directly
cool into solids. The solid form of carbon dioxide is called dry ice, and the food industry uses it to
freeze food. The water cycle is an excellent example of the phase transition between the three states
(Fig. 1.4).
6 1 Foundations of Quantum Mechanics
Fig. 1.5 Lightning creates a highly conductive plasma channel in the air. (Photo by Hallie Larsen, National Park
Service)
We can transform matter from one state to another by changing the temperature and pressure. A
simple example we see every day is the melting of ice into water and then into steam. We can reverse
this phase transition by cooling the steam. Sublimation is a process where solids convert into gases
without melting. Some examples we come across every day are air fresheners and mothballs.
At high temperatures, the electrons rip off from the atoms forming an ionized gas called plasma.
Like gases, plasma is not defined by any shape. Plasma can conduct electricity and produce
electromagnetic fields. We can see plasma every day in lightning and neon lamps (Fig. 1.5).
Matter also exists in some exotic states such as Bose-Einstein condensates, neutron-degenerate
matter, and quark-gluon plasma. These occur under extreme conditions of cold, density, and energy.
Nevertheless, what is matter itself made of? The next section answers this question.
1.2.1 Atoms
Atoms are the basic building blocks of ordinary matter, and they are, in turn, made up of subatomic
particles. These subatomic particles are the protons, neutrons, and electrons. Atoms of the same
kind make up the given chemical element. Atoms are too tiny to be seen with naked eyes. They are so
small (around 1 1010 m in size), and classical physics cannot explain their behavior.
We use quantum mechanics to explain the behavior of atoms.
1.2 Atoms, Elementary Particles, and Molecules 7
Fig. 1.6 The periodic table. (Image Credits: Offnfopt, Wikipedia, CC BY-SA 4.0)
The periodic table lists all chemical elements known to us in a tabular form. The elements are
arranged in a particular order (Fig. 1.6).
The Russian Scientist Dmitri Ivanovich Mendeleev published the first version of the periodic
table in 1869. To commemorate its 150th anniversary, the United Nations declared the year 2019 as
the “International Year of the Periodic Table of the Chemical Elements.”
The periodic table is an excellent tool to help us understand the properties of the chemical
elements. The rows in the periodic table are called “periods.” The period number of a chemical
element indicates the highest energy level an electron in that chemical element can occupy in the
ground state.
The columns are called “groups.” The group number of a chemical element indicates the number
of valence electrons in it. Valence electrons are present in the outermost shell (called valence shell)
of the atoms. They can be transferred or shared with other atoms. Elements belonging to the same
group have similar chemical properties.
With this introduction, let us now explore the structure of the atom in some detail.
Though this model is somewhat obsolete, we can safely imagine that an atom has a nucleus consisting
of protons and neutrons (the nucleons). The electrons are orbiting the nucleus in a finite set of orbits.
The number of protons in an atom is its atomic number Z. The atomic number defines which chemical
element the atom belongs to.
For example, Hydrogen has one proton, and its atomic number is 1. Helium has two protons, and
its atomic number is 2 (Fig. 1.7).
8 1 Foundations of Quantum Mechanics
Inside the nucleus, the protons (p or p+) are positively charged particles with a charge of +1e
(e here stands for an elementary charge), and neutrons have no charge. They both are attracted to
each other by nuclear forces. The electrons (e) are negatively charged particles with a charge of
1e, and they are attracted to the nucleus by electromagnetic forces.
The discovery of the subatomic particles and the development of quantum mechanics is an
interesting story [1] in the history of science.
The clues to the presence of electrons were perhaps first noticed by the German physicist Johann
Wilhelm Hittorf in 1869 when he discovered that the glow emitted from the cathode increased in size
when the gas pressure is decreased. Later in 1897, the British physicist J. J. Thomson discovered the
electrons with his famous cathode ray tube experiments.
In 1886, the German Physicist Eugen Goldstein discovered the existence of positively charged
rays in the discharge tube by using a perforated cathode. He named them as anode rays or canal rays.
In 1899, the British physicist Ernest Rutherford discovered alpha and beta rays from uranium. He
later demonstrated that alpha rays are the nuclei of helium atoms.
In 1914, Rutherford discovered that the nucleus of an atom was extremely dense, but only
occupied a small fraction of the volume of an atom. He also found that the nucleus was positive in
charge. At this time, the scientists concluded that particles opposite in charge to that of electrons must
exist to balance the charge of the atoms. Rutherford named this as “positive electron,” which later
came to be known as “proton.”
Scientists observed that the atomic mass number A of nuclei was more than twice the atomic
number Z for most atoms. This was a puzzle, and there were some proposals to explain the higher
value of the atomic mass number. The scientists knew that almost all of the mass of the atom is
concentrated in the nucleus (Rutherford’s famous gold foil experiment).
By around 1930, it became known that alpha particles that hit beryllium produced radiation, which
was not usual. For example, this radiation knocked off high energy photons from paraffin wax. In
1932, a British Scientist James Chadwick explained that the radiation from beryllium was a neutral
particle with a mass close to a proton.
In 1934, this particle was named neutron, which completed the Bohr’s model of the atom.
1.2 Atoms, Elementary Particles, and Molecules 9
In Bohr’s model of the atom, the electrons revolved around the nucleus at certain discrete distances
for which the angular momentum is an integral multiple of reduced Planck’s constant, that is, nħ,
where n ¼ 1, 2, 3, . . . is the principal quantum number. This provided for the quantization of the
angular momentum.
Arnold Johannes Wilhelm Sommerfeld, a German physicist, extended this model by adding two
quantum numbers: the Azimuthal quantum number l and the Magnetic quantum number ml.
The azimuthal quantum number defines the orbital angular momentum, and consequently, this
defines the shape of the orbitals. It takes the values l ¼ 1, 2, 3. . .n. The magnetic quantum number
is a projection of the orbital angular momentum along an axis. In other words, it describes the
orientation of the orbitals in space. It takes the integer values between l and l namely,
ml ¼ l, l + 1, l + 2, . . ., 2, 1, 1, 2, . . ., l 2, l 1, l. Hence it can take 2l + 1 possible
values.
As new particles were discovered and their behaviors observed, scientists had to create new theories
to explain them. Quantum mechanics is a successful theory that explains these behaviors well.
However, the advent of quantum mechanics altered the views of classical physics known in the
earlier part of the twentieth century. The concept that a single particle can span a field as a wave was
quite radical, and it is still a subject of research.
The Standard Model of particle physics is a widely successful theory that tries to explain the
fundamental forces of nature: the electromagnetic, strong, and weak interactions. It also classifies the
elementary particles known so far. Elementary particles are subatomic particles that are not composed
of other particles.
Protons and neutrons are not elementary particles as they are made of quarks. Quarks are
elementary particles that can combine to form composite particles called hadrons. Protons and
neutrons are hadrons (Fig. 1.8).
A proton is made of two “up quarks” and one “down quark”. Gluons mediate the force between the
quarks. Gluons are exchange particles for the strong force between the quarks. Exchange particles
are virtual particles that interact with particles to create the effects of attraction or repulsion. The
virtual particles cannot be observed.
Neutrons are made up of two down quarks and one up quark. Gluons also mediate the forces
between the quarks.
Fig. 1.9 The standard model of elementary particles. (Author: Cush, Source: Wikipedia, Public Domain)
Electrons are considered to be elementary particles. However, under extreme conditions, the
electrons in a solid are shown to split into three quasiparticles: holons (charge), spinons (spin), and
orbitons (orbital) representing the three degrees of freedom the electron enjoys in a molecule.
Figure 1.9 summarizes the standard model of elementary particles known so far.
The first-generation fermions, namely, the up and down quarks, the electron, and the electron
neutrino, make up the ordinary matter. The higher-order fermions are observed in some extreme
environments, and they fall back into the first order fermions.
The Gauge bosons do not constitute matter. They are interaction energy or force carriers that act
upon matter. For example, the Gluons represent the energy interaction between the up and down
quarks in a proton or a neutron and adds to their mass.
The standard model describes bosons, the force-carrying fields well. However, the mass of W and
Z bosons seemed to be a mystery to explain. The Higgs boson, also known as the “god particle,”
comes to help here. The Higgs boson is a scalar field and adds up mass to the W and Z bosons in a
process called the Higgs mechanism.
1.2 Atoms, Elementary Particles, and Molecules 11
H N H
H
Any particle that interacts with the Higgs field acquires a mass. Particles such as photons that do
not interact with the Higgs field do not acquire mass!
According to the classification of elementary particles, electrons are fermions with one-half spins
(we shall explore the concept of spins in a later section). Fermions are particles that follow Fermi-
Dirac statistics and obey Pauli’s exclusion principle. In extreme conditions, the electrons move past
each other in a process known as Quantum Tunneling. It has been proved that under these scenarios,
the electrons split into its constituent quasiparticles. Quantum Tunneling is an everyday phenome-
non observed in semiconductors and applied in a class of Quantum Computers known as Quantum
Annealers.
Quantum Annealers belongs to a class of quantum computing called Adiabatic Quantum
Computation, which has applications in solving optimization problems where a local minimum is
required to be found from a discrete search space. This process uses Quantum Tunneling. We shall
explore this concept in detail in a later discussion.
Photons, gluons, W, and Z bosons are force-carrying particles, and they are called bosons. Bosons
have integer spins and follow Bose-Einstein statistics.
1.2.5 Molecules
Molecules are the smallest particle of a substance that retains its physical and chemical properties.
Two or more atoms make up the molecules, and they are held together by chemical bonds. The
molecules are electrically neutral.
Figure 1.10 illustrates the Ammonia molecule, formed by a covalent bond between three Hydro-
gen and one Nitrogen atom. Each Hydrogen atom shares one electron with the Nitrogen atom.
Industrial production of Ammonia involves heating Nitrogen and Hydrogen to a degree of 400 C
(930.2 F) under high pressure of 200 atmospheres.
It is one of the most energy-consuming and effluent producing processes in the world. Nature
produces Ammonia in the root nodules of plants at room temperature without producing any effluent.
An essential application of quantum computers is to simulate atoms and chemical reactions.
Someday, quantum computers may help us synthesize enzymes that can create molecules like
Ammonia with less energy and less waste.
The preceding sections provided a basic knowledge of matter. An understanding of matter is the
first step in learning about energy and electromagnetic radiation. The following sections focus on
light and quantization of energy, thereby introducing the foundations of quantum mechanics.
12 1 Foundations of Quantum Mechanics
In physics, a blackbody is an imaginary object that absorbs all of the radiation incident on it. An ideal
blackbody does not reflect any radiation, so it appears dark. The blackbody is also a perfect emitter of
radiation. Hence, at a given temperature, the blackbody emits the maximum energy. In other words,
the wavelength (or rather the color) of radiation depends upon the temperature of the body and not its
composition.
Figure 1.11 shows the relation between the intensity of light emitted as a function of wavelength
for various temperatures of a blackbody.
In classical physics, an ideal blackbody at a given temperature is expected to emit radiation in all
frequencies, and the energy of the emitted radiation increases with an increase in frequency. In other
words, classical physics expects energy to increase or decrease continuously. This does not explain
the sharp decrease in the intensity of radiation emitted at shorter wavelengths at lower temperatures.
Also, the blackbody is expected to emit an infinite amount of energy, which is against the principle of
conservation of energy. This difference between classical theoretical physics and experimental
observation is known as the “ultraviolet catastrophe.” Therefore, a new theory is essential to
explain the behavior of blackbodies. The K here refers to the Kelvin scale in which scientists measure
temperature. 0 K (273.15 C or 459.67 F) is known as Absolute Zero, the lowest possible
temperature with no heat energy. Water freezes at 273.15 K (0 C) and boils at 373.15 K (100 C)
under standard atmospheric pressure.
As early as 1872, Ludwig Boltzmann theorized that energy states of a physical system could be
discrete. He divided the energy of a system into tiny discrete packages [2] in his calculations.
In 1900, the German physicist Max Planck explained the blackbody problem with the idea that the
discrete energy states are proportional to the frequency of the radiation. He postulated that the atoms
and molecules in an object behave like oscillators, and they absorb and emit radiation. The energy of
Fig. 1.11 Blackbody radiation. (Source: University Physics Volume 3, Released under CC BY 4.0)
1.3 Light and Quantization of Energy 13
the oscillating atoms and molecules is quantized. It is emitted or absorbed in integral multiples of
small steps, known as the “quantum.” The following equation describes this.
E ¼ nhν ð1:1Þ
where,
E - Energy Element
h - Planck’s constant (6.626 1034 Js)
ν - frequency of the radiation.
n – 0, 1, 2, 3. . . .
This equation means that the energy can increase or decrease only in discrete steps defined by ΔE,
the smallest value by which energy can change:
ΔE ¼ hν ð1:2Þ
In 1887, the German scientist Heinrich Hertz first observed the photoelectric effect. Hertz observed
that, when light above a certain frequency (called the threshold frequency) is incident on a metal,
electrons are released. This effect is something classical physics cannot easily explain.
In 1905, Albert Einstein explained the photoelectric effect using Planck’s theory. Einstein
received his Nobel Prize in 1921 for explaining the photoelectric effect (Fig. 1.12).
Einstein proposed that the energy in the light is in discrete “packets” called quanta. Each of these
packets contained energy defined by this equation:
E ¼ hν ð1:3Þ
where,
Knocked off
electrons
Incident
Light
Metal Plate
14 1 Foundations of Quantum Mechanics
This is the energy of one quantum of light. This equation also relates energy with the frequency
(¼ color) of light. We now call this quantum of light as a photon. Moreover, light is electromagnetic
radiation, similar to radio waves.
According to Particle Physics, photons are bosons, and they serve as the force carriers for the
electromagnetic radiation. Photons are also elementary particles. Hence, photons are not made of
other particles. Photons carry no mass. Photons have a spin of 1, and they have no charge. Photons
travel at a speed of c ¼ 299,792,458 ms1 in a vacuum.
The following equation is called the photoelectric equation:
hf ¼ ϕ þ Ek , ð1:4Þ
where h is the Planck’s constant, f is the frequency of the incident light, ϕ is the work function—the
minimum energy required to remove an electron from the surface of the metal, and Ek is the
maximum kinetic energy of the emitted electrons.
Photons exhibit wave-particle duality, a property we shall explore shortly.
The Bohr’s model of an atom proposes that the electrons move around the nucleus in circular orbits of
certain allowed radius, like the planets moving around the sun. The angular momentum (quantity of
rotation) of electrons in such orbits meets the following criteria:
nh
L n ¼ m n vn r n ¼ ð1:5Þ
2π
where,
L—angular momentum
m—the mass of the electron
r—radius of the orbit
h—Planck’s constant.
n—orbit 1,2,3. . .
Each of these orbits is assigned a number n. In other words, the angular momentum of an electron
is quantized! The closest orbit to the nucleus is n ¼ 1, where the energy holding the electron to the
nucleus is high.
For example, the hydrogen atom has one electron that occupies the lowest orbit n ¼ 1. This lowest
orbit is also its “ground” state. When light (photons) is incident on an atom, the light can bounce off
(reflected), pass through, or absorbed.
The choice depends upon the kind of atom and the frequency (or energy) of the light. If the light
has the right energy, the atom can absorb the energy, thereby pushing the electrons to higher orbits.
The atom is now in an “excited” state. The excited state is not a natural state. Hence, the electron
emits the absorbed energy back into the environment and returns to its ground state.
In a hydrogen atom, the energy level E1 for the ground state (n ¼ 1) is determined to be 13.6 eV.
The unit eV stands for electron Volt and the value of 1 eV ¼ 1.6022e 19 joules. This energy is
negative because it is relative to a free electron at rest. A free-electron at rest is at an infinite distance
from the nucleus and has zero energy. The most negative energy of an electron is at the orbitals
closest to the nucleus (n ¼ 1). This also the most stable orbital and the ground state.
1.3 Light and Quantization of Energy 15
Paschen
Series
Series
n=1
n=2 Pfund
Series
n=3
n=4
n=5
n=6
The energy level E2 for the first excited state (n ¼ 2) is 3.4 eV. For the second excited state
(n ¼ 3), the energy E3 is 1.51 eV, and for the third excited state (n ¼ 4), the energy E4 is 0.85 eV.
Figure 1.13 shows the electron energy levels. It also shows the spectral line series arising due to the
electron transition between the levels.
If we must move an electron from the ground state to the first excited state in a Hydrogen atom, we
need—
16 1 Foundations of Quantum Mechanics
ΔE ¼ E1 E2 ¼ 13:6 eV 3:4 eV
ΔE ¼ 10:2 eV ¼ 1:66626e 18 J ð1:6Þ
i:e:, ΔE ¼ 0:00000000000000000166626 J
Compare this number with a 40 W electric bulb, which emits 40 joules of energy per second. The
energy to move an electron out of its orbit is so low that we have to isolate the qubits (the quantum
equivalent of classical bits used in digital computers) from the thermal and electromagnetic back-
ground and keep them inside dilution fridges under micro kelvin temperatures.
We use this concept to measure the state of qubits. By shining a measured dose of light on a qubit
and measuring the emerging light, the qubit’s state can be deterministically measured! Of course, this
process destroys the state of the qubit.
We shall learn more of quantum measurements in subsequent sections.
In the previous section, we saw the energy involved when a photon hits an electron and the energy
levels occupied by the electrons. The electronic configuration helps describe the distribution of the
electrons in the orbitals using the four quantum numbers: the principal quantum number n, the orbital
angular momentum quantum number l, the magnetic quantum number ml, and the spin angular
momentum quantum number ms. The electron configuration is subject to Pauli’s exclusion principle.
According to this principle, no two fermions (particles having half-integer spins) in a quantum
mechanical system can occupy the same quantum state. The Austrian physicist Wolfgang Pauli
formulated this principle in 1925 for electrons. This was later extended to all fermions. In an atom,
two electrons residing in the same orbital can have n, l, ml the same. However, they must have
different spin angular momentum (ms) with values 12 and 12.
Pauli’s exclusion principle does not apply to particles with integer spins (bosons). Bosons can
occupy the same quantum state (e.g., photons and Bose-Einstein condensates). This is due to the
nature of the exchange interaction between bosons, which adds up the probability of two similar
particles entering the same state.
The principal quantum number n denotes the shell or the energy level in which the electron can be
found. It takes values n ¼ 1, 2, 3, . . . The total number of electrons that can be present in a shell is 2n2.
The orbital angular momentum quantum number l describes the subshell. The values orbital angular
momentum can have are l ¼ 0, 1, 2, . . ., n 1. The subshells are also described by alphabet labels
1.5 Wave-Particle Duality and Probabilistic Nature 17
starting from s, that is, l ¼ s, p, d, f. . . . We can calculate the total number of electrons present in a
subshell by using the formula 2(2l + 1). Each of these subshells has orbitals with two electrons in each
orbital, obeying Pauli’s exclusion principle and accounting for the two spin states of the electrons.
The s subshell has one orbital, p has 3 orbitals, d has five orbitals, and f has seven orbitals.
Electrons occupy the orbitals in the order of increasing energy as defined by the Aufbau principle:
1s < 2s < 2p < 3s < 3p < 4s < 3d < 4p < 5s < 4d < 5p < 6s < 4f < 5d < 6p < 7s < 5f < 6d < 7p
The photoelectric effect demonstrated that light behaved like a particle. However, some other
experiments and theories had a view that light behaves like a wave. Is light a wave or a particle?
Well, it depends upon how we measure it!
The nineteenth century was bubbling with many inventions around electricity, and magnetism and
new theories were developed in explaining them. The invention of the telegraph, the first electric
motor, electromagnetic induction, electric bulbs, motion picture, and phonograph were great things
that changed the lives of people in that century. However, a unified theory of electricity and
magnetism was missing. In this time, the Scottish scientist James Clerk Maxwell created his famous
18 1 Foundations of Quantum Mechanics
Electric Field
By the second decade of the twentieth century, it became widely accepted that light had both wave-
like and particle-like properties. Matter itself was still thought of particle-like. In 1924, Louis de
Broglie challenged this assumption and proposed that electrons too must behave like a wave and must
possess a wavelength. He went one step forward and proposed that all matter must have wave-like
behavior and their wavelength related to their momentum, as described in the following equation.
h h
λ¼ ¼ ð1:7Þ
mv p
where,
The American scientists, Clinton Davisson and Lester Germer, proved this later in an experi-
ment where electrons scattered by the surface of a nickel crystal displayed a diffraction pattern—
again a wave-like behavior (matter waves!)
To study the probabilistic and wave-like nature of matter, we must perform the classical Young’s
double-slit experiment.
1.5 Wave-Particle Duality and Probabilistic Nature 19
Consider the following setup, where a sandblaster gun can randomly fire sand particles at an
assembly, which has two slits. We can keep the slits either opened or closed. The sand particles
can pass through the slits and hit an observation screen at the back.
In the first run of the experiment, let us close Slit 2 and turn on the sandblaster. The sand particles
pass through Slit 1, hit the observation screen, and pile up in a wave-like pattern, as in Fig. 1.17.
If we represent the amplitude of the wave-like pattern as ψ (Greek letter psi) at a point x in the
screen, then the probability P1 of a sand particle hitting the point x in the screen can be written as:
P1 ðxÞ ¼ ψ 2 ð1:8Þ
Now, let us close Slit 1, open Slit 2, and rerun the experiment.
The sand particles pass through Slit 2, hit the screen, and form a similar pattern. Figure 1.18 shows
this pattern. The probability P2 of a sand particle hitting the screen at a point x in the screen can be
written in the same way as:
P2 ðxÞ ¼ ψ 2 ð1:9Þ
Finally, let us open both the slits and rerun the experiment.
The sand particles now have the option of passing through one of the slits and hit the screen. In this
final run, the probability P12 of a sand particle hitting the screen at a point x in the screen is the sum of
the probability of the sand particle passing through Slit 1 and the probability of the sand particle
passing through Slit 2 (Fig. 1.19).
The new probability can be written as:
This experimental result concurs with classical physics, and we do not doubt this behavior.
Now, let us replace the sandblaster gun with an electron gun (the ones used in CRTs, if you
remember them) and watch the results!
When we replace the sandblaster gun with an electron gun and repeat the experiment, we expect a
similar behavior: the electrons pass through the two slits and hit the screen creating two bars like
patterns, as drawn in Fig. 1.20.
Fig. 1.22 (a) Constructive interference when two waves of the same phase meet. (b) Destructive interference when
two waves with opposite phases meet
However, the observed behavior is entirely different! The electrons pass through the two slits, but
form a fringe pattern, as shown in Fig. 1.21. This fringe pattern requires the electron to behave like a
wave.
If the electrons are a wave, they shall interfere with each other after passing through the slits. At
places where the peaks of the waves meet, we get a bright spot, that is, a constructive interference. At
places where a peak meets a low, they cancel each other out, and we get a dark spot, that is, a
destructive interference. Intermediates create grey bands. Figure 1.22 illustrates constructive and
destructive interferences.
We repeat the experiment with an electron gun, which releases one electron at a time. We can use
attenuators to release one electron at a time. Thus, this setup prevents more than one electron from
passing through the slits at the same time and causing interference on the other side of the double-slit
assembly.
When we run the experiment, the results are quite surprising. The electrons produce a similar
pattern of interference fringes (Fig. 1.23)!
The formation of interference fringes cannot be explained unless the electron somehow passes
through both slits and interferes with itself on the other side. This is impossible unless the electron
behaves like a wave. This is explained in Fig. 1.24a.
Using the analogy before, if ψ 1(x, t) is the probability amplitude of the electron passing through
Slit 1 and if ψ 2(x, t) is the probability amplitude of the electron passing through Slit 2, then we can
22 1 Foundations of Quantum Mechanics
Fig. 1.23 Single-electron beam experiment showing the electron build-up over a period of time—images (a) to (e)
shown in the observation screen. The pattern is not the electron itself. However, it is the probability that the electron
shall arrive at a given spot on the screen
Fig. 1.24 A single electron gun experiment. (a) A single electron passes through both the slits and interferes with itself
on the other side. (b) Experiment repeated with sensors mounted on each path
summarize the probability amplitude of the electron passing through both the slits and hit a point x in
time t as:
where x is the position on the screen, the electron could be found at a given time t.
1.6 Wavefunctions and Probability Amplitudes 23
Now let us mount some sensors at the slits to check whether the electron did pass through both the
slits simultaneously!
When we repeat the experiment by mounting two sensors at the slits (Fig. 1.24b), we see that the
electrons pass through both slits with a 50% probability in each. Here, the act of measurement
changes the experiment, and the interference pattern disappears. We shall explore the concept of
measurements in a later section.
We learned in a previous section that an electromagnetic (EM) wave is an alternating wave of Electric
! !
field E and Magnetic field B. These two fields are perpendicular to each other and the direction of the
propagation of the wave (Fig. 1.16). The energy density (u) of an EM wave is proportional to the
square of either of these two fields. The following equation describes this:
1 2
u ¼ ε0 E 2 ¼ B ð1:12Þ
μ0
where,
We can safely assume that the greater the energy density, the higher the probability of finding the
photon. In other words, the probability of finding the photon is proportional to the square of the fields.
Though the photon and the electron are different kinds of elementary particles, de Broglie has
shown that electrons (and other matter as well) behave like waves, and this analogy can be applied
to them.
Let us now introduce a term wavefunction, or the probability amplitude ψ(x, t) where x is the
position where the quantum system (electron in our discussion here) can be found at time t.
If we plot the interference pattern we got when we did the double-slit experiment with the electron
gun, against the position x on the screen, the graph looks like Fig. 1.25. The peaks and lows in the
graph correspond to the bright and dark bands on the screen.
If we take the square of this function and plot it against the x-axis, the graph looks like Fig. 1.26.
The height of the graph at any point on the x-axis is proportional to the probability of finding the
electron at that point.
Recollect from the lessons on calculus that the probability of finding the electron, somewhere
between two points x1 and x2 on the graph can be written as the integral:
ð
x2
A more generalized version of this equation in a normalized form, defining the probability of
finding an electron somewhere in the universe, is given by:
ð
þ1
Like the EM waves, if we assume that the de Broglie waves contain two alternating parts, we can
write the wavefunction as an ordered pair:
ψðx, tÞ ¼ fA cos ðkx ωtÞ, A sin ðkx ωtÞg, ð1:15Þ
where k ¼ 2πλ , λ ¼ hp, h ¼ Planck’s constant. p ¼ momentum, ωt - represents the phase factor of the
wave, ω ¼ 2πν, A - represents the amplitude of the wave, and ν—frequency of the wave.
Note: For the sake of brevity [3], this book does not discuss how we arrived at the term kx ωt.
This equation can be written in a complex form as:
ψðx, tÞ ¼ fAcos ðkx ωtÞ þ iAsin ðkx ωtÞg ð1:16Þ
pffiffiffiffiffiffiffi
where i ¼ 1
We know from the Euler’s formula eiθ ¼ cos (θ) + i sin (θ), so we can write the above equation as:
In this equation, the factor eiωt is a constant for a given time t, and it can be factored out into A.
The resulting equation is:
1.6 Wavefunctions and Probability Amplitudes 25
The probability of finding the electron (or in general, a quantum system) can now be written as the
absolute square of the probability amplitude:
In classical physics, realism means the quality of the universe exists independently of ourselves. Even
if the result of a possible measurement does not exist before measuring it, it does not mean that it is a
creation of the person experimenting.
Quantum mechanics rejects the concept of realism. A quantum system may always exist in all
possible states simultaneously until a measurement is made. We do not know the state of the system
until we measure it. When we make a measurement, the wavefunction collapses, and the system is
localized.
In any experiment we do with a quantum computer, we set the qubits to the initial states and perform
several operations on the qubits. Finally, we measure the state of the qubits by projecting them into
one of the measurement basis.
When we perform a measurement on a quantum system, the measured quantity gets well defined.
This is because the wavefunction is a probability density over all possible states. According to the
Copenhagen Interpretation of Quantum Mechanics, the act of measurement causes the
wavefunction to collapse into the corresponding eigenfunction.
If we measured the position of the quantum system to be x0, then the wavefunction is now the
eigenfunction δ(x x0). This function is known as the Dirac delta function. It is a linear function
which maps the density of a point mass or a point charge to its value at zero (Fig. 1.27).
If we measured the momentum of the quantum system and found it to be p0, then the wavefunction
ip0 x
is now the eigenfunction e ħ , which we derived earlier.
The Uncertainty Principle was introduced in 1927 by the German physicist Werner Heisenberg. It
imposed a limit on how accurately we can measure canonically conjugate observables like position or
momentum simultaneously. Time and Energy are another set of examples of canonically conjugate
26 1 Foundations of Quantum Mechanics
Fig. 1.27 The Copenhagen interpretation and the collapsing of the wavefunction after measurement
observables. According to the uncertainty principle, the more accurately we measure one of them, the
less accurate the other becomes and vice versa. The uncertainties with the products of these canoni-
cally conjugate observable pairs have a minimum value as defined by the following equations:
ħ
Δpx Δx and
2π ð1:21Þ
ħ
ΔtΔE ,
2π
where Δ -“delta” is a small difference, ħ ¼ 2πh
, px-momentum, x-position, t-time, E-Energy.
The uncertainties are so small that they are significant only with small masses of atomic and
subatomic particles. We need not worry about their effects on everyday objects like vehicles and
electric bulbs!
Two observables are said to be canonically conjugate if their operators Ab and Cb do not commute.
Specifically, they should satisfy the following condition:
^ C
½A, ^ ¼A
^C^ C
^A^ ¼ iħ ð1:22Þ
Here, the hat accent is used to denote an operator. ħ is the reduced Planck’s constant and i is an
imaginary number. We shall discuss operators in the next chapter.
In the last few years, some research papers have been published about the possibility of weak
measurements [5] in quantum systems. Weak measurements do not introduce many disturbances in
the system, and hence the wavefunction does not collapse. However, we obtain only very little or less
accurate information about the observable.
Weak measurements are a challenge to the system engineers designing quantum computers. In
Chap. 4, we discuss qubit modalities and learn about the construction and functionality of the qubits.
For each modality, we also discuss how to make the measurement. If the system design does a weak
measurement of the qubit, the results may be inaccurate. This is a problem the system engineers are
required to solve and adds to the complexity of designing quantum computers.
1.7 Some Exotic States of Matter 27
Example 1.1
Prove that the position and momentum operators do not commute.
Solution:
ħ ∂
We know that xb ¼ x and pb ¼
i ∂x
Note: The momentum operator can be obtained by partial differentiation of the momentum
eigenfunction. For brevity, that step is ignored.
ħ ∂ψ ħ ∂xψ
½xb, pbψ ¼ xbpbψ pbxbψ ¼ x
i ∂x i ∂x
ħ ∂ψ ∂ψ ∂x
¼ x x ψ
i ∂x ∂x ∂x
ħ ħ
¼ ψ ¼ ¼ iħ
i i
Since this value is iħ, we can say that the position and momentum operators do not commute. Since
these two operators do not commute, position and momentum cannot be measured precisely at the
same time. Position and momentum are an example pair of canonically conjugate
variables (Eq. 1.22). The commutative property of operators is discussed in section 2.6.2.5.
◄
In quantum mechanics, quasiparticles and collective excitations are two closely related behaviors.
They are used to describe the complex dynamics of strongly interacting particles in quantum systems
as simpler dynamics of quasi-independent particles in free space. An example is the motion of
electrons and holes in a semiconductor. The quasiparticles are not comprised of matter, but they
behave like elementary particles with some differences. Like ordinary matter, the quasiparticles can
be localized in space, and they can interact with other matter or with other quasiparticles. However,
they cannot exist outside a medium, whose elementary excitations like the spin waves are needed for
this existence. The term “quasiparticle” refers to fermions, and “collective excitation” refers to
bosons.
1.7.2 Phonons
In quantum mechanics, phonons are a type of vibrations in which the crystalline (lattice) structure of
atoms or the molecules of an element uniformly oscillate at a single frequency. Phonons are
quasiparticles that appear as collective excitations in condensed matter. The phonons play a vital
role in the thermal and electrical conductivity of an element. They also exhibit wave-particle duality.
28 1 Foundations of Quantum Mechanics
The electrons in a metal behave like free particles, and since they are all negatively charged, they
repel each other. However, they attract the positively charged ions, which make up the crystalline
structure (called lattice) of the metal. This attraction slightly distorts the lattice structure. As electrons
move, the lattice structure undergoes continual distortion. The collective motion of the lattice
structure is represented as phonons, and the interaction between the electrons and phonons results
in a small attraction between the electrons in a metal. The electrons thus pair up and behave like
single particles of spin 0 or 1. In other words, they behave like bosons and become the Bose-Einstein
Condensate. This pairing up of electrons is called Cooper Pairs / BCS Pairs. American physicist
Leon Cooper first announced this behavior in 1956. The interaction energy between the paired
electrons is quite low 103 eV, and hence this behavior can be seen only at very low temperatures.
The paired electrons in the condensate are called superconducting electrons, and the rest of the
electrons are called normal electrons. At a temperature lower than the critical temperature (TC),
there are very few normal electrons. As the temperature is increased, there are more normal electrons.
At the critical temperature, all electrons are normal electrons.
The paired-up electrons can be quite far apart—up to a few hundred nanometers or so since the
interaction is long-ranged. The electron pairs behave coherently. The characteristic distance their
number density can change is called coherence length (ξ). The wavefunction of the Cooper Pairs is
symmetric with integer spins. Therefore, more than one Cooper pair can be in the same state, a
property linked with superconductivity (a condition where the electrical resistivity vanishes) and
superfluidity (a condition where the viscosity of a fluid vanishes.) The American scientists John
Bardeen, Leon Cooper, and John Schrieffer developed the BCS theory of superconductivity for
which they won the Nobel prize in 1972.
In 2019, scientists at the Max Planck Institute in Germany announced superconductivity at 250 K
using lanthanum hydride under a pressure of 170 gigapascals. This is the highest temperature where a
substance exhibits superconductivity. Superconductivity at room temperature is not far away!
(Fig. 1.28).
1.7.4 Superconductors
In metals such as copper, the electrical resistance decreases gradually as the temperature is reduced.
The thermal coefficient of resistance is 0.00386 per degree C for copper. This means, if the
temperature changes by 1 C, the electrical resistance of copper changes by 0.386%.
In superconductors, the electrical resistance drops rapidly to zero at a critical temperature Tc. Since
there is no resistance, a superconducting loop can retain the electric current almost infinitely!
Superconductivity was first observed by the Dutch physicist Heike Kamerlingh Onnes in 1911.
Onnes also noticed that the superconductivity could be destroyed by applying an electrical current
above a certain critical value IC, or by applying a magnetic field above the critical field HC. It is
interesting to note that copper, silver, and gold are excellent electrical conductors that we know of,
but they do not exhibit superconductivity!
In 1933, W. Meissner and R. Ochsenfeld discovered another exciting property of
superconductors, called the Meissner effect. In their experiments, Meissner and Ochsenfeld found
that the superconductor expels the magnetic field. This effect is observed not only when the magnetic
field is increased at temperatures T < TC, but also when the superconductor is cooled from the normal
state with the magnetic field applied (Fig. 1.29). Depending upon how they behave in a magnetic
field, superconductors can be classified as type-I or type-II.
A type-I superconductor has a single critical magnetic field HC, above which superconductivity is
lost. If the magnetic field is less than the critical level, the superconductor expels the magnetic field.
The critical field is dependent upon the temperature of the superconductor, as described by the
following equation.
" 2 #
T
H C ðT Þ ¼ H C ð0Þ 1 ð1:23Þ
TC
The left-hand side of Fig. 1.30 illustrates the phase diagram of the type-I superconductor. Note that
the magnetic induction B ¼ 0 inside the superconductor. Technically, the magnetic field H does
penetrate the superconductor, up to a length called London’s magnetic field penetration depth,
denoted by λ, which is approximately about 100 nm. Screening currents flow in this region between
the surface and penetration depth, creating magnetization M inside the superconductor, which
balances the applied field H. Thus B ¼ 0 inside the superconductor.
As new alloys were tested for superconductivity, new behaviors were invented. It was found that in
some materials, two critical fields—the lower critical field strength HC1 and higher critical field
strength HC2 were found.
• When H < HC1, the superconductor behaves like a diamagnet, exhibiting the Meissner effect.
• In the range HC1 < H < HC2, it was found that the magnetic field penetrates the superconductor
forming small tubes called “vortices.” The vortices are quantized with the magnetic flux quantum
Φ0 ¼ 2eh
. When H is increased, the number and the density of vortices also increase.
• When H > HC2, the superconductor returns to the normal state.
Superconductors exhibiting this behavior are called type-II superconductors. The right-hand side
of Fig. 1.30 illustrates the phase diagram of the type-II superconductors.
Note that above HC1, the superconductor does not make a sudden switch into the normal state.
However, a thin cylindrical region of normal material appears to be passing through the material,
parallel to the axis of the field. This region is called the normal core. As the applied field is increased,
more of these normal cores appear, and they get more closely packed. When the applied field
reaches HC2, the material returns to its normal state. The state between HC1 and HC2 is called the
vortex state or the mixed state. Note that both HC1 and HC2 depend upon the temperature.
Figure 1.31 illustrates the vortices formed in a type-II superconductor in a magnetic field. Each
vortex contains one flux quantum. The core of the vortices contains normal electrons, and the
1.7 Some Exotic States of Matter 31
superconducting order parameter is zero at the center of the vortices. The coherence length ξ is a
function of the number of superconducting electrons ns. For type-II superconductors, the coherence
length ξ is generally lower than the penetration depth λ. For type-I superconductors, ξ > λ.
The superconducting wavefunction for a Cooper pair is asymmetric. It has components for the motion
around the center of mass (k), spin (S), and orbital (L ) angular momentum, in the order as shown in
the following equation.
ψ ðr 1 , σ 1 , r 2 , σ 2 Þ ¼ eikR f ðr 1 r 2 Þχ ðσ 1 σ 2 Þ
ð1:24Þ
¼ ψ ðr 2 , σ 2 , r 1 , σ 1 Þ
The spin states can be a “0” or “1.” The orbital angular momentum can have L ¼ 0 (s), L ¼ 1 (p),
L ¼ 2 (d), and L ¼ 3 (f) states. The order parameter of superconductivity Δ(k)eiϕ(k), where Δ(k)
is the superconducting gap, k is the momentum of the center of mass of the Cooper pair, and ϕ(k) is
the phase of the superconducting order. The superconducting gap is the energy required to break a
Cooper pair.
The spin-singlet is a state in which all the available electrons are paired. In an s-wave supercon-
ductor, the spin-singlet (S ¼ 0) states are caused when two electrons in a BCS pair have opposite
1 1
momenta ð and Þ . Due to this, the center of mass momentum (k) is zero. However, being
2 2
fermions, the electrons do not commute and can support only asymmetric exchange in Eq. (1.24).
Hence if the spin is asymmetric, the orbital angular momentum of the wavefunction must be
symmetric and vice versa.
When the spin wavefunction is asymmetric, the orbital wavefunction is symmetric and has even
parity (L ¼ 0, 2, 4. . .) denoting s, d, . . . states.
1
χ ðσ 1 , σ 2 Þ ¼ pffiffiffi ðj"#i j#"iÞ ð1:25Þ
2
When the spin wavefunction is symmetric, the orbital wavefunction is asymmetric and has odd
parity (L ¼ 1, 3, 5, . . .) denoting p, f, . . . states.
8
>
> j""i
>
>
< 1
χ ðσ 1 , σ 2 Þ ¼ pffiffiffi ðj"#i þ j#"iÞ ð1:26Þ
>
> 2
>
>
:
j##i
Here the arrows denote the direction of the spin, and the vertical bar together with the right-facing
angular bracket represents the ket vector in Dirac’s bra-ket notation. In the upcoming chapters, this
convention and the concept of spin shall be explained.
The bound state caused by the isotropic electron-electron interaction in an s-wave superconductor
is symmetric when the electrons change positions. This interaction only depends upon |k| and has
angular momentum L ¼ 0. The spin wavefunction is asymmetric with the spin-singlet state S ¼ 0,
L ¼ 0. The resulting spin-singlet Cooper pair is (k", k#). In this mode, the pairing wavefunction is
spherically symmetric. Δ(k) in an s-wave superconductor is a constant irrespective of the direction of
k and has the same phase in all directions, that is, isotropic. Spin-singlet states are characterized by a
32 1 Foundations of Quantum Mechanics
single spectral line arising due to the spin-singlet state. Elements such as Al, Nb, Pb exhibit s-wave
superconductivity.
We get a d-wave spin-singlet when S ¼ 0, L ¼ 2. The d-wave superconductor breaks rotational
symmetry and the phase changes by 180 degrees at the boundaries. In a d-wave superconductor, the
superconducting gap becomes zero in certain directions. Cuprate is an example of a high-temperature
d-wave superconductor.
A spin-triplet is a state with S ¼ 1, and hence the spin angular momentum can take three values
ms ¼ 1, 0, 1. Spin-triplet states are characterized by the threefold splitting of spectral lines. Spin-
triplet Cooper pairs are realized in 3 He (S ¼ 1, L ¼ 1). Strontium Ruthanate (Sr2RuO4) is another
example of a p-wave superconductor. In a p-wave superconductor, the electron-electron interaction is
mediated by magnetic spin fluctuations.
There is some evidence for f-wave (S ¼ 1, L ¼ 3) superconductivity in the exotic high-fermion
superconductor UPt3.
1.7.6 Anyons
Anyons are particles that exist in a two-dimensional space [4]. They are neither bosons nor fermions,
but something in between and can follow either of the two statistics. However, like fermions, they
cannot occupy the same space. Between two layers of Aluminum Gallium Arsenide, a thin layer of
two-dimensional electron gas (2DEG) forms at extremely cold temperatures. By cooling the 2DEG
further, in the presence of a strong magnetic field, anyons form out of the excitations (which we shall
discuss in Chap. 4) of the 2D lattice. Anyons have peculiar properties under particle exchange: they
are classified as abelian and non-abelian depending upon their behavior during particle exchange.
When we exchange two anyons, if they do not leave any measurable difference, except for a phase
factor, they belong to the abelian group. In systems with at least two degenerate ground states, the
exchange of two particles can rotate the state to another wavefunction in the same degenerate space.
Anyons of this type are non-abelian anyons. It is this property of non-abelian anyons that interests
quantum computing, and we shall explore this in detail in Chap. 4. Anyons have been observed in the
Fractional Quantum Hall Effect (FQHE), a quantum version of the Hall Effect. Recall that the
Hall effect produces the electrical voltage difference across an electrical conductor in a direction
transverse to the flow of the electric current and perpendicular to the direction of the magnetic field.
Under extremely cold temperatures in high-quality materials, the 2DEG exhibits collective states, in
which the electrons bind magnetic flux lines to form quasiparticles and excitations with fractional
elementary charges of magnitude e ¼ qe , q ¼ 3, 5, 7⋯ and the Hall conductance forms a series of
2
plateaus at fractional values of eh . This brings anisotropic features in the 2D space and a new
topological order exploited in the topological quantum computing.
Majorana Fermions are quasiparticle excitations, and they follow non-abelian statistics. The
Majorana fermions are antiparticle for themselves. These particles were first proposed by the Italian
physicist Ettore Majorana in 1937. The fermions defined in the Standard Model (Fig. 1.9) are all
Dirac’s fermions except in the case of neutrinos, which are unsettled. In the theory of Supersymme-
try, every boson has a fermion as the superpartner and vice-versa. The superpartners have the same
electric charge and a few other common properties, but they have different mass and spin. The
Practice Problems 33
hypothetical neutralinos are the superpartners for the gauge bosons and Higgs bosons, and they are
thought to be Majorana particles.
Majorana fermions are expected to be found as quasiparticles in superconductors, as a quasiparti-
cle is its antiparticle in a superconductor. Majorana bound states have been predicted to emerge as
localized zero-energy modes in superconductors, and there is some experimental evidence to this in
iron-based superconductors. The ground level degeneracy in the topological order of Majorana
fermions is a property used for realizing topological qubits. In Chap. 4, we shall discuss the
topological qubits in detail.
1.8 Summary
In this chapter, we learned about some of the building blocks of quantum mechanics. We started with
the definition of the matter and went on learning about what matter is made of. Quantization of
energy, wave-particle duality, and the probabilistic behavior of nature were the next few topics we
read about. We concluded this chapter by learning about wavefunctions, probability amplitudes, and
some exotic states of matter.
The following chapter is a math refresher that focuses on linear algebra and introduces Dirac’s
bra-ket notation.
Practice Problems
1. A source emits gamma rays of wavelength λ ¼ 3 1012 m. If a burst of gamma rays from the
source contained 2 J of energy, calculate the number of photons in the burst. (use: Planck’s
constant h ¼ 6.626 1034 Js and speed of light c ¼ 3 108 ms1.)
2. What is the minimum uncertainty in an electron’s speed, if the uncertainty of its position is
100 nm? (use: mass of electron ¼ 9:10938356 1031 kilograms.)
3. A quantum measurement experiment measures the position and wavelength of a photon simulta-
neously. The wavelength of the photon is measured to be 500 nm, with an accuracy of 106
6
(that is, Δλ
λ ¼ 10 ). What is the minimum uncertainty in the position of the photon.
4. Photons with energy 6.0 eV are incident on a photoelectric plate. This produces photoelectrons
with a kinetic energy of 3.2 eV. What is the work function of the photoelectric plate? If we double
the energy of the incident photons, does the kinetic energy of the emerging photoelectrons
double?
5. Describe the quantum numbers of all orbitals in the 4f subshell.
6. Write the ground state electron configuration of Silicon.
7. Calculate the energy and wavelength of the photon emitted, when an electron undergoes a
transition from its first excited state (n ¼ 2) to its ground state (n ¼ 1). (use: Energy of a particle
n2 h2
in an infinite potential well of width L and state n is given by: En ¼ 8mL 2 .)
8. A stationary electron is accelerated through a potential of 10 MeV. Find its de Broglie wave-
pffiffiffiffiffiffi
19
length. (use: Velocity of a charged particle is 2eV m where e ¼ 1.6 10 Coulombs.)
9. Light of wavelength 500 nm is incident on a double-slit with a distance 0.01 mm between the
slits. Calculate the angle made by the first order bright (constructive interference) fringe (n ¼ 1).
θ
(use: λ ¼ d sin
n .)
34 1 Foundations of Quantum Mechanics
10. In a double-slit experiment, the distance between the slits was d ¼ 0.2mm. The screen was kept at
a distance of L ¼ 1m from the slits. The second bright fringe was found at a distance of 5 cm from
the center. Find the wavelength of light used. (use: λ ¼ nLxd
.)
References
1. The Second Creation: Makers of the Revolution in Twentieth-Century Physics by Robert P. Crease, Charles C. Mann
(1986)
2. http://philsci-archive.pitt.edu/1717/2/Ludwig_Boltzmann.pdf
3. Wave Mechanics. For further reading, please refer the following text book: Quantum Wave Mechanics, 2/e, Larry
Reed, 2018.
4. Toric Codes and the theory of anyons – For further reading, Introduction to abelian and non-abelian anyons, Sumathi
Rao, 2016, https://arxiv.org/pdf/1610.09260.pdf
5. Weak Measurements: https://arxiv.org/ftp/arxiv/papers/1702/1702.04021.pdf, http://www-f1.ijs.si/~ramsak/
seminarji/KnaflicSibka.pdf, https://www.scientificamerican.com/article/particle-measurement-sidesteps-the-uncer
tainty-principle/
Dirac’s Bra-ket Notation and Hermitian
Operators 2
“Contrariwise,” continued Tweedledee, “if it was so, it might be; and if it were so, it would
be; but as it isn’t, it ain’t. That’s logic.”
― Lewis Carroll, Alice’s Adventures in Wonderland.
This chapter is a refresher course on linear algebra and probability theory. Those who have recently
studied quantum mechanics or linear algebra may skip this chapter and proceed to the following
chapters. For those who continue to read this chapter, the learning objectives are as follows:
2.1 Scalars
By definition, a scalar is a physical quantity described by a single field called magnitude, which
is mostly a real number. Scalars may have a unit of measure. Beyond the magnitude, scalars do not
have any other property.
Examples of scalars are mass of an object, speed of a vehicle, money in our wallet, marks scored in
the mid-term, and monthly salary.
A scalar is often represented by a lower-case letter.
We used the concept of complex numbers in Chap. 1 when we worked out the wavefunction of an
electron passing through two slits and hitting a screen. In this section, we shall briefly study the
complex numbers.
r
b
θ
Real axis (Re)
A complex number has two parts: a real and an imaginary part. The complex numbers are plotted
on a graph by representing the x-axis with the real part and the y-axis with the imaginary part.
Figure 2.1 shows this representation. In the rectangular form, the complex numbers are written as
a + ib where a and b are real numbers. a is the real part and ib is the imaginary part. i is an imaginary
pffiffiffiffiffiffiffi
number with a value i ¼ 1: Complex numbers are used to solve polynomial equations that real
numbers cannot solve.
In the polar form, the complex number is represented as r ∠ θ, which is to be read as r at angle θ.
Here r is the length (or norm) of the complex number, and θ is the angle the norm makes with the
horizontal axis. (Fig. 2.2).
The coordinates a and b can be written in terms of r and θ as:
a ¼ r cos θ
ð2:1Þ
b ¼ r sin θ
Complex numbers can also be expressed in exponential form. We shall request our readers to
work out the proof:
z ¼ reiθ , ð2:3Þ
De Moivre’s Theorem:
De Moivre’s theorem helps us to find the powers of complex numbers. For a complex number z and an
integer n, de Moivre’s theorem states that:
The complex conjugate of a number has the same real part; the imaginary part has the same
magnitude but opposite in sign.
For example, the complex conjugate of z ¼ a + ib is z ¼ a ib.
The following equation gives the norm or the length of a complex number:
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
j z j ¼ a2 þ b2 ð2:5Þ
The norm of a non-zero complex number is always a positive number. We can easily verify that the
square of the norm is equal to the product of the complex number and its conjugate:
2.3 Vectors
Vectors are quantities having both magnitude and direction. Examples are force, weight (the force
gravity exerts on a body), and velocity. Vectors are often represented using an upper-case letter or a
bold typeface. In a two-dimensional space, vectors are drawn as arrows; the arrows have a starting
point, and their length represents the magnitude.
In a 2D plane, the angle the vector makes from the x-axis in the anticlockwise direction is its
direction. A vector can also be written using its cartesian coordinates by measuring the horizontal and
!
vertical components. The vector in Fig. 2.2 can be written as A ¼ ½5, 4: The arrow above the letter
38 2 Dirac’s Bra-ket Notation and Hermitian Operators
Example 2.1
Row and Column Vectors
2 3
5
6 7
647
6 7
! ! 6 7
A ¼ ½5, 4, 3, 2, 1 is a row vector. A ¼ 6 7
6 3 7 is a column vector.
6 7
627
4 5
1
◄
Two vectors can be added or subtracted by adding or subtracting the components of the two vectors.
Let,
!
V ¼ ½v1 , v2 , v3 , and ð2:9Þ
!
U ¼ ½u1 , u2 , u3 then ð2:10Þ
! !
V U ¼ ½v1 u1 , v2 u2 , v3 u3 ð2:11Þ
Vector addition and subtraction can also be done graphically by using the head-to-tail method. To
add, we draw the first vector from the origin. The second vector is drawn by placing its tail on the head
of the first vector. If there are more vectors to be added, we follow the same process. Finally, we draw
the vector sum from the origin to the head of the last vector. The vector sum is shown in Fig. 2.3.
2.3 Vectors 39
Subtraction is done similarly, but by flipping the direction of the second vector. Vector subtraction
is shown in Fig. 2.4.
Vectors exhibit two different properties of multiplication. Two vectors can be multiplied to produce a
scalar result, or they can be multiplied to produce a vector result. We shall study both these two
methods in the following sections.
If v ¼ [v1, v2, . . ., vn] and w ¼ [w1, w2, . . ., w], then the dot product of v and w is defined as:
X
n
vw¼ vi w i ð2:12Þ
i¼1
If θ is the angle between the two vectors, then the dot product can be written as:
where jvj and jwj are the magnitude of the two vectors v and w.
where jvj and jwj are the magnitude of the vectors v and w. nb is a unit vector perpendicular to the plane
containing v and w. The direction of nb is defined by the right-hand rule. (Fig. 2.6).
The vector product is anticommutative and distributive over addition, that is,
v w ¼ w v
ð2:15Þ
u ðv þ wÞ ¼ u v þ u w
We can show that the unit vectors we saw earlier satisfy the following cross product relations:
i j ¼ k, j i ¼ k
j k ¼ i, k j ¼ i
ð2:16Þ
k i ¼ j, i k ¼ j
ii¼jj¼kk ¼0
2.4 Matrices 41
2.4 Matrices
In the above matrix, the numbers aij are its elements (row i, column j). The dimension of the matrix
is m n. The matrix is called a square matrix if m ¼ n. We can easily figure out that a matrix of
dimensions m 1 is a column vector, and a matrix of dimensions 1 n is a row vector. With this
definition, let us revise some of the key properties of matrices.
Equality: Two matrices are equal if they both have the same dimensions, and the corresponding
elements are the same.
That is, given two matrices A and B, A ¼ B if and only if aij ¼ bij; 8 i and j.
Scalar Multiplication: In order to multiply a matrix by a scalar, we have to multiply all the elements
of the matrix by the scalar.
42 2 Dirac’s Bra-ket Notation and Hermitian Operators
Example 2.2
Scalar Multiplication of a Matrix
If B ¼ αA, where α is a scalar, then bij ¼ αaij; 8 i and j.
3 2 53 52 15 10
5 ¼ ¼ ð2:18Þ
0 1 5 0 5 ð1Þ 0 5
Addition and Subtraction: We can add or subtract two matrices of the same dimensions by
individually adding or subtracting the elements.
If C ¼ A + B then cij ¼ aij + bij.
Example 2.3
Matrix Addition
4 3 2 6 4þ2 3þ6 6 9
þ ¼ ¼ ð2:19Þ
1 5 7 3 1 þ 7 5 þ ð3Þ 6 2
Subtraction can be thought of as adding the negative. The following properties are applicable for
matrix additions:
A þ B ¼ B þ A ðCommutative Property of additionÞ
ð2:20Þ
A þ ðB þ CÞ ¼ ðA þ BÞ þ C ðAssociative PropertyÞ
Multiplication of Two Matrices: The product C of two matrices A with dimension m p and B
with dimensions p n yields an m n matrix. This is given by the formula:
X
p
cij ¼ aik bkj ð2:21Þ
k¼1
Example 2.4
Matrix Multiplication
2 3 5 3 4
Consider ð2:22Þ
4 5 2 1 6
25þ32 23þ31 24þ36
¼ ð2:23Þ
45þ52 43þ51 44þ56
16 9 26
¼ ð2:24Þ
30 17 46
◄
2.4 Matrices 43
It must be noted that the multiplication of two matrices is generally not commutative. This means
AB 6¼ BA.
The following properties are applicable for matrix multiplication:
AðBCÞ ¼ ðABÞC ðAssociative PropertyÞ
ð2:25Þ
AðB þ CÞ ¼ AB þ AC ðDistributive PropertyÞ
The Identity Matrix: The identity matrix I is a square matrix with 1’s along the diagonal and 0’s at
other places.
2 3
1 0 0
6 7
I3 ¼ 4 0 1 05 ð2:26Þ
0 0 1
AI ¼ IA ¼ A ð2:27Þ
The Transpose of a Matrix: AT denotes the transpose of a matrix A and it is obtained by swapping
the rows with columns, that is, aTij ¼ aji :
Example 2.5
Transpose of a Matrix
The following example is a matrix composed of complex numbers:
2 3
1 þ 3i 5 2i
6 7
Let A ¼ 4 6 3i 3 þ 5i 5 ð2:28Þ
5 þ 7i 4 þ 2i
1 þ 3i 6 3i 5 þ 7i
A ¼
T
5 2i 3 þ 5i 4 þ 2i
ðABÞT ¼ BT AT ð2:29Þ
The Trace (Tr) of a Square Matrix is defined as the sum of its diagonal elements. This is defined
by the following equation:
X
Tr ðAÞ ¼ aii ð2:30Þ
i
44 2 Dirac’s Bra-ket Notation and Hermitian Operators
Example 2.6
The trace of the following matrix is:
1 3
Tr ¼1þ5¼6 ð2:31Þ
4 5
Exercise 2.1
Prove that Tr(I) = n
◄
Exercise 2.2
Prove that Tr(AB) = Tr(BA)
◄
The Determinant of a Matrix: The determinant of a matrix is a scalar value derived from the
elements. The determinant of a matrix is considered the volume enclosed by the row vectors of the
matrix. This property is applicable only for square matrices, and two encapsulating vertical bars are
used to denote a determinant. The determinant of a 2 2 matrix is defined by the following equation.
a b
detðAÞ ¼ jAj ¼ ¼ ad bc ð2:32Þ
c d
Calculating the determinant of a 3 3 matrix follows a similar method outlined by the following
equation:
a b c
e f
b d f þ c d e
jAj ¼ d e f ¼ a ð2:33Þ
g h i
h i g i g h
A similar method can be used for matrices of a higher order. Determinants have the following
properties, and these can be easily verified.
1. det(I ) ¼ 1
2. det(AT) ¼ det (A)
3. det(AB) ¼ det (A) det (B)
4. detðA1 Þ ¼ detðAÞ
1
, det (A) 6¼ 0
5. det(cA) ¼ cn det (A) where n is the dimension of the matrix.
The Adjugate of a Matrix: The adjugate of a matrix is the transpose of its cofactor. The cofactors of
a matrix are obtained by taking out the intersecting row and the column of a given element, as shown
below, and forming a new matrix. Note the alternating signs. The cofactor of a 3 3 matrix is
calculated as follows:
2.4 Matrices 45
2 3
a b c
6 7
Let A ¼ 4 d e f5 ð2:35Þ
g h i
Exercise 2.3
Prove that adj(I) = I
◄
The Inverse of a Matrix: The inverse of a square matrix A is denoted by A1, and it satisfies the
following relation:
One way to find the inverse of a matrix is through its adjugate matrix. This is shown in the
following equation:
1
A1 ¼ adjðAÞ ð2:39Þ
j Aj
The Symmetric Matrix: A matrix A is symmetric if AT ¼ A, that is, aij ¼ aji 8 i and j.
The Self-Adjoint Matrix: A matrix A is self-adjoint if A ¼ A, that is, aij ¼ aji 8 i and j.
46 2 Dirac’s Bra-ket Notation and Hermitian Operators
Note that A is the conjugate transpose of A. We obtain this by taking the complex conjugate of
each element in A and then transposing.
The bar on a denotes the complex conjugation, a superscript of * is also used to denote the
complex conjugation.
The following is a Hermitian matrix.
2 3
2 3 i2 6 þ i5
6 7
4 3 þ i2 1 4þi 5 ð2:42Þ
6 i5 4 i 5
Note that the diagonal elements are real, as they have to be self-conjugate.
In quantum mechanics, most operators are Hermitian. We shall return to this subject and examine
the properties of Hermitian operators in later sections.
Unitary matrices are complex square matrices whose Hermitian conjugate is also their inverse.
Hence, they satisfy the following condition:
AAy ¼ Ay A ¼ I ð2:43Þ
2.5 Linear Vector Spaces 47
The following set of three matrices with dimensions 2 2 are called Pauli matrices. They are used to
represent spin angular momentum, which we shall look in detail in Chap. 3. In quantum computing,
we use Pauli matrices to set the rotational parameters for qubits and measure quantum errors.
0 1
σ1 ¼ σx ¼ X ¼ ð2:44Þ
1 0
0 i
σ2 ¼ σy ¼ Y ¼ ð2:45Þ
i 0
1 0
σ3 ¼ σz ¼ Z ¼ ð2:46Þ
0 1
Exercise 2.4
Prove that the Pauli matrices are traceless, Hermitian, and unitary.
◄
Exercise 2.5
Prove that the Pauli matrices satisfy the following equation.
X2 þ Y 2 þ Z 2 ¼ I ð2:47Þ
We shall revisit Pauli matrices when we discuss spin angular momentum, and the gate model of
quantum computing.
We now have sufficient background to learn about vector spaces, and start using Dirac’s bra-ket
notation.
A linear vector space is a collection of vectors that meets the following conditions:
In these definitions, we have used the Dirac’s ket notation j i denoted by the vertical bar, and the
right facing angular bracket. The ket represents a column vector, and we shall learn this a bit more in
subsequent sections.
The scalars a, b, c, . . . belong to the field F over which the vector is defined.
If the field is composed of all real numbers, then the vector space is a Real Vector Space ℝ. If it is
composed of complex numbers, then it is a Complex Vector Space ℂ.
A finite set of vectors { jv1i, jv2i, jv3i, . . ., jvni} are said to be linearly dependent, if there exists a
set of corresponding scalars {a1a2, a3, . . ., an} with at least one of them having a non-zero value, such
that:
X
n
ai jvi i ¼ j0i ð2:48Þ
i¼1
The vector jv1i is said to be in a linear combination of other vectors. This is an important property
we shall use when we describe the Quantum Superposition Principle.
A vector space of n linearly independent vectors is said to have a dimension of n. It is written as n.
More specifically, ℝn for real vector spaces and ℂn for complex vector spaces.
It must be noted that a vector jVi in an n-dimensional vector space can be written as a linear
combination of n linearly independent vectors { jv1i, jv2i, jv3i, . . ., jvni}.
2.5.2.1 Basis
A set of n linearly independent vectors in an n-dimensional vector space is called a basis.
X
n
jVi ¼ ai jvi i ð2:50Þ
i¼1
Here, the vectors jvii form a basis, labeled by the integers i ¼ 1, 2, 3, . . . . The coefficients ai are
called the components of the state vector jVi on the basis jvii. The components are usually complex
numbers.
2.5 Linear Vector Spaces 49
X
n
jV 2 i ¼ bi jvi i then ð2:53Þ
i¼1
X
n
jV 1 i þ jV 2 i ¼ ðai þ bi Þ jvi i ð2:54Þ
i¼1
The inner product or the scalar product of two vectors jXi and jYi is denoted by the notation hXj Yi.
The inner product has the following properties.
1. hXjYi ¼ hYjXi
2. Positive Definite Property: hXjXi 0, where the equality holds iff jXi ¼ j0i.
3. hαXjYi ¼ αhXjYi
4. Linearity: hX + YjZi ¼ hXjZi + hYjZi
5. hXjY + Zi ¼ hXjYi + hXjZi
6. hX + YjX + Yi ¼ hXjXi + hXjYi + hYjXi + hYjYi
The inner product produces a scalar value, in most cases, a complex number, and it is equivalent to
the dot product in vectors.
50 2 Dirac’s Bra-ket Notation and Hermitian Operators
X
n
jV b i ¼ b j v j ð2:58Þ
j¼1
Then the inner product of the two vectors can be written as:
XX
hV a jV b i ¼ ai b j vi jv j ð2:59Þ
i j
If the basis vectors jvii and jvji are orthonormal, then the following relation holds good:
(
1, i ¼ j
vi jv j ¼ ¼ δij : ð2:60Þ
0, i 6¼ j
The function δij is known as the “Kronecker” delta function. This function gives a value of 1 if the
variables i and j are the same. Otherwise, the function returns a value of 0.
By applying this in the previous Eq. (2.59), we get:
X
hV a jV b i ¼ ai bi ð2:61Þ
i
Since both the vectors jVai and jVbi are uniquely specified by their respective components in the
respective basis, we can write jVai and jVbi as column vectors.
2 3 2 3
a1 b1
6a 7 6b 7
6 27 6 27
jV a i ¼ 6 7 and jV b i ¼ 6 7 ð2:62Þ
4⋮5 4⋮5
an bn
The inner product of the two vectors jVai and jVbi can be written as the product of the transpose
conjugate of jVai and jVbi.
2.6 Using Dirac’s Bra-ket Notation 51
2 3
b1
6 7
6 b2 7
hV a jV b i ¼ a1 a2 ⋯ an 6 7 ð2:63Þ
4⋮5
bn
This means the basis vectors are all possible values of x, which is an important property in
quantum mechanics.
Example 2.7
3 4
Assume jVi in a subspace ℝ with the basis
2
, : Find an orthonormal basis of jVi.
2 6
Solution:
3 4
Let v1 ¼ and v2 ¼ ð2:65Þ
2 6
Let us first check if they are orthogonal by verifying the inner product.
4
hv1 jv2 i ¼ ½ 3 2 ¼ 3 4 þ 2 6 ¼ 0 ð2:66Þ
6
The inner product is zero, hence they are orthogonal. The set {v1, v2} is an orthogonal basis for
jVi. We can now normalize {v1, v2} to get the orthonormal basis.
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffi
jv1 j ¼ 32 þ 22 ¼ 13
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffi pffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffi ð2:67Þ
jv2 j ¼ 4 þ ð6Þ2 ¼ 52 ¼ 4 13 ¼ 2 13
Exercise 2.6
Prove that the vectors of the standard basis are orthogonal.
◄
In the preceding sections, we have seen the process of writing an abstract vector jVi as a column
vector in a basis jvii. This we can call as ket jVi,and we can write it as:
52 2 Dirac’s Bra-ket Notation and Hermitian Operators
2 3
a1
6a 7
6 27
jVi ¼ 6 7 ð2:69Þ
4⋮5
an
We have also seen how to take the adjoint (transpose conjugate) of jVi and write it as a row vector.
We can call the conjugate transpose vector as bra hVj on the basis hvij. We can write the bra hVj as:
Thus, for every ket vector, there is a corresponding bra vector and vice-versa. Together, the bra
and ket vectors form dual vector spaces.
In a given basis, we can write this linear conversion from the ket to the bra and vice-versa as:
2 3
a1
6a 7
6 27
jVi ¼ 6 7 $ ½ a1 a2 ⋯ an ¼ hVj ð2:71Þ
4⋮5
an
The basis ket jvii can be written as a column matrix with the ith component being “1” and the rest
“0.” Similarly, the basis bra hvij can be written as a row matrix with the ith component being “1” and
the rest “0.”
Hence, the ket jVi can be written as:
X
n
jVi ¼ ai jvi i ð2:72Þ
i¼1
2 3 2 3 2 3
1 0 0
6 0 7 6 1 7 6 0 7
6 7 6 7 6 7
jVi ¼ a1 6 7 þ a2 6 7 þ ⋯ þ an 6 7 ð2:73Þ
4⋮5 4⋮5 4⋮5
0 0 1
With this introduction about bra and ket vectors, we can now move on to study operators and their
properties.
2.6.1 Operators
An operator is a rule that transforms a vector jVi into another vector jV0i. For simplicity, in this book,
we shall assume that the transformation happens in the same vector space. We can write this
transformation as follows:
bjVi ¼ jV 0 i
O ð2:74Þ
b ¼ hV 0 j
hVjO ð2:75Þ
2.6.2.6 Anticommutator
The anticommutator of two operators is:
n o
b Pb ¼ O
O, bPb þ PbO
b ð2:82Þ
n o
b Pb ¼ 0
Then O,
Exercise 2.7
Prove the Table 2.1 of commutators and anticommutators of the Pauli matrices.
◄
Example 2.8
Prove that any matrix that commutes with all the three Pauli matrices is a multiple of the Identity
matrix.
Solution:
Any 2 2 matrix can be written as a linear combination of the Pauli matrices.
" #
a b
M¼
c d ð2:83Þ
1
¼ ða þ dÞI þ ðb þ cÞσ x þ ðb cÞσ y þ ða dÞσ z
2
Recall the following facts.
• The Identity matrix I commutes with all matrices, including the three Pauli matrices.
• From Table 2.1, Pauli matrices do not commute among themselves.
Since the Pauli matrices do not commute among themselves, M cannot have any component from
the Pauli matrices. Hence, (b þ c) ¼ (b c) ¼ (a d) ¼ 0. This means b ¼ c ¼ 0 and a ¼ d.
Hence from Eq. (2.83), we can say that any matrix that commutes with all three Pauli matrices
must be a multiple of the Identity matrix.
◄
2.6.2.7 Power
The nth power of an operator is obtained by successively applying the operator n times.
O bO
b3 jVi ¼ O bO
bjVi ð2:84Þ
The operators that we use in quantum mechanics are all linear operators, they can be written in a
matrix form, and they meet the following criteria:
b jVi ¼ aO
Oa bjVi ð2:85Þ
2.6 Using Dirac’s Bra-ket Notation 55
bðjVi þ jWiÞ ¼ O
O bjVi þ O
bjWi ð2:86Þ
Example 2.9
Prove that the momentum operator given in the following equation is linear.
d
pb ¼ iħ ¼ iħ∇ ð2:87Þ
dx
Solution:
From Eq. (2.85), we can write the action of the momentum operator on ajVi as:
d d
iħ ajVi ¼ iħa jVi ð2:88Þ
dx dx
Using the sum law of differentiation, we can derive,
d d d
iħ ðjVi þ jWiÞ ¼ iħ jVi iħ jWi ð2:89Þ
dx dx dx
This proves the Eq. (2.86). Hence, we can say that the momentum operator is linear.
◄
b such that
If there exists an operator P,
bPb ¼ O
O bOb1 ¼ I ð2:93Þ
Let us now learn about the concept of Hermitian operators. Assume two arbitrary vectors jVai and
jVbi on a given basis.
It is a practice in quantum mechanics to write the bra and ket vectors using the subscript (or the
label) only and moving forward, we shall adopt that convention.
56 2 Dirac’s Bra-ket Notation and Hermitian Operators
Adopting the subscript (label) convention and following the expansion of arbitrary vectors from
Eq. (2.50), we can write these two vectors:
X
n X
n
jai ¼ a j j ji, jbi ¼ b j j ji ð2:95Þ
j¼1 j¼1
Due to the orthonormality of the basis vectors and j, hij ji ¼ δij. Hence, we can write the matrix
elements:
b
Oij ¼ hijOjji ð2:98Þ
We shall return to the integral form a little later in the derivation. Note that we have now switched
to using the subscript (label) convention. We can also write this equation in the matrix form as:
2.6 Using Dirac’s Bra-ket Notation 57
2 32 3
O11 O12 ⋯ O1n b1
6O ⋯ O2n 7 6 b2 7
7 6
6 21 O22 7
¼ ½ a1 a2 ⋯ an 6 76 7 ð2:103Þ
4 ⋮ ⋮ ⋯ ⋮ 5 4⋮5
On1 On2 ⋯ Onn bn
Let us now apply this logic to basis vectors jii and jji.
y
^ ¼ hijO^ ji
hOijji ð2:105Þ
y
^ ¼ hijO^ ji
hjjOii ð2:106Þ
This representation is nothing but the conjugate transpose of the same matrix O. From our earlier
discussion on Hermitian matrices, we can say that matrix O is a Hermitian matrix.
O ¼ Oy ð2:108Þ
In other words, the operator O b is a Hermitian operator. In quantum mechanics, all observables
are represented by Hermitian operators.
Returning to the integral form, it follows that integration over an infinite space is a requirement of
a Hermitian operator.
ð ð
b
ψ j ðxÞO ψ i ðxÞdx ¼ ψ i ðxÞ Ob ψ j ðxÞ dx ð2:109Þ
hijOjji ^ ; 8i and j
^ ¼ hjjOjii ð2:110Þ
Example 2.10
Prove that the position operator b
x is Hermitian.
Solution:
Let us start with the following equation.
ð
ψ j ðxÞb
x ψ i ðxÞdx ð2:111Þ
QED.
◄
Example 2.11
Prove that the momentum operator b
p is Hermitian.
Solution:
ð ð
d
ψ j ðxÞb
p ψ i ðxÞdx ¼ ψ j ðxÞ iħ ψ i ðxÞ dx ð2:114Þ
dx
ð
¼ iħ ψ j ðxÞ dψ i ðxÞ ð2:115Þ
Ð Ð
By integrating by parts (that is, using u dv ¼ uv v du)
h ix¼1 ð
¼ iħ ψ j ðxÞψ i ðxÞ ψ i ðxÞ dψ j ðxÞ ð2:116Þ
x¼1
Since the wavefunction vanishes at infinity, the first term is zero. We can now write this as:
ð
¼ iħ ψ i ðxÞ dψ j ðxÞ Þ ð2:117Þ
d
Since iħ dx ¼ iħ d
dx , we can write as:
ð
¼ ψ i ðxÞ pbψ j ðxÞ dx ð2:118Þ
QED.
◄
Example 2.12
b is Hermitian.
Prove that the Hamiltonian operator H
Solution:
For a single particle system, the Hamiltonian operator can be written as:
2.6 Using Dirac’s Bra-ket Notation 59
b ¼ pb þ VbðxÞ ¼ Tb þ Vb
2
H ð2:119Þ
2m
Since Vb is a function of x, it becomes Hermitian by default. So, we must prove that the Potential
Energy Operator Tb is Hermitian.
ð ð
1
ψ j ðxÞTb ψ i ðxÞdx ¼ ψ j ðxÞp2 ψ i ðxÞdx ð2:120Þ
2m
QED.
◄
by ¼ U
Ub U by Ub ¼ I ð2:122Þ
Exercise 2.8
Prove that if H is a Hermitian matrix, then there exists a unitary matrix U, such that the matrix
UyHU is diagonal.
◄
Exercise 2.9
If A and B are two operators, prove that (AB)y ¼ By Ay.
◄
Consider an operator (jii hij),which is made up of the outer product of a ket vector and a bra vector in
an orthonormal basis. We call this outer product the projection operator Pi of the ket jii. Applying
the projection operator to an arbitrary vector jVi, we get:
From this equation, we can understand that Pi acting on jVi multiplies the components ai of jVi by
a factor of jii. This is a sort of projection of the components of jVi along jii. Due to this reason, Pi is
called a projection operator along jii.
Projection operators can also work on the bra vectors in a similar fashion:
hVjPi ¼ hVjiihij ¼ ai hij ð2:124Þ
We can write jVi as an expansion of the projection operator in a given orthonormal basis in a given
vector space.
X
n
jVi ¼ jiihij jVi ð2:125Þ
i¼1
This is not possible unless the sum of the ket-bra operator behaves like an identity operator.
X
n X
n
jiihij ¼ I ¼ Pi ð2:126Þ
i¼1 i¼1
This equation illustrates an important property that the sum of all projection operators is the
identity operator itself.
This equation is called “completeness relation” for the chosen orthonormal basis. This equation is
also called “resolution of the identity.”
This property is a condition for a Hermitian operator to be a projection operator. Let us examine
this property:
Pi Pi ¼ jiihijiihij ¼ jiihij ¼ Pi ð2:127Þ
This means that once we project jVi along jii, further projections along jii makes no difference.
Property 3: Once projected along jii, further projections on another perpendicular direction jji
results in zero.
To test this property, let us apply the projection Pi first and then Pj.
Pi P j ¼ jiihijjih jj ¼ δij P j ð2:128Þ
Once we project out along jii, further projection along a perpendicular axis jji results in a zero as
there are no more components in that direction. Since i 6¼ j, this equation results in a zero.
We use this property in quantum communications to measure light polarized in one direction.
Exercise 2.10
If P is a projection operator, prove that (1 P) is also a projection operator.
◄
In Chap. 1, we learned that the probability of finding a quantum system could be written as the square
of the probability amplitude, as shown in the following equation.
where hxi denotes the expectation value of the position x, and xb denotes the position operator. The
expectation value is the average measurement of x for the quantum state ψ. Like the average value of
a fair 6-faced dice, 3.5, representing an impossible outcome, the expectation value hxi does not need
to make physical sense.
Equation (2.130) can be rewritten:
ð
þ1
This can also be written conveniently using the Dirac’s bra-ket notation as:
hxi ¼ hψjb
xjψ i ð2:133Þ
The various measurements of the position x are scatted around hxi, as this is described by the same
wavefunction. The degree of the scatter is termed as the variance of x, and it is given by the following
relation:
σ 2x ¼ x2 hxi2 ð2:134Þ
The square root of this quantity σ x is known as the standard deviation of x. The concept of
expectation value applies to any observable in the quantum system.
Interested readers can explore quantum errors in qubits as variances in measurement and develop
new logic for quantum error correction.
In a quantum system where we are deterministically able to measure the qubits, the standard
deviation of the measurement σ ¼ 0. Note that a quantum measurement collapses the wavefunction,
and the qubit is localized.
We have learned that when a linear operator O b acts on a ket jVi, it transforms that ket into a new ket
0
jV i. It is needless to say that, unless the operator is an identity operator or a multiple of identity, the
transformed ket will be in a different shape.
62 2 Dirac’s Bra-ket Notation and Hermitian Operators
There may be certain kets, such that the action of an operator results in a linear multiple of the ket.
Mathematically, this is written as the following equation:
bjψ i ¼ ajψ i
O ð2:135Þ
Such kets are known as eigenkets. In the above example, jψi is an eigenket of the operator O.b The
wavefunction ψ is called eigenstate. This is because the ket in the Eq. (2.135) is independent of any
observable. When we project this ket into an observable basis (say position or momentum), ψ
becomes a function of that observable. In such cases, ψ is called an eigenfunction. The value a is
the eigenvalue. Such equations, which produce scalar times a function, are known as eigenvalue
equations. The set of eigenvalues of an operator are called its spectrum. Note that the eigenvalues of
an operator need not be distinct. The eigenvectors corresponding to the distinct eigenvalues form a
sub-space called the eigenspace.
Example 2.13
Time Independent Schr€
odinger Equation (TISE)
The general form of the time-independent Schr€
odinger equation is given by the following
equation:
b ¼ Eψ,
Hψ ð2:136Þ
where, Hb is the Hamiltonian operator of the eigenfunction ψ. E is the eigenvalue. In this equation,
the Hamiltonian operates upon the wavefunction to produce energy (which is a scalar) times the
wavefunction. This is an example of an eigenvalue equation.
Supposing that Ob be a Hermitian operator corresponding to a physical observable O, ψ a be the
eigenstate and a be the eigenvalue, we can then write the expectation value of O from Eq. (2.132):
ð
þ1 ð
þ1
hO i ¼ ψ a b ψ dx ¼ a
O ψ a ψ a dx ¼ a ð2:137Þ
a
1 1
Similarly,
ð
þ1 ð
þ1
2
O ¼ b ψ dx ¼ a2
ψ a O
2
ψ a ψ a dx ¼ a2 ð2:138Þ
a
1 1
σ ¼ O2 hOi2 ¼ a2 a2 ¼ 0 ð2:139Þ
Since the variance is zero, we can deterministically measure the quantity O to the same value a.
It also implies that the eigenstate ψ a is uniquely attached to the eigenvalue a for the Hermitian
b
operator O:
When two eigenstates ψ a and ϕa of the same Hermitian operator O b correspond to the same
eigenvalue a, then the eigenstates are said to be degenerate. Besides, the eigenstates ψ a and ϕa of
a Hermitian operator, corresponding to different eigenvalues a1 and a2 are orthogonal.
◄
2.8 Eigenstates, Eigenvalues, and Eigenfunctions 63
Example 2.14
Prove that the eigenvalues of a Hermitian operator are all real.
Solution:
From (2.109) for Hermitian operators,
ð ð
b ψ ðxÞdx ¼ ψ ðxÞ O
ψ j ðxÞO b ψ ðxÞ dx ð2:140Þ
i i j
If we assume ψ i(x) ¼ ψ j(x) ¼ ψ and if we assume ψ is normalized, then by referring to (2.137) this
equation reduces to
a ¼ a ð2:141Þ
Let us consider two eigenfunctions ψ i(x) and ψ j(x) of Hermitian operator O b with corresponding
eigenvalues ai and aj.
Since Ob is Hermitian, the eigenvalues are all real. Besides, the eigenfunctions are orthogonal, if
ai6¼ aj.
ð
ψ i ðxÞψ j ðxÞ ¼ 0 ð2:142Þ
where the weights a1, a2 are complex numbers and normalized constants. ψ i(x) are properly
normalized (that is, mutually orthogonal) eigenfunctions.
This property is generalized as the “Quantum Superposition” principle, which we shall explain
in the next chapter. ψ(x) can now be written as:
X
n
ψ ðxÞ ¼ ai ψ i ðxÞ, ð2:144Þ
i¼1
Condition Number:
The condition number of a symmetric matrix is the ratio between its maximum and minimum of
max ðλi Þ
the eigenvalues (that is, min ðλ9 Þ, where λi are the eigenvalues.)
64 2 Dirac’s Bra-ket Notation and Hermitian Operators
The characteristic polynomial of a square matrix is a polynomial, whose roots are the eigenvalues of
the square matrix.
By definition, for a given square matrix A, we can say that λ is its eigenvalue, if there exists a
non-zero vector v, called eigenvector such that:
Av ¼ λv ð2:146Þ
ðA λI Þv ¼ 0 ð2:147Þ
Example 2.15
Find the eigenvalues and eigenvectors of the Pauli matrices.
Solution:
The Pauli matrices are given by the Eqs. (2.44), (2.45), and (2.46).
The first Pauli matrix is given by:
0 1
X¼ ð2:148Þ
1 0
From our discussions in the previous section, the determinant of the characteristic equation of X is:
0 1 λ 0 λ 1
jX λI j ¼ ¼ ð2:149Þ
1 0 0 λ 1 λ
¼ λ2 1 ¼ ðλ þ 1Þ ðλ 1Þ ð2:150Þ
This implies that the eigenvalues of X are +1 and 1. To find the eigenvector, we substitute the
values of λ, into the characteristic equation. For λ ¼ + 1, this equation is:
1 1 v1 0
¼ ð2:151Þ
1 1 v2 0
v1 þ v2 ¼ 0
ð2:152Þ
v1 v2 ¼ 0
1
Solving this, we get v1 ¼ 1 and v2 ¼ 1. Hence, the eigenvector is . This eigenvector can be
1
normalized. The norm of this eigenvector is:
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
1 pffiffiffi
¼ 12 þ 12 ¼ 2 ð2:153Þ
1
2.10 Definite Symmetric Matrices 65
1
The normalization constant is p1ffiffi2. Hence, the eigenvector for λ ¼ + 1 is p1ffiffi2 . Now let us try this
1
for λ ¼ 1.
1 1 v1 0
¼ ð2:154Þ
1 1 v2 0
1
Here again, the normalization constant is p1ffiffi2. Hence, the eigenvector for λ ¼ 1 is p1ffiffi2 .
1
Likewise, we can calculate the eigenvalue and eigenvectors for the rest of the Pauli matrices.
Table 2.2 summarizes these values.
◄
2.11 Tensors
Tensors are mathematical objects that are used to describe physical properties, such as elasticity and
electrical conductivity in physics. Tensors obey certain transformation rules about the physical
properties they represent and are considered generalizations of scalars, vectors, and matrices. A
scalar is a tensor of rank (or order) zero. A vector is a tensor of rank one. The rank of a tensor is the
number of directions (and hence the dimensionality of the matrix) required to describe the object it
represents. A tensor of rank n in an m dimensional space has n indices and mn components. A scalar
has zero indices, and a vector has one index.
Recall our earlier discussions that a vector can be described in terms of basis (refer Eq. (2.50))
vectors. Let us consider two vectors jVi and jWi that are expanded in some orthonormal basis {jii}
and {jji} respectively, as shown in the following equation.
X
n
jV i ¼ vi jii
i¼1
X
m ð2:157Þ
jW i ¼ w j j ji
j¼1
These two vectors can be expanded as elements of the direct sum by filling the unused entries as
zeros making a total of n + m elements in each.
2 3 2 3
v1 01
6 v2 7 6 02 7
6 7 6 7
6 7 6 7
6⋮7 6⋮7
6 7 6 7
6v 7 60 7
6 n7 6 n7
jVi ¼ 6 7 and jWi ¼ 6 7 ð2:159Þ
6 01 7 6 w1 7
6 7 6 7
60 7 6w 7
6 27 6 27
6 7 6 7
4⋮5 4⋮5
0m wm
3 2
v1
6 v2 7
6 7
6 7
6⋮7
6 7
6v 7
6 n 7
jVi jWi ¼ 6 7 ð2:160Þ
6 w1 7
6 7
6w 7
6 27
6 7
4⋮5
wm
Example 2.16
2 3
3
1 6 7
If jVi ¼ and jWi ¼ 4 4 5, find the direct sum jVi jWi .
2
5
Solution:
2 3
1
2 3 6 7
3 627
1 6 7 6 7
jVi jWi ¼ 445 ¼ 6
637
7 ð2:161Þ
2 6 7
5 445
5
The tensor product is also known as Kronecker product or the direct product. We use the tensor to
describe the system state of two or more qubits (Chap. 5). For the two vectors we used in the previous
section, let us define a new set of basis vectors nm, which is defined by the tensor product i j of the
basis vectors. This space is bilinear, meaning it is linear in both jVi and jWi. We can write the tensor
product of jVi and jWi as:
P
n P
m
jVi jWi ¼ vi jii wj jji
i¼1 j¼1
ð2:162Þ
P
n P
m
¼ vi wj ðjii jjiÞ
i¼1 j¼1
This equation can be interpreted as a vector jVi jWi that spans a basis vector jii jji whose
coefficients are viwj. The following equation describes this.
68 2 Dirac’s Bra-ket Notation and Hermitian Operators
23
v1 w1
6 v1 w2 7
6 7
6 7
6 ⋮ 7
2 3 2 3 66 7
7
v1 w1 6 v1 w m 7
6v 7 6w 7 6v w 7
6
6 27 6 27 6 2 17 7
jVi jWi ¼ 6 7 6 7¼ ð2:163Þ
4⋮5 4 ⋮ 5 6 6 v2 w2 7
7
6 7
vn wm 6 ⋮ 7
6 7
6v w 7
6 2 m7
6 7
4 ⋮ 5
vn w m
Example 2.17
2 3
3
1 6 7
If jVi ¼ and jWi ¼ 4 4 5, find the tensor product jVi jWi .
2
5
Solution:
2 3 2 3
13 3
6
2 3 61 47 6 4 7 6 7
7
3 6 7 6 7
1 6 7 6 6
1 57 6 5
7¼6
7
7
jVi jWi ¼ 445 ¼ 6 7 6 7 ð2:164Þ
2 62 37 6 6 7
5 6 7 6 7
42 45 4 8 5
25 10
Exercise 2.11
Prove that (haj hbj) (jci jdi) ¼ hajci hbjdi.
◄
2.12 Statistics and Probability 69
In the following chapters, we shall learn that probability is built into nature. For example, when we
make a quantum measurement—it involves several parameters—the number of degrees of freedom
the system possesses, interaction with the environment and other qubits, decoherence of the qubits,
the initial status of the measurement equipment, and so on. With the uncertainties associated with the
variables involved, it is good to start with some probabilistic assumptions. In Eq. (2.133), the
expectation value of the observable xb can be interpreted as the probability that a measurement shall
give a certain value. How exactly probability enters quantum mechanics is an intriguing study. In this
introductory section, we shall refresh some of the basics of statistics and probability, which may be
helpful with the following chapters.
2.12.1 Definitions
The following frequency table illustrates the number of COVID-19 cases in the first ten counties in
Colorado, as on 8/1/2020 (Table 2.3).
This table is one way of collecting and analyzing data. We do not know the probability of survival
of a certain case. However, we can calculate the percentage of people who survived based on data.
In statistics, the quantity that is studied is called a random variable. A possible outcome of the
study is called observable. All such observables constitute the population. Data is a collection of
observables. Typically, we study a sub-set of the population, called the sample. To ensure that the
distribution is uniform, we perform a random sample. It is a good idea to illustrate data graphically.
In the following chapters, we shall be using histograms to plot the outcome of quantum measurements
we perform after each experiment. Figure 2.7 is a plot of Table 2.3.
Exercise 2.12
For the data contained in Table 2.3, identify the random variable and an observable. Also, form
some random samples of the data. What can be inferred from this data?
◄
6000
4000 1890
2000 224 33 14 5 406 286 8
0
County
70 2 Dirac’s Bra-ket Notation and Hermitian Operators
1X
n
x1 þ x2 þ . . . þ xn
x¼ ¼ x, ð2:166Þ
n n i¼1 i
where n is the total number of data elements xi. As it appears, the mean is the same as the average of
the data. If the data is tabulated as a frequency table, if the outcomes y1, y2, . . . correspond to
frequencies f1, f2, . . ., the formula for calculating the mean is:
1X
n
y1 f 1 þ y2 f 2 þ . . . þ yn f n
x¼ ¼ y f ð2:167Þ
n n i¼1 i i
In a data set, the sample median is the middle of the data element, when the data is sorted in
ascending order. The median is defined as follows:
8
< xnþ1 if n is odd
median ¼ 1
2
ð2:168Þ
: xn þ xnþ1 if n is even
2 2 2
The mode is the value that occurs with the highest frequency.
mode ¼ fyi j f i ¼ max f f i gÞg ð2:169Þ
The range is the difference between the largest and smallest data elements. If the data is sorted in
ascending order, we can write the range as:
range ¼ xn x1 ð2:170Þ
The sample variance is the average squared distance of the observation from the mean.
1 X
n
s2 ¼ ðx xÞ2 ð2:171Þ
n 1 i¼1 i
2.12.4 Probability
Probability theory is useful to model situations in which the outcome of an experiment is random. The
possible outcomes of the experiment are called the sample space, defined as the set S. A subset of the
sample space is called an event.
Consider the sample space S ¼ {a, b, c, d, e, f} and two events A ¼ {a, b, c, e} and
B ¼ {b, d, e, f}.
2.12 Statistics and Probability 71
Exercise 2.13
Prove that A \ A ¼ f g and A [ A ¼ S.
◄
Let us define a function P called probability measure, which acts on the subsets of S. In an
experiment, the following limit determines the probability that an event A can occur:
r
PðAÞ ¼ lim , ð2:172Þ
n!1 n
where r is the number of times the event A occurred in n repeats of the experiment. If the sample space
is constructed in such a way that each of the outcomes has an equal probability of occurring, then we
can rewrite the above equation:
Number of ways A can occur
Pð AÞ ¼ ð2:173Þ
Total number of outcomes
Examples of this type of problem are the dice, deck of cards. We can define the following
properties.
• In an experiment, one of the outcomes occur, that is, P(S) ¼ 1. Note that P({ }) ¼ 0.
• The probability is positive definite. If A ⊆ S, then P(A) 0.
• The probability of two or more experiments adds up, that is, P(A [ B) ¼ P(A) [ P(B).
• P(A [ B) ¼ P(A) + P(B) P(A \ B). This property is also known as the addition rule.
• P A ¼ 1 PðAÞ:
• It follows that if A ⊆ B, then P(A)
P(B).
• If there are n experiments, and if p1, p2, . . .pn are the likely outcomes in each of the experiments,
then the likely possible outcomes of the n experiments are ∏i pi : This property is also known as the
multiplication principle.
• The conditional probability of A if the probability of B is given is: PðAjBÞ ¼ PðPA\B Þ
ðBÞ , iff P(B) > 0.
Example 2.18
A dice has six sides. Each time the dice is thrown, there are six possible outcomes. If we throw a
dice two times, the possible outcomes are 6 6 ¼ 36.
The probability of getting a one in both the throws is 16 16 ¼ 36
1
.
The probability of getting a one in one of the throws is 6 þ 6 36
1 1 1
¼ 11
36, using the addition rule.
◄
72 2 Dirac’s Bra-ket Notation and Hermitian Operators
2.12.5 Permutation
Assume we have a set of n natural numbers N ¼ {1, 2, . . ., n}, if we have to select r unique numbers
from this set, we have to repeat the experiment r times. The first attempt has n outcomes. The second
experiment has n 1 outcomes. The rth experiment has n r + 1 outcomes. The number of ordered
ways in which the r numbers can be selected from the set is called the permutation, and it can be
derived from the multiplication principle.
Note that if the numbers need not be unique, then we can do this in nr times.
Example 2.19
A password scheme requires four unique digits. Calculate how many ways the ten digits 0. . .9 can
be arranged to create a password so that each digit is used only once.
10! 10 9 8 7 6 5 4 3 2 1
Pnr ¼ ¼ ¼ 5040
ð10 4Þ! 6 5 4 3 21
2.12.6 Combinations
Assume we have a set of n natural numbers N ¼ {1, 2, . . ., n}, and we must select r numbers from
this set. If the order of the selection does not matter, the number of possible ways of selecting
r numbers, called combinations, is defined as:
Pn
n n!
Cðn, r Þ ¼ Cnr ¼ ¼ rr ¼ ð2:175Þ
r Pr r!ðn r Þ!
This number is also called the binomial coefficient or the combinatorial number.
Exercise 2.14
Prove that C(n, r) ¼ C(n, n r)
◄
2.13 Summary
This chapter was intended to be a math refresher. It started with the simple definition of scalars and
then proceeded with complex numbers, vectors, and matrices. The concept of linear vector spaces and
Dirac’s bra-ket notation was introduced next. This was followed by an introduction to Hermitian
operators and outer products. After this stage, this chapter briefed expectation values, eigenstates,
eigenvalues, and tensor math. This chapter ended with a short none on statistics and probability.
References 73
Practice Problems
1. Find the real part of (cos0.5 + i sin 0.5)12. (Hints: Write this in the exponential form.)
2. Solve x2 32 ¼ 0. (Hints: write this in polar form and use de Moivre’s theorem.)
!
3. Find a vector that points to the same direction of x ¼ i þ 3j þ 9k , but with a magnitude of
5. (Hints: Normalize the vector and scale it to a magnitude of 5.)
4. On a 2D surface, an ant starts from the origin and walks for 10 cm at a 45 angle, stops for a while,
and then walks for another 10 cm at a 45 angle. What is the final coordinate of the ant?
5. If A and B are symmetric matrices of the same order, prove that AB is symmetric, iff A and
B commute.
6. Given a square matrix A, if A2 is invertible, prove that A is also invertible.
7. If A and B are square matrices of the same order, prove that tr(AB) ¼ tr(BA).
8. If {u, v, w} are linearly independent vectors in a vector space , prove that {u + v, u + w, v + w}
is also linearly independent.
9. Evaluate whether the vectors (1, 0, 1), (2, 1, 1), and (2, 1, 4) form a basis in ℝ3.
2 3
3 4 2
6 7
10. Find the eigenvalues of the matrix 4 0 1 2 5 and its eigenvectors.
0 0 0
pffiffi
11. Evaluate lim 4x : (Hints: Multiply numerator and denominator by the conjugate of the
2 x
x!4
numerator.)
12. dx if y ¼ (x +
Calculate dy 1)5e5x.
Ð 2
13. Calculate the integral (x + x + 1)3 (4x + 2) dx. (Hints: Assume u ¼ x2 + x + 1.)
14. Prove that (jui hvj)y ¼ jvi huj.
15. Prove that jui hvj is a linear operator.
16. Two systems A and B have angular momentum LA ¼ 1 and LB ¼ 2. Find the eigenstates of the
total angular momentum.
17. Hermitian operators A, B, C meet the following conditions [A, B] ¼ 0, [B, C] ¼ 0, and [A, B] 6¼ 0.
Prove that one of the eigenvalues of C must degenerate.
P P P
18. If huj ¼ bi hij and jvi ¼ ai jii , then prove that hujvi ¼ ai bi .
i i i
19. A computer program generates two-digit random numbers (that is, between 10 and 99.) What is
the probability that a generated number is a multiple of five.
20. Assume that there are three coins. Two of them are regular coins, and one of them is a toy coin
with both sides as heads. A coin is randomly picked and tossed to get a head. What is the
probability that it is a regular coin? If all three coins are tossed together. What is the probability of
getting all three heads?
21. In how many ways can we arrange n plates of r chocolate cookies and s butter cookies.
References
1. Mathematical Methods for Physicists - A Comprehensive Guide, 7/e, Arfken, Weber and Harris.
2. Algebra 2/e, Michael Artin.
3. A modern introduction to Probability and Statistics, Understanding Why and How, F.M. Dekking, C. Kraaikamp,
H.P. Lopuhaa, L.E. Meester.
The Quantum Superposition Principle
and Bloch Sphere Representation 3
“Curiouser and curiouser!” cried Alice (she was so much surprised, that for the moment
she quite forgot how to speak good English);
― Lewis Carroll, Alice in wonderland
In Chap. 2, we took a short break to refresh our knowledge on linear algebra and start using Dirac’s
notation. In this chapter, we return to building up further on the principles of quantum mechanics.
Those who have studied quantum mechanics in recent times can directly go to section 3.8 on Bloch
sphere representation and read from there. Others will indeed find the discussions quite interesting.
Griffith [1], Shankar [2], and Neilsen & Chuang [3] shall serve as references for further reading.
• Hilbert space
• Schr€odinger equation and the cat state
• Quantum superposition principle
• Postulates of quantum mechanics
• Quantum tunneling
• Stern and Gerlach experiment and the development of spin angular momentum
• Concept of qubits
• Bloch sphere representation
• Quantum measurements
• Qudits and qutrits
This chapter begins with the definition of Euclidian space, condition for completeness, and applies
them to Hilbert space.
We are familiar with the two- or three-dimensional Euclidian space defined by the principles of
Euclidian geometry. The Euclidian space is a vector space of real numbers ℝn. The Cartesian
coordinate system in the two-dimensional x, y plane, the three-dimensional x, y, z space, the formula
to determine the Euclidian distance between two points in these two coordinate systems, are the basic
principles of this system. The square of the Euclidian distance is an essential parameter in statistical
methods, and it is used in the notion of least squares in regression analysis.
A metric space is a set of objects with a metric, usually a function that measures the distance between
two objects (also called points) in the set. The distance function d satisfies the following criteria:
The Euclidian space is a metric space. We denote a metric space by (X, d).
A sequence can be defined as a list of elements in a particular order. A list of positive even integers is
an infinite sequence of elements. The Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .) form a
sequence. Each number in the Fibonacci sequence is the sum of two preceding numbers.
By definition, a sequence of real numbers a1, a2, a2, . . . converges to a real number a, if, for every
ε > 0, there exists N 2 ℕ, such that for all n N, jan aj < ε. This can be written as a limit n!1
lim an ¼ a:
For example, the following sequence:
1 2 3 n
, , , ..., , ... ð3:1Þ
2 3 4 nþ1
converges to 1, as lim n
¼ 1:
n!1 nþ1
In a Cauchy sequence, the elements become arbitrarily close to each other as the sequence
progresses. For every ε > 0, there exists N 2 ℕ, such that for all m, n N, jam anj < ε. A sequence
converges iff it is Cauchy.
By definition, in a metric space (X, d ), if every Cauchy sequence converges to some element in X,
then that metric space is said to be complete. Here, d the metric is a distance function.
Example 3.1
Prove that the sequence 1n is a Cauchy sequence.
Solution:
Let us assume that there exists a positive real number ε > 0. Assume that there exists a positive
integer N 2 ℕ, such that N > 2ε. Consider two integers m and n such that m, n N.
Using the triangle inequality, we can write:
1 1 1 1
jxn xm j ¼ þ ð3:2Þ
n m n m
1 1 ε 1 1 ε
< and < ð3:3Þ
n N 2 m N 2
€dinger Equation
3.4 Schro 77
This means,
1 1 ε ε
þ < þ <ε ð3:4Þ
n m 2 2
Hence the sequence converges, and we can say 1n is a Cauchy sequence.
◄
The concept of Hilbert space is an extension of the mathematical methods of the two- or three-
dimensional Euclidian space into finite or infinite dimensions. In quantum mechanics, we represent the
state of a quantum system as a vector (called state vector) in the Hilbert space (called state space). The
Hilbert space H is a complex vector space ℂn, with an inner product. The inner product provides for the
orthogonality of the linear state space. It helps us visualize the geometry of the finite or infinite number of
coordinate axes that are orthogonal to each other. The inner product gives rise to an associated norm
defined by:
pffiffiffiffiffiffiffiffiffiffi
for x 2 H, jxj ¼ hxjxi ð3:5Þ
The Hilbert space is complete for this norm. Here, the term complete means that every Cauchy
sequence of elements in the Hilbert space H converges to an element in the same space H, while the
norm of differences between successive terms in the sequence approaches zero.
In the previous chapter, we found that the measurement of a physical observable scatters around an
expectation value, and it is probabilistic. We also learned that the probability of finding a quantum system
is the absolute squared of the wavefunction. Therefore, the wavefunction must be square-integrable (that
is, a L2 function) such that the integral of the absolute value squared of the wavefunction over an infinite
space converges, meeting Cauchy’s convergence criteria. The Hilbert space meets this condition. The
Hilbert space is also linear, which lays the foundation for the quantum superposition principle. These are
some reasons why we chose to represent quantum systems as vectors in the Hilbert space.
The Schr€odinger equation is a fundamental equation of quantum mechanics. Erwin Schr€ odinger, an
Austrian physicist, published this equation in 1925. He was awarded a Nobel Prize for his work on
wave mechanics in 1933. Schr€odinger studied the de Broglie waves and thought that if the electrons
behaved like waves, it should be possible to write a wave equation for them, like Maxwell’s equation
for electromagnetic waves.
In classical mechanics, the total energy of a particle is the sum of its kinetic and potential energies.
It is defined by the following equation.
p2
E¼ þ V ðxÞ, ð3:6Þ
2m
where,
If we assume that the particle is confined to a certain space by a potential around it, the particle
needs minimum energy to escape the potential. If the potential changes from one place to another,
assuming that the particle’s energy is a constant, only the momentum changes. If the momentum
changes, so must the de Broglie wavelength. Hence, the momentum and the de Broglie wavelength
are related:
h
λ¼ , ð3:7Þ
p
where,
To represent this phenomenon, Schr€odinger suggested a wavefunction ψ(x, t), which varied with
position and time. Replacing the momentum with a differential operator, Schr€
odinger created a partial
differential equation which solves for the wavefunction ψ(x, t).
2
∂ψ ħ2 ∂
iħ ðx, tÞ ¼ ð þ Vðx, tÞÞψðx, tÞ ð3:8Þ
∂t 2m ∂x2
This is the time-dependent form of the Schr€odinger equation for a particle of mass m, acted upon
by a potential V(x, t) while moving along the xaxis at non-relativistic speeds at time t. We have
chosen one dimension (the xaxis) for convenience. This equation can be defined for multiple
coordinate axes or basis vectors in the Hilbert space.
The time-dependent form of the Schr€odinger equation is a first-order differential equation in time.
It has the following property that applies to all spaces where the particle can be found: If we can
define the wavefunction at an arbitrary starting time t ¼ 0, then we can determine the wavefunction
for any future time t for the particle.
The square of the wavefunction, that is, ψ 2 defines the probability of finding the particle at a given
place and time.
The transient term (that is, the left-hand side) of this equation has an imaginary component; hence
this is, a complex equation. It is convenient if we can find an interpretation of the wavefunction in real
values. By seeking an analogy with the norm-squared of the complex numbers we saw in Chap. 2,
Eq. (2.6), we can write:
We call this the Probability Density P(x, t), which we came across in Chap. 1, Eq. (1.20). This
definition is one of the axioms of Born rule, a key postulate of quantum mechanics.
The probability density is always a positive number, and it defines the probability of finding the
particle between a tiny space [x, x + Δx] at time t. Δx is a small incremental value to x.
This property requires the wavefunction to be normalized, and the integral of the probability
density overall space must be 1 since the particle should be somewhere in the space. This integral is
expressed in the following equation:
€dinger Equation
3.4 Schro 79
ð
þ1 ð þ1
jψ ðx, tÞj2 dx ¼ ψ ðx, tÞψ ðx, tÞ dx ¼ 1 ð3:11Þ
1
1
The Schr€odinger equation is a linear equation for ψ. If we assume ψ 1, ψ 2, . . . are its solutions, then
from our discussions on linear vector spaces in Chap. 2, a linear combination of these solutions is a
solution as well:
ψ ¼ a1 ψ 1 þ a2 ψ 2 þ . . . , ð3:12Þ
where the coefficients a1, a2, . . . are complex numbers having a magnitude and a phase.
This property is known as the Linear Superposition Principle. We can write this using Dirac’s
bra-ket notation as:
j ψ i ¼ a1 j ψ 1 i þ a2 j ψ 2 i þ . . . , ð3:13Þ
where {jψ 1i, jψ 1i. . .} are the basis vectors. From Eq. (2.144), we can rewrite this as a summation as
follows:
X
n
jψ i ¼ ai jψ i i ð3:14Þ
i¼1
The probability of projecting (or measuring) the state jψi into a basis state jψ ii is equal to the
square of the absolute value of the corresponding probability amplitude, that is, jaij2. The sum of the
square of the absolute value of the probability amplitudes is 1.
X
n
jai j2 ¼ 1 ð3:15Þ
i¼1
The quantum state jψi is characterized by two n-dimensional vectors: the probability amplitudes
(a1, a2, a3, . . ., an), which are complex numbers and the probabilities, which is a vector of real
numbers (ja1j2, ja2j2, ja3j2. . ., janj2).
This means a quantum state can be described as a sum of two or more quantum states. In other
words, we can say that a quantum system can always be in all possible states until a measurement is
done. When a measurement is made, the wavefunction collapses into one of the probable states, and
the quantum system is localized. This concept can be explained better using Schr€ odinger’s cat, a
thought experiment.
3.4.1 Schrödinger’s Cat Thought Experiment (Do Not Try This at Home!)
The Schr€odinger’s cat thought experiment was created by Ervin Schr€ odinger in 1935 as part of the
discussions around the EPR paradox (which we shall see in a later chapter). The experiment intends to
illustrate the superposition principle in a larger system that is dependent on a quantum system in a
superposition state.
In this thought experiment, a cat is put in a steel chamber. Inside the steel chamber, there is an
experimental setup. The setup has a small amount of radioactive material with a 50% probability of
decaying in the next 1 hour (Fig. 3.1).
80 3 The Quantum Superposition Principle and Bloch Sphere Representation
The Geiger counter inside the chamber can detect the radiation. If there is radiation in the chamber,
the Geiger counter releases a weight block that breaks a poison potion. If the potion is broken, it
releases a deadly hydrogen cyanide gas, killing the cat instantaneously (Fig. 3.2).
If the radioactive material does not decay, there is no radiation, and the poison potion is not
broken. In this case, the cat lives. Now, we put the cat inside this experimental chamber and lock it.
One hour passes. . . Is the cat alive or dead?
If we do not open the chamber, according to Copenhagen Interpretation of Quantum Mechanics,
the cat is both alive and dead at the same time—meaning the cat is in a superposition state (Fig. 3.3).
When we open the chamber, we make an observation; at this point, the wavefunction of the cat
collapses into one of the states—dead or alive.
There are many interpretations of this thought experiment, and we leave it to our readers for further
reading and imagination!
The quantum superposition principle is an important concept we apply in quantum computing.
Before jumping into setting the qubits in superposition states, we should learn two important concepts
in quantum mechanics—quantum tunneling and the experiment that established spin angular
3.5 Postulates of Quantum Mechanics 81
momentum and the randomness of quantum systems. These two concepts shall help us understand the
quantum systems better, as we start representing the qubit states as Bloch spheres.
The cat state is a state of a quantum system that is composed of two diametrically opposite states at
the same time. For example, in Schr€odinger’s thought experiment, the state of the cat is dead and alive
at the same time. These are two diametrically opposite states! This equation will become quite
familiar to us in the forthcoming chapters, of course, we will not experiment with cats!
3.5.1 Postulate 1
!
A quantum mechanical system is described by a complex wavefunction ψ r , t , which contains all
the information that can be known about that system. The wavefunction is a continuous, square-
integrable, and single-valued function of position and time of the system.
82 3 The Quantum Superposition Principle and Bloch Sphere Representation
! !
• The probabilistic interpretation of the wavefunction is ψ ð r , tÞψð r , tÞdV . According to this
interpretation, the quantum mechanical system must be within the volume element dV at position
!
r and time t.
• The wavefunction is spatially localized (that is, normalized). Since the wavefunction must find the
Ð1 ! !
quantum system somewhere in the space, this gives rise to its norm: 1 ψ ð r , tÞψð r , tÞdV ¼ 1:
• The state-space of the wavefunction is the Hilbert space. Hence the superposition principle
holds good.
3.5.2 Postulate 2
• The expectation value of an operator corresponding to an observable is a real value. Hence the
operator must be Hermitian (Example 2.14) In other words, the measured quantities are real
values.
• Every operator has got some states which do not change when the operator operates on them, that
is, Ab jψ i ¼ a jψ i: The states are just multiplied by a constant. Such states are called eigenstates.
The constants a are the eigenvalues of the operator.
3.5.3 Postulate 3
In a quantum measurement of an observable, the only possible outcome is one of the eigenvalues of
the corresponding operator.
We can write the system state as a linear combination of probability amplitudes, as shown in
Eq. (2.50).
X
n
jψ i ¼ ci jψ i i ð3:17Þ
i¼1
Here, the value of n can scale to infinity. Hence, we can write the eigenequation as a complete set
of eigenvectors Ab jψ i i ¼ ai jψ i i. Even though we may have an infinite number of eigenvalues ai, the
measurement operation produces only one eigenvalue with a probability 1. The probability of which
eigenvalue we measure is given by the absolute square of the corresponding coefficient, jcij2.
When we measure jψi, we get an eigenvalue ai for a certain value of i. This causes the
wavefunction to collapse to jψ ii, and jcij2 ¼ 1. If ai is degenerate (refer to earlier Sect. 2.8), the
wavefunction collapses to one of the degenerate subspaces.
The probability of measuring a certain eigenvalue ai can be defined as:
where jψ ii is an eigenket of A, corresponding to the eigenvalue ai to which the system collapses after
the measurement.
3.5 Postulates of Quantum Mechanics 83
3.5.4 Postulate 4
3.5.5 Postulate 5
The wavefunction of an isolated quantum system evolves in time following the time-dependent
b !
Schr€odinger equation: Hψð ∂
r , tÞ ¼ iħ ∂t
! b is the Hamiltonian operator of the system.
ψð r , tÞ, where H
!
Once we are given an initial state of the system ψð r , t0 Þ, it is possible to derive the state of the
system at time t, if no observations are made. Note that performing a measurement alters the state of
the system, which cannot be described by the time-dependent Schr€ odinger equation. When we
measure a physical quantity of the system, the state vector undergoes a probabilistic change, which
can be observed in the measurement outcome.
Example 3.2
Consider the system evolution jψ 0i ! eiθjψi, where the system picks up a global phase eiθ. The
probability of measuring a certain ai at the initial and final state of the system can be calculated as
follows:
2
Final state jψ 0 i Pðai Þ ¼hψ i jeiθ ψi ð3:19Þ
2
¼eiθ jhψ i jψij2
¼jhψ i jψij2
Thus, the states jψi and jψ 0i are equivalent. The global phase is not observable and insignificant.
We shall discuss global and relative phases in detail in later sections and provide additional proof.
◄
Consider a system of two identical particles. Since the particles are indistinguishable, under the
exchange of coordinates (which includes spin), the probability density should not be affected. For
such systems, the probability density of the wavefunctions describing the two particles must be
identical:
Bosons have zero or integral intrinsic spin. The wavefunctions representing bosons are symmetric.
Fermions (such as electrons) have half-integral spins, and their wavefunctions are antisymmetric
under particle exchange. Hence, any number of bosons can occupy the same state, whereas two
fermions cannot occupy the same state. Pauli’s exclusion principle derives from the antisymmetric
wavefunctions (Sect. 1.4.1).
Note:
Readers who cannot follow the math can skip the derivation and continue to read the text.
Quantum tunneling is an exciting quantum mechanical phenomenon in which particles can pene-
trate through a potential barrier, even if the height of the potential barrier is higher than the total
energy of the particle. This behavior is in total violation of classical physics. However, we observe
this phenomenon every day in semiconductor devices and the sun. Quantum tunneling is used in a
class of quantum computers known as “Quantum Annealers.” Quantum annealing is a method used to
solve combinatorial optimization problems, employing the principles of quantum tunneling. In this
section, we shall explore quantum tunneling in detail as it is a useful application of the Schr€odinger’s
wavefunction we learned in the previous section. We shall first look at a classical pedagogical
example, much recited in classrooms and textbooks.
Assume that we kick a football with about 100 J of energy. As the ball rolls, it encounters a hill.
Assume that it takes about 200 J of energy to reach the summit of the hill. Since the ball has energy
lower than the energy needed to climb up to the summit, it has no way of climbing up the hill and
appearing on the other side. No matter how many times we try this experiment, the ball will not make
it to the other side of the hill. At some point (It is an excellent exercise to calculate the maximum
height the ball can climb up the hill.), while climbing up the hill, the ball will lose its energy and be
pulled back by gravity. Classically, the probability of the ball making it to the other side of the hill is
0%, while the probability of the ball being reflected by the hill is 100%.
In quantum mechanics, there is a possibility for the ball to appear on the other side of the hill. The
reason is, the ball also has wave-like properties. Even though the ball can be localized, its
wavefunction is defined all over the space. If the wave packet of the ball is larger than the width of
the hill, the ball has a probability of appearing on the other side of the hill!
The equivalent of a hill in quantum mechanics is the potential barrier shown in Fig. 3.4. The
function describing the potential energy of the barrier is described in the following equation.
8
< 0, when x < 0
>
V ðxÞ ¼ V 0 , when 0 x L ð3:21Þ
>
:
0, when x > L
3.6 Quantum Tunneling 85
POTENTIAL ENERGY
REFLECTED
INCIDENT TRANSMITTED
DISTANCE
0 L
Figure 3.4 has three distinct regions. In the first region, the distance x < 0. This region is potential
free, and the incoming particles (and their wave packets) move freely. There may be some particles
that were reflected by the barrier in this region.
In the second region, some of the particles that were not reflected at the barrier boundary x ¼ 0
propagate as a transmitted wave with a constant potential V(x) ¼ V0. If the width L and height V0 of
the barrier are finite, part of the wave packet penetrates the barrier boundary and propagates through
the barrier. Inside the barrier, the wave packet is gradually attenuated. The wave packet tunnels
through the second region and emerges as a transmitted wave packet at x ¼ L.
The third region is a potential-free zone. In this region, the particle has tunneled through the
potential barrier at x > L and moves as a free particle.
The probability of a particle to tunnel through the barrier depends on three factors: the barrier
width L, the height of the barrier V0, and the energy E of the particle. We can calculate this by solving
the time-independent form of the Schr€odinger equation for the potential barrier described above.
ħ2 d 2 ψ ð x Þ
þ V ðxÞψ ðxÞ ¼ Eψ ðxÞ; where 1 < x < þ1 ð3:22Þ
2m dx2
We assume that the energy E of the incoming particle is less than the barrier height V0. We solve
the Schr€odinger equation for ψ(x) in such a way that the wavefunction is continuous, and the first
derivative of the solution is continuous at the boundary between the regions. This solution can
provide a probabilistic interpretation with jψ(x)j2 ¼ ψ (x)ψ(x) as the probability density.
For the three regions, we can write the Schr€odinger equation as follows:
REGION I ħ2 d2 ψ 1 ðxÞ
¼ Eψ 1 ðxÞ
1 < x < 0 2m dx2
REGION II ħ2 d2 ψ 2 ðxÞ
þ V 0 ψ 2 ðxÞ ¼ Eψ 2 ðxÞ ð3:23Þ
0xL 2m dx2
Note that the wavefunction needs to be continuous at the region boundaries. This means,
ψ 1(0) ¼ ψ 2(0) at the boundary between the regions I and II, and ψ 2(L ) ¼ ψ 3(L ) at the boundary
between the regions II and III.
We also said that the first-order derivative of the solution is continuous at the region between the
boundaries:
dψ 1 ðxÞ dψ 2 ðxÞ
¼ at the boundary between I and II
dx dx
x¼0 x¼0 ð3:24Þ
dψ 2 ðxÞ dψ 2 ðxÞ
¼ at the boundary between II and III
dx x¼L
dx x¼L
The solutions to the Schr€odinger equation for the regions I and III can easily be found, and they
take the following form:
We can derive this for the reflected and transmitted wave as jBj2 and jFj2, respectively. The square
of the amplitude is proportional to the intensity of the wave. So, if we want to know how much of the
wave penetrates the barrier, we must find the ratio between the intensity of the transmitted wave and
the intensity of the incident wave. This ratio is known as the transmission probability or the
tunneling probability.
jψ trans ðxÞj2 jFj2 F2
T ðL, EÞ ¼ ¼ ¼ ð3:27Þ
jψ in ðxÞj2 jAj2 A
ħ2 d 2 ψ 2 ðxÞ
¼Eψ 2 ðxÞ þV 0 ψ 2 ðxÞ
2m dx2
d 2 ψ 2 ðxÞ 2m
¼ 2 ð V 0 EÞ ψ 2 ð x Þ ð3:28Þ
dx2 ħ
d 2 ψ 2 ðxÞ 2m
¼β2 ψ 2 ðxÞ; where β2 ¼ 2 ð V 0 EÞ
dx 2
ħ
3.7 Stern and Gerlach Experiment 87
POTENTIAL ENERGY
REFLECTED
INCIDENT TRANSMITTED
DISTANCE
0 L
Since V0 > E, β2 is a positive real number. The solutions to this equation do not contain oscillatory
terms. They contain exponentials that denote the gradual attenuation of ψ 2(x):
This is illustrated in Fig. 3.5. With a little bit of math work, we can derive the approximate value of
the tunneling probability.
E E
T ðL, EÞ ¼ 16 1 eβL ð3:30Þ
V0 V0
Note that the tunneling probability is dependent upon the barrier width L and the potential barrier
V0 .
Figure 3.5 illustrates the three solutions to the Schr€
odinger equation for a particle encountering a
potential barrier. In regions I and III, the particle moves freely. In region II, the particle moves with
potential V0, and it is attenuated exponentially.
Quantum tunneling was first examined by the German physicist Friedrich Hund in 1927. Later,
the Russian–American theoretical physicist George Gamow explained the radioactive α-decay of
atomic nuclei by quantum tunneling. In 1957, tunnel diode, which worked on the principles of
quantum tunneling, was invented by Leo Esaki, Yuriko Kurose, and Takashi Suzuki at Tokyo
Tsushin Kogyo (now Sony.)
In Chap. 1, we saw that the orbital angular momentum quantum number l takes only certain discrete
values. This restriction means, the angular momentum vector can only have certain orientations
called “space quantization.” In 1922, the German physicists Otto Stern and Walther Gerlach set
out to prove whether the spatial orientation of the angular momentum is quantized. An orbiting
electron must be producing a magnetic moment proportional to the orbital angular momentum. They
88 3 The Quantum Superposition Principle and Bloch Sphere Representation
Beam of
silver atoms
Expected
result
Furnace
Experimental Inhomogeneous
result
Fig. 3.6 Stern and Gerlach Experiment setup. (Image source: Wikipedia, Author: Tatoute.CC BY-SA 4.0)
thought that by measuring the magnetic moment of the atoms, they could prove whether spatial
quantization existed.
In their experimental setup, a collimated beam of neutral silver atoms emanating from a furnace
passes through an inhomogeneous magnetic field and hits a target screen (Fig. 3.6). Let the direction
of the beam be along the y-axis and let the direction of the magnetic field be along the z-axis. The
!
electrons in a circular orbit have an angular momentum L ¼ mωr 2 : Since the electrons in orbit carry a
charge, they produce a small current loop around them, which creates a dipolar magnetic field and a
!
magnetic moment μ ¼ 2m
2
L.
! !
The magnetic field B created by the experiment creates a torque μ B around this dipole in such a
!
way that the angular momentum L starts to precess along the direction of the magnetic field. Since the
magnetic field is inhomogeneous along the direction z, the atoms experience a force defined by the
following equation:
! !
∂B
Fz ¼ ∇ z μ B ¼ μ z ð3:31Þ
∂z
Due to the random thermal effects inside the oven, we can expect the magnetic moment vectors of
the silver atoms to be randomly oriented in different angles in the space as they emerge from the oven.
Once they pass through the inhomogeneous magnetic field, they are deflected along the +z and
z directions. On the screen, we expect a maximum distribution at an angle of zero deflection with a
decreasing distribution on both sides. What was seen was different. The incoming beam was deflected
into two distinct beams (Fig. 3.7). Hence the force that deflects the beam must have certain discrete
values, and Stern and Gerlach thought that it meant “Spatial Quantization” is true.
As quantum mechanics advanced with the theories of Heisenberg and Schr€ odinger, it was found
that the experiment was right, but the inference was wrong. Stern and Gerlach assumed that the
angular momentum L was 1 for silver atoms. They thought that the magnetic moment of atoms with
L ¼ 1 had two components along the direction of the magnetic field μz ¼ 4m eh
, which caused the two
deflected beams. However, the silver atoms are in L ¼ 0 state. If the silver atoms are in L ¼ 1 state,
then the magnetic quantum number m must have 2L + 1 ¼ 3 states, as we have seen in Chap. 1. This
must have caused the beam to split into three parts. However, we got two.
3.7 Stern and Gerlach Experiment 89
In 1925, the Dutch–American physicists George Eugene Uhlenbeck and Samuel Abraham
Goudsmit proposed an alternate theory that solved this problem. They proposed that in addition to
the orbital angular momentum L, the electrons have an intrinsic angular momentum or the spin
ħ
angular momentum S with the value of 2π (Fig. 3.8).
The total angular momentum of electrons is the sum of the orbital and spin angular momentum.
J ¼LþS ð3:32Þ
90 3 The Quantum Superposition Principle and Bloch Sphere Representation
The electron configuration of silver is 4d10 5s1. So, it has one valence electron in the n ¼ 5 shell.
The remaining core electrons have a total angular momentum of zero. Their orbital angular momen-
tum is zero, and their spins cancel each other out. Hence, they do not contribute to experimental
observation. The valence electron does not have orbital angular momentum. Its total angular
momentum comes entirely from its spin. The magnetic moment must be from this electron, which
means the experimental observation is due to the spin. Hence, L ¼ 0 for silver atoms.
Based on the experimental observation, the spin can have two different values, and we say that the
electrons are spin-12 particles. The same is true for other fermions.
If we measure the spin along the direction of the z-axis, the two spin states are as follows:
1
Sz ¼ ħ ð3:33Þ
2
The same applies to other axes as well. We could have experimented with the magnetic field along
either of the other axes and got similar results.
1 1
Sx ¼ ћ, Sy ¼ ћ, ð3:34Þ
2 2
The two spin states Sz ¼ þ 12 ħ (spin upward ") and Sz ¼ 12 ħ (spin downward #) of the electron
can be described in terms of two basis vectors, {j"zi, j#zi} in a two dimensional Hilbert space. We can
write this as a linear superposition state using Dirac’s bra-ket notation:
j ψ i ¼ aj "z i þ bj # z i ð3:35Þ
The coefficients a and b are arbitrary complex numbers meeting the normalization criteria
jaj2 + jbj2 ¼ 1.
We can define a spin operator Sbz with the two eigenstates (spin upward and spin downward) having
the eigenvalues 12 ħ. The spin states can be written as:
1
Sbz j"z i ¼ þ ħj"z i ð3:36Þ
2
1
Sbz j#z i ¼ ħj#z i ð3:37Þ
2
For convenience (we shall later relate this to the qubits), we can refer the basis states j"zi and j#zi
1 0
as j0i and j1i. We can also describe them as column vectors and respectively. In the next
0 1
few steps, we shall establish that these kets form an orthonormal basis.
1
j "z i ¼ j 0i ¼ ð3:38Þ
0
0
j #z i ¼ j 1i ¼ ð3:39Þ
1
The basis bra vectors can be obtained by taking the conjugate transpose.
Let us consider an experimental setup, where we have cascaded two Stern & Gerlach experimental
apparatuses, as shown in Fig. 3.9. Both the apparatuses used in this setup have the inhomogeneous
magnetic field along the z-axis. The first apparatus produces j"zi and j#zi beams, each with a 50%
probability. This is because the atoms are randomly oriented in the oven. We feed the j"zi output to
the second apparatus, leaving out the j#zi beam.
We notice that the output of the second apparatus has only the j"zi components. The j#zi
component is entirely absent. This observation is what we expect because we blocked out the j#zi
component from the first apparatus. This suggests that we have an orthonormal basis.
The output of the second apparatus consisted only of j"zi components. This means the incoming
beam did not have any j#zi components. Besides, the second apparatus did not produce any other
component other than j"zi.
From this observation, we can derive the condition for an orthonormal basis by relating to Chap. 2,
Eq. (2.60).
From Eq. (2.100), we can write the matrix form of the spin operator as:
2D E D E3
"z jSbz j"z "z jSbz j#z
6 7
Sbz ¼ 4 D E D E5 ð3:44Þ
#z jSbz j"z #z jSbz j#z
Since there are only two spin states, this is a 2 2 matrix. From Eqs. (3.36), (3.37), and (3.43), we
can write the individual components of this matrix as:
D E
ћ ћ
"z jSbz j"z ¼ h"z j"z i ¼
2 2
D E
b ћ
"z jSz j#z ¼ h"z j#z i ¼ 0
2 ð3:45Þ
D E
b ћ
#z jSz j"z ¼ h#z j"z i ¼ 0
2
D E
ћ ћ
#z jSbz j#z ¼ h#z j#z i ¼
2 2
92 3 The Quantum Superposition Principle and Bloch Sphere Representation
Raising/lowering operators increase or decrease the eigenvalue of another operator. They are also
called creation and annihilation operators in quantum mechanics.
The raising and lowering operators for spin angular momentum are given by:
Note: For brevity, we are not detailing how these equations were derived.
With a little math work, we can rewrite these two equations as:
1
Sbx ¼ Sbþ þ Sb
2 ð3:48Þ
b 1 b
Sy ¼ Sþ Sb
2i
The general form of the ladder operators for the spin angular momentum is:
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
Sbþ js, mi ¼ћ sðs þ 1Þ mðm þ 1Þ js, m þ 1i
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð3:49Þ
Sb js, mi ¼ћ sðs þ 1Þ mðm 1Þ js, m 1i
Note: For brevity, we are not detailing how these two equations were derived.
Considering s ¼ 12 and m ¼ 12, we get,
E E
1 1 1 1
Sbþ , ¼ћ ,
2 2 2 2
E E ð3:50Þ
1 1 1 1
Sb , ¼ћ ,
2 2 2 2
Other combinations cancel out. We can write these operators in a matrix form using Chap. 2,
Eq. (2.100), and applying orthonormality. With a little bit of math work, we get:
" #
0 1
Sbþ ¼ћ
0 0
" # ð3:51Þ
0 0
b
S ¼ћ
1 0
3.8 Bloch Sphere Representation 93
σ x and σ y are the remaining two Pauli matrices we didn’t derive so far. We shall be using the Pauli
matrices in the next few chapters.
Exercise 3.1
Verify the following commutation relationships for the spin operators.
h i
Sby , Sbz ¼iћSbx
h i
Sbz , Sbx ¼iћSby
h i
Sbx , Sby ¼iћSbz
In the previous section, we have seen that the spin-12 system is a two-state quantum system, and it is
represented in a two-dimensional Hilbert space. The two-states of this system are the spin-up (")and
spin-down (#) states. We have also seen that irrespective of the measurement axis, the spin is always
ħ
2 : In the theory of Quantum Information Systems, this kind of a two-state system is referred to as the
“qubit” meaning quantum bits by drawing an analogy with the digital bits of classical computers. In
the following chapters, we shall learn more about qubits. However, for now, we have to introduce
some additional math work in this chapter, which shall help further discussions.
Let us recollect from our previous discussions that the state vector of the qubit (we shall use this
term moving forward for systems expressed in the two-dimensional Hilbert space) can be written
using the linear superposition principle in an orthonormal basis of {j"i, j#i} as:
a
jψ i ¼ aj"i þ bj#i ¼ ð3:53Þ
b
Alternatively, if we use an orthonormal basis of {j0i, j1i}, called computational basis, we can
write the wavefunction as:
a
jψ i ¼ aj0i þ bj1i ¼ , ð3:54Þ
b
where the weighing factors, a and b, are probability amplitudes and normalized complex numbers,
meeting the normalization criteria: jaj2 + jbj2 ¼ 1. The relative phase between a and b is responsible
for Quantum Interference, and we shall explore that in detail in Chap. 5, Sect. 5.12.
94 3 The Quantum Superposition Principle and Bloch Sphere Representation
The matrix form of the kets j0i and j1i can be derived from Eq. (3.56), and are the same as
Eqs. (3.38) and (3.39):
1 0
j0i ¼ and j1i ¼ ð3:55Þ
0 1
For convenience, this state vector can be drawn as a vector pointing to the surface of a unit sphere
called the Bloch sphere, as shown in Fig. 3.10. The spin-up state j0i is at the north pole, and the spin-
down state j1i is at the south pole, as shown in Fig. 3.11. The various equal superposition states are
q –x
–Y Y
–Z
Z Z
–X –X
–Y Y –Y Y
X X
–Z –Z
y
y
Fig. 3.11 Bloch sphere showing states “0” and “1”. In state “0” the state vector points to the north pole and in state “1”
the state vector points to the south pole
3.8 Bloch Sphere Representation 95
along the equator, as shown in Fig. 3.10. Assume for now that the radius of the Bloch sphere to be
1. We shall explain this in the forthcoming Sect. 6.3.2.
Using the spherical coordinate system, an arbitrary position of the state vector of a qubit can be
written in terms of the angles θ (elevation, the state vector makes from z-axis) and ϕ (azimuth, the
angle of projection of the state vector in the xy plane from the x-axis) it makes in the Bloch sphere as:
2 3
θ
6 cos 2 7
θ θ 6 7
jψ i ¼ cos j0i þ eiϕ sin j 1i ¼ 6 7 ð3:56Þ
2 2 4 iϕ θ 5
e sin
2
!
We can measure the direction of the qubit’s state vector by directing a magnetic field B along the
z-axis and measuring the energy. This is the same direction as the expectation value vector of Sbz .
The qubit is in a superposition state described by Eqs. (3.53) and (3.54). When we measure the
qubit, it can measure either “0” or “1” equivalent to the digital bits. The probability of the outcome
j0i which measures “0” is equal to jaj2, and the probability of the outcome j1i which measures “1” is
equal to jbj2.
Example 3.3
a
If the state vector of a qubit is jψi ¼ , calculate the expectation value of b
Sz .
b
Solution:
From Eq. (2.133), using Eq. (3.46), we can write the expectation value of Sbz as:
" #
hai
^ ^ ħ 1 0
hSz i ¼ hψ j Sz j ψi ¼ ½a b ð3:57Þ
2 0 1 b
The Pauli matrices can be used to rotate the state vector of the qubit by 180 along the respective axes.
Pauli rotations are performed by applying a measured dose of a π rotational pulse along the respective
axis. These operations are called “gates”. We shall learn about the qubit gate operations in the next
chapter. For now, since we discussed the Bloch sphere representation and spin matrices, we should
look at the Pauli rotations on the qubits.
The application of this gate rotates the qubit by 180 along the x-axis. This gate is also called NOT
gate, as it flips the qubit state from j1i to j0i and vice versa. Figure 5.6 illustrates the operation of the
X-gate.
96 3 The Quantum Superposition Principle and Bloch Sphere Representation
The application of this gate rotates the qubit by 180 along the y-axis. This gate is also called phase-
shift gate as it shifts the phase of the qubit.
" #" # " # " #
0 i 1 0 0
Y j0i ¼ ¼ ¼i ¼ ij1i
i 0 0 i 1
" #" # " # " # ð3:60Þ
0 i 0 i 1
Y j1i ¼ ¼ ¼ i ¼ ij0i
i 0 1 0 0
The application of this gate rotates the qubit by 180 along the z-axis. This gate is also called a phase
flip gate. This gate leaves state j0i as such but flips the state j1i to j1i.
" #" # " #
1 0 1 1
Z j 0i ¼ ¼ ¼ j0i
0 1 0 0
" #" # " # " # ð3:61Þ
1 0 0 0 0
Z j 1i ¼ ¼ ¼ ¼ j1i
0 1 1 1 1
where, nb is the unit vector along the axis of rotation, θ is the angle to be rotated, and σ is the
corresponding Pauli matrix. To perform a rotation along, say, y-axis, we replace the term ðnb σ Þ
with Y.
Calculating this for the three rotational axes, we get:
2 3
θ θ
6 cos 2 i sin
6 2 7
7
Rbx ðθÞ ¼ 6 7 ð3:63Þ
4 θ θ 5
i sin cos
2 2
3.8 Bloch Sphere Representation 97
2 3
θ θ
6 cos sin
6 2 2 7
7
Rby ðθÞ ¼ 6 7 ð3:64Þ
4 θ θ 5
sin cos
2 2
" θ
#
ei2 0
Rbz ðθÞ ¼ θ ð3:65Þ
0 ei2
Some authors consider rotations to be calculated by taking the negative of the angles. Applying
that convention, note that the Pauli matrices are equal to the phase factor i times the general rotation
Example 3.4
Let us perform a 90 (actually 90 , but by using the negative angle convention) rotation along the
x-axis on a qubit at state j0i.
By substituting the angle directly in Eq. (3.63) and applying the rotation over the state j0i we get,
2 3
90 90
cos i sin
6 2 7 1
Rbx ð90Þj0i ¼ 4
2
5 ð3:69Þ
90 90 0
i sin cos
2 2
2 3 2 3
1 1 1
pffiffiffi i pffiffiffi
pffiffiffi
6 2 7 1 6 7 1 0
¼6
27
¼ 6 2 7 ¼ p1ffiffiffi þ ð3:70Þ
4 1 1 5 0 4 1 5 2 0 i
i pffiffiffi pffiffiffi i pffiffiffi
2 2 2
1 1 0
¼ pffiffiffi þi ð3:71Þ
2 0 1
1
¼ pffiffiffi ðj0i þ ij1iÞ ð3:72Þ
2
The qubit is rotated to a position intersecting the y-axis on the surface of the Bloch sphere, which is
readily seen in Fig. 3.12.
◄
Qubit rotations are important gate operations in quantum computing. In Chap. 5, we learn about a
few rotational operations and apply them in Chap. 7. It is interesting to know that arithmetic can be
done by rotations. However, that is in Chap. 7!
98 3 The Quantum Superposition Principle and Bloch Sphere Representation
Z Z
–X –X
–Y Y –Y Y
X X
–Z –Z
y y
Fig. 3.12 Bloch sphere showing a qubit’s initial state vector at |0i and after a Rbx ð90Þ to the final state of
p1ffiffi ðj0i þ ij1iÞ
2
We now have an idea about the qubits, which are two-state systems. We also learned about some
basic rotational operations on the qubits. We shall learn about the construction of the qubits and gate
operations in the forthcoming chapters. In this introductory section, we learn about the measurement
of the qubits.
We know that a quantum system can be described using the quantum superposition principle as
jψi ¼ aj0i + bj1i in the computational basis. Under this definition, the probability of measuring the
system in state j0i is jaj2, and the probability of measuring the system in state j1i is jbj2.
Measurements are an essential activity in quantum computation and performed most often at the
end of the computation. Sometimes, we perform measurements during the computation to correct
errors or to implement “if” statements. In the computational basis, measurements are done along the
z-axis. However, we may use other basis or measure several qubits at the same time. Therefore, it is
advantageous to define a mathematical formalism for making quantum measurements.
In this section, we discuss projective (or von Neumann) measurements and von Neumann’s
description of the measurement process.
where Pm are the complete set of orthogonal projectors onto the eigenspace of M. If we assume the
state of the system before the measurement is jψi, then the following axioms hold good.
3.9 Projective Measurements 99
Axiom—1:
P
The total probability of all projective measurements sums to 1, that is, Pm ¼ I: Here, I represents
m
the identity matrix.
Axiom—2:
The probability of observing a certain measurement m is p(m) ¼ hψjPmjψi. Let us derive this state.
Consider the following equation for a system in state jψi ¼ aj0i + bj1i.
We can similarly prove h1jψi ¼ b. From this equation, we can write the probability of finding the
quantum system in state j0i as follows:
Axiom—3:
The state of the system immediately after the measurement is given by:
Pm ψ
jψ 0 i ! pffiffiffiffiffiffiffiffiffiffi ¼ jmi ð3:76Þ
pð m Þ
Measurement causes the system to collapse into a state that is consistent with the measurement.
This abrupt change is often called the projection postulate. It states that the outcome of a measure-
ment is a new state, which is a normalized projection of the original system ket into the ket
corresponding to the measurement. Note that the projective measurements can be repeated. Hence,
the outcome of a projective measurement is deterministic. However, repeated measurements do not
have much significance in quantum computation and often violated. For example, in a quantum
communication channel, the encoded photons arriving at the end of the channel get absorbed by the
photodetectors. They are no longer available for repeat measurements. In quantum computation, we
are usually not interested in the post-measurement state of the system. Quantum algorithms are
mostly concerned with the probabilities of the measurement outcomes, and we shall see them in the
algorithms we explore in Chap. 7.
Exercise 3.2
Prove that projective measurements can be repeated.
◄
The operators of the projective measurements are called projectors. We learned about them in the
previous chapter. Projective measurements are thought to be the ideal measurements of a quantum
system. Projective operators satisfy the equality P2 ¼ P, and they can be written as outer products.
For example, in the computational basis of {j0i, j1i}, we can define two measurement operators P0
and P1 as follows:
100 3 The Quantum Superposition Principle and Bloch Sphere Representation
P 0 ¼ j 0i h 0j
ð3:77Þ
ðj0ih0jÞ2 ¼ j0ih0jj0ih0j ¼ j0i h0j0i h0j ¼ j0ih0j
Similarly,
P 1 ¼ j 1i h 1j
ð3:78Þ
ðj1ih1jÞ2 ¼ j1ih1jj1ih1j ¼ j1i h1j1i h1j ¼ j1ih1j
Besides, these two operators form a complete set, and we infer this from Eq. (2.126):
We have successfully defined two operators, P0 and P1, in the computational basis. Let us now
return to the system state jψi ¼ aj0i + bj1i, and verify that these operators work.
The probability of measuring the system in state j0i is given by:
This derivation is according to our earlier statement of the probability of measuring the quantum
system in state j0i. The state of the system after the measurement is:
P0 ψ j0ih0jðaj0i þ bj1iÞ a
jψ 0 i ! pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ¼ ¼ j0i ð3:81Þ
hψjP0 jψ i j a j j aj
Note that a
jaj ¼ eiϕ for some phase angle ϕ. This global phase cannot be measured and has no
significance (Refer to Example 3.2). Hence, we can say that the final state of the system is j0i. In a
similar way, we can derive the system state after a measurement of j1i as jbbj j1i:
Using the same procedure, we can create measurement operators for other basis that may be
required. For example, the measurement operators for the polar basis {j+i, ji} is given in the
following equation. We shall learn about the polar basis in forthcoming chapters.
1
Pþ ¼jþihþj ¼ pffiffiffi ðj0i þ j1iÞ ðh0j þ h1jÞ
2
ð3:82Þ
1
P ¼jihj ¼ pffiffiffi ðj0i j1iÞðh0j h1jÞ
2
Axiom—4:
The average value of the measurement is:
X
h M i m pð m Þ
m
* +
X X
ð3:83Þ
¼ m hψjPm jψ i ¼ ψ mPm ψ
m m
¼hψjMjψ i
3.9 Projective Measurements 101
With this definition, we can define the standard deviation of the observed values.
σ M 2 ¼ ΔM2 ¼ M2 þ hMi2 ð3:84Þ
Quantum circuits are constructed with multiple qubits. In Chaps. 5 and 7, we learn about the quantum
circuits in detail. Section 5.4.5 explains the method of writing multi-qubit systems using tensor
products. In this section, we focus on measuring the multi-qubit systems. Our readers may want to
jump to that section, read ahead, and come back here.
To keep our discussions simple, we use a two-qubit system to explain the concept. The
method outlined here can be extended to larger circuits. Consider the following two-qubit state
explained in Sect. 5.4.5. The combined state is written as a tensor product of the two qubits. Assume
jψ 1i ¼ a1j0i + b1j1i and jψ 2i ¼ a2j0i + b2j1i.
jψ i ¼jψ 1 i jψ 1 i
¼a1 a2 j00i þ a1 b2 j01i þ b1 a2 j10i þ b1 b2 j11i ð3:85Þ
¼αj00i þ βj01i þ γ j10i þ δj11i
By drawing an analogy with the single-qubit measurement, we can define a complete set of four
measurement operators for each of the states contained in the ket vectors of this equation.
In most scenarios, we may have to measure only one of the qubits. For example, if we measure the
first qubit alone, we must distinguish between state “00” and “01.” Hence, the measurement operators
must be able to project to all states consistent with the measurement. Therefore, the operator that
measures the first qubit in the state j0i, must have projectors for the states “00” and “01.” These
operators are defined as follows:
ð0Þ
P0 ¼P00 þ P01 ¼ j0ih0j j0ih0j þ j0ih0j j1ih1j
¼j0ih0j ðj0ih0j þ j1ih1jÞ
¼ j 0i h 0j I
ð0Þ
ð3:87Þ
P1 ¼P10 þ P11 ¼ j1ih1j j0ih0j þ j1ih1j j1ih1j
¼j1ih1j ðj0ih0j þ j1ih1jÞ
¼ j 1i h 1j I
We have now defined the projectors that can measure a system of multiple qubits. We have used a
notation Pðm jÞ , where m denotes the measurement outcome, and j denotes the qubit the operator
operates upon. Note that, in this book, qubits are numbered relative to 0, that is, the first qubit is
named q[0]. This numbering scheme is in line with the programing languages we use in later chapters.
We can now calculate the probability of the first qubit being measured in state j0i.
102 3 The Quantum Superposition Principle and Bloch Sphere Representation
ð0Þ
pð0Þð0Þ ¼ hψ j P0 j ψi
¼ ðα h00 j þ β h01j þ γ h10 j þ δ h11jÞ ðj 0ih0j IÞ ð3:88Þ
ðαj 00i þ βj 01i þ γj10i þ δj 11iÞ
The probability of the first qubit being measured in state j0i is the sum of the probabilities of
measuring j00i and j01i. The system state after this measurement is as follows:
ð0Þ
P0 ψ
j ψ 0 i ! qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ð0Þ
hψ j P0 j ψi
ðj 0ih0 j IÞ ðαj 00i þ βj 01i þ γj 10i þ δj11iÞ
¼ qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð3:90Þ
jαj2 þ jβj2
αj00i þ βj01i
¼ qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
jαj2 þ jβj2
Therefore, when we measure the first qubit in state j0i, the probability of the system being in states
j10i and j11i, no longer exists. We can similarly derive the first qubit in state j1i. We leave that as an
exercise for our audience.
3.9.3 Measurements
When we measure the voltage in an electrical circuit, we bring a voltmeter across the circuit and
perform the measurement. Von Neumann proposed a similar procedure for measuring quantum
systems. To measure an observable Q of a quantum system S, we bring it in proximity with a
meter M and allow them to interact
P linearly. At the time of measurement, assume that the system is
in a superposition state jψi ¼ ai jxi i, and the meter is in state jmi. The composite state of the
i
P
system S + M is given by the tensor product ai jxi i jmi: jxii are the eigenvectors of Q, and the
i
possible outcomes of the measurement are qi. When the meter registers the measurements qi, the state
P
of the system is γ i jxi i jmi i, where the mi are orthonormal vectors, that is, aj0ijm0i + bj1ijm1i. In
i
this state, the meter is entangled (Sect. 5.6) with the quantum system.
P
Due to the measurement process, the system “collapses” from the state γ i jxi i jmi i into the
i
state jxii jmii, for some i.
A density matrix function can describe the state of the meter. From Eq. (6.16), we can write this as:
where ρM is the density matrix of the meter, m0 is the state of the meter if the quantum system
measures j0i, and m1 is the state of the meter if the quantum system measures j1i. This equation
represents a probability distribution over all possible values the meter can measure. The probability is
3.11 Summary 103
jaj2 for the meter to be in state jm0i and jbj2 for the meter to be in state jm1i. This is the physics of the
measurement.
Positive Operator Valued Measures are concerned about the statistics of the measurement, and not
about the post-measurement state of the system. There are many use cases of this measurement, for
example, quantum algorithms in which the measurement is performed at the end of the circuit.
Assume that we measure a quantum system jψi with a measurement operator Mm, and the outcome
of the measurement be m. The probability of the outcome is given by pðmÞ ¼ ψjMym Mm jψ . If we
P
can define Am ¼ Mym Mm , it follows that Am ¼ I and p(m) ¼ hψjAmj ψi.
i
The operators Am are positively well defined.
Note that since p(m) ¼ hψjAmj ψi, we can use the set of operators {Am} to estimate probabilities of
the outcomes, instead of {Mm}. The complete set of {Am} is known as POVM. If we consider a
projective measurement done by a complete set of projectors Pm, then Am Pym Pm ¼ Pm : This means
projective measurements are an example of the POVM formalism.
3.10 Qudits
Qudits [4] are basic units of quantum computation, like the qubits. While the qubits store quantum
information in a superposition of two-states, the qudits work on a superposition of d states (d > 2).
There are also qutrits that have a dimension of three. Extending the dimensionality of the computa-
tional units brings a lot of computing power. A system of two qudits, each with 32 dimensions, is
equal to 20 qubits.
Qudits are early in the research, and researchers have reported few applications. Qudits with
d ¼ 10 have been experimentally realized in labs. Qudits are considered as substitutes for the
ancilla qubits. This reduces the number of interactions between information carriers in multi-qubit
gates. Qudits can create alternate hardware topologies reducing circuit depth (Chap. 5.) Qudits can
also improve quantum communication. If we can encode more information in one photon, the channel
efficiency can increase tremendously.
3.11 Summary
In this chapter, we continued our learning on quantum mechanics. We started with the definition of
Hilbert space and learned about the Schr€odinger equation. After refreshing our knowledge on the
postulates of quantum mechanics, we learned about quantum tunneling and the concept of two-state
systems using the Stern and Gerlach experiment. We applied this learning into building the concept of
qubits, the basic unit of information in quantum computing. We learned how to use Pauli operators to
rotate the state vector of the qubits and performing projective measurements.
The next chapter is an essential milestone in our learning, and it focuses on the physical systems—
how qubits are constructed.
104 3 The Quantum Superposition Principle and Bloch Sphere Representation
Practice Problems
1. If x is the position operator and p is the momentum operator, calculate the commutators [x, p],
[x2, p], and [x, p2].
2. Characterize the operator σ ¼ σ x iσ y.
3. Consider a system of 4 qubits (spin-12 states.) How many states are exhibited by the system?
4. Find the eigenvalues of the spin operator s of an electron, along a direction, perpendicular to the
x-z plane.
2 3 2 3
1 2 0 3
6 7 6 7
5. The Hamiltonian of a quantum state jψi ¼ 4 2 5 is given by H ¼ 4 0 1 0 5: Supposing, if we
1 3 0 2
measure the quantum state in an arbitrary basis, which eigenvalue is the most probable? Also,
calculate the expectation value of that state.
6. In a region, a particle of mass m, and zero kinetic energy has a wavefunction ψ ðxÞ ¼ Axex =k ,
2 2
References
1. Introduction to Quantum Mechanics, 3/e, David J. Griffiths (Author), Darre; F. Schroeter (Author.)
2. Principles of Quantum Mechanics, 2/e, R. Shankar (Author.)
3. Quantum Computation and Quantum Information (Cambridge Series on Information and the Natural Sciences), 1.e,
Michael A. Nielsen (Author), Isaac L. Chuang (Author.)
4. For more information of Qudits: (a) Scalable quantum computing with qudits on a graph, Kiktenko et al., 2020,
https://arxiv.org/pdf/1909.08973.pdf; (b) The geometry of quantum computation, Dowling and Neilsen, 2008,
https://arxiv.org/pdf/quant-ph/0701004.pdf; (c) High-dimensional optical quantum logic in large operational spaces,
Imany, P., Jaramillo-Villegas, J.A., Alshaykh, M.S. et al. npj Quantum Inf 5, 59 (2019). https://doi.org/10.1038/
s41534-019-0173-8
Part II - Essentials
Qubit Modalities
4
“Well, in our country,” said Alice, still panting a little, “you’d generally get to somewhere
else—if you run very fast for a long time, as we’ve been doing.”
“A slow sort of country!” said the Queen. “Now, here, you see, it takes all the running you
can do, to keep in the same place. If you want to get somewhere else, you must run at least
twice as fast as that!”
― Lewis Carroll, Alice’s Adventures in Wonderland.
The previous chapters gave an introduction to the principles of quantum mechanics. We learned about
Hilbert space, wavefunctions, quantum superposition principle, two-state systems (qubits), Bloch
sphere representation, and Pauli matrices. We used Dirac’s bra-ket notation in explaining these
concepts. This chapter takes us through the next steps in our journey and focuses on qubit modalities.
We begin this chapter by building up a vocabulary of quantum computing.
Qubits
The qubits (meaning quantum bits) are the quantum equivalent of classical digital bits. The qubits
work on the principles of quantum mechanics and are in the superposition state. We must use the
principles of quantum mechanics to change the state of the qubits. At the end of the computation, we
can measure the qubit’s state by projecting them into classical digital bits.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 107
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_4
108 4 Qubit Modalities
Quantum Annealing
It is a procedure for finding a heuristic algorithm that identifies a global minimum from a finite set of
candidate solutions using Quantum Fluctuations. Combinatorial optimization problems with a
discrete search space with many local minima, such as the traveling salesman problem, can be solved
using Quantum Annealing. The system starts with the superposition of all candidate states using
quantum parallelism and evolved using the time-dependent Schr€ odinger equation. By adjusting the
transverse field (a magnetic field perpendicular to the axis of the qubit), the amplitudes of all states
can be changed, causing Quantum Tunneling between the states. The goal is to keep the system
close to the ground state of the Hamiltonian. When the transverse field is finally turned off, the system
reaches its ground state, which corresponds to the solution of the optimization problem. In 2011,
D-Wave systems demonstrated the first-ever Quantum Annealer.
Quantum Speedup
An optimal scenario, where there is a proof that no classical algorithm can outperform a given
quantum algorithm. Besides factorization and discrete logarithms, there are a handful of quantum
algorithms with a polynomial speedup. Grover’s algorithm is one such algorithm that we shall see in
an upcoming chapter. Simulation algorithms for physical processes in quantum chemistry and solid-
state physics have been reported. An approximation algorithm [3] for Jones polynomial with a
polynomial speedup and a solution to Pells’s equation, and the principal ideal problem in polynomial
time [4] have been published [5]. This space is evolving.
Quantum Advantage
The computational advantage of quantum computers. A notion that quantum computers can perform
some computations faster than classical computers.
Quantum Supremacy
The potential ability [6] of quantum computers to solve problems that classical computers practically
cannot.
Decoherence
The process in which the qubit loses the quantum information in time, due to interactions with the
environment.
Quantum Volume
A pragmatic [7] way to measure and compare progress toward improved system-wide gate error rates
for near-term quantum computation and error-correction experiments. It is a single-number metric
that a concrete protocol can measure using a near-term quantum computer of modest size n ≲ 50.
4.2 Classical Computers—A Recap 109
The computers we use today store information in a binary format—as 0s and 1s using transistor
switches, called bits. The bits are the basic computational units in a digital computer. There are
billions of such switches integrated into minuscule circuits in a computer today. Each time we do a
task on a computer system, these switches are turned on/off a billion times!
By forward biasing the transistor, the transistor can be turned ON, equivalent to the switch being in
the CLOSED state. When the switch is closed, the current drain in the circuit denoting a binary state
of “0.”
By reverse biasing the transistor, the transistor can be turned OFF. This is equivalent to the switch
being turned OPEN. When the switch is open, it denotes a binary state of “1” (Figs. 4.1 and 4.2).
By creating arrays of these switches in 8-bit, 16-bit, 32-bit, or 64-bit sizes, large numbers can be
stored and processed. Figure 4.3 shows an 8-bit register storing the alphabet “A” in the standard
ASCII encoding.
The digital gate operations help us manipulate this binary information. A sequence of these gates is
created to perform basic mathematical operations such as addition, subtraction, multiplication, or
division. In Chap. 5, we shall construct a quantum circuit to perform a basic addition operation.
Any operation that we do at the application level—indexing, sorting, statistical calculations, and
user interface—they all boil down to a sequence of gate operations at the processor level.
Figure 4.4 shows the set of digital gates, called universal digital gates and their truth table. The
truth table summarizes the various combinations of inputs and outputs. These gates are called
C VOUT
VOUT
RI B SWITCH
VIN
CLOSED
E
GND GND
C VOUT
VOUT
RI B SWITCH
VIN
OPEN
E
GND GND
110 4 Qubit Modalities
GND
A A
A Z Z Z
B B
universal digital gates because all other digital gates can be constructed from them (or NAND and
NOR gates). The transistor switches we saw earlier are used to construct these gates. To keep our
discussions minimal on this topic, we do not show how these gates are constructed [8]. Chapter 5
describes the quantum universal gates.
A fundamental difference between the digital bits and the qubits is the way they operate. The digital
bits can be deterministically set in a “0” or a “1” state, and read (or measured) any number of times as
long as it is powered. Reading a digital bit does not destroy its state. Moreover, the digital bit retains
its state as long as it is powered.
The qubits are probabilistic, and they are in a superposition state of “0” and “1” with different
probabilities. They possess the characteristics of both the states simultaneously, at all times, until
measured. The qubits lose their internal state when they are measured. Besides, due to the laws of
nature, the qubits interact with the environment, pick-up Rabi oscillations, and “decohere” over a
period of time. We shall learn more about the characteristics of the qubits in subsequent sections
(Fig. 4.5).
4.4 Noisy Intermediate Scale Quantum Technology 111
The digital bits we saw earlier are designed as transistor circuits in silicon substrates. It is a mature
semiconductor technology now, and it took several decades to get us to this stage. For the past
30 years or so, research labs and the industry are researching the right modality for implementing
commercial-grade qubits. Several physical systems have been researched so far: Nuclear Magnetic
Resonance devices, valency centers in diamonds, photonics, trapped ion devices, superconducting
transmons, quantum dots, and topological qubits. The research in this space is expanding, and new
technologies are reported by research labs quite frequently.
The digital bits are fabricated on a single technology, namely semiconductors. The physical
systems for qubits are based on technologies that differ in the way how they store, manipulate, and
measure the quantum state. Irrespective of the underlying technology, we expect the qubits to have a
longer coherence time and high gate fidelity. Scalability and quantum error correction are other
essential factors. Another important factor is the coupling between the qubits. Coupling is needed, at
least at 2-qubit levels. Quantum algorithms require coupling between any combinations of qubits. If
that is not possible, SWAP operations may be required to exchange states between qubits for running
the algorithm (like data exchange between two variables in classical programming). This constraint
limits the length of the quantum computation we can perform before the system decoheres. Several
methods are under research for qubit coupling.
The physical system must not be just confined to research labs for research work. It should be
possible to implement commercial-grade real-time systems. For this, the physical system must be
scalable to thousands of qubits. Elaborate error correction mechanisms and coupling schemes should
be built so that developers can focus on creating quantum algorithms rather than creating code to fix
quantum errors and manage coupling schemes.
This task is quite challenging for system engineers to characterize and improvise qubits. It may
take a few years before large-scale fault tolerance systems are available for commercialization. In the
next few sections, we shall learn the most researched and industry adopted qubit modalities, all of
which have a high potential for scalability in the future.
Noisy Intermediate Scale Quantum Technology is a term [9] coined by Prof. John Preskill, Caltech, to
denote the current quantum computing era. Though some of the algorithms we can run on the
currently available 50 or so qubit quantum processors cannot be simulated efficiently on classical
112 4 Qubit Modalities
computers, the algorithms known to us today are sensitive to quantum errors. They cannot be run
reliably in real-time environments. The susceptibility of the current devices to decoherence and
quantum noises limits the systems’ usability to demonstrations or prototypes in current times. This
situation is frustrating, we know the quantum systems are more powerful than the classical computers
in some ways, but we cannot put the quantum systems to good use beyond the research labs.
According to Prof. John Preskill, “Noisy Intermediate-Scale Quantum (NISQ) technology will be
available in the near future. Quantum computers with 50–100 qubits may be able to perform tasks
which surpass the capabilities of today’s classical digital computers, but noise in quantum gates will
limit the size of quantum circuits that can be executed reliably. NISQ devices will be useful tools for
exploring many-body quantum physics, and may have other useful applications, but the 100-qubit
quantum computer will not change the world right away—we should regard it as a significant step
toward the more powerful quantum technologies of the future. Quantum technologists should
continue to strive for more accurate quantum gates and, eventually, fully fault-tolerant quantum
computing.”
So, we are there, but not quite yet. In our discussions so far, we touched upon decoherence and
quantum errors a few times. We know they can impact quantum computation. If we are given a
quantum processor with a certain number of qubits, how do we measure the qubits’ quality? The next
section describes the metrics adopted by the industry and facilitated by research. Once we know the
device metrics, we can determine what algorithms can be potentially run on them.
This measure is the characteristic time taken by a qubit to return to its ground state from an excited
state due to spin-environment coupling. We measure this by inversion recovery. The qubit is first
prepared in the state j0i. We then apply an X transform and wait for a time t to measure the probability
of the qubit to be in state j1i, that is, relaxation did not occur (Fig. 4.6).
-X
t=0
-Y Y
t = T1
X
-Z
4.5 Qubit Metrics 113
Z Z
(a) (b)
-X -X
-Y Y -Y Y
X X
-Z -Z
Fig. 4.7 (a) The Bloch vector starts to decohere. (b) A fully decohered Bloch Vector (T2)
j0iþ
pffiffij1i .
Assume a qubit in an equal superposition state 2
When the qubit is not interacting with the
environment, it undergoes a constant precession at a frequency ω, known as the qubit frequency at an
azimuthal angle ∅ (Fig. 3.10 in Chap. 3). Due to environmental influence, the Bloch vector starts to
decohere (Fig. 4.7a). The time it takes to decohere completely (Fig. 4.7b) is known as the
Decoherence Time, and it is a measure of the qubit’s usable lifetime. The decoherence time can be
measured using Hann Echo or Ramsay Experiment.
In this method, we prepare the qubit in the equal superposition state j0iþ
pffiffij1i (by applying a Hadamard
2
gate), and wait for half the time 2t. After this, we apply an X transform and wait for the remaining time
2t. Finally, we apply a Hadamard gate again to measure its probability of being in state j0i. The wait
time gives the qubit the time to start to decohere.
4.5.5 Ramsay Experiment T 2
In this method, we prepare the qubit in the equal superposition state j0iþ
pffiffij1i (by applying a Hadamard
2
gate) and wait for the time t. After the wait time, we apply a Hadamard gate to measure its probability
of being in state j0i.
114 4 Qubit Modalities
The number of gate operations one can perform before the qubit completely decoheres and loses its
usable lifetime. The gate time is equal to TT∅2 , and it is in the range of 100–10,000 for the leading qubit
modalities.
Qubits are two-state systems in which information equivalent to one classical bit can be stored. Any
quantum mechanical system that can exhibit two distinct states and coupling can be used to construct
a qubit. Since the 1990s, many physical systems have been researched and prototyped as qubits. Some
of the notable implementations are NMR, nitrogen valence centers in diamonds, trapped ion qubits,
superconducting devices, photonics, semiconductor-based quantum dots, etc. Each of these
implements is benchmarked against standard metrics such as the ability to store and measure quantum
states, the fidelity of operations, and continual improvement. Scalability, speed, and the probability of
errors and recovery are paramount conditions of usability.
This section studies four leading qubit modalities: trapped ion, superconducting transmons,
topological, and quantum bits.
Note: Reading Sect. 1.7, on exotic states of matter may be helpful to read the following
sections in this chapter.
In Chap. 1, we learned that we could create ions by stripping off electrons from atoms. This qubit
modality follows a similar method. A small amount of calcium is molten in a vacuum, and the
evaporating vapor is hit with a high energy electron beam. This process strips off one electron from
each of the calcium atoms and creates Caþ ions. A Paul trap attracts some of these ions. The Paul
43
trap is powered by DC electrodes and RF fields. The RF field is set up in such a way that the
confinement is alternating between the x and y axes. The oscillating force is minimal at the center of
the trap and grows significantly toward the edges. This oscillating force confines the ions to the center
of the trap, where the total energy is minimal. The DC electrodes provide the needed potential so that
the ion does not escape along the z-axis. A blue laser cools the ion trap into millikelvin degrees and
stabilizes the qubit.
Any additional thermal energy acquired or lost by the ions from the environment must be very
small compared to the kinetic energies involved in the controlled operation of the qubit. If this is not
possible, the ion is not stable, and the Bloch vector diffuses rapidly. The energy gained by a trapped
ion by absorbing or emitting a photon by interacting with the environment is about
4.6 Leading Qubit Modalities 115
Fig. 4.8 Schematic of a trapped ion qubit. (Image: APS/Alan Stonebraker, Copyright 2014 American Physical
Society. Printed with permission)
0.00000000000000000000000000002 joules. This thermal energy is so low that we must cool the
qubit to millikelvin temperatures (Fig. 4.8).
In atoms, the hyperfine structure in the spectral lines happens due to the interaction between the
magnetic field caused by the electron’s movement and the nuclear spin. Caþ ions have two
43
hyperfine ground states at S12 ðF ¼ 3, MF ¼ 0Þ and S12 ðF ¼ 4, MF ¼ 0Þ: Here F is the total angular
momentum of the atom and MF ¼ F, F + 1, . . ., F 1, F. The energy-level separation between
the two hyperfine ground states is 2.3 GHz, and a minimum magnetic field of about 146 G can create
this. The hyperfine states are large enough, and they are not susceptible to magnetic field fluctuations.
Since the hyperfine structure is at the ground state, its lifetime is higher. These are some reasons for
the choice of Caþ ions for this modality. Some organizations have reported the use of ytterbium
43
(Yb) atom, however. The two hyperfine structures represent the j0i and j1i states.
We can prepare the qubit to the desired j0i or j1i states by applying measured RF pulses through
the RF electrodes. By applying measured doses of RF pulses along the required axes, we can perform
gate operations. The trapped-ion qubits are coupled through mutual Coulomb repulsion or by using
lasers. The state of the qubit is read by monitoring the fluorescence. Only the state j1i results in
fluorescence, and hence it is easy to implement the measurement part. The coherence time of the
trapped-ion qubits is 50 s and have a 99.97% error rate in 150,000 operations. These are good
numbers for trying out quantum algorithms.
The trapped-ion qubits are constructed as micro-circuits using the same processes used to make
silicon-based integrated circuits. The diode lasers and the electrodes used in the circuit are fabricated
in the same ways the integrated circuits are made. The setup must be kept in a high vacuum. The
challenge with this modality is that it employs too many lasers, and qubit coupling is difficult. The
sources of noise are the heating of the qubits, environmental noises, and instability of the laser fields.
We do not yet have much proof that the trapped ion qubits are the way forward, but yes, they are an
excellent alternative to superconducting transmons. The Spanish physicist Ignacio Cirac and the
Austrian physicist Peter Zoller first reported the trapped-ion qubits in a research paper in 1995.
Several research labs and companies are using this modality. The following table summarizes them
[26] (Table 4.1).
116 4 Qubit Modalities
Note: Readers can skip the equations and continue to read the text, without compromising
the understanding.
∂ψ 1
iħ ¼ E1 ψ 1 þ Kψ 2
∂t ð4:1Þ
∂ψ
iħ 2 ¼ E2 ψ 2 þ Kψ 1 ,
∂t
where E1 and E1 are the lowest energies the Cooper pairs on the superconducting islands can occupy.
K is a coupling constant.
We assume the wavefunctions as:
pffiffiffiffiffi
ψ 1 ¼ n1 eiθ1 and
pffiffiffiffiffi ð4:2Þ
ψ 2 ¼ n2 eiθ2 ,
where n1 and n2 are the density of Cooper pairs in the islands. θ1 and θ2 are the phases.
With this, Eq. (4.1) can be written as:
∂n1 ∂n pffiffiffiffiffiffiffiffiffi
ħ ¼ ħ 2 ¼ 2K n1 n2 sin ðθ2 θ1 Þ
∂t ∂t : ð4:3Þ
∂ ðθ 2 θ 1 Þ
ħ ¼ E2 E1
∂t
The application of voltage V shifts the energy level by E2 E1 ¼ 2 eV. The time derivative of the
charge density n1 gives the Josephson current or the supercurrent IJ in the circuit. The constant
pffiffiffiffiffiffiffiffiffi
I c ¼ 2K
ħ n1 n2 defines the critical current of the junction, and the superconducting phase difference is
defined by γ ¼ θ1 θ2 . With this, we can rewrite Eq. (4.3) as:
I J ¼ I c sin γ
ħ ∂γ Φ0 ∂γ ð4:4Þ
V¼ ¼ ,
2e ∂t 2π ∂t
where Φ0 ¼ 2e h
¼ 2:07 1015 T m2 is the “superconducting magnetic flux quantum.” The mag-
netic flux in a superconducting loop is quantized with value n ∙ Φ0, where n ¼ 0, 1, 2,. . . .
By differentiating the first equation and substituting ∂γ
∂t
with V, we get
dI J 2π
¼ I c cos γ V: ð4:5Þ
dt Φ0
The term cos1 γ means that we have a nonlinear behavior with the inductance, which we shall use in
the next steps. Now that the nonlinear behavior is established, we can focus our attention on the
creation of nondegeneracy required to create a two-state system. For that, we need to use the
inductance in an LC circuit to make it behave like a Quantum Harmonic Oscillator.
Consider the LC circuit, shown in Fig. 4.10b. This circuit is made by connecting an inductor of
inductance L in parallel with a capacitor of capacitance C. Let V be the voltage across the circuit and
let I be the current flowing in the circuit. Let ϕ be the magnetic flux. This circuit is an example of a
simple harmonic oscillator, with a characteristic frequency ¼ p1ffiffiffiffi
LC
ffi . The voltage and current in this
118 4 Qubit Modalities
Energy
3 +V
L C
2
1
0
LC Circuit
circuit oscillate at the same frequency, but the voltage leads the current by a phase difference of π2. It
can be shown that the classical energy of this circuit is given by the following equation:
1 1
E ¼ CV 2 þ LI 2 : ð4:7Þ
2 2
The first term in this equation represents the electrical energy stored in the capacitor when it is
charging. The second term represents the energy stored in the magnetic field when the current I flows
through the inductance.
It can be shown that the Hamiltonian for an LC circuit, equivalent to the classical energy in
Eq. (4.7), can be written by the following equation [13]:
1
H ¼ 4Ec n2 þ EL ϕ2 , ð4:8Þ
2
where Ec ¼ e2/(2C) is the charging energy required to add each electron in the Cooper pair into the
2
island and EL ¼ ðΦ0L=2π
J
Þ
is the inductive energy. The reduced flux ϕ 2πΦ
Φ0 , is known as the “gauge-
invariant phase” across the inductor. The reduced charge n ¼ 2C Q
is the excess number of Cooper
pairs on the island.
This equation is identical to the Hamiltonian of a single particle Quantum Harmonic Oscillator in
one dimension. The first term represents the kinetic energy stored in the inductor, and the quadratic
second term represents the potential energy stored in the capacitor. We can solve this equation as an
eigenvalue problem on the coordinate basis, with ϕ as the position coordinate, for the wavefunction
hϕjψi ¼ ψ(ϕ). The solution leads to an orthogonal polynomial called Hermite functions with an
infinite set of eigenstates jni, n ¼ 0, 1, 2, . . . .
The corresponding eigenenergies are:
1
En ¼ ħω n þ , where n ¼ 0, 1, 2, . . . , ð4:9Þ
2
pffiffiffiffiffiffiffiffiffi
where 8Eħc EL ¼ p1ffiffiffiffi
LC
ffi.
This has few inferences—the energies are quantized (which is good!), and equally spaced by ħω.
The lowest energy in the ground state (or the vacuum state) represented by n ¼ 0 is called “zero-
point energy.” Quantum mechanically, this does not represent a zero particle. Instead, it must be
4.6 Leading Qubit Modalities 119
Island Cg
F
Vg
CJ EJ
Bulk
Fig. 4.12 The charge qubit or the Cooper pair box, schematic
voltage Vg. The quantum state is determined by the number of Cooper pairs that have tunneled
through the junction (N ). The below equation outlines the Hamiltonian of the charge qubit:
2
H ¼ Ec N N g Ej cos ðϕÞ, ð4:11Þ
2
where the charging energy Ec ¼ ð2C
2eÞ Cg V g
Σ
, CΣ ¼ Cg þ CJ , the gate charge N g ¼ 2e , Josephson energy
I c Φ0
Ej ¼ 2π, and ϕ is the guage invariant phase difference between the two junctions.
The bias voltage Vg is adjusted until the charge degeneracy point N g ¼ 12 is reached. This results in
a broader separation between states j0i $ j1i than other states. Hence, this is a candidate for a
two-state system.
The coherence times are in the order of 1–2 μs. Readouts are performed by coupling the island to a
single electron transistor (SET).
The sources of noise in superconducting qubits can arise from fluctuating charges (quasiparticles,
electron hopping, electric dipole flipping), fluctuating magnetic spins, and fluctuating magnetic
vortices.
At low temperatures, fluctuating magnetic spins, and fluctuating magnetic vortices are the sources
of flux noises. The charge noises arise out of the fluctuating charges.
Cg
Cin
Cin CJ EJ
Cg1 Lr Cr CB
C’B Cg2 Vg
Fig. 4.13 Superconducting split symmetric transmon. (Ref: Koch et al., 2007)
capacitance CB across the superconductors, a proportional gate capacitance Cg is added to the circuit
(Fig. 4.13).
We treat the split Josephson Junctions as a single junction with energy E0J. The Hamiltonian of this
qubit is given by the following equation, ignoring the effects of the transmission line introduced in the
circuit:
2
H ¼ 4Ec N N g 2EJ j cos ðφe Þj cos ðϕÞ, ð4:12Þ
where φe ¼ πΦ 0
Φ0 and EJ ðφe Þ ¼ 2EJ j cos ðφe Þj.
ext
The ratio EJ/EC determines the anharmonicity of the energy levels and the charge dispersion. The
charge dispersion relates to the susceptibility to charge noise, and the anharmonicity in the energy
levels correspond to the device’s ability to perform as a two-state system.
From the second term of the above equation, we can infer that the Josephson energy E0J ranges from
0 to 2EJ, and it can be tuned using the external flux Φext. While this helps to reduce charge dispersion,
it increases the qubit’s sensitivity to the flux. A solution to this problem is by using asymmetric
junctions, which suppresses the flux sensitivity across the range. The Hamiltonian of an asymmetric
split transmon is given by the equation (4.13):
2 qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
H ¼ 4Ec N N g EJΣ cos 2 ðφe Þ þ d2 sin 2 ðφe Þ cos ðϕÞ, ð4:13Þ
where EJΣ ¼ EJ1 + EJ2, the respective junction energies. The junction asymmetry parameter
d ¼ (γ 1)(γ + 1) with γ ¼ EEJ2J1 :
Here again, we can treat the two junctions as a single junction with energy
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
E0J ðφe Þ ¼ EJΣ cos 2 ðφe Þ þ d 2 sin 2 ðφe Þ.
When d ¼ 0, this equation reduces to the symmetric case as in Eq. (4.12).
When jdj!1, the asymmetric energy E0J ðφe Þ ! EJΣ, and the equation reduces to the single junction
Eq. (4.11).
This setup suppresses the flux sensitivity across the range and also reduces the range itself. So the
qubit can be calibrated using a small tuning frequency against fabrication variances. This small tuning
range decreases the susceptibility to flux noise and hence improves coherence.
In recent times, new qubit designs that protect against noise at the hardware level—charge-parity
qubits [31], fluxon-pair qubits [28], and 0 π qubits [30] have been reported. Section 9.6 provides an
introduction to these qubits with fault-tolerance at the hardware level.
Because of the scalable potential of this technology, several companies and research labs are
working on this technology. Some of them are listed in the table below [26] (Table 4.2).
122 4 Qubit Modalities
Table 4.2 List of research institutes and companies working on superconducting qubits
CAS-Alibaba Quantum Computing Bleximo Chalmers University of
Laboratory Technology
Google IBM Intel
IQM Finland MDR MIT
Origin Quantum Computing Oxford Quantum Circuits Oxford University
Quantic Quantum Circuits Inc Qutech
Raytheon BBN Rigetti SeeQC.EU
University of California, Santa Barbara University of Science & Technology of University of Waterloo—IQC
China
University of Wisconsin Yale Quantum Institute
In the quest for building fault-tolerant quantum computers, several techniques are researched. In the
last section, we came across several improvements to a standard Josephson Junction—the shunt
capacitance, the transmon, and the usage of asymmetric Josephson Junctions. Since quantum
computing is very niche at this time of writing, it receives much funding for research, and researchers
experiment with many avenues to achieve quantum supremacy. One such technology currently being
researched is based on the application of Majorana fermions into a modality called Topological
qubits, which is novel and promising. Topological qubits use Majorana zero modes to create highly
degenerate ground states in which quantum information can be encoded nonlocally, protecting it from
local noise. At this time of writing, there are no functional topological qubits to experiment with.
However, the underlying physics is quite fascinating, and this section is devoted to exploring this
modality from the theoretical perspective.
The Majorana fermions are antiparticle to themselves. Hence, we can say that the Majorana
fermions are created by the operator given below:
γ i ¼ ai þ a{i , ð4:15Þ
which means, γ i ¼ γ {i . Thus, the creation and annihilation operators are the same for Majorana
fermions, while for a Dirac fermion, they are different. This behavior is somewhat difficult to
4.6 Leading Qubit Modalities 123
comprehend. We cannot easily imagine the physical systems where this scenario is possible. For
example, if we consider the case of electrons, the creation operator a{j creates an electron of charge
e. The annihilation operator ai creates a hole of charge +e. This means, γ i creates a superposition of
two different charges, which is not ordinarily possible. However, this is possible in superconductors,
where electrons pair up to form Cooper pairs (which are bosons), which condensates. We shall study
this possibility in detail later in this chapter.
jψ 1 ψ 2 i ¼ eiθ jψ 2 ψ 1 i: ð4:16Þ
The phase factor eiθ is 1 for bosons (which obey Bose–Einstein statistics) and 1 for fermions
(which obey Fermi–Dirac statistics). We can interpret this equation as follows: when two particles
rotate anticlockwise about each other for half a turn, they return to the same quantum state, except by
getting multiplied by a complex phase factor eiθ. For clockwise rotations, it would be eiθ.
1
See Appendix for braid word labeling convention.
124 4 Qubit Modalities
This process works very well in a two-dimensional space, where the clockwise and anticlockwise
directions make sense. When θ is 0, it represents bosons, and when it is π, it represents fermions.
However, between these two states (θ ¼ 0 for bosons and θ ¼ π for fermions), there could be other
particles which we call anyons, and we refer them as anyons with statistics θ.
The anyons have a peculiar property that, if they revolve about each other for half turn in the
anticlockwise direction to swap places, and if they revolve again for half turn in the clockwise
direction to go back to their original places, their wavefunction is not the same, but multiplied by a
phase factor e2iθ. This is a sort of memory that helps us to track the trajectory of the particles. By
controlling the path, the anyons can take, we can implement a two-state system. This system is one
way to implement a topological qubit.
bi b j ¼ b j bi for ji jj 2 Commutativity
: ð4:17Þ
bi biþ1 bi ¼ biþ1 bi biþ1 for 1 i < N Braid relation
with statistics θ, we can make a bound state of these two particles with statistics 4θ. If we can bring
two such abelian anyons close together, they can be approximated as a single particle by combining
the quantum numbers. This process is called fusion. When we bring together an anyon and an anti-
anyon, it results in a state of zero particle called vacuum or the trivial particle denoted in boldface
as 1. This process applies to abelian anyons, and they form larger composites of mπ particles.
When two non-abelian anyons are brought together, the outcomes are probabilistic, as there is no
unique way of combining the topological quantum numbers. For example, two spin-12 particles can
combine to form a spin-0 or a spin-1 particle, and the outcome of this combination is probabilistic.
The different possibilities in which the non-abelian anyons combine to form new particles are through
126 4 Qubit Modalities
different fusion channels. Each of these fusion channels is responsible for the degenerate multiparti-
cle states.
Fusion Space
In an anyon model spanned by some particles M ¼ {1, a, b, c, . . .}, where a, b, c are topological
charges carried by the anyons when a particle of species a fuses with another particle of species b, the
fusion channel is defined as a sum of all possible anyons in the system, including the trivial particle
c ¼ 1:
X
ab¼ N cab c ð4:18Þ
c
The fusion coefficient2 N cab is the total number of distinct quantum states through which a and
b can merge. The result of this fusion can be a particle c if the fusion coefficient N cab 6¼ 0:
In the case of non-abelian anyons, there is at least one a,b for which there are multiple fusion
channels c with N cab 6¼ 0: For abelian anyons, for each a and b, there exists a c such that N cab ¼ 1 and
N cab ¼ 0 for everything else. The fusion process corresponds to a Hilbert space consisting of all
distinct orthonormal quantum states of a and b defined as hab; cj ab; di ¼ δcd.
Hence, a system of N distinct fusion channels in the presence of a pair of particles exhibits N fold
degeneracy, called fusion space. This fusion space is a protected low-energy, decoherence-free
subspace, in which local perturbations do not affect the degeneracy. This subspace is a collective
nonlocal property of the anyons, and it can be used to encode quantum information.
The fusion states jab; ci and jab; di belong to two different topological charge sectors defined by
c and d. Hence, they cannot be used to create a superposition. Therefore, we cannot use these two
fusion states to create a qubit. We need more than two anyons which can fuse in different ways but
produce the same result.
Consider three anyons a, b, and c, which may fuse in some order producing intermediate
outcomes, but always produce d at the end. There are two distinct basis for these three anyons, as
shown in Fig. 4.17. In the first scenario, a and b fuses to produce i. In this case, the basis states are
labeled by i and denoted by j(ab)c; ic; di. In the second scenario, b and c fuse to produce j. In this
case, the basis states are labeled by j and denoted by ja(bc); aj; di. These two are related by a fusion
matrix Fdabc, which is determined by the Pentagon identities. This relation is shown in the following
equation:
X j
jðabÞc; ic; di ¼ Fdabc i jaðbcÞ; aj; d i: ð4:19Þ
j
j
This is summed over all the anyons b and c can fuse to subject to the condition N bc 6¼ 0, which we
saw earlier. Thus, the F matrix describes the fusion space.
Figure 4.18 shows the fusion outcome 5 of four anyons 1, 2, 3, 4. The first diagram has
intermediate outcomes a and b. The two F moves in the upper path lead to the final fusion diagram
with intermediate outcomes c and d. The alternative path on the lower part of the diagram has three
F moves and produces the same outcome. We require that these two paths are equivalent and produce
the same outcome. These two paths are stated in the following pentagon identity equation:
2
Note the potential notation difference: in some literature, the subscript and superscript can be reversed.
4.6 Leading Qubit Modalities 127
d b X c 5 d 5 e
F512c a
F5a34 c
¼ Fd234 e
F1e4 b F123 b: ð4:20Þ
e
Braiding Operations
When anyons are exchanged (braided), the fusion space undergoes a unitary evolution. We saw
earlier that in the case of abelian anyons, the exchange operation results in a complex factor. We also
saw that the phase factor depends upon the type of the anyon and the direction of the exchange, but
not on the order of exchange. We can now define an exchange operator Rab ¼ eiθab ; 0 θab 2π,
which applies to abelian anyons.
In the case of non-abelian anyons, the resultant phase depends upon the type of the anyons and the
c
fusion channel. We can define a corresponding exchange operator as Rcab ¼ eiθab . Here, we see that
braiding assigns different phases to different fusion channels that depend on the orientation of the
exchanges and the order of the exchange. These R matrices (derived from a set of identities known as
Hexagon identities) describe all unitary evolutions happening in a fusion space. Considering the
basis j(ab)c; ic; di from Eq. (4.19), the clockwise exchange of a and b can be written as a unitary
evolution:
X j
jðbaÞc; ic; d i ¼ Rab δij jðabÞc; ic; di: ð4:21Þ
j
128 4 Qubit Modalities
Figure 4.19 shows the clockwise exchange of non-abelian anyons a and b, producing the fusion
outcome c with a phase factor Rcab .
Consider the anyons 1, 2, 3, which fuse to produce 4. The fusion channel is through a. By applying
an alternate sequence of F and R moves, we can interchange the fusion order of the anyons and create
two distinct paths producing the same fusion outcome. These two paths are shown in Fig. 4.20.
The two paths are required to yield the same outcome, and we can describe this in the hexagon
equation as follows:
X c b c
F4231 b R41b F4123 a ¼ Rc13 F4213 a Ra12: ð4:22Þ
b
Summary
Thus, an anyon model can be described by three primary factors—the fusion coefficients N cab, which
defines the number of distinct anyons and how they fuse, the F matrices that define the structure of the
fusion space, and the R matrices, which defines the mutual statistics of the anyons. The pentagon and
hexagon identities are self-sufficient in describing the non-abelian models, and we do not need further
conditions. However, these two identities are trivial for abelian anyons, which can have arbitrary
statistical phases. For a given set of fusion rules, the solution to these two equations is a discrete set of
F and R matrices known as Ocneanu rigidity [15], a state without deformations. The discrete nature
of topological models is thus resilient to local perturbations.
We have now learned about the theoretical model of anyons. We can now apply the model to two
types of non-abelian anyons considered for quantum computing.
4.6 Leading Qubit Modalities 129
Exercise 4.1
Derive the braiding unitary for two anyons that do not have a fusion channel. (Hint: Use F- moves
to rearrange the order of fusion.)
◄
Exercise 4.2
Derive the equivalent of the pentagon equation by using anticlockwise exchange operator R1.
◄
11¼1
1τ ¼τ ð4:23Þ
ττ ¼1þτ ,
where the symbol denotes the fusion operation, and the + symbol denotes the possible fusion
channels.
The fusion rules of the Fibonacci anyons are shown in Fig. 4.21. The τ anyons are antiparticles to
themselves, and two τ anyons can behave like a single τ anyon. The repeated application of the fusion
rule grows the dimension of the fusion space, which looks like the Fibonacci series, and hence the
name. This is shown in Eq. (4.24):
τ τ τ ¼ 1 þ 2τ
τ τ τ τ ¼ 2 1 þ 3τ ð4:24Þ
τ τ τ τ τ ¼ 3 1 þ 5τ:
As in Eq. (4.19), we need three τ anyons to encode a qubit. The basis for this fusion space is given
by the states {j(τ τ )τ; 1τ; τ i and j(τ τ )τ; τ τ; τ i}.
The F matrix and R matrices are given by:
" 1
#
τ
Φ1 Φ 2
F ¼ Fτττ ¼ 1
Φ 2 Φ1
" 1 # " 4πi # ð4:25Þ
Rττ 0 e5 0
R¼ ¼ ,
Rτττ
3πi
0 0 e 5
pffiffiffi
where Φ ¼ 1 þ 5 / 2 is the Golden ratio of the Fibonacci series.
Fig. 4.22 The quantum H gate operation by the braiding of non-abelian anyons
When two τ anyons are fused, from Eq. (4.23), we can say that the fusion outcome 1 and τ occurs
each with some probability. We know that the non-abelian anyons have degenerate ground states. In a
system of M anyons, the dimensionality of the ground state is dM2a . The term da is the asymptotic
degeneracy or the quantum dimension of the particle of charge a. Abelian anyons have
one-dimensional ground state degeneracy irrespective of the number of particles. Hence, da ¼ 1 for
abelian anyons. The quantum dimension of non-abelian anyons need not be an integer. The quantum
dimension of particle 1 is d1 ¼ 1. The quantum dimension of the particle τ is dτ ¼ Φ, the golden ratio.
The probability of the fusion outcome 1 is P1 ¼ Φ12 . The probability of the fusion outcome τ is
Pτ ¼ ΦΦ2 ¼ Φ1 .
By braiding these anyons, we can evolve the system unitarily, making these anyons suitable for
universal quantum computing. There are some limitations, however. Since there is no tensor product
in the structure, if we have to implement two qubits, we need six anyons. Besides, simple gate
operations require several braiding operations (Fig. 4.22). Furthermore, realizing these anyons in the
laboratories is quite challenging, and some methods are under research.
Let us now return to the Ising anyons and apply our learning of the Ising model.
The family of Ising anyons has three particles 1, σ (anyon), ψ (fermion), with the following fusion
rules:
11¼1 ψ ψ ¼1 σσ ¼1þψ
1σ ¼σ ψ σ ¼σ ð4:26Þ
1ψ ¼ψ
These fusion rules can be explained better in the context of a p-wave superconductor (Sect. 1.7.5)
In a p-wave superconductor, the trivial particle 1 behaves like a Cooper pair condensate. The
fermions ψ are Bogoliubov quasiparticles, which pair up to become Cooper pairs and become
trivial particles. The σ anyons are Majorana zero modes bound to vortices. The Majorana zero modes
correspond to 12 of a complex fermion mode. Hence, we need a pair of vortices to host a single
nonlocal fermion mode (ψ). The vortices are either unoccupied if the fusion role σ σ ¼ 1 is used, or
occupied if the fusion rule σ σ ¼ ψ is used. Hence this is a two-dimensional fusion space associated
with two fusion channels {jσσ, 1i, jσσ, ψi}, namely, the vacuum channel and the Majorana
channel respectively. These two fusion channels represent two different ψ-parity sectors and hence
cannot be used for creating quantum superposition. Hence, we need three or more anyons, which can
fuse to a single σ or 1 in two different ways using repeated application of the fusion rules:
σ σ σ ¼ 2σ
σ σ σ σ ¼ 2 1 þ 2σ ð4:27Þ
σ σ σ σ σ ¼ 4σ:
From these fusion rules, we can infer that each time a pair of σ anyons are added to the system, the
dimensionality of the fusion space doubles. The basis for the fusion of two left most anyons into 1 or
ψ, is {j(σ σ )σ; 1σ; σ i and j(σ σ )σ; ψ σ; σ i}. The fusion matrix for changing the basis from right to
left is given by:
1 1 1
F ¼ Fσσσσ ¼ pffiffiffi : ð4:28Þ
2 1 1
The fusion matrix resembles the Hadamard gate, which we shall see in the next chapter and creates
an equal superposition. We see that the tensor product is inbuilt into the Ising anyons, and the fusion
orders correspond to the basis we need to create a qubit.
The R matrix corresponding to the exchange of two left most anyons in the clockwise direction is
given by:
" #
R1σσ 0 iπ8 1 0
R¼ ¼ e : ð4:29Þ
0 Rψσσ 0 i
To create the qubits, we pull out pairs of σ anyons from the vacuum. We need four such σ anyons
to form one qubit and six to form two qubits. Since the pairs are initialized in the σ σ ¼ 1
fusion channel, the system generally belongs to the vacuum sector, and the qubits are initialized to the
state j0 i.
Gate operations can be performed by braiding operations. For example, the X gate can be created
using a F1R2F 1, and the Z gate can be implemented by a R2 1 transaction (working this out is a
good exercise.) It has been proved that the braiding operations of Ising anyons can only create the
132 4 Qubit Modalities
quantum gates belonging to the Clifford group. Hence, it cannot implement a universal quantum
computer [16], without additional nontopological elements. One way is to bring the anyons closer
nontopologically and then precisely separate them, in a process where we can create a non-Clifford π8
phase gate. However, any nontopological interaction between the anyons cancels the degeneracy of
the fusion space, and the system dephases quickly. Nevertheless, since the Ising anyons can be
realized as Majorana zero modes in nanowires, it is a candidate for experimenting topological
quantum computing.
To perform a measurement, we bring the anyon pairs physically closer and measure the fusion
outcome. Since the σ anyons can fuse to 1 or ψ, the corresponding energy states are detectable, and
hence we can measure the qubit on the computational basis.
Errors can happen due to stray anyons that can get introduced into the system. These stray anyons
can cause unexpected braiding operations and tweak the results of the experiments. Unexpected
braiding can be avoided by containing the stray anyons to the vacuum channels. Besides, the anyons
can tunnel into neighboring topological structures, which requires isolation.
S ¼ αj∂Aj γ, ð4:30Þ
the anyon model. Unfortunately, these two are not unique properties of anyon models. Hence the
ground state degeneracy must be derived using some advanced methods, and currently, we do not
have any viable methods for quantum computation that uses intrinsic topological order.
N. Read and Dimitry Green from the Yale University established [18] in 1999 that in a spinless
p-wave superconductor, the weak and strong pairing of the fermions in two dimensions with broken
charge (C) and time-reversal (T ) symmetry is topological. The weak pairing phase exhibits
non-abelian statistics, and the strong pairing phase exhibits abelian modes. The transition between
the two phases involves a Majorana fermion. We do not yet have much experimental proof for this
method at this time of writing, but what is promising is a Majorana wire.
When nanowires made of half metals (half metals conduct electrons of one type of spin and
insulate the other) such as strontium ruthenate are placed on top of a p-wave superconductor with
unidirectional spin, they host Majorana modes at the end of the wires or at the domain walls (that is,
between topological and trivial phases) under certain orientation of the magnetic field. This behavior
is an example of an SPT state, and the Majorana modes are Ising anyons. These nanowires are
topologically free from noises and are candidates for quantum computing (Fig. 4.23).
Kitaev’s one-dimensional toy model [19] explains the Majorana modes at the ends of the
nanowires. Assume a one-dimensional lattice, occupied by composite fermions at L sites. Let us
define a pair of annihilation and creation operators a j , a{j for each of these fermions. We have seen
that the Majorana mode is half of a composite fermion mode. So, we need two Majorana modes to
make up a composite fermion mode. The two Majorana operators γ 2j 1, γ 2j pertaining to the site j can
be written as:
a j a{j
γ 2j1 ¼ a j þ a{j , γ 2j ¼ , where j ¼ 1, 2, 3, . . . , N: ð4:31Þ
i
If the fermionic mode is not occupied (that is, a{j a j ¼ 0), then the corresponding Majorana mode
is the vacuum. If the fermionic mode is occupied (that is, a{j a j ¼ 1), then the corresponding Majorana
mode is the particle ψ.
If the Majorana modes γ 1 and γ 2 exist as quasiparticle excitations localized far apart, then the
composite fermion shared by them is nonlocal.
Figure 4.24 illustrates this one-dimensional lattice structure.
Fig. 4.23 A Majorana wire placed on top of a three-dimensional p-wave superconductor with spin-triplet pairing. The
ends of the wire display Majorana mode
Fig. 4.24 Kitaev’s one-dimensional toy model showing the occupation of composite fermions at sites along a
one-dimensional lattice and their corresponding Majorana modes
134 4 Qubit Modalities
The Hamiltonian for the superconducting fermions along this one-dimensional wire of length L is
given by the following equation:
L h
X i
1
H¼ w a{j a jþ1 þ a {
a
jþ1 j μ a {
a
j j þ þ Δa {
a
j j þ Δ {
a a
jþ1 j , ð4:32Þ
j¼1
2
where w is the tunneling amplitude, μ is the chemical potential, and Δ ¼ jΔjeiθ is the superconducting
pairing potential. For simplicity, the phase factor θ can be encoded into the Majorana operators,
which can be rewritten as:
where, j ¼ 1, 2, 3, . . ., L.
With this, the Hamiltonian can be rewritten in terms of the Majorana operators as:
i X
L
H¼ μγ 2j1 γ 2j þ ðw þ jΔjÞγ 2j γ 2jþ1 þ ðw þ jΔjÞγ 2j1 γ 2jþ2 : ð4:34Þ
2 j¼1
Case 1
The trivial case in which jΔj ¼ w ¼ 0, μ < 0. The Hamiltonian, in this case, simplifies to the following:
i X L
H ¼ ðμÞ γ 2j1 γ 2j: ð4:35Þ
2 j¼1
In this case, the Majorana operators γ 2j 1γ 2j from the site j are paired together to form a ground
state ða{j a j ¼ 1Þ at every site. This state arises due to the localization of the fermion modes at physical
sites. Hence this state is topologically trivial. This state is illustrated in Fig. 4.25.
Case 2
In this case, jΔj ¼ w > 0, μ ¼ 0. The Hamiltonian for this case can be written as:
X
L
H ¼ iw γ 2j γ 2jþ1: ð4:36Þ
j¼1
Fig. 4.25 Case #1, Trivial phase arising from the fermion modes binding at physical sites
4.6 Leading Qubit Modalities 135
In this case, we find that the Majorana operators from adjacent sites γ 2jγ 2j + 1 pair together. We can
define a set of new annihilation and creation operators ae j ¼ 12 γ 2j þ iγ 2jþ1 and ae{j ¼ 12 γ 2j þ iγ 2jþ1
that work on adjacent sites j and j + 1. The Hamiltonian can now be written as:
L1
X
1
H ¼ 2w ae j ae{j ð4:37Þ
j¼1
2 :
In this case, the Majorana operators γ 1 and γ 2L are no longer represented in the Hamiltonian. The
Hamiltonian now describes the interactions between L 1 composite fermions only. We can define a
θ
new operator that describes the missing fermion as d ¼ ei2 12 ðγ 1 þ iγ 2L Þ. This operator is delocalized
between the ends of the Majorana wire.
Figure 4.26 illustrates this state.
Since [d{d, H] ¼ 0, this is a twofold degenerate system with delocalized fermion mode
{
(d d ¼ 0, 1). We might as well add this state to the original Hamiltonian as a zero-energy mode.
This is the reason why we call the edge Majorana modes as Majorana zero modes. Thus, this system
exhibits ground state degeneracy with the edge states where the two Majorana zero modes arise due to
the delocalized fermion modes. At the sites where the fermions are localized, the ground states are
unique and have finite energy, a characteristic of the SPT state. The ends of the Majorana wires
should indeed be viewed as defects which bind anyons.
We must note that the end of the wire can behave like a domain wall between the topological
phase and the vacuum, which is the trivial phase. Therefore, a domain wall can host a Majorana zero
mode. The domain wall is illustrated in Fig. 4.27.
Now, lets us equate this with the Ising anyons. The trivial particle state 1 represents the ground
state of the topological phase in which there are neither excitations nor Majorana zero modes. We can
assume the Majorana zero modes as the σ anyons. The intrinsic excitations created by the operator d{j
are the fermionic quasiparticles, and they should be considered as the ψ particles. In a superconduc-
tor, the ground states are the condensate of the Cooper pairs formed from fermions. The elementary
excitations can be created by breaking up the pairs by spending energy of 2Δ. This is equal to the
energy gap between a pair of ψ. As per the fusion rules, these two fermions pair up to become a
Fig. 4.26 Case #2, Topological phase arising from the pairing of fermion modes with adjacent sites
Fig. 4.27 Domain wall between topological and trivial phases hosting a Majorana zero mode
136 4 Qubit Modalities
Cooper pair and dissolve into the condensate. This action preserves the parity of ψ. Thus, we can
assume that the system is comprised only of σ anyons. From our previous discussions, the state
d{d ¼ 0 can be identified with the fusion rule σ σ ¼ 1, and we can say that the state d{d ¼ 1 can be
identified with σ σ ¼ ψ.
The two degenerate states of the ground state can be now written as the orthogonal fusion
channels:
iγ 1 γ 2L jσσ, 1i ¼ jσσ, 1i
ð4:38Þ
iγ 1 γ 2L jσσ, ψ i ¼ þjσσ, ψ i ,
where jσσ, ψi ¼ d{jσσ, 1i. However, we cannot use this to construct a qubit, as they belong to two
separate charge sectors. To construct a qubit, we need two nanowires.
Quantum gate operations are performed by braiding, and it requires moving the anyons. We can
achieve this by adiabatically tuning the chemical potential (μ). By adjusting the chemical potential,
we can even make one nanowire behave like multiple segments of Majorana wires. By locally tuning
the chemical potential, we can extend or contract the topological domains and move the domain wall
that binds the Majorana modes along the wire. Figure 4.28 illustrates how we can implement a
Clifford gate with the help of a T junction.
The π8 -phase gate can be implemented by adjusting the chemical potential in such a way that two
domain walls are brought nearby and allowed to dephase for a specific time. This function can ensure
the universality of this modality.
To perform a measurement, the Majorana fermions are brought close to each other adiabatically by
shrinking the topological domain and allowing them to fuse together. This operation results in the
Table 4.3 List of research institutes and companies working on topological qubits
Chalmers University of Technology Microsoft QuTech
Neils Bohr Institute Nokia Bell Labs University of California, Santa Barbara
Joint Quantum Institute/Institute of Maryland
system state to either vacuum (1) or the fermion ψ. Since the energy associated with the fermion Δ, is
relatively high, the differentiation between the states can be easily measured.
A good number of research institutes and companies are working on this technology [26, 27], and
Table 4.3 summarizes them:
Quantum dots take advantage of our decades of accumulated knowledge of making semiconductor
devices. In 1997 Daniel Loss and David P. DiVincenzo proposed [21] a scalable model of making
quantum computers by confining the spin-12 states of electrons inside semiconductor devices, called
quantum dots (QDs) In quantum dots, the tunnel barrier between neighboring dots can be changed by
altering the gate voltage using electrical circuits. By altering the tunnel barrier, we can enable time-
dependent electron–electron interactions that modify the spin states through the Heisenberg exchange
coupling. Quantum information could be encoded in the spin states of the quantum dots. This qubit
modality has the potential for universal and scalable quantum computing.
There are at least three types of quantum dots under research. In the first category of self-
assembled QDs, the InGaAs layers are grown on top of GaAs, where islands form spontaneously
due to mismatch in lattice constants. After a critical layer height, the structure is encapsulated in
further layers of GaAs. Electron confinement happens due to the differences in the conductance and
valence bands of the materials used. The second category of lateral QDs utilizes 2DEG
(two-dimensional electron gas) formed between heterogeneous layers of semiconductors. The
2DEG is confined along the growth direction and can be depleted using metal gates mounted at the
top of the fabrication. In the third category, semiconductor nanowires are used as the confinement due
to their nanosizes, which can be shrouded with other layers to provide the barrier. QDs are also made
of colloids, or carbon-based materials such as graphene and are used in displays.
In this book, we examine the second category, the quantum dots.
Fig. 4.29 The quantum dot. (a) Heterostructure of the semiconductor device with 2DEG between the GaAs and
AlGaAs layers. (b) The 2DEG is depleted by applying a negative voltage on the electrodes. (Credits: Laurens Willems
Van Beveren, with permission to reuse)
perfect crystalline layers of extreme purity with an atomically sharp transition between the
layers [22].
In standard semiconductors, the energy levels of the electrons are so close that we can assume that
they are continuous. Some of the energy levels are forbidden to electrons, and this region is called the
bandgap. While most of the electrons occupy the energy levels below the bandgap called the valence
band, some of them may be found in the energy levels above the bandgap called the conduction
band. Electrons in the valence band can be made to jump to the conduction band by imparting some
energy, the minimum of which is equivalent to the bandgap. An electron that leaves the valence band
creates a hole, and the pair formed by the excited electron and the hole is called an exciton. However,
the excited electrons fall back to the valence band in a short time.
In a quantum dot, the energy levels of the electrons are discrete due to the quantum confinement.
Hence, quantum dots are also called “artificial atoms.” Besides, the bandgap can be modified by the
geometry of the quantum dot and by choosing the right materials. One method to increase the
bandgap is to replace a few of the Ga atoms with Al atoms. This changes the crystalline structure
from GaAs to AlGaAs, and increases the bandgap ΔEg from 1.42 to 1.79 eV. When layers of GaAs
and AlGaAs are stacked up, it creates a bandgap mismatch ΔEc, due to the difference in the electron
affinity between GaAs and AlGaAs. The discontinuity in the valence band is ΔEV ¼ ΔEc ΔEg.
These energy levels are shown in Fig. 4.30.
Si atoms are added as dopants in the AlGaAs layer marking it as a donor region (n-AlGaAs). This
arrangement causes free electrons to accumulate at the heterojunction in a triangular-shaped quantum
well at about 90 nm below the surface of the heterostructure. The electrons in this quantum well are
strongly confined in the growth direction, forming discrete states. The electrons can move only on the
plane of the interface, forming two-dimensional electron gas (2DEG.)
The 2DEG is separated from the donor region by an undoped AlGaAs layer. This separation
reduces the scattering of electrons by the Si donors, and electrons with high mobility are concentrated
in the 2DEG layer. The heterostructure is to be kept in a dilution fridge. At a temperature of 4.2 K, the
2DEG has mobility of 105–106 cm2/V s and a density of ~3 1015/m2. Compare this with Si at room
temperature (300 K): the electron mobility is 1400 cm2/V s , and density is 9.65 109/cm3. Due to the
high mobility of the 2DEG, the GaAs–AlGaAs heterostructure is often called high electron mobility
transistor (HEMT) wafer [22]. The electron density is relatively lower. Hence, they can be depleted
by applying a potential.
4.6 Leading Qubit Modalities 139
Metal electrodes (~50 nm) are formed at the top of the heterostructure using lithographic
techniques. By applying a negative voltage through the electrodes, the 2DEG can be depleted, and
we can confine the 2DEG to form a dot of electrons. The gate voltage is defined by the chemical
potential of the metal, and the semiconductor: eVg ¼ μM μS. ΦB represents the Schottky barrier
formed at the metal-semiconductor junction, and it ensures that charges do not leak into the
heterostructure. If we examine Fig. 4.30, we can see that the conduction band has a steep slope at
the metal–semiconductor junction.
The steep slope of the conduction band is due to the high charge density at the surface, but donors
balance this. Thus, most of the donor electrons are required to balance the Schottky barrier, while a
fraction makes it to the 2DEG. The 2DEG remains isolated from the surface.
If the gate voltage is higher, it pushes the conduction band below the Fermi level (energy of the
highest occupied single-particle state in a quantum system) and creates parallel conduction [22]. If the
parallel conduction interferes with the qubit operation, the qubit may become unusable. The qubit is
usually characterized to avoid this.
The “+” signs in Fig. 4.30, denote the Si doping region. The Fermi level ensures that no net charge
transport can happen in the growth direction (Fig. 4.31).
The quantum dot is coupled via tunnel barriers into the source and drain reservoirs, as shown in
Fig. 4.32. The quantum dot is coupled with gate electrodes Vg, which can tune the dot’s electrostatic
potential with respect to the reservoirs. By measuring the voltage VSD between the reservoirs and
current I in the circuit, the electronic properties of the dots can be estimated. A quantum point
contact (QPC) device implemented close to the dots serves as a sensitive electrometer.
Quantum point contact is a narrow constriction in a 2DEG formed by electrostatic gating. The
2
conductance through the QPC channel is quantized in integer multiples of 2eh , where e is the
elementary charge. The transition between the quantized conductance is sensitive to the electrostatic
environment, such as the number of electrons in the dot [24].
Figure 4.33 illustrates the quantum dot equipped with QPCs. The dotted circles are the two
quantum dots. The gates T, M, R define the quantum dot on the right, and the gates T, M, L define
the quantum dot on the left. The gates R, Q – R, and L, Q – L for the QPCs on the right and left,
respectively. The gates PR and PL are connected to pulse sources to perform qubit rotations.
140 4 Qubit Modalities
Fig. 4.31 Lateral quantum dot device formed by the surface electrodes. (a) Device schematics showing depleted
2DEG. (b) The two white circles are the quantum dots connected via tunable tunnel barriers to the source (S) and drain
(D) reservoirs. (Source: Laurens Willems Van Beveren, with permission to use)
The arrows show the possible direction of the current. A bias voltage VDOT applied between the
source2 and drain1 is responsible for the current IDOT. The bias voltages VVSD between the sources
and drains of the left and right quantum dots give rise to the respective currents IQPC.
Returning to our discussions, for an electron to tunnel from the source to the dot and then to
the drain, the electrochemical potential must be within the bias window: μs μ μD with
jej VSD ¼ μs μD, so that the electron does not lose or gain energy. The quantum dot is small,
typically in the dimensions around 10–50 nm. Hence it forms a low-capacitance tunnel junction. At
low temperatures, the junction resistance increases because the electron charge is discrete. This
process is known as the Coulomb blockade. Due to the Coulomb blockade, the number of electrons
in the dot is fixed, and no current flows through the dot.
By adjusting the gate voltage, the chemical potential of the reservoirs can be adjusted in such a
way that only when an electron tunnels off into the drain; another electron can flow into the source.
This current is known as a single-electron tunneling current. Thus, by tuning the gate voltage, we
can control the number of electrons in the quantum dot. Since we can have a precise number of
electrons, the quantum dot displays an atom-like shell structure associated with a two-dimensional
harmonic potential. When a magnetic field is applied in a direction parallel to the tunneling current,
the electrons pair into spin degenerate single-particle states.
In a single electron system (N ¼ 1), the two possible spin orientations are j"i parallel to the
magnetic field or j#i along the antiparallel direction to the magnetic field. The Zeeman splitting
! !
between these two basis states is given by ΔEZ ¼ μB g B, where μB is the Bohr Magneton, B is the
magnetic field, and g is the gyromagnetic ratio (or the g-factor) that describes the effects of nonpoint
charge distribution. This system is equivalent to an artificial hydrogen atom.
When there are two electrons (N ¼ 2) in a quantum dot (artificial Helium atom), the electron state
is a product of orbital and spin states. Since the electrons are fermions, the state must be antisymmet-
ric in particle exchange. If the orbital part is symmetric, the spin part is antisymmetric and vice versa.
The antisymmetric two spin state is the spin-singlet jSi ¼ j"#ipffiffij"#i , with a total spin S ¼ 0. This
2
spin-singlet state is the ground state at zero magnetic fields. The symmetric two spin states are the
spin-triplet states with a total spin S ¼ 1 and a magnetic quantum ms ¼ 1, 0, + 1. We can define this
as jT þ i ¼ j""i, jT 0 i ¼ j"#ipþffiffij"#i , and jTi ¼ j##i. The triplet states are split by the Zeeman energy
2
ΔEZ. The spin-triplet states are also the lowest excited states.
Figure 4.34a shows the energy diagram for a fixed gate voltage. By changing the gate voltage, the
single-electron state below the dotted horizontal line can jump upward or downward relative to the
two-electron states. The vertical arrows show the six allowed transactions. Figure 4.34b shows the
electrochemical potential difference between the one- and two-electron states. Note that the six
transitions correspond to four different electrochemical potentials. By adjusting the gate voltage, the
electron levels can be shifted upward or downward. These transitions can easily form a qubit system.
Fig. 4.34 Transitions of one and two electron states and the electrochemical potential. (Source: Laurens Willems Van
Beveren, with permission to use)
4.6.5.3 Measurement
There are a few ways of performing measurements in this qubit methodology. One way to perform a
single-shot readout of the spin state is to induce a spin-charge conversion using a Zeeman split with a
strong magnetic field parallel to the 2DEG, and detecting single-electron tunneling events with the
electrometer. Another method is to use an RF QPC tuned to a resonant frequency (~1 GHz) and
measuring the reflection of the resonant carrier wave. In another method, the dot is raised above the
Fermi level, which causes the electron to leave. The tunneling rate for the spin-up electron is higher
than the tunneling rate of the spin-down electron. The spin state can be determined by measuring the
charge on the dot within the spin relaxation time.
Table 4.4 List of research institutes and companies working on spin qubits
Archer Materials Limited C12 Quantum Electronics Intel
CEA-Leti/Inac Silicon Quantum Computing Photonic
RWH Aachen Hitachi Cambridge Laboratory Qutech
HRL Laboratories Sandia National Laboratories Equal1
Origin Quantum Computing University of Wisconsin Simon Fraser University
Quantum Motion Technologies University of Basel
Center for Quantum Computation & Communication Technology
4.6.5.5 Summary
Ever since the first proposals were made, the quantum dots have become a subject of study at various
research labs, and many improvements have been made. We now have the ability to manipulate the
qubits precisely. The primary challenge with this modality is decoherence, which occurs due to
nuclear spins and spin–orbit interactions. These aspects require further studies to channelize these
effects. The other challenges are with cabling systems and measurement electronics. Scalability of
exchange schemes, surface codes, long-distance spin–spin coupling, exchange interaction in triple
quantum dots are some areas where current research is focused.
Quantum dots are a promising technology as they have applications beyond quantum computing.
Because of their ability to be controlled purely through electrical circuits, they have a great appeal for
the future since they can be fabricated like the regular semiconductor devices.
Table 4.4 lists the organizations and research institutes that are engaged in researching this
modality [26].
The dilution refrigerator provides a low temperature (cryogenic) environment for hosting the qubits.
The current design uses the heat mixing of 3 He and 4 He isotopes, and can produce temperatures as
low as 2 mK. The dilution refrigerator [25] was first designed by the German-British physicist Heinz
London in 1950 and experimentally verified in 1964 at the Leiden University.
Figure 4.35 shows the schematics of the dilution refrigerator.
The 3 He gas is first cooled and purified by liquid nitrogen at 77 K. It is then cooled to a temperature of
4.2 K using a 4 He bath. After this stage, the 3 He gas enters a vacuum chamber, where it is further
cooled to a temperature of 1.2 – 1.5 K by the 1 K bath. Here a vacuum-pump decreases the pressure of
4
He, and its boiling point reduces to the 1 K range. At this stage, the 3 He gas becomes a liquid.
The liquefied 3 He passes through the main and secondary impedance capillary tubes, where a set
of heat exchangers cool it to about 500–700 mK using the returning 3 He liquid from the main
chamber.
In the mixing chamber, the two phases of the 3 He–4 He mixture are in equilibrium and separated by
a phase boundary, as shown in Fig. 4.36. The concentrated phase consists purely of 3 He, and the dilute
phase is a mixture of about 6.6% 3 He, and 93.4% 4 He.
144 4 Qubit Modalities
Fig. 4.35 (a) Schematic of the dilution refrigerator. (b) Schematic of the cold part of the dilution refrigerator. (Image
courtesy of Wikipedia. Author: Adwaele, CC BY-SA3.0)
Inside the chamber, the 3 He flows through the phase boundary—from the concentrated phase to
the dilute phase and gets diluted (hence the name dilution refrigerator.) This movement is endo-
thermic and removes heat from the mixing chamber. This endothermic process provides the cooling
power of the refrigerator.
The 3 He then leaves the mixing chamber, cools the downward following 3 He, and reaches the still.
In the still, the 3 He flows through 4 He, which is in a superfluid state. Vacuum pumps keep the
pressure in the still to about 10 Pa. The partial pressure difference between 3 He and 4 He in the still
creates an osmotic pressure, which draws the 3 He upward from the mixing chamber. The temperature
Practice Problems 145
of the still is maintained to ensure a steady flow of 3 He: Vacuum pumps take out the 3 He from the still,
purify, and pump it back at a pressure of a few hundred millibars. This action keeps the cycle flowing.
4.8 Summary
In this interesting chapter, we learned about the vocabulary of quantum computing and qubit metrics.
We studied in detail how the qubits are constructed. We learned about the four leading qubit
modalities – trapped ion qubits, superconducting transmons, topological qubits, and quantum dots.
We ended this chapter after learning about how dilution refrigerators work.
The next chapter focuses on quantum circuits and quantum gates. This chapter also briefs the basic
elements of quantum computing.
Practice Problems
2. In the context of a superconductor, explain what does coherence length (ξ) mean?
3. Write the braid word for the braid shown in Fig. 4.37.
4. C. F. Gauss’ famous four braids are given by the braid word σ 3 σ 1 1
2 σ 2 σ 1 σ 3 . Draw the
corresponding braid diagram.
5. Yang-Baxter Equation is given below:
ðR I ÞðI RÞðR I Þ ¼ ðI RÞðR I ÞðI RÞ: ð4:40Þ
Draw a braid diagram showing the braids. Assume that the identity matrix I represents a straight
strand and the solution matrix R represents two winding strands. Explain how matrix representa-
tion of the braid groups can be used to implement quantum gates.
6. According to definition, a braid word ω is considered to be reduced if it is null or if the main
generator of ω occurs only positively or only negatively. For example, the braid word σ 1 σ 2 σ 1
2 σ1
is not reduced as the generator σ 2 appears both positively and negatively. Whereas, the braid
word σ 1 σ 2 σ 1
3 σ 2 is reduced. Implement Dehornoy’s reduction algorithm [32] on braid words.
7. Develop a logic to swap the status of two Majoraja qubits.
8. How would you implement a CNOT gate on a trapped ion qubit?
9. Device a scheme for transferring qubit status to photons.
10. Define quantum volume. Compute the quantum volume of commercially available quantum
computers, based on publicly available information.
11. Differentiate between quantum supremacy and quantum volume.
12. Write a comparative report on the various qubit modalities under research today.
References
1. https://en.wikipedia.org/wiki/Quantum_Turing_machine
2. Deutsch, David, 1985. Quantum theory, the Church-Turing principle and the universal quantum computer.
3. A Polynomial Quantum Algorithm for Approximating the Jones Polynomial, Aharonov et al, 2005, https://arxiv.
org/pdf/quant-ph/0511096.pdf
4. Polynomial-Time Quantum Algorithms for Pell’s Equation and the Principal Ideal Problem, Sean Hallgren, 2006,
http://www.cse.psu.edu/~sjh26/pell.pdf
5. Quantum Computers, Jon Schiller.
6. For scholarly discussions on Quantum Supremacy, refer to these publications: (a) Characterizing Quantum
Supremacy in Near-Term Devices, Boixo et al, 2016, https://arxiv.org/abs/1608.00263, (b) Quantum Computa-
tional Supremacy, Aram W Harrow, Ashley Montanaro, 2018, https://arxiv.org/abs/1809.07442, (c) How many
qubits are needed for quantum computational supremacy?, Dalzell, Harrow et al, 2018, https://arxiv.org/abs/1805.
05224
7. Validating quantum computers using randomized model circuits, Cross et al, 2019. https://arxiv.org/pdf/1811.
12926.pdf
8. For further reading, Digital Computer Electronics by Jerald A Brown Albert P. Malvino and Electronic Principles
by Albert Malvino and David Bates
9. Quantum Computing in the NISQ era and beyond, John Preskill, https://arxiv.org/abs/1801.00862
10. Spin relaxation and decoherence of two-level systems, Wang et al, 2005, https://arxiv.org/pdf/cond-mat/0509395.
pdf
11. Superconducting Qubits: Dephasing and Quantum Chemistry, Peter James Joyce O’Malley, 2016, https://web.
physics.ucsb.edu/martinisgroup/theses/OMalley2016.pdf
12. The Josephson Effect, Jakob Blomgren 1998, Per Magnelind 2005 , http://fy.chalmers.se/~delsing/LowTemp/
Labbar/SQUIDlab-rev3.pdf
13. A Quantum Engineer’s Guide to Superconducting Qubits, Krantz et al, 2019, https://arxiv.org/pdf/1904.06560.pdf
14. Charge insensitive qubit design derived from the Cooper pair box, Koch et al, 2007.
15. Lectures on tensor categories, Damien Calaque and Pavel Etingof, 2008, https://arxiv.org/pdf/math/0401246.pdf
16. A Short Introduction to Fibonacci Anyon Models, Simon Trebst et al, 2008, https://arxiv.org/abs/0902.3275
17. For further reading on Clifford group and universality of quantum computing interested readers can read:
(a) Implementation of Clifford gates in the Ising-anyon topological quantum computer, Ahlbrecht et al, https://
arxiv.org/pdf/0812.2338.pdf, (b) Clifford group, Maris Ozols, http://home.lu.lv/~sd20008/papers/essays/Clifford%
20group%20[paper].pdf, (c) Gottesman–Knill theorem, https://en.wikipedia.org/wiki/Gottesman%E2%80%
93Knill_theorem
18. Paired states of fermions in two dimensions with breaking of parity and time-reversal symmetries, and the fractional
quantum Hall effect. N. Reed, Dimitry Green, 1999, https://arxiv.org/abs/cond-mat/9906453
19. Unpaired Majorana fermions in quantum wires. Alexei Yu Kitaev, 2000, Microsoft Corporation. https://arxiv.org/
abs/cond-mat/0010440
References 147
20. Physics of p-wave spin-triplet pairing with the experimental examples of Strontium Ruthenate, Suk Bum Chung,
Department of Physics, University of Illinois at Urbana-Champaign, Illinois 61801, USA. http://guava.physics.uiuc.
edu/~nigel/courses/569/Essays_2004/files/chung.pdf
21. Quantum Computation with Quantum Dots, Daniel Loss, David P. DiVincenzo, 20-July-1997, https://arxiv.org/pdf/
cond-mat/9701055.pdf
22. Electron Spins in few-electron lateral quantum dots, Laurens Henry Willems Van Beveren, 1-Sep-2015, https://
repository.tudelft.nl/islandora/object/uuid:b33738cd-b8e5-49b6-aff2-573640012f98/datastream/OBJ/download
23. Electron spin qubits in quantum dots, R. Hanson et al, September 24, 2014, https://qutech.nl/wp-content/uploads/
2019/01/2004_09_01419211.pdf
24. Real-time detection of single-electron tunneling using a quantum point contact, Vandersypen et al, 8-November-
2004, http://kouwenhovenlab.tudelft.nl/wp-content/uploads/2011/10/149-real-time-detection.pdf
25. For further reading on the dilution fridge, interested readers can refer to: https://en.wikipedia.org/wiki/Dilution_
refrigerator
26. List of organizations and research labs: https://quantumcomputingreport.com/qubit-technology/
27. For further reading on Topological Quantum Computing, readers may refer to the following publications:
(a) Introduction to Topological Quantum Computation, Jiannis K. Pachos, (b) Non-Abelian Anyons and Topologi-
cal Quantum Computation, Nayak et al, 2008, https://arxiv.org/abs/0707.1889, (c) A Short Introduction to Topo-
logical Quantum Computation Lahtinen et al, 2017. https://arxiv.org/abs/1705.04103, (d) A Pedagogical Overview
On 2d And 3d Toric Codes And The Origin Of Their Topological Orders, Resente et al, 2019, https://arxiv.org/abs/
1712.01258, (e) Introduction to abelian and non-abelian anyons, Sumathi Rao, 2016, https://arxiv.org/abs/1610.
09260, (f) Designer non-Abelian anyon platforms: from Majorana to Fibonacci, Jason Alicea and Ady Stern, https://
arxiv.org/pdf/1410.0359.pdf
28. Bifluxon: Fluxon-Parity-Protected Superconducting Qubit, Kalashnikov et al, 9-Oct-2019, https://arxiv.org/pdf/
1910.03769.pdf
29. Not All Qubits Are Created Equal, A Case for Variability-Aware Policies for NISQ-Era Quantum Computers,
Swamit S. Tannu, Moinuddin K. Qureshi, https://arxiv.org/ftp/arxiv/papers/1805/1805.10224.pdf#:~:text¼A%
20qubit%20in%20an%20high,retention%20time%20of%20DRAM%20cells).
30. Coherence properties of the 0-π qubit, Peter Groszkowski et al, 9-Aug-2017, https://arxiv.org/pdf/1708.02886.pdf
31. A Parity-Protected Superconductor-Semiconductor Qubit, T. W. Larsen et al, 8-April-2020, https://arxiv.org/pdf/
2004.03975.pdf
32. A fast method for comparing braids, Patrick Dehornoy, https://dehornoy.users.lmno.cnrs.fr/Papers/Dfo.pdf
33. Protected gates for superconducting qubits, Peter Brooks, Alexei Kitaev, John Preskill, 17-Feb-2013, https://arxiv.
org/abs/1302.4122v1
Quantum Circuits and DiVincenzo Criteria
5
“And how many hours a day did you do lessons?” said Alice, in a hurry to change the
subject.
“Ten hours the first day,” said the Mock Turtle: “nine the next, and so on.”
“What a curious plan!” exclaimed Alice.
“That’s the reason they’re called lessons,” the Gryphon remarked: “because they lessen
from day to day.”
― Lewis Carroll, Alice’s Adventures in Wonderland.
The previous chapters provided an overview of the formulation of quantum mechanics. We built
sufficient mathematical background and learned about the qubit modalities currently under research.
We also learned how to represent the qubit as a Bloch sphere and perform Pauli rotations. With this
knowledge, we are ready to write some quantum code. In the first part of this chapter, we set up our
systems with IBM Q and Microsoft Quantum Development Kit and then proceed to learn about
the quantum gates. In the second part of this chapter, we learn about constructing quantum circuits.
We use Dirac’s bra-ket notation to describe the circuits. We intermix theory with practice throughout
this chapter.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 149
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_5
150 5 Quantum Circuits and DiVincenzo Criteria
This section focuses on setting up the development system with the tools to build quantum circuits
and perform experiments on IBM Q and Microsoft QDK.
IBM Quantum Experience is a cloud-based platform for experimenting and deploying quantum
applications in areas such as chemistry, optimization, finance, and AI [3–5, 9–11]. A visualizer helps
in building the quantum circuits visually, while we edit the code side by side. IBM Q also provides a
full-stack quantum development kit—Qiskit, available as a Jupyter notebook.
To sign up with IBM Q, launch the following website from your web browser and create your
IBMid. If you already have an IBMid or a social account, you can log in using the login button or
clicking the social account you want to use. The login link is provided here for your easy reference:
https://quantum-computing.ibm.com/login
After creating your IBMid, or signing in using a social account, accept the IBM Quantum End User
Agreement and select “Accept & Continue.” After this, fill in the survey by providing your name and
your organization details. You are all set!
You can launch the Circuit Composer or the Qiskit Notebook from the page that opens up. You
may want to bookmark this launcher page for easy access in the future. If you ever forget the link, it is
provided here for your easy reference:
https://quantum-computing.ibm.com/
[1]. Install Visual Studio 2017 runtime from the link below:
https://go.microsoft.com/fwlink/?LinkId¼746572
[2]. Download and install Anaconda from the following link:
https://www.anaconda.com/download/
[3]. Open Anaconda Prompt by searching it in the windows search in the taskbar. Launch the
Anaconda Prompt in administer mode. Execute the following commands:
These commands install the Qiskit by creating a new environment, “ibmqiskit.” You can explore
the wealth of information available on the Qiskit website and gain more insights into using IBM Q
and quantum computing in general.
Microsoft Quantum Development Kit (QDK) comes in various flavors supporting C# and
Python [6–8]. All flavors require us to write the quantum code in the Microsoft Q# language,
which we shall get acquainted with by writing code. Installation instructions for QDK can be
found in the link below or by googling.
https://docs.microsoft.com/en-us/quantum/install-guide/?view¼qsharp-preview
In this book, we shall use the Visual Studio Code. Instructions for setting up Visual Studio Code
can be found in the following link, or by searching the Internet.
https://docs.microsoft.com/en-us/quantum/install-guide/csinstall?view¼qsharp-preview
You can install the QDK by following the given steps:
[1]. Install VS Code from the following link:
https://code.visualstudio.com/download
[2]. Install.Net Core SDK 3.1 or later from the following link:
https://www.microsoft.com/net/download
Remember to select the SDK and not the runtime!
[3]. Install the Quantum VS Code Extension:
https://marketplace.visualstudio.com/items?itemName¼quantum.quantum-devkit-vscode
[4]. Install Q# Project Template
Launch VS Code now.
Go to View -> Command Palette
Select Q#: Install project templates
You should be all set now. The process requires the installation of additional extensions. Follow
the instructions that pop-up on the screen.
It is a good idea to verify the installation and troubleshoot any errors at this stage. Both these two
development environments install several subcomponents. Some minor differences may exist as
different groups develop these subcomponents in parallel and release with varying schedules and
features. The general advice is to follow the installation instructions. Installing later versions of
Python is usually problematic as the subcomponents do not support them readily.
To verify Qiskit, launch Anaconda Navigator (you can locate this application from the windows
search bar). Ensure that you have selected “ibmqiskit” from the application channels. Selecting this
ensures the usage of the right environment. Look for the Jupyter notebook from the list of
applications in the home tab. Install the Jupyter notebook by selecting the “install” button.
Now launch Jupyter notebook. The Jupyter notebook opens in your default system browser.
In the browser tab that opens, select New->Python 3 from the menu on the right-hand side panel.
This selection opens a new browser window. In this browser window, enter the Python code from List-
ing 5.1 in the first cell.
import qiskit
The given Python code saves the API token in your local cache. Don’t forget to copy your API
token obtained earlier in line 3. In the next cell, type the code from Listing 5.2:
# Apply an X gate
qc.x(q[0])
The given code creates a quantum circuit with one qubit. It then applies an X-gate to the qubit and
projects the qubit into a classical register. The final step is to plot the circuit. These steps become
familiar in the next few sections. Let us continue writing some code to execute this on a simulator and
plot the output. Type the code provided in Listing 5.3 in the third cell, and execute the same:
5.1 Setting Up the Development Environment 153
Executing the given code plots in the following circuit (Fig. 5.1).
Now, type the code given in Listing 5.4 in a new cell and execute the same:
This quantum circuit illustrates the X-gate we implemented with one qubit q. The measurement
operation projected the qubit into the classical register c. The histogram records an output “1,” 100%
of the times of the 1024 shots we took. Each shot is a repeat of the experiment. Note that your
outcome may be slightly different from the histogram shown in Fig. 5.2. We shall discuss this
outcome in subsequent sections. For now, you have successfully run a quantum program. Voila!
namespace QTest1 {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
for (i in 0..99) {
set count += Xgate() == One ? 1 | 0;
}
Message($"The probability of getting 1 for the operation\
X|0⟩ is:{count} / 100");
}
}
Listing 5.5 Sample code for the QDK. Program.qs, the Q# file
5.1 Setting Up the Development Environment 155
This code creates a single qubit, performs an X-gate, and measures the results of the X-gate. This
step executes for about 100 times.
Edit the file Driver.cs and enter the code from Listing 5.6:
using System;
using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;
namespace QTest1
{
class Driver
{
static void Main(string[] args)
{
using (var qsim = new QuantumSimulator())
{
RunQuantumMain.Run(qsim).Wait();
}
}
}
}
Listing 5.6 The Driver.CS, C# accompanying file for the QDK program
This file creates an instance of the quantum simulator and invokes the method RunQuantumMain
created in the Program.qs file.
Execute the program by selecting the menus Debug->Start Debugging. The program executes,
and displays the following line in the Debug Console:
The probability of getting 1 for the operation X|0〉 is: 100 /100
In the given example codes that we run on IBM Q and Microsoft Quantum Development Kit, we
prepared a qubit in its default state j0i and applied a bit-flip gate—the X-gate—to flip the qubit to the
state j1i. We saw the bit-flip as a reliable operation, and we got the state j1i all the time.
The pip package gets upgraded frequently. It is a good idea to update pip. To upgrade pip, close all
Jupyter notebooks and Anaconda instances. Execute the following command from the Anaconda
command prompt “ibmqiskit.”
It is a good idea to keep qiskit and the visualization library updated. Execute the following
commands from the Anaconda command prompt “ibmqiskit.”
The quantum programming languages referred to in this book are somewhat easy to learn. Anyone
with a reasonable programming experience can learn them with ease. The quantum code for
Microsoft QDK requires coding in the Q# programming language. The quantum code developed in
Q# integrates with a C# or Python code to provide a user interface. Qiskit integrates well with the
Python development environment. The OpenQASM is another quantum programming language. It
somewhat resembles assembly language programming. In this section, we provide a quick tutorial to
these three systems. Reference links provided at the end of this chapter can help our readers with
further reading and practice.
OpenQASM is a programming language that provides the interface to the IBM Quantum Experience.
The Circuit Composer converts the QASM code into a quantum circuit, which we can edit using the
graphical UI. Any change we make on the quantum circuit using the graphical UI automatically
reflects in the QASM code. This graphical UI makes it easy to construct and verify quantum circuits
with less circuit depth.
The QASM code snippet provided in Listing 5.7 declares two quantum and classical registers. A
set of quantum gates are used to create entanglement between the two quantum registers (qubits), and
the last segment of the code projects the qubits into the respective classical registers.
OPENQASM 2.0;
File header and standard include file
include "qelib1.inc";
qreg q[2];
Declare quantum and classical registers
creg c[2];
h q[0];
Gate operations. H and CNOT gates are examples here.
cx q[0],q[1];
OPENQASM 2.0;
include "qelib1.inc";
gate nG0(theta, phi) q { Subroutine nG0 with two parameters theta and phi and
a quantum gate, implementing a U2 rotation.
u2 theta,phi,q;
}
qreg q[2];
creg c[2];
A QASM code generally follows the given convention. Besides, there is a provision to create a
subroutine. An example is given in Listing 5.8.
The Q# programming language is used to develop quantum algorithms in conjunction with the
Microsoft QDK. The Q# code has the structure outlined in Listing 5.9.
The C# driver code creates an instance of the QuantumSimulator object and passes that as the
argument to the “Run” method of the Quantum operation you want to invoke. Listing 5.10 contains
the structure of the C# driver code.
Besides the intrinsic methods, the QDK provides a variety of functions for direct integration into
the program. Libraries for Quantum Chemistry, Quantum Machine Learning, and Quantum Numerics
contain the prework required for easy integration into projects.
158 5 Quantum Circuits and DiVincenzo Criteria
open Microsoft.Quantum.Canon;
Referenced modules
open Microsoft.Quantum.Intrinsic;
An operation
operation NOTGate(input:Bool, shots:Int) : (Int) { is a Q# function
mutable c0 = 0;
using (q0 = Qubit()) { Declare the Qubits here
for (i in 1..shots){
Reset(q0);
if ( true == input) {
X(q0);
} Gate operations
X(q0);
if ( One == result ) {
set c0 += 1;
}
}
Reset(q0); Reset the qubits before returning
return c0;
}
}
using System;
Import Microsoft Quantum
using Microsoft.Quantum.Simulation.Core;
Core and Simulators
using
Microsoft.Quantum.Simulation.Simulators;
namespace QTest1
{
class Driver
{
static void Main(string[] args)
{
Quantum Simulator
Using(var qsim = new instance
QuantumSimulator())
{
RunQuantumMain.Run(qsim).Wait(); Call the main
method in the Q#
}
code
}
}
}
Listing 5.10 The accompanying driver code for QDK implementing the main function
The Qiskit, when integrated with a Python development environment such as the Jupyter notebook, is
an excellent tool for developing and experimenting with quantum computing. Like the OpenQASM,
the Qiskit interfaces with IBM Q and provides the opportunity to work directly with real quantum
processors (backends). Listing 5.11 outlines the structure of Python code using Qiskit.
The given example executes the code on the simulator. Make the changes provided in Listing 5.12
to execute the code on a backend.
Qiskit comes with four frameworks.
• Qiskit Terra is a software framework that provides visualization, transpilation, and handles user
inputs. Qiskit Terra also interfaces with the Qiskit Aer simulator and other backends.
• Qiskit Aer provides the high-performance simulator functions.
• Qiskit Ignis provides the framework for understanding and mitigating noise in quantum circuits
and systems.
• Qiskit Aqua is a library of algorithms we can experiment on chemistry, AI, optimization, and
finance applications for near-term quantum computers.
160 5 Quantum Circuits and DiVincenzo Criteria
qc.h(q[0]) Circuit
operations
qc.cx(q[0], q[1])
%matplotlib inline
qc.draw(output="mpl")
Execute the
# setup a job monitor job in a
job = execute(qc, backend=processor, shots=1024) backend and
setup a job
job_monitor(job) monitor
For a comparison of the software development platforms at the gate level, interested readers can refer
to Ryan LaRose [2].
On a classical digital computer, any operation such as an arithmetic operation starts by preparing
individual bits with an initial value. We then use a sequence of digital gates to perform the required
arithmetic operation. We finally read out the bits to know the results of the operation deterministi-
cally. Any operation we do at the application level, boils down to a sequence of digital gate
operations, irrespective of the complexity of the operation.
A quantum computer works similarly. Similar to the classical computer, we construct a quantum
circuit to implement a specific quantum algorithm. The quantum circuit solves a specific problem by
implementing unitary operations in the Hilbert space on a finite number of qubits. Quantum gates
implement the unitary operations. The unitary operations also mean that the quantum circuits have the
same number of inputs and outputs. Furthermore, the quantum circuits are acyclic, meaning there are
no feedback circuits or loops.
We learned in previous chapters that the quantum evolution is unitary. Hence, every quantum
circuit qc corresponds to a particular unitary operator Uqc in the Hilbert space, meeting the criteria:
U qc U {qc ¼ U{qc U qc ¼ 1: From this equation, we can infer that Uqc has an inverse operator. Hence, we
can say that the quantum circuit is reversible. In other words, if we start from the output and work
backward, we should be able to retrieve the inputs. This process preserves the information. Therefore,
the input data are fully recoverable. The reversibility is a specific property of quantum gates.
A quantum circuit consists of three stages. In the first stage, we prepare a certain number of qubits
with the initial state. In the second stage, we perform quantum gate operations and use quantum
mechanics to solve the problem. In the final stage, we measure the qubits by projecting them to a set
of classical bits using a computational basis. The quantum circuit shown in Fig. 5.3 illustrates this.
In this quantum circuit, we start with a device having six quantum registers q[0]. . q[5]. There are
also three classical registers (digital bits) c[0], c[1], c[2]. We start the qubits with an initial state of j0i.
162 5 Quantum Circuits and DiVincenzo Criteria
q [ 0] H H
q [ 1] H H
Qubit q [ 2] H H
registers q [ 3]
q [ 4]
q [ 5]
Classical c3
0 1 2
registers
Compute Measure
Fig. 5.3 A quantum circuit showing the three stages of execution
Note that in this example, we start the qubits with the state j0i. Most algorithms require the qubits to
be initialized to a superposition state and ancilla qubits to be set for phase kickback. As we progress
through this chapter, these steps become clear.
Proceeding further with this circuit into the compute state, we apply H-gates to qubits q[0], q[1],
q[2]. After this we apply a sequence of 3 controlled-NOT gates. The first CNOT gate is applied with
q[0] as the control and q[3] as the target qubit. The second CNOT gate is applied with q[1] as the
control and q[4] as the target qubit. The third CNOT gate is applied with q[2] as the control and
q[5] as the target qubit. After this step, we apply H-gates one more time to qubits q[0], q[1], q[2]. We
then finally measure the state of the qubits q[3], q[4], q[5] by projecting them to classical registers
c[0], c[1], c[2].
You can construct this circuit on the IBM Q circuit composer and execute it by selecting the “Run”
button. Select 1024 shots and “ibmq_qasm_simulator” as the back end. The execution queue
appends the quantum experiment, and you may have to return after a few minutes to see the result.
The dotted vertical bars indicate the barrier component, which separates circuit sections from being
optimized by the transpiler. The transpiler is a pre-processing software that analyzes quantum circuits
for optimization and translation to fit the topology of a given hardware platform. The barrier is
introduced in this circuit to improve clarity. Its purpose can be safely ignored for now. We shall return
to the barrier circuit in a later section. Executing this circuit generates a histogram, as shown
in Fig. 5.4:
We can interpret the histogram as follows. The probability of projecting the state to j000i is 10.8%,
the probability of projecting the state to j001i is 13%, the probability of projecting the state to j010i is
13.3%, and so on. Ideally, we expect an equal 12.5% distribution with this circuit, since we put the
qubits q[0], q[1], q[2] in an equal superposition state. The differences are due to the way the quantum
systems work in nature. In a real device, it is challenging to perform an error-free measurement, and
the quantum device is always subject to environmental noises and interactions. This process becomes
clear as we progress through this chapter.
Note that the measured values of the classical registers c0. . c2 are shown under the bars along
the x-axis. The order of the individual bits is the same as that of digital bits. The least significant
classical registers are on the right, and the most significant classical registers are on the left, that is,
... c2 c1 c0.
5.3 Introducing Quantum Circuits 163
Fig. 5.4 Histogram resulting from executing the code in Fig. 5.3
(a) (b)
We can describe the quantum state of a qubit in an arbitrarily unknown state using the quantum
superposition principle as:
where the coefficients a and b are complex numbers representing probability amplitudes of finding
the qubit in one of the states j0i or j1i. When we measure a qubit in the computational basis, we
project the qubit to the states j0i or j1i. The probability of the outcome is determined by the
coefficients a and b.
In the quantum circuits, the analog dial symbol shown in Fig. 5.5 represents a measurement
operation. The alphabet “M” denotes the measurement. Some systems use “Z,” as we measure the
qubit in the z basis. The quantum devices are, in general, designed to perform z measurement. In the
quantum circuit diagrams, the measurement operation projects the qubit that needs to be measured
into the classical bit. The “Measure” stage of the circuit shown in Fig. 5.3 illustrates this.
164 5 Quantum Circuits and DiVincenzo Criteria
We measure a 000 on the classical bit, with probability jaj2 and a 010 in the classical bit, with
probability jbj2. The total probability of the system, however, is jaj2 + jbj2 ¼ 1. At the end of the
compute operation, if we measure n qubits, the measurement outcome projected on the classical
register can be one of the 2n possible values. For example, in the quantum circuit shown in Fig. 5.3,
we measure three qubits, q[0], q[1],and q[2]. The measurement outcome could be one of the eight
(23 ¼ 8) possible values shown in Table 5.1.
The outcome can be different each time the experiment is run for the same circuit. This difference
is because of the randomness of the quantum systems in nature. The measurement errors can only add
to this. When we repeat the experiment a certain number of times, we get a distribution of the
measurement outcome. This distribution is illustrated in the column named “Outcome” in Table 5.1.
The distribution gives an indication of the most probable outcomes based on which inferences can be
drawn. Note that the sum of all outcomes is 100%, which corresponds to the total probability being “1.”
Before understanding how the “compute stage” works, we must build a knowledge of the quantum
gates. The following section takes us through this next step in our journey.
In the previous chapters, we learned that the qubits are two-state systems, implemented in the
computational basis {j0i, j1i}. The following column matrices or ket vectors describe the
two-states of the computational basis:
" #
1
j0i ¼
0
" # ð5:2Þ
0
j1i ¼
1
The quantum gates are unitary operations on the qubits and are reversible. We shall study the
universality of quantum gates in detail in subsequent sections. If we start with a qubit in state jψi and
5.4 Quantum Gates 165
-X
−
-Y Y
-Z |
apply a unitary operation U, the final state of the qubit jψ 0i is as shown in the following transformation
equation:
jψ 0 i ¼ U jψ i ð5:3Þ
For single qubits the unitary operations can be defined using 2 2 unitary matrices.
5.4.1.1 The Bit-Flip Gate or the NOT Gate or the Pauli X-Gate
The Pauli X-gate applies a π2 rotational pulse along the x-axis. The action of this gate is to flip the qubit
from state j0i to j1i and vice versa. The X-gate is illustrated in Fig. 5.6.
The action of this gate on the basis states can be derived as follows:
" #" # " #
0 1 1 0
Xj0i ¼ ¼ ¼ j1i
1 0 0 1
" #" # " # ð5:5Þ
0 1 0 1
Xj1i ¼ ¼ ¼ j0i
1 0 1 0
166 5 Quantum Circuits and DiVincenzo Criteria
Alternate form
X ¼ U 3 ðπ, 0, π Þ ð5:6Þ
Syntax
Truth Table
Input Output
j0i j1i
j1i j0i
The action of the identity gate on the basis states can be derived as follows:
" #" # " #
1 0 1 1
I j0i ¼ ¼ ¼ j0i
0 1 0 0
" #" # " # ð5:8Þ
1 0 0 0
I j1i ¼ ¼ ¼ j1i
0 1 1 1
Syntax
Truth Table
Input Output
j0i j0i
j1i j1i
5.4 Quantum Gates 167
Since the information of the qubit along the x-axis is rotated to the z-axis, the H-gate gives us a way
of measuring the qubit in x basis. The Hadamard gate puts the qubit in an equal superposition state in
the computational basis. The H-gate is defined by the following equation.
j 0i þ j 1i j 0i j 1i
H¼ pffiffiffi h0j þ pffiffiffi h 1j ð5:9Þ
2 2
Using the matrix form, we can write the action of the H-gate on the basis states as:
" #" # " #
1 1 1 1 1 1
Hj0i ¼ pffiffiffi ¼ pffiffiffi ¼ jþi
2 1 1 0 2 1
" #" # " # ð5:13Þ
1 1 1 0 1 1
Hj1i ¼ pffiffiffi ¼ pffiffiffi ¼ ji
2 1 1 1 2 1
Recall that (1)0 ¼ 1 and (1)1 ¼ 1. Hence, this equation can be written as a summation.
1 X
1
H jxi ¼ pffiffiffi ð1Þxy jyi ð5:16Þ
2 y¼0
We shall use the representations shown in Eqs. (5.14) and (5.16) while developing quantum
algorithms in the next few chapters.
Let us now try the H-gate. Construct the circuit, as shown in Table 5.2 using the circuit composer.
You can also try this using the QDK or using the Qiskit.
Upon execution of this code, we get a histogram, as shown in Fig. 5.8.
The histogram shows a 49.8% probability of the qubit being in the state j0i and 50.2% probability
in the state j1i. Ideally, for an H-gate, we expect a 50–50% distribution. The differences are due to the
qreg q[3];
creg c[3];
h q[0];
measure q[0] -> c[0];
The H gate
5.4 Quantum Gates 169
randomness in the underlying physics and measurement errors. Hence, each experiment could have a
slightly different distribution.
simulator = Aer.get_backend('qasm_simulator')
job = execute(qc, backend=simulator, shots=1024)
result = job.result()
QDK:
To run this in QDK, edit the file Program.qs with the code from Listing 5.14.
namespace QTest1 {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
operation Hgate() : Result {
// Define a single qubit
using (qubit = Qubit()) {
// Apply a H gate to the qubit
H(qubit);
// Now measure the same
let result = M(qubit);
// It is a good practice to reset the qubit
if (result == One )
{
Reset(qubit);
}
return result;
}
}
Recall the Eqs. (5.11) and (5.12). The probability amplitude vectors of the states j+i and ji are
h i h i
p1ffiffi , p1ffiffi
and p1ffiffi2 , p1ffiffi2 , respectively. However, the probability vector is the same, and it is 12 , 12 .
2 2
The Hadamard transform is one example where two states can have different probability amplitudes
but the same probability vector.
5.4 Quantum Gates 171
Alternate form
H ¼ U 2 ð0, π Þ ð5:17Þ
Syntax
Truth Table
Input Output
j0i p1ffiffi ðj0i þ j1iÞ
2
j1i p1ffiffi ðj0i j1iÞ
2
Let us cascade two H-gates, and study the system evolution. We can write the following equations
for qubit states j0i and j1i.
1
HHj0i ¼ Hjþi ¼ Hðpffiffiffi ðj0i þ j1iÞÞ
2
1 1 1
¼ pffiffiffi ðpffiffiffi ðj0i þ j1iÞ þ pffiffiffi ðj0i j1iÞÞ
2 2 2
1 1 ð5:18Þ
¼ ðj0i þ j1iÞ þ ðj0i j1iÞ
2 2
1 1
¼ j0i þ j0i
2 2
¼ j0i
1
HHj1i ¼ Hji ¼ Hðpffiffiffi ðj0i j1iÞÞ
2
1 1 1
¼ pffiffiffi ðpffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞÞ
2 2 2
1 1 ð5:19Þ
¼ ðj0i þ j1iÞ ðj0i j1iÞ
2 2
1 1
¼ j1i þ j1i
2 2
¼ j1i
Thus, when we apply the H transform twice in succession, the qubit is returned to its original state.
Let us verify this in IBM Q Circuit Composer. Construct the quantum circuit, as shown in Table 5.3.
172 5 Quantum Circuits and DiVincenzo Criteria
qreg q[6];
creg c[5];
x q[0];
h q[0];
h q[0];
Two H gates in a sequence.
measure q[0] -> c[0];
In the circuit shown in figure, we start with a state of j0i and apply an X-gate, which flips the qubit
to j1i. After this, we apply two H-gates in succession. Figure 5.9 shows the histogram we get upon
executing the circuit.
The outcome is as expected. We got state j1i, 100% of the time. The reader is advised to try this
without the X-gate and verify that we get j0i all the time.
Thus, the Y gate maps the state j0i to ij1i and the state j1i to ij0i.
Alternate form
π π
Y ¼ U 3 π, , ð5:22Þ
2 2
Syntax
Truth Table
Input Output
j0i ij1i
j1i ij0i
Thus, the Z gate leaves the state j0i unchanged and changes the state j1i to j1i. For this reason,
the Z gate is called the Phase-flip gate.
Alternate form
Z ¼ U 1 ðπ Þ ð5:25Þ
Fig. 5.10 Diagram illustrating (a) Pauli Y rotation from j0i to j1i and (b) Pauli Z rotation from j+i to ji
Syntax
Truth Table
Input Output
j0i j0i
j1i j1i
The effect of this gate on the basis states can be derived as follows.
" #" # " #
1 0 1 1
Sj0i ¼ ¼ ¼ j0i
0 i 0 0
" #" # " # " # ð5:27Þ
1 0 0 0 0
Sj1i ¼ ¼ ¼i ¼ ij1i
0 i 1 i 1
5.4 Quantum Gates 175
Alternate form
π
S ¼ U1 ð5:28Þ
2
Syntax
Truth Table
Input Output
j0i j0i
j1i ij1i
Alternate form
π
S{ ¼ U 1 ð5:31Þ
2
Syntax
Truth Table
Input Output
j0i j0i
j1i ij1i
176 5 Quantum Circuits and DiVincenzo Criteria
The gates S and S{ rotate the qubit between the x and y basis and are considered the two possible
square roots of the Z gate. Figure 5.11 illustrates the S and S{gates.
We can rotate the qubits arbitrarily along the x, y, or the z-axis. In this section, we learn about the
R gates that can perform arbitrary rotation.
5.4.2.1 RX-Gate
The RX-gate rotates the qubit along the x-axis by θ radians. The matrix form of this gate is as follows:
2 3
θ θ
6 cos 2 isin 7
6 2 7
Rx ðθÞ ¼ 6 7 ð5:32Þ
4 θ θ 5
isin cos
2 2
Alternate form
π π
Rx ðθÞ ¼ U 3 θ, , ð5:34Þ
2 2
5.4 Quantum Gates 177
Syntax
5.4.2.2 RY-Gate
The RY-gate rotates the qubit along the y-axis by θ radians. The following equation is the matrix
form:
2 3
θ θ
6 cos 2 sin
6 2 7
7
R y ðθ Þ ¼ 6 7 ð5:35Þ
4 θ θ 5
sin cos
2 2
Alternate form
Ry ðθÞ ¼ U 3 ðθ, 0, 0Þ ð5:37Þ
Syntax
5.4.2.3 RZ-Gate
The RZ-gate rotates the qubit along the zaxis by ϕ radians. The matrix form of this gate is as shown
in the following equation:
" ϕ #
ei 2 0
R z ð ϕÞ ¼ ϕ ð5:38Þ
0 ei 2
Alternate form
ϕ
Rz ðϕÞ ¼ ei 2 U 1 ðϕÞ ð5:40Þ
ϕ
Note that the RZ-gate is equivalent to a U1-gate, but with a global phase offset of ei 2 :
178 5 Quantum Circuits and DiVincenzo Criteria
Syntax
pffiffiffi
5.4.2.4 T Gate and the T{ Gate or the S Gate
The T gate and the T{ gates are cases of the Rz gate with θ ¼ π4. These two gates are the square root
of the S gate. The matrix form of these two gates are as follows:
" # " iπ #
1 0 π e 8 0
T¼ π
¼ ei 8 π
0 ei 4 0 ei 8
" # ð5:41Þ
{
1 0
T ¼ π
0 ei4
Alternate forms
π
T ¼ U1 ð5:42Þ
4
π
T { ¼ U1 ð5:43Þ
4
Syntax
Note that, historically, the T gate is sometimes referred to as the π8 gate, because of the diagonal
π
elements appearing in the form of a global phase of ei8 . The gate does indeed perform a π4 rotation
about the z-axis, as shown in the Fig. 5.12.
The U gates are implemented physically in the quantum device. We can derive the single-qubit gates
that we saw in the previous sections from the U gates.
5.4 Quantum Gates 179
5.4.3.1 U3-Gate
Equation (5.44) gives the matrix form of the U3-gate.
2 3
θ θ
6 cos e iλ
sin
6 2 2 77
U 3 ðθ, ϕ, λÞ ¼ 6 7 ð5:44Þ
4 iϕ θ iλþiϕ θ 5
e sin e cos
2 2
In this equation, θ and ϕ are the rotational angles in the Bloch sphere (see Fig. 3.10) and eiλ is a
global phase. The matrix form of the U3-gate is also the general form of the unitary for single-qubit
operations. Hence, we can derive the rest of the U gates from the U3-gate itself.
Let us now apply the U3-gate on the qubit states j0i and j1i.
2 3
θ θ " #
6 cos 2 e sin
iλ
7 1
6 2 7
U 3 j0i ¼ 6 7
4 θ θ 5 0
eiϕ sin eiðλþϕÞ cos
2 2
2 3
θ
6 cos 2 7 " # " # ð5:45Þ
6 7 θ 1 θ 0
¼6 7 ¼ cos 2 þ e sin
iϕ
4 θ 5 0 2 1
iϕ
e sin
2
θ θ
¼ cos j0i þ e sin
iϕ
j1i
2 2
180 5 Quantum Circuits and DiVincenzo Criteria
2 3
θ θ " #
6 cos 2 e sin
iλ
6 2 7 7 0
U 3 j1i ¼ 6 7
4 θ θ 5 1
eiϕ sin eiðλþϕÞ cos
2 2
2 3
θ
6 e sin 2 7
iλ
6 7
¼6 7 ð5:46Þ
4 θ 5
eiðλþϕÞ cos
2
" # " #
θ 1 θ 0
¼ eiλ sin þ eiðλþϕÞ cos
2 0 2 1
θ θ
¼eiλ sin j0i þ eiϕ cos j1i
2 2
We see that the U3-gate rotates the qubit into an arbitrary superposition state as determined by the
angle of rotation.
Syntax
5.4.3.2 U2-Gate
The following equation defines the U2-gate:
π 1 1 eiλ
U 2 ðϕ, λÞ ¼ U3 , ϕ, λ ¼ pffiffiffi iϕ ð5:47Þ
2 2 e eiðϕþλÞ
Syntax
5.4.3.3 U1-Gate
We can derive the U1-gate from the U3-gate by assuming θ and ϕ are 0.
1 0
U 1 ðλÞ ¼ U 3 ð0, 0, λ Þ ¼ ð5:48Þ
0 eiλ
5.4 Quantum Gates 181
Syntax
In this section, we shall learn how to represent a system of two or more qubits and the gate operations,
which are performed on two or more qubits.
A system of n-qubits has 2n orthonormal computational basis states, simultaneously. Collectively this
is denoted by the ket jx1x2. . .xni; x 2 {0, 1}n. The quantum state of a n-qubit system is a superposition
state with 2n probability amplitudes (ax.) These statements are summarized in the following equation:
X X
jψ i ¼ ax jxi, where j ax j 2 ¼ 1 ð5:50Þ
x2f0, 1gn x2f0, 1gn
When we measure this system, we get x, with a probability jaxj2 ¼ 1. Let us study this in detail with
a two-qubit example.
Recollect the tensor math, we learned in Chap. 2. We use the tensor product to represent the
collective state of two or more qubits. Assume that we have two qubits jψ 1i ¼ a1j0i + b1j1i and
jψ 2i ¼ a2j0i + b2j1i. The two-qubit state describing them can be written as a tensor product described
in the following equation:
jψi ¼ jψ 1 i jψ 2 i
ð5:51Þ
¼ a1 a2 j00i þ a1 b2 j01i þ b1 a2 j10i þ b1 b2 j11i
We require this state to be orthonormal, that is, hψjψi ¼ 1. Hence, we infer that ja1a2j2 + ja1b2j2
+ jb1a2j2 + jb1 b2j2 ¼ 1 from previous chapters.
When we measure the two-qubit state, we get two bits of information x 2 {0, 1}2. The four
possible eigenvalues (λi) are as follows:
182 5 Quantum Circuits and DiVincenzo Criteria
2 3
1
2 3 2 3 6 7 6
7
1 1 607
6 7
j00i ¼ 4 5 4 5 ¼ 6 7, when we measure a ‘00’
6 7
0 0 607
4 5
0
2 3
0
2 3 2 3 6 7 6
7
1 0 617
6 7
j01i ¼ 4 5 4 5 ¼ 6 7, when we measure a ‘01’
6 7
0 1 607
4 5
0
2 3 ð5:52Þ
0
2 3 2 3 6 6 7
7
0 1 607
6 7
j10i ¼ 4 5 4 5 ¼ 6 7, when we measure a ‘10’
617
1 0 6 7
4 5
0
2 3
0
2 3 2 3 6 6 7
7
0 0 607
6 7
j11i ¼ 4 5 4 5 ¼ 6 7, when we measure a ‘11’
607
1 1 6 7
4 5
1
Note that, the notation j00i is also used to represent an unsigned binar encoding of “00” into the
qubits, and the usage of the tensor operator is implicit. The alternate forms of representing the
multi-qubit system are outlined here.
1 1
j00i ¼ ¼ j0i j0i ¼ j0i2 ¼ j0i j0i ð5:53Þ
0 0
In a two or more qubit system, the qubits are correlated, and information is stored across all the
qubits simultaneously. Joint measurement of the qubits is needed to reveal the information.
As in the case of single qubit, the probability of measuring an eigenvalue is given by the Born rule.
2
i ¼ jhλi jψ ij ,
Pzz ð5:54Þ
where z indicates the direction of measurement, and λi is one of the possible eigenvalues described in
Eq. (5.52).
It is also possible to measure just one of the qubits separately. In that situation, the state of that
qubit alone collapses into the computational basis. The other qubits continue to be in a superposition
state.
5.4 Quantum Gates 183
The probability of measuring a 0 in the first qubit (this book uses a zero based indexing of qubits) is
given by:
Such a partial measurement of the system results in a new superposition state. We can calculate
the new superposition state by removing the terms, which are no longer applicable. Moreover, we
must normalize the new superposition state, since the sum of the square of the amplitudes is no
longer 1.
a1 a2 j00i þ a1 b2 j01i
jψ i ¼ q ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð5:56Þ
j a1 a2 j 2 þ j a1 b2 j 2
The SWAP gate performs the following mapping of the basis vectors of the target qubits:
j00i↦j00i
j01i↦j10i
ð5:60Þ
j10i↦j01i
j11i↦j11i
We can implement the SWAP gate using three CNOT gates. Section 5.5.1 describes the steps.
Syntax
Circuit
Composer OpenQASM Qiskit Python Q#—MS QDK
swap qubitjqreq, qc.swap (qubit, Operation SWAP(qubit1:Qubit, qubit2:
qubitjqreq; qubit) Qubit): Unit
swap q[0], q[1]; qc.swap (q[0], q SWAP(q[0], q[1]);
[1])
Truth Table
Input Output
j00i j00i
j01i j10i
j10i j01i
j11i j11i
The general form of the Controlled-U gates (where U is the unitary matrix pertaining to the gate
operation) is given by the following matrix:
2 3
1 0 0 0
60 1 0 0 7
6 7
CðU Þ ¼ 6 7, ð5:62Þ
4 0 0 u00 u01 5
0 0 u10 u11
u00 u01
where, the unitary matrix U ¼ is one of the Pauli matrices.
u10 u11
5.4 Quantum Gates 185
j00i↦j00i
j01i↦j01i
ð5:63Þ
j10i↦j1i U j0i
j11i↦j1i U j1i,
where the qubit on the left-hand side of the tensor product serves as the control qubit, and the qubit on
the right-hand side of the tensor product serves as the target qubit.
Syntax
Circuit
Composer OpenQASM Qiskit Python Q#—MS QDK
cx qubitjqreq, qc. cx (qubit, Operation CNOT(control:Qubit, target:Qubit):
qubitjqreq; qubit) Unit
cx q[0], q[1]; qc. cx (q[0], q[1]) CNOT(q[0], q[1]);
Truth Table
Input Output
j00i j00i
j01i j10i
j10i j11i
j11i j10i
186 5 Quantum Circuits and DiVincenzo Criteria
The cY and cZ gates apply the unitary transform (Pauli Y or the Pauli Z gates) to the target qubit,
only if the control qubit is in state j1i. The target qubit is unaltered, if the control qubit is in state j0i
Syntax
Circuit
Composer OpenQASM Qiskit Python Q#—MS QDK
cy controljqreq, qc. cy (control, Operation CY(control:Qubit, target:Qubit):
targetjqreq; target) Unit
cy q[0], q[0]; qc. cy (q[0], q[1]) CY(q[0], q[1]);
Truth Table
Input cY cZ
j00i j0i j0i j0i j0i
j01i j0i j1i j0i j1i
j10i j1i ij1i j1i j0i
j11i j1i ij0i j1i j1i
j00i↦j00i
j01i↦j01i
ð5:67Þ
j10i↦j1i H j0i
j11i↦j1i H j1i
5.4 Quantum Gates 187
Syntax
Truth Table
Input Output
j00i j00i
j01i j01i
j10i p1ffiffi ðj10i þ j11iÞ
2
j11i p1ffiffi ðj10i j11iÞ
2
j00i↦j00i
j01i↦j01i
ð5:68Þ
j10i↦j1i Rz ðθÞj0i
j11i↦j1i Rz ðθÞj1i
Syntax
j00i↦j00i
j01i↦j01i
ð5:69Þ
j10i↦j1i U3 ðθ, ϕ, λÞ j0i
j11i↦j1i U3 ðθ, ϕ, λÞj1i
188 5 Quantum Circuits and DiVincenzo Criteria
Syntax
Circuit Q#—MS
Composer OpenQASM Qiskit Python QDK
cu3 (theta, phi, lambda) controljqreq, qc. cu3 (theta, phi, lambda, control, See
targetjqreq; target) Appendix
cu3 (pi/2, pi/2, pi/2) q[0], q[1]; qc. cu3 (pi/2, pi/2, pi/2, q[0], q[1])
j00i↦j00i
j01i↦j01i
ð5:70Þ
j10i↦j1i U1 ðλÞ j0i
j11i↦j1i U1 ðλÞ j1i
Syntax:
The Toffoli gate is a quantum gate with two control qubits and one target qubit. The Fredkin gate has
one control qubit, but it operates on two target qubits. We study them as extended gates in this section.
Syntax
Circuit
Composer OpenQASM Qiskit Python Q#—MS QDK
ccx control1jqreq, qc. ccx (control1, Operation CCNOT(control1:Qubit,
control2jqreq, targetjqreq; control2, target) control1:Qubit, target:Qubit): Unit
ccx q[0], q[1], q[2]; qc. ccx (q[0], q[1], q CCNOT(q[0], q[1],q[2]);
[2])
Truth Table
Syntax
Circuit
Composer OpenQASM Qiskit Python Q#—MS QDK
cswap controljqreq, target1jqreq, qc. ccx (control, target1, To be implemented as a
target2jqreq; target2) user gate
cswap q[0], q[1], q[2]; qc. cswap (q[0], q[1], q[2])
The following permutation matrix describes the Fredkin gate (Fig. 5.15).
190 5 Quantum Circuits and DiVincenzo Criteria
(a) (b )
Fig. 5.15 Diagram showing: (a) Toffoli (CCNOT/CCX) and (b) Fredkin (CSWAP) gates
2 3
1 0 0 0 0 0 0 0
60 07
6 1 0 0 0 0 0 7
6 7
60 0 1 0 0 0 0 07
6 7
60 07
6 0 0 1 0 0 0 7
6 7 ð5:74Þ
60 0 0 0 1 0 0 07
6 7
60 07
6 0 0 0 0 0 1 7
6 7
40 0 0 0 0 1 0 05
0 0 0 0 0 0 0 1
Truth Table
The specific example of the Deutsch gate with θ ¼ π2 functions as the Toffoli gate.
where a and b are complex numbers representing the probability amplitudes of finding the qubit in
state j0i or j1i. If we can write these complex numbers in exponential form, by drawing from
Eq. (2.3), we get:
If we calculate the probability amplitude jψj2, by drawing an analogy with Eq. (2.7), we can
readily say that the factor eiθ1 , vanishes. This factor is called global phase, and it does not affect the
quantum computation. The quantity (θ2 θ1) is called relative phase and it is an observable. To
illustrate this further consider the action of the X-gate on the state ji. From Eq. (5.12),
1
ji ¼ pffiffiffi ðj0i j1iÞ ð5:79Þ
2
We see that this operation adds a global phase 1. But this phase is not observable.
Now, consider the circuit shown in Fig. 5.17:
We can work out the system state of this circuit as follows. We begin the system with the qubits
q[0] and q[1] initialized to state j0i.
jψ i ¼ j0ij0i ð5:81Þ
The next step is to apply a H-gate to q[1]. The new system state is as follows:
1 1
jψi ¼ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2 ð5:83Þ
1
¼ ðj00i j01i þ j10i j11iÞ
2
Now we apply a CNOT gate, with the qubit q[0] as the control qubit and q[1] as the target qubit.
1
jψi ¼ CNOT ðj00i j01i þ j10i j11iÞ
2
1 ð5:84Þ
¼ ðj00i j01i þ j11i j10iÞ
2
1
¼ ðj00i j01i ðj10i j11iÞ
2
Comparing Eqs. (5.83) and (5.84), we find that a global phase is added to the target qubit[1]. We
can separate this state, into the states of two separate qubits.
1 1
¼ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ ð5:85Þ
2 2
Note that this operation has resulted in a relative phase to the control qubit. This process of
transferring the global phase occurring in a qubit into a relative phase of another qubit using a
controlled gate is called phase kickback or simply kickback.
The phase kickback method is used extensively in quantum algorithms. We shall see some of them
in Chap. 7.
This sequence reduces to a Z gate. Similarly, we can prove the following identities:
YXY -X XXX X
YYY Y XYX Y
YZY -Z XZX Z
These identities mean that we can make composite gates, which can transform Pauli operators into
other Pauli operators, which forms the basis for universality [12].
5.4.8.3 Universality
In the world of classical computers, we saw that every operation at the application level boils down to
a set of digital gate operations at the hardware level. AND, OR, and NOT gates are the basic digital
gates with which we can develop Boolean functions solving problems in Boolean algebra. If we have
to find optimal gates that serve as the building blocks to solve any problem in Boolean algebra, these
basic gates are probably not the right choices, for example, the AND gate can be constructed using
OR and NOT gates. However, the two gates OR and NOT do not form a complete logical set by
themselves. The choices are with NAND and NOR gates, as they are complete by themselves, and
they can be used to construct all other logic. Hence, in the world of digital electronics, the NAND and
NOR gates are called Universal Logic Gates.
Similarly, we can define Universal Quantum Gates. Universal Quantum Gates are a set of gates
to which any operation possible on a quantum computer can be reduced. In other words, any unitary
operation can be expressed as a finite sequence of gates from the set of Universal Quantum Gates.
If such a set of gates existed then, for example, we may be able to implement a gate RðθÞ, 8θ 2 R.
Since this is a wide range, it may seem an impossibility to implement universality with a finite
number of gates. So, we must resort to some approximations. The Solovay–Kitaev theorem proposes
that approximations to any desired gate can be created using fairly short sequences of gates from the
generating set. In short, we can say that the unitary U0 simulates the required unitary U to an accuracy
within ε if kU U0 k ε.
According to Solovay–Kitaev theorem, we can say that a set of G quantum gates are universal if,
8U, 8ε > 0, ∃g1, g2 , . . . , gn 2 G :
U U g1 , U g2 , . . . , U gn
ε: ð5:87Þ
One set of common Universal Quantum Gates available today are the Clifford Group and the
T gates.
the current generation of NISQ processors. They have many design constraints due to the complexity
of the underlying physics and the control electronics required to operate the qubits. Especially, qubit
to qubit interaction channels and multi-qubit gate control are often limited. Due to these constraints,
the NISQ processors have a specific configuration (called Hardware Topology) with a limited set of
basis gates and qubits connections. For example, multi-qubit gates such as CNOT and SWAP
operations can only be performed between certain qubit combinations. Hence, quantum circuits
need to be optimized and translated into those basis gates and circuit combinations to suit specific
hardware design constraints.
Let us explore these constraints a bit. The first constraint we shall explore is the hardware
topology. Type the code from Listing 5.15 in your Jupyter notebook and execute the same.
Figure 5.18 shows the output of the program for the processor “ibmq_athens.” Note that IBM
Quantum Experience announces new backends, and old backends are taken offline from time to time.
The current list of backends is found at this link: https://quantum-computing.ibm.com/systems?
skip¼0&system. if the backend “ibmq_athens” is not available at the time of your experimentation,
please try another backend. You can run the code with the other processors, and get some familiarity
with their hardware topology. Note that, in this processor, there is no connection between qubits 0 &
2, 0 & 3, 0 & 4, and 2 & 4. Does this mean, we cannot perform a multi-qubit operation between these
qubits? The answer is both yes and no. At the physical level, it is not possible. However, at the circuit
level, we can construct a multi-qubit gate operation between these qubits. We shall learn how this
works in a subsequent section.
Type the following code in a new cell and execute the same.
backend.configuration().basis_gates
Executing this code generates the list of basis gates for the backend “ibmq_athens.” We get the
following list upon execution of this code:
As the list shows, the backend “ibmq_athens” implements only the given basis gates at the
hardware level! If we have expected all the gates outlined in the previous sections are supported at
the hardware level, we are a little surprised by this information. Most backends implement the basis
gates at the hardware level.
All other gates we outlined in previous sections can be constructed from combinations of the basis
gates. Besides, gates such as Z, T, S, T{, and S{are not performed on the hardware. These gates are
implemented in software as “virtual gates.” The other name for virtual gates is “frame changes.”
Frame changes execute in zero time and have no associated error. In other words, we regard them as
free gates on hardware. To illustrate this, type the following code in a new cell and execute the same
in your notebook (Listing 5.16).
qc.h(q[1])
qc.cx(q[0],q[1])
qc.cx(q[2],q[1])
qc.ccx(q[1],q[0],q[2])
qc.measure(q[1], c[0])
qc.draw(output='mpl')
Executing the given code generates the circuit shown in Fig. 5.19. We start with all qubits prepared
at state j0i. We then apply an H-gate to qubit q[1], and a CNOT gate to qubits q[0]!q[1]. After this
step, we apply another CNOT gate to qubits q[2]!q[1]. The next step is to apply a CCX gate to qubit
q[2], with qubits q[0] and q[1] as the control qubits. We finally measure qubit q[2]. This code does not
do anything creative. We shall use this for illustration.
Enter the following code in a new cell and execute it in your notebook. These two lines of code
decompose the circuit into its constituents.
qc_basis = qc.decompose()
qc_basis.draw(output=’mpl’)
Executing the code fragment generates a decomposed circuit as shown in Fig. 5.20.
The decomposition of our original circuit should not be surprising as we have learned that
advanced gates are composed of basis gates!
We can try some math to prove that Figs. 5.19, 5.20 are the same. The question is: How did this
happen?
5.4.9.2 Transpilation
We must also note that it is not efficient to write code for each hardware topology. As much research
is happening in this space, we can expect frequent announcements of new backends with an increased
number of qubits and hardware configuration. The older generation of backends is outdated and
removed from the execution pipeline. So, it is advantageous if we can have software convert the given
quantum circuit to suit any backend. When we submit a quantum circuit for execution, a process
known as transpilation takes place first. The transpiler converts the input circuit to suit the target
backend and optimizes it for execution. Note that the transpilers are improved as new optimization
schemes are invented. So your version of the decomposed circuit may not be exactly similar to
Fig. 5.20, but it should be quantum mechanically equivalent to Fig. 5.19.
comparing it with the Gate Time TT∅2 and predicting how much noisy the circuit can be.
Let us examine the depth of our circuit now. Enter the following code in a new cell and execute the
same.
qc.depth()
5.4 Quantum Gates 197
We should get an output of 5. Note that the depth calculations include the measurement operations.
Execute the following code to determine the width of the circuit.
qc.width()
The width of the quantum circuit is the total number of qubits and classical registers. In our case, it
is 4.
Now, let us check the size of the circuit with the following code:
qc.size()
The size of a quantum circuit is a measure of the raw operations. It is 3 for our circuit.
To check the total number of circuit operations, execute the following code.
qc.count_ops()
qc.u3(math.pi,0,math.pi,q[0])
qc.u3(math.pi,0,math.pi,q[0])
qc.measure(q[0], c[0])
qc.draw(output='mpl')
Upon executing the given code, we get the diagram shown in Fig. 5.21(a).
Now, execute the code provided in Listing 5.18.
The circuit is transpiled, and we get the diagram shown in Fig. 5.21(b).
In the given example, the U3(pi, 0, pi) operation is equivalent to an X-gate. Two successive
X-gates, bring the qubit to the original state. Hence, the transpilation process has merged the U3 gates
into a no-operation state. The transpilation results in a circuit, which measures the qubit. To prevent
198 5 Quantum Circuits and DiVincenzo Criteria
(a) (b)
Fig. 5.21 Transpilation Example (a) Circuit with two successive U3 gates which are functionally equivalent to
X-gates. (b) Circuit after transpilation
qc = transpile(qc)
qc_basis = qc.decompose()
qc_basis.draw(output='mpl')
qc.u3(math.pi,0,math.pi,q[0])
qc.barrier(q[0])
qc.u3(math.pi,0,math.pi,q[0])
qc.measure(q[0], c[0])
qc.draw(output='mpl')
Listing 5.19 Test code with the barrier gate inserted between the U3 gates
the transpiler from merging gates, we should introduce a barrier gate, as shown in the given code
(Listing 5.19).
Upon execution of the given code, we get the circuit diagram, as shown in Fig. 5.22. The
transpilation process does not alter this quantum circuit. A barrier separates the two X-gates.
We shall use the barrier gate in our future examples, appropriately.
5.4 Quantum Gates 199
Syntax
In Listing 5.4, we used the plot_histogram function. In this section, we shall see a couple of other
methods, which may be useful.
5.4.10.1 Plot_Bloch_Multivector
After executing a quantum circuit, the Bloch vector of the resultant state can be plotted. Be sure to use
“statevector_simulator” as the backend (Listing 5.20).
Executing this code produces the image, as shown in Fig. 5.23. For the given circuit, the Bloch
vector may point to different directions, each time the code is executed. The reason is that the qubits
are in a superposition state.
q = QuantumRegister(2, 'q')
c = ClassicalRegister(2, 'c')
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q[0], c[0])
qc.measure(q[1], c[1])
backend = Aer.get_backend('statevector_simulator')
job = execute(qc, backend).result()
5.4.10.2 Plot_State_City
In a new cell in the Jupyter notebook, execute the following statement.
plot_state_city(job.get_statevector(qc))
In the previous sections, we learned that the quantum circuit evolves unitarily. Assuming U is unitary
in group ð2n Þ, and n is the number of qubits, the following equation describes the unitary evolution.
ψ final ¼ U jψ initial i ¼ U j01 , 02 , . . . , 0n i ð5:88Þ
According to the Gottesman–Knill theorem, a quantum unitary evolution that uses the following
operations can be simulated effectively on a classical computer.
Daniel Gottesman and Emanual Knill proposed this theorem. This theorem proves that on a
classical computer, we can simulate quantum circuits constructed from the Clifford group in
polynomial time. Therefore, quantum circuits that rely on entanglement created by H and CNOT
gates alone cannot create a quantum advantage.
Gottesman made some important contributions to quantum error correction and stabilizer circuits.
In the last chapter of this book, we shall return to Gottesman–Knill theorem briefly. Several
references related to Gottesman’s work are provided in the reference section of that chapter.
With the knowledge we built so far on quantum gates, quantum circuits, and circuit optimizations, we
are now ready to dive deep into the compute stage. In the following sections, we start by exploring
simple circuits such as cascading of two CNOT gates and constructing digital logic equivalents. We
then move on with some advanced topics such as quantum entanglement and quantum teleportation.
j ψ i ¼ j Ai j Bi ð5:89Þ
We now apply the first CNOT gate to qubit B with qubit A as the control. The equation becomes:
j ψ i ¼ j Ai j A A Bi ð5:91Þ
We infer that two CNOT gates return the system to the original state. Now consider the circuit
shown in Fig. 5.26.
Fig. 5.26 Quantum circuit with three CNOT gates, performing a SWAP operation
q[0]
q[1]
In this circuit, a CNOT gate in the opposite direction is sandwiched between two cascaded CNOT
gates. Let us calculate the final state of the system. The starting state of the system is the same as the
previous example:
j ψ i ¼ j Ai j Bi ð5:93Þ
We now apply the first CNOT gate to qubit B with qubit A as the control. The equation becomes:
j ψ i ¼ j Ai j A Bi ð5:94Þ
The next step is to apply a CNOT gate to qubit A with qubit B as the control. The system state now
changes to (refer to previous example):
The final step is to apply another CNOT gate to qubit B with qubit A as the control. The system
now transforms into:
The final state is the SWAP of the input states. Hence, we can infer that this sequence of CNOT
gates functions as a SWAP gate.
Now, consider the circuit shown in Fig. 5.27.
In this circuit, we apply a CNOT gate to two qubits in equal superposition state. The system state
can be derived as follows. We begin the system with the qubits q[0] and q[1] initialized to state j0i.
jψ i ¼ j0ij0i ð5:97Þ
The next step is to apply H-gates to q[0] and q[1]. The new system state is as follows:
1 1
jψi ! pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i þ j1iÞ
2 2 ð5:98Þ
1
! ðj00i þ j01i þ j10i þ j11iÞ
2
Now we apply a CNOT gate, with the qubit q[0] as the control qubit and q[1] as the target qubit.
5.5 The Compute Stage 203
q[0]
q[1]
CX q½0 , q½1
1
! ðj00i þ j01i þ j10i þ j11iÞ
2
1
! ðj00i þ j01i þ j11i þ j10iÞ ð5:99Þ
2
1 1
! pffiffiffiðj0i þ j1iÞ pffiffiffi ðj0i þ j1iÞ
2 2
Note that this leaves the system state unchanged. Consider a variant of this circuit which adds two
H-gates after the CNOT, with the target qubit starting in state j1i (Fig. 5.28).
Comparing with Fig. 5.17, Eq. (5.85), we can write the state of the system upto the CNOT gate as
follows:
1 1
jψ i ¼ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ ð5:100Þ
2 2
Now, applying final set of H-gates to both the qubits, by referring to Eqs. (5.18) and (5.19) we can
simplify this equation as:
jψ i ¼ j1ij1i ð5:101Þ
We see that the control qubit has flipped its state. This also means the roles of the control qubit and
target qubit are exchanged! Test this with other initial states!
We can now proceed with the next steps by constructing the quantum equivalent of the conventional
digital logic gates. Starting at this level shall help us to understand the complex quantum circuits in
the upcoming chapters. Of course, the quantum equivalent of digital gates is not significantly useful,
beyond helping us to understand the quantum circuits better.
Qiskit QDK
def NOTGate(input, backend, shots): operation NOTGate(input:Bool, shots:Int) :
q = QuantumRegister(1, 'q') (Int) {
c = ClassicalRegister(1, 'c') mutable c0 = 0;
qc = QuantumCircuit(q, c) using (q0 = Qubit()) {
for (i in 1..shots){
if ( 1 == input ): Reset(q0);
qc.x(q) if ( true == input) {
X(q0);
qc.x(q) }
X(q0);
qc.measure(q, c) let result = M(q0);
qreg q[1];
creg c[1];
Input Output
j0i j1i
j1i j0i
Qiskit QDK
def ORGate (Input1, Input2, backend, operation ORGate(Input1:Int, Input2:Int,
shots): shots:Int): Int {
q = QuantumRegister(3, 'q') mutable c0 = 0;
c = ClassicalRegister(1, 'c') using(q = Qubit[3]){
qc = QuantumCircuit(q, c) if (0 == Input1){
X(q[0]);
if ( 0 == Input1 ): }
qc.x(q[0]) if (0 == Input2){
X(q[1]);
if ( 0 == Input2 ): }
qc.x(q[1]) for (i in 1..shots){
X(q[2]);
qc.x(q[2]) CCNOT(q[0], q[1], q[2]);
qc.ccx(q[0], q[1], q[2]) let r = M(q[2]);
qc.measure(q[2], c) if ( One == r ) {
set c0 += 1;
job = execute(qc, backend, }
shots=shots)
Reset(q[2]);
result = job.result()
}
counts = result.get_counts(qc)
Reset(q[0]);
Reset(q[1]);
return counts
return c0;
}
}
Experiment with the circuit by changing the X-gates before the barrier gate and verify all four
combinations of the inputs, as shown in the Truth Table.
Qiskit QDK
def ANDGate (Input1, Input2, backend, operation ANDGate( Input1 : Int, Input2 :
shots): Int, shots : Int ) : Int {
q = QuantumRegister(3, 'q') mutable c0 = 0;
c = ClassicalRegister(1, 'c') using (q = Qubit[3]) {
qc = QuantumCircuit(q, c) for ( i in 1..shots ) {
if (1 == Input1) {
if ( 1 == Input1 ): X(q[0]);
qc.x(q[0] }
if ( 1 == Input2 ): if ( 1 == Input2) {
qc.x(q[1]) X(q[1]);
}
qc.ccx(q[0], q[1], q[2]) CCNOT(q[0], q[1], q[2]);
qc.measure(q[2], c) let r = M(q[2]);
if ( r == One) {
job = execute(qc, backend, set c0 += 1;
shots=shots) }
result = job.result() Reset(q[0]);
counts = result.get_counts(qc) Reset(q[1]);
Reset(q[2]);
return counts }
return c0;
}
}
Listing 5.26 Constructing the AND gate using the circuit editor
Qiskit QDK
def XORGate (Input1, Input2, backend, operation XORGate( Input1 : Int, Input2 :
shots): Int, shots : Int ) : Int {
q = QuantumRegister(2, 'q') mutable c0 = 0;
c = ClassicalRegister(1, 'c') using (q = Qubit[2]){
qc = QuantumCircuit(q, c) for ( i in 1..shots ) {
if ( 1 == Input1 ): if (1 == Input1) {
qc.x(q[0]) X(q[0]);
}
if ( 1 == Input2 ): if ( 1 == Input2) {
qc.x(q[1]) X(q[1]);
}
qc.cx(q[0], q[1]) CNOT(q[0], q[1]);
qc.measure(q[1], c) let r = M(q[1]);
if ( r == One) {
job = execute(qc, backend, set c0 += 1;
shots=shots) }
result = job.result() Reset(q[0]);
counts = result.get_counts(qc) Reset(q[1]);
return counts }
return c0;
}
}
Listing 5.28 Constructing the XOR gate using the circuit editor
Exercise 5.1
1. Write unit test code to prove that the given circuits work the way we meant.
2. Construct NOR, XNOR and NAND gates using the examples.
◄
S ¼ A B CIN ð5:102Þ
+ COUT
∧
An XOR gate can replace the OR gate at the last stage of computing COUT. This is apparent from
Table 5.4.
The last two columns of this table are the same. Therefore, we can rewrite Eq. (5.103) as:
We can cascade a sequence of full adder circuits to add two n-bit numbers. To perform the full
addition, the COUT of the nth bit needs to connect with the CIN of n+1th bit. Such a circuit is known as
a “ripple adder” as the carry ripples through all the adders. We shall implement a quantum ripple
adder in Chap. 7. Let us return to our discussions on the full adder circuit and implement a quantum
version of it.
Consider the quantum circuit shown in Fig. 5.30. This circuit uses four qubits. Qubits A and B are
the inputs to be added. The qubit CIN is the carry-in. When the circuit completes, this qubit also
contains the sum (S). The qubit AUX holds information temporarily. However, when the circuit
completes, it holds the carry-out (COUT).
Let us now derive the math to show how this circuit works.
The circuit starts with qubit AUX in state j0i. The inputs A, B, and CIN can be in state j0i or j1i.
The following equation describes the starting state of the system.
210 5 Quantum Circuits and DiVincenzo Criteria
B B
CIN S
Aux 0 COUT
We then apply a Toffoli gate to AUX qubit, with A and B serving as the control qubits. By
referring to Eq. (5.71), we can rewrite the above equation.
¼ jAijBijCIN ij0 A ^ Bi, ð5:106Þ
We then apply a CNOT gate to B, with A as the control gate. By referring to Eq. (5.65), we can
rewrite the given equation as follows:
¼ jAijA BijCIN ijA ^ Bi ð5:108Þ
After this operation, we perform a Toffoli gate with AUX qubit, with B and CIN as the control
qubits. The system state is as follows:
¼ jAijA BijCIN ijðA ^ BÞ ðA BÞ ^ CIN i ð5:109Þ
The next step is to perform a CNOT on CIN, with B as the control gate.
Comparing the previous equation with Eqs. (5.102) and (5.104), we infer the following:
It is optional to retrieve A and B from the circuit. To do so, we have to apply a CNOT operation to
qubit B with A as the control. The above equation now becomes:
From our calculations that lead to Eq. (5.92), we can simplify this equation as:
¼ jAijBijSij COUT i ð5:113Þ
This equation preserves the input, at the same time has the elements representing the Sum (S) and
Carry-out (COUT).
5.5 The Compute Stage 211
1/2 1/2
q[1]
Exercise 5.2
Construct the full adder circuit using Qiskit and QDK and prove that it works by developing unit
testing code.
◄
pffiffiffiffiffiffiffiffiffiffiffiffi
5.5.3 Implementing a CNOT Gate with a SWAP gate
pffiffiffiffiffiffiffiffiffiffiffiffiffi
In section 5.4.5.2, we learned about the SWAP gate with a note that it is a universal quantum gate. In
pffiffiffiffiffiffiffiffiffiffiffiffiffi
this section, we shall implement a CNOT gate using two SWAP gates and a couple of rotational
gates. Consider the quantum circuit shown in Fig. 5.31. Let us assume we started the system in the
state j1ij1i. To the second qubit, a Y gate is applied. We can write the system state as follows:
2 3
0
6 7
0 0 i 0 0 i 6 0 7
j ψ i ! j 1i Y j 1i ! ! !6 7 ð5:114Þ
1 0 0 1 1 0 4 i 5
0
Note that we used tensor multiplication in the last step of the given equation. After the Y gate,
pffiffiffiffiffiffiffiffiffiffiffiffiffi
SWAP is applied. The new system state can be derived as follows:
2 3 2 3
1 0 0 0 2 3 0
0
6 1þi 1i 7 6 1þi 7
60 0 76 0 7 6 7
6 2 2 76 7 6 2 7
!6 7 6 7 ¼6 7 ð5:115Þ
6 0 1 i 1 þ i 0 74 i 5 6 1 þ i 7
4 2 2 5 4 2 5
0
0 0 0 1 0
2 32 3
1
0 0 0 0
6 76 7
6 0 1 þ i 1 i 0 76 1 i 7
6 2 2 76 2 7
!6
6
76
76
7
7
6 0 1 i 1 þ i 0 76 1 þ i 7
4 2 2 5 4 2 5
0 0 0 1 0
2 3
0
6 7 ð5:117Þ
6 0 7
6 7
!6 7
6 1 7
4 5
0
" #" #
0 1
!
1 0
! j1ij0i
We see that up to a global phase; this circuit works like a CNOT gate. As an exercise, this sequence
can be tried with possible input combinations.
In the previous sections, we learned that we represent a quantum system with n qubits as a complex
vector in the Hilbert space with 2n dimensions. We use the tensor product to represent such a
composite system. For example, a system of two qubits jψ0i and jψ1i is written as a tensor product
jψi ¼ jψ0i jψ1i. This composite system is a collection of individual qubits. There is no correlation
between the qubits. If we can somehow find a correlation between the qubits and describe the system
as a single system, we say that the qubits are entangled.
Entanglement is a unique property of quantum systems, and we use it, especially in quantum
communications. Consider the circuit shown in Fig. 5.32, which we can construct equally in Qiskit/
QDK.
In this circuit, we prepare two qubits in the default state of j0i. We then apply an H-gate to qubit
q[0], and perform a CNOT operation to the target qubit q[1], with the q[0] being the control qubit.
Finally, we measure the qubits q[0] and q[1].
We can derive the final state of the quantum circuit as follows:
q[1]
C
5.6 Quantum Entanglement 213
H½0 1
Step 1 Apply H‐gate j00i ! pffiffiffi ðj0i þ j1iÞ j0i
2
" # " #! " #
1 1 0 1
! pffiffiffi þ
2 0 1 0
02 3 2 31 ð5:118Þ
1 0
B6 7 6 7C
B6 7 6 7C
1 B6 0 7 6 0 7C
! pffiffiffi B6 7 þ 6 7C
2B 6 7 6 7C
@4 0 5 4 1 5A
0 0
CX q½0 , q½1 1
Step 2 Apply CNOT gate ! pffiffiffi
2
02 3 2 31 2 3
1 0 1 0 0 0
B6 0 7 6 0 7C 6 0 07
B6 7 6 7C 6 1 0 7
B6 7 þ 6 7C 6 7
@4 0 5 4 1 5A 4 0 0 0 15
0 0 0 0 1 0
ð5:119Þ
02 3 2 3 1
1 0
B6 0 7 6 0 7 C
1 B6 7 6 7 C 1
Final State : ! pffiffiffi B6 7 þ 6 7C ¼ pffiffiffi ðj00i þ j11iÞ ¼ jϕþ i ð5:120Þ
2 @4 0 5 4 0 5 A 2
0 1
The final state jϕþ i ¼ p1ffiffi2 ðj00i þ j11iÞ cannot be expressed separately in terms of q[0] and q[1].
We call this resultant state an entangled state, and the qubits are said to be in a maximally entangled
state with each other. The entangled qubits are called EPR Pair. jΦ+i is one of the Bell States. We
can create the remaining Bell states by changing the initial state of the qubits. The following set of
equations describes the four Bell states.
1
j00i ! pffiffiffi ðj00i þ j11iÞ ¼ jϕþ i ð5:121Þ
2
1
j01i ! pffiffiffi ðj00i j11iÞ ¼ jϕ i ð5:122Þ
2
1
j10i ! pffiffiffi ðj01i þ j10iÞ ¼ jΨ þ i ð5:123Þ
2
1
j11i ! pffiffiffi ðj01i j10iÞ ¼ jΨ i ð5:124Þ
2
Readers can calculate the four Bell states to gain more familiarity. Execute the Qiskit code shown
in the Listing 5.29 to try the Bell state jϕ+i.
A plot of this code should get almost equal measurements for both the qubits, as shown in
Fig. 5.33. The differences, as we know, are due to the underlying physics.
The equivalent code in QDK is given in Listing 5.30.
214 5 Quantum Circuits and DiVincenzo Criteria
q = QuantumRegister(2, 'q')
c = ClassicalRegister(2, 'c')
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q[0], c[0])
qc.measure(q[1], c[1])
Upon executing the code, we can verify that both the qubits measure the same.
We shall return to the Bell States in the next chapter and explore its applications in quantum
communications.
Exercise 5.3
Create the four Bell States and verify that the four Bell states form an orthonormal basis.
◄
if ( result1 == One) {
set c0 += 1;
}
if ( result2 == One){
set c1 += 1;
}
}
Message($"We got: {c0} , {c1} ");
return (0);
}
}
According to the no-cloning theorem, this is not physically possible. We can only copy mutually
orthogonal states.
Assume we have a cloning operator C, which can copy states jϕi or jψi. We start with two qubits.
The first qubit is in an arbitrarily unknown state. The second qubit is set to state j0i. We expect the
cloning operation to copy the information in the first qubit to the second qubit. After the cloning
operation, we expect both the qubits to have the same information.
C
jϕi j0i ! jϕi jϕi
ð5:125Þ
C
jψi j0i ! jψi jψi
¼ hϕjψ i2 ð5:130Þ
This equality is possible only if C is a unitary and hϕjψi ¼ 0 or 1, that is, jϕi and jψi are mutually
orthogonal.
The No-Cloning theorem forbids us from making copies of qubits in arbitrary quantum states. Of
course, we can make a copy of an original qubit by destroying its state and transmitting the copied
qubit’s state over vast distances. Consider the quantum circuit shown in Fig. 5.34, which can be
constructed by typing the code in Listing 5.31 in the Circuit Editor.
In this circuit, Alice and Bob1 share two maximally entangled qubits q[1] and [q2]. Alice has
access to qubit q[1], and Bob has access to qubit q[2].
Now, Alice has access to a data qubit q[0], which is in an arbitrarily unknown state jψi ¼ aj0i + bj1i.
Alice first creates entanglement between her qubits q[0] and q[1]. Alice then measures her qubit
q[1] and sends it status to Bob using a classical channel. If Bob receives a 1 on the classical channel,
he performs a bit flip (X-gate) on his qubit q[2].
Alice then measures her data qubit q[0] and sends the status to Bob. If Bob receives a 1 on the
classical channel, he performs a phase flip (Z gate) on his qubit q[2].
In this process, when Alice first measures her qubit q[1], its state collapses and the entanglement is
between q[0] and q[2]. When the qubit q[0] is measured, information is encoded only in q[2]. The X
and Z gates are correction operations. Let us look at the math to make this concept clear.
The initial state of the system is as follows:
c01
c11
c21
1
Alice and Bob are fictional characters used in cryptography and other thought experiments. http://cryptocouple.com/
5.8 Quantum Teleportation 217
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c0[1];
creg c1[1];
creg c2[1];
h q[2];
cx q[2],q[1];
cx q[0],q[1];
h q[0];
Then, we apply a CNOT gate to qubit q[1]. This operation puts q[1] and q[2] in a maximally
entangled state. By using the Bell state Eq. (5.121), we get the following:
1
ðaj0i þ bj1iÞ CNOT j0i pffiffiffi ðj0i þ j1iÞ
2
1
! ðaj0i þ bj1iÞ pffiffiffi ðj00i þ j11iÞ ð5:133Þ
2
1
! pffiffiffi ðaj000i þ aj011i þ bj100i þ bj111iÞ
2
We can see that the use of Dirac’s bra-ket notation helps us to write the tensor products easily. The
next step is to apply a CNOT gate, with q[0] as the control qubit and q[1] as the target qubit. The state
of the system now becomes:
1
! pffiffiffi ðaj000i þ aj011i þ bj110i þ bj101iÞ ð5:134Þ
2
In this equation, we just flipped the state of q[1] depending upon the state of q[0]. Now, we apply
an H-gate to q[0]. Applying H-gate to q[0] in the given equation may be a little difficult to understand.
To simplify our understanding of this step, we can temporarily separate the kets, apply the H-gate to
q[0] and then recombine the kets. Separable kets are a property of tensor products.
To begin with, let us separate the kets. We can rewrite the given equation as:
218 5 Quantum Circuits and DiVincenzo Criteria
1
! pffiffiffi ðaj0ij00i þ aj0ij11i þ bj1ij10i þ bj1ij01iÞ ð5:135Þ
2
1 1
! pffiffiffi pffiffiffi ðaj0ij00i þ aj1ij00i þ aj0ij11i þ aj1ij11i þ bj0ij10i bj1ij10i þ bj0ij01i bj1ij01iÞ
2 2
ð5:138Þ
We can now recombine the kets to get the final form of the quantum circuit at this stage.
1
! ðaj000i þ aj100i þ aj011i þ aj111i þ bj010i bj110i þ bj001i bj101iÞ ð5:139Þ
2
We can now examine the outcome of the possible measurements.
Case 1:
If we measured a j0i in q[1], the system collapses to the following state with qubits q[0] and q[2]:
E
1
ψ q½0 q½2 ! ðaj00i þ aj10i þ bj01i bj11iÞ ð5:140Þ
2
Since we measured a j0i, we do not perform the X-gate with q[2].
Case 2:
If we measured a j1i in q[1], the system collapses to the following state:
E
1
ψ q½0 q½2 ! ðaj01i þ aj11i þ bj00i bj10iÞ ð5:141Þ
2
Since we measured a j1i, we perform the X-gate with q[2]. This results in a new state given by:
E
1
ψ q½0 q½2 ! ðaj00i þ aj10i þ bj01i bj11iÞ ð5:142Þ
2
We see that Eqs. (5.140) and (5.142) are the same. The correction operation X has ensured that we
have the same system state at this point. We now proceed with measuring q[0]. There can be two
possible outcomes now.
Subcase 1:
If we measured a j0i with q[0], the system collapses into the following state for q[2]:
E
1
ψ q½2 ! ðaj0i þ bj1iÞ ð5:143Þ
2
5.8 Quantum Teleportation 219
Since a and b are complex numbers, we can factor in 12 into these constants and we can rewrite the
above equation as:
E
ψ q½2 ! aj0i þ bj1i ¼ jψ i ð5:144Þ
Subcase 2:
If we measured a j1i with q[0], the system collapses into the following state for q[2]:
E
1
ψ q½2 ! ðaj0i bj1iÞ ð5:145Þ
2
In this case, we apply a Z gate to q[2] and the result of this operation, after considering the logic in
Eq. (5.144), we get:
1
ψ q½2 i !Z ðaj0i bj1iÞ
2
1
! ðaj0i þ bj1iÞ ð5:146Þ
2
! aj0i þ bj1i ¼ jψi
From Eqs. (5.144) and (5.146), we can conclude that the resultant state of q[2] is jψi ¼ aj0i + bj1i.
This superposition state is where Alice started with her data qubit q[0]. We can, therefore, say that the
quantum state of q[0] is copied into q[2]. This operation is known as “Quantum Teleportation.” The
status of q[0] is, however, destroyed. The reason for calling this operation as “teleportation” is
because the qubits q[1] and q[2] can be far apart. We shall explore the concept of two entangled qubits
being far apart in the next chapter.
Upon executing this circuit in the simulator for 1024 times, we get the histogram shown in
Fig. 5.35.
In the histogram, the values of the classical registers are shown along the x-axis under the bars.
Recall that we projected q[2] into c2. It must be easy to figure out that the state of the classical register
c2 is 0. This can mean that the state j0i of qubit q[0] was copied to qubit q[2]. To confirm this,
construct the following circuit, by flipping the state of q[0] to j1i (Fig. 5.36).
28
25.684% 26.074%
26 24.512%
23.730%
24
22
%
20
18
16
14
12
10
8
6
4
2
0
000 001 010 011
States
Fig. 5.35 Histogram obtained after teleporting qubit q[0] in state j0i to qubit q[2]
220 5 Quantum Circuits and DiVincenzo Criteria
q [ 2] H X Z
c01
c11
c21
28 26.367%
26 24.805% 24.707% 24.121%
24
22
%
20
18
16
14
12
10
8
6
4
2
0
100 101 110 111
States
Fig. 5.37 Histogram for the teleportation experiment with qubit q[0] in state
We can flip the qubit q[0] by adding the instruction x q[0] above the instruction that performs
H-gate on q[2]. Upon executing the given circuit, we get the histogram shown in Fig. 5.37.
If we observe the values of the classical registers below the bars along the x-axis, we note that the
classical register c2 is always 1.
By comparing both the experiments, we can conclude that we teleported qubit q[0] into qubit q[2].
Exercise 5.4
1. Perform the teleportation experiment using Qiskit using Python code and using QDK in Q# code.
2. Execute the experiment on a Quantum Processor on the IBM Q, compare the results with that of
the simulator. What do you conclude? Is your Quantum Processor able to produce the same results
as that of the simulator?
Hints:
To execute the code on a real Quantum Processor, use the modifications shown in the Listing 5.32 into
your Python code.
5.9 Superdense Coding 221
Holevo’s theorem puts an upper bound on how much information we can transmit using qubits.
According to this theorem, it is not possible to transmit more than n classical bits of information by
transmitting n qubits [14]. Let us say Alice has got some information x 2 {0, 1}n that she wishes to
transmit to Bob. She does that by creating a quantum state jψxi in the Hilbert space H 2 ℂd and
transmits that to Bob over a quantum communication channel. Bob receives the qubits and measures
their quantum state to retrieve the input x 2 {0, 1}n faithfully. This transmission is possible only if the
dimensionality of the state d ¼ 2n. In our discussion on the no-cloning theorem, we learned that
non-orthogonal states could not be precisely measured. In order to have a dimensionality of d ¼ 2n,
we need to have n qubits. In other words, in order to transmit n bits of classical information, we need
n qubits.
Superdense coding comes handy here. Using this protocol, Alice can send two classical bits of
information by just sending one qubit to Bob, provided they both share an entangled qubit.
Assume that both Alice and Bob have access to a source that creates entangled pairs of qubits and
sends one qubit each to Alice and Bob. Assume that the qubits are prepared in the Bell state
jϕþ i ¼ p1ffiffi2 ðj00i þ j11iÞ. Alice has the qubit A, and Bob has the qubit B. There are four scenarios
now.
• If Alice wants to send the message “00” to Bob, she does not perform any operation on her qubit.
• If Alice wants to send the message “01” to Bob, she performs an X-gate on her qubit A. The state
of the entanglement now becomes jψ+i as shown in the following steps.
222 5 Quantum Circuits and DiVincenzo Criteria
1
pffiffiffi ðXj0ij0i þ Xj1ij1iÞ
2
1
¼ pffiffiffi ðj1ij0i þ j0ij1iÞ ð5:147Þ
2
1
¼ pffiffiffi ðj10i þ j01iÞ ¼ jψ þ i
2
• If Alice wants to send the message “10” to Bob, she performs a Z-gate on her qubit A. The state of
the entanglement becomes jϕi as shown in the following derivation:
1
pffiffiffi ðZj0ij0i þ Z j1ij1iÞ
2
1
¼ pffiffiffi ðj0ij0i j1ij1iÞ ð5:148Þ
2
1
¼ pffiffiffi ðj00i j11iÞ ¼ jϕ i
2
• If Alice wants to send the message “11” to Bob, she performs an X-gate and then a Z-gate to her
qubit A. The new entangled state is jψi.
1
pffiffiffi ðZXj0ij0i þ ZXj1ij1iÞ
2
1
¼ pffiffiffi ðZj1ij0i þ Z j0ij1iÞ
2
ð5:149Þ
1 1
¼ pffiffiffi ðj1ij0i þ j0ij1iÞ ¼ pffiffiffi ðj0ij1i j1ij0iÞÞ
2 2
1
¼ pffiffiffi ðj01i j10iÞ ¼ jψ i
2
After encoding the information using the above scheme, Alice then sends her qubit A to Bob. Bob
now has both the qubits A and B, entangled in one of the four mutually orthogonal Bell states. To
retrieve the encoded information, Bob must perform a couple of operations. Bob first performs a
CNOT on the qubit B, with qubit A as the control. The following set of equations illustrate how each
of the Bell states transforms after the CNOT operation.
1 CNOT A,B 1
jϕþ i ¼ pffiffiffi ðj00i þ j11iÞ ! pffiffiffi ðj00i þ j10iÞ ð5:150Þ
2 2
1 CNOT A,B 1
jψ þ i ¼ pffiffiffi ðj10i þ j01iÞ ! pffiffiffi ðj11i þ j01iÞ ð5:151Þ
2 2
1 CNOT A,B 1
jϕ i ¼ pffiffiffi ðj00i j11iÞ ! pffiffiffi ðj00i j10iÞ ð5:152Þ
2 2
1 CNOT A,B 1
jψ i ¼ pffiffiffi ðj01i j10iÞ ! pffiffiffi ðj01i j11iÞ ð5:153Þ
2 2
After performing the CNOT, Bob performs an H-gate on qubit A. By referring to Eqs. (5.11) and
(5.12), we can write the transforms as follows:
5.10 Greenberger–Horne–Zeilinger State (GHZ State) 223
1 1
Case #1 pffiffiffi ðj00i þ j10iÞ ! pffiffiffi ðH j0ij0i þ Hj1ij0iÞ
2 2
1 1 1
¼ pffiffiffi pffiffiffi ðj0i þ j1iÞj0i þ pffiffiffi ðj0i j1iÞj0i
2 2 2 ð5:154Þ
1
¼ ðj0ij0i þ j1ij0i þ j0ij0i j1ij0iÞ
2
¼j0ij0i ¼ j00i
1 1
Case #2 pffiffiffi ðj11i þ j01iÞ ! pffiffiffi ðHj1ij1i þ Hj0ij1iÞ
2 2
1 1 1
¼ pffiffiffi H pffiffiffi ðj0i j1iÞj1i þ pffiffiffi ðj0i þ j1iÞj1i
2 2 2 ð5:155Þ
1
¼ ðj0ij1i þ j1ij1i þ j0ij1i j1ij1iÞ
2
¼ j0ij1i ¼ j01i
1 1
Case #3 pffiffiffi ðj00i j10iÞ ! pffiffiffi ðH j0ij0i Hj1ij0iÞ
2 2
1 1 1
¼ pffiffiffi pffiffiffi ðj0i þ j1iÞj0i pffiffiffi ðj0i j1iÞj0i
2 2 2 ð5:156Þ
1
¼ ðj0ij0i þ j1ij0i j0ij0i þ j1ij0iÞ
2
¼j1ij0i ¼ j10i
1 1
Case #4 pffiffiffi ðj01i j11iÞ ! pffiffiffi ðHj0ij1i Hj1ij1iÞ
2 2
1 1 1
¼ pffiffiffi pffiffiffi ðj0i þ j1iÞj1i pffiffiffi ðj0i j1iÞj1i
2 2 2 ð5:157Þ
1
¼ ðj0ij1i þ j1ij1i j0ij1i þ j1ij1iÞ
2
¼ j1ij1i ¼ j11i
By performing a Z measurement on the qubits A and B, Bob can retrieve the encoded information
as “00” or “01” or “10” or “11.”
In 1992, Charles Henry Bennett (IBM Research) and Stephen J. Wiesner (Columbia Univer-
sity) proposed the superdense coding protocol. Four years later, it was verified using entangled photon
pairs.
1
jGHZ i ¼ pffiffiffi ðj000i þ j111iÞ ð5:158Þ
2
The GHZ state is a special case of the cat state p1ffiffi2 j0in þ j1in with n ¼ 3.
Let us assume Alice, Bob, and Charlie each share one of the qubits. If Charlie measures his qubit in
the computational basis, the system collapses to an unentangled pure state of j00i or j11i, depending
upon what Charlie measured—j0i or j1i. Now the correlation between Alice’s qubit and Bob’s qubit
is trivial. If Alice’s qubit is j0i, then Bob’s qubit is also j0i. If Alice’s qubit is j1i, then Bob’s qubit is
also j1i. This is true, if Charlie didn’t measure his qubit, and either Alice or Bob did the measurement.
Therefore, in order to have non-trivial correlations, we need to determine the joint statistics of Alice,
Bob, and Charlie. The entanglement of the GHZ state lies purely with the collective measurement of
the three parties!
There is another state called W-state, which also exhibits multipartite entanglement. The
W-state for a three-party system has the following definition.
1
jW i ¼ pffiffiffi ðj001i þ j010i þ j100iÞ ð5:159Þ
3
The W-state is quite different from the GHZ state. If one of the qubits is measured or lost, the rest
of the system still stays entangled. In the GHZ state, the entanglement is lost, if one of the qubits is
measured. Because of this property, the W-state has applications in implementing quantum memory.
In a W-state, if one of the states is lost, the system can be reconstructed.
Exercise 5.5
Construct a quantum circuit demonstrating W-state.
◄
The Walsh–Hadamard transform is a reversible randomization operation and a tensor power of the
Hadamard transform. Given n qubits, the Walsh–Hadamard transform produces a quantum mechani-
cal system of N ¼ 2n states. This collective state forms the basis of Quantum Parallelism and creates
a single large superposition state of all possible register values. Let us explore this concept in detail
(Fig. 5.39).
5.11 Walsh–Hadamard Transform 225
For the sake of simplicity, consider a two-qubit register (that is, n ¼ 2). The concept can be scaled
to any number of qubits. Let us assume that the qubits are prepared in state j0i. The Walsh–Hadamard
transform on this two-qubit register can be written as follows:
1 X n
2n 1
H n j0in ¼ pffiffiffiffinffi jxi ð5:167Þ
2 x¼0
1 X
2n 1
n
n
H jxi ¼ p ffiffiffiffi
n
ffi ð1Þxy jyin , ð5:168Þ
2 y¼0
In Eq. (5.13), we derived the action of the Hadamard gate on a qubit already put in an equal
superposition state by another Hadamard gate (that is, cascading of two Hadamard gates). We used
the matrix method to prove that this operation reverses the state of the qubit to its initial state. Let us
now derive the same operation using the Dirac’s bra-ket notation. Assume the initial state of the qubit
as follows.
1
jψ i ¼ H j0i ¼ pffiffiffi ðj0i þ j1iÞ ð5:169Þ
2
Applying a Hadamard gate to this initial quantum state, we get the following:
1 1
H jψi ¼ H pffiffiffi ðj0i þ j1iÞ ¼ pffiffiffi ðHj0i þ H j1iÞ
2 2
1
¼ ðj0i þ j1i þ j0i j1iÞ ð5:170Þ
2
1
¼ ðj0i þ j0iÞ ¼ j0i
2
Upon studying Eq. (5.170), we find that the probability amplitudes of j1i had the same magnitude,
but were opposite in sign. Therefore, the probability amplitudes of the state j1i have interfered
destructively, and hence, removed from the system. Therefore, the resultant state Hjψi does not have
a component along the direction j1i anymore. The probability amplitudes of the state j0i have
interfered constructively, and made it to the final state of the system.
We use this property in quantum computing. Using circuit elements, we can create constructive
and destructive Quantum Interference to systematically evolve the most probable system states,
which can be the candidate solutions to a given problem.
We can explain the concept of quantum interference (which is similar to the interference of light,
we saw in Chap. 1) using a lab experiment using the Mach–Zehnder Interferometer. Consider the
setup shown in Fig. 5.40.
5.12 Quantum Interference 227
D0
Mirror D1
Mirror
A
Light Beam
B
D0
Mirror D1
Mirror
A
Light Beam
Fig. 5.41 The Mach–Zehnder Interferometer with the second beam splitter
In this experimental setup, we use laser equipment that emits one photon at a time. Using a set of
attenuators, we can filter out light from the laser and ensure that only one photon emerges from the
apparatus at a time. This light is then passed through a beam splitter SA, which splits this light into two
components j0i and j1i with equal probabilities. Let us assume that P0 be the probability for the
photon to be split along the path j0i, and P1 be the probability for the photon to be split along the path
j1i. The beam with component j0i passes horizontally, gets deflected by a mirror, and reaches the
detector D0. The beam with component j1i passes vertically, get deflected by a mirror, and reaches the
detector D1. In this setup, the detectors D0 and D1 receive an equal number of photons. The beam
splitter, indeed, behaves like a Hadamard gate, creating equal superposition of light.
If we assume that the light emitted by the laser apparatus was prepared in the ground state j0i, we
can write the action of the beam splitter as shown in the following equation:
SA 1
j0i ! pffiffiffi ðj0i þ j1iÞ ð5:171Þ
2
Now, let us modify the setup by adding another beam splitter at the intersecting point before the
detectors (Fig. 5.41).
228 5 Quantum Circuits and DiVincenzo Criteria
In this setup, the second beam splitter splits the incoming beams into two new components. The
photons taking path j0i can directly pass to detector D0, or it can be deflected and sent to detector D1.
Similarly, the photons taking the path j1i can directly pass to detector D1, or it can be deflected and
sent to detector D0. We expect the probability of a photon arriving at the detector D0 or D1 to be still 12.
The reasoning for this assumption is clear from our knowledge of probabilities, and we can calculate
the probability of a photon arriving at the detector D0 as follows:
This is the same result we obtained from Eq. (5.170). This property means the photon was in a
superposition state, and it travelled through both the paths j0i and j1i simultaneously. At the second
beam splitter, both the components interfered, constructively along j0i and destructively along j1i.
The resultant photon is in state j0i.
Recall that, Kickback is a method, where a global phase added to a qubit by a gate operation is
“kicked back” into another qubit using a controlled gate operation. In this section, we shall see how a
cU1 gate can be used to demonstrate this concept.
Recall the matrix form of the U1 gate from Eq. (5.48). Applying this on state j1i, we get,
" #
1 0
π π
U1 ¼ U 3 0, 0, ¼ π
4 4 0 ei 4
" #" # " #
1 0 0 0 ð5:174Þ
π
U1 j1i ¼ π
¼ π
4 0 ei 4 1 ei4
π
¼ ei4 j1i
π
The operation of the U1 gate adds a global phase ei4 to the state j1i. This global phase cannot be
observed. Note that the U1 π4 gate is equivalent to a T gate. Consider the circuit shown in Fig. 5.42, in
π
which a cU 1 4 gate operates on an equal superposition state.
Let us derive the system state. The system starts with the qubits in state j0i. The first step is to
apply an H-gate to qubit q[0] and an X-gate to the qubit q[1]. The resultant state of the system can be
written as:
5.14 DiVincenzo’s criteria for Quantum Computation 229
q[1]
1 1
jψ i ¼ pffiffiffi ðj0i þ j1iÞ j1i ¼ pffiffiffi ðj01i þ j11iÞ ð5:175Þ
2 2
π
The next step is to apply the cU 1 4 gate. The new system state is as follows:
π 1 π
cU 1 jψi ¼ pffiffiffi j01i þ ei4 j11i
4 2
ð5:176Þ
1 π
¼ pffiffiffi j0i þ ei4 j1i j1i
2
Note that this has added a relative phase to the qubit q[0].
We can conclude Chap. 5 with a brief discussion on DiVincenzo’s criteria for quantum computation.
Ever since the early pioneers—the Russian physicist Yuri Manin and the American physicist
Richard Feynman proposed the concept of a quantum computer, several technologies are under
development to create one on a working scale. In Chap. 4, we learned about the leading qubit
modalities. Some of them have the potential to create a scalable system to run sophisticated quantum
algorithms, such as Shor’s algorithm. When we build such a quantum computer, what are its
characteristics? DiVincenzo’s criteria provide answers to this question by setting up the basic
expectations of a quantum computer. In 2000, the American physicist David P. DiVincenzo proposed
the seven criteria any quantum computer should meet. The first five criteria are about the quantum
computation itself. The remaining two criteria describe the needs of quantum communication. Here
are the seven criteria!
In the previous chapter, we learned that a qubit is a two-state system. In a well-characterized qubit,
the two states are distinct, and the measurement systems are well-calibrated. Well-characterized
qubits are somewhat possible with the current qubit modalities. The problem is, however, with
scalability. A multi-qubit system must have phase channels and coupling between arbitrary qubits.
230 5 Quantum Circuits and DiVincenzo Criteria
Quantum tunneling between the qubits and the presence of stray particles should not create a mixed
state. Cooling and electromagnetic isolation systems for such a vast array of qubits are engineering
challenges we need to resolve. Most qubit modalities we are experimenting with today operate under
high power magnetic fields. Targeting the magnetic flux lines for specific qubits is another engineer-
ing challenge. Error correction is another challenge. For community adaption, error-corrected logical
qubits are a must. These are some challenges associated with scalability. The more the number of
qubits embedded in a device, the more these problems are.
The requirement here is that the qubits in large-scale systems are well- characterized and error-
corrected. In such environments, it shall be possible to run real-time mission-critical algorithms.
5.14.2 The Ability to Initialize the State of the Qubits to a Simple Fiducial State
The quantum circuits help the unitary evolution of the system. The unitary evolution starts with an
initial state. Hence, preparing the qubits to the initial state of a well-defined j0i is essential.
Furthermore, it should be possible to initialize the qubits to the state j0i rapidly, before the
decoherence sets in. Fast initialization is essential, especially in large-scale systems, so that all qubits
are relatively in the same T2 state. Parallel initialization of the qubits is essential to minimize the
latency from initializing q[0] to initializing q[n]. Otherwise, the qubits initialized first would have
started to decohere and lose their initialized state. Partial decoherence of the qubits makes the circuit
unusable after a few steps.
For effectively running a quantum algorithm, the qubits must have a longer decoherence time than the
gate time. Longer decoherence time also helps in building error correction schemes. Qubit modalities
that have high response times (T1), and high fidelity may quickly interact with the environment and
start to decohere. We need to make a trade-off between these characteristics in large-scale systems.
To implement most quantum algorithms, we need a minimum set of universal quantum gates. We can,
today, expect that the industry is aware of this requirement, and most experimental systems offer a
universal set of quantum gates.
The ability to measure the qubit’s state is an essential step in any quantum computation. The
measurement scheme is quite complicated, and it is specific to the qubit modality. We learned
about some of that in Chap. 4. A strong measurement is needed to project the qubit’s state faithfully
into classical registers. However, weak measurements and non-destructive measurements are
reported quite often and may help improve circuit reliability, error resilience coding, and may even
help invent new quantum algorithms.
Practice Problems 231
When we create an entanglement of the qubits, the state is within the quantum device. We must
transfer qubit states to other quantum devices to enable quantum communications, but it is not easy. A
quantum communications channel requires us to send the quantum state as a flying qubit (photon),
essentially encoding information by polarizing photons and transmitting them to the receiving device
using fiber optics. The receiving station must decode the information in the photons and transfer the
state to the local quantum device. Some research labs are already working on establishing this
capability.
Even if we can encode information in photons, decoherence is another challenge. The photons start
interacting with the environment and lose their state. Research labs are using optical repeaters to
transfer quantum information over several miles with some success [15, 16].
5.15 Summary
This chapter was another milestone in our learning. We configured our systems with the required
tools for quantum algorithm development, and learned about quantum circuits and quantum gate
operations. We learned about the essential elements of quantum computing—quantum entanglement,
no-cloning theorem, quantum teleportation, superdense coding, quantum interference, and phase
kickback.
We concluded this chapter by reading about DiVincenzo’s criteria for quantum computing.
The next chapter focuses on quantum communications.
Practice Problems
1. Prove that a controlled unitary matrix can be written as j0i h0j I + j1ih1j U.
2. The state of a three-qubit system is described as p1ffiffiffi3ffi ðj0i þ j0i þ j1iÞ. Verify whether this is a
2
valid quantum state. (Hints: The norm of a valid quantum state is 1.)
pffiffiffiffiffi pffiffiffiffiffi
3. The state of a qubit is described by jψi ¼ aj0i + bj1i, where a ¼ 13 þ 3i and b ¼ 33:5 þ i 33:5 .
Check whether the wavefunction is normalized. If it is normalized, evaluate the probability of
measuring the qubit in a state of “0” or “1.”
4. When we discussed global and relative phases, it became clear that j1i and j1i are the same
state, excepting up to a phase, which cannot be measured. Explain why the same argument does
not hold good for the states p1ffiffi2 ðj0i þ j1iÞ and p1ffiffi2 ðj0i j1iÞ.
5. A quantum gate performs the transformation ji!j0i and j+i!j1i. Write the corresponding
unitary matrix.
6. Verify whether the CCNOT gate is universal.
7. If two states jϕi and jψi can be cloned, prove that hϕj ψi ¼ 0.
232 5 Quantum Circuits and DiVincenzo Criteria
(a) (b)
q[2] 0
q[3] 0
15. The square root of the X-gate and its Hermitian conjugate are called the V and V{ gates. The
matrices in Eq. 5.177 define them. Develop quantum circuits to emulate them. Derive the math
and establish that the circuit works.
" #
1 1þi 1i
V¼
2 1i 1þi
" # ð5:177Þ
{ 1 1i 1þi
V ¼
2 1i 1i
References
1. Quantum Computation and Quantum Information, 10th Anniversary Edition, Michael A. Nielsen, Isaac I. Chuang.
2. Overview and Comparison of Gate Level Quantum Software Platforms Ryan LaRose, March 22, 2019, https://arxiv.
org/pdf/1807.02500.pdf
3. Open Quantum Assembly Language, Andrew, Lev, John, Jay, January 10, 2017 https://arxiv.org/pdf/1707.03429.
pdf
4. OpenQASM language reference: https://github.com/Qiskit/openqasm/blob/master/spec-human/qasm2.pdf
5. Github for OpenQASM: https://github.com/Qiskit/openqasm
6. Q# Programming language reference: https://docs.microsoft.com/en-us/quantum/language/
7. Microsoft Quantum Intrinsic reference: https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.
intrinsic
8. https://github.com/microsoft/Quantum
9. Qiskit: An opensource framework for quantum computing, 2019. H’ector Abraham et al, https://github.com/Qiskit/
qiskit-terra
10. Qiskit Textbook: https://qiskit.org/textbook/preface.html
11. Qiskit API Documentation: https://qiskit.org/documentation/
12. Equivalent Quantum Circuits, Juan Carlos and Pedro Chamorro, October 14, 2011, https://arxiv.org/pdf/1110.2998.
pdf
13. A Simple Proof that Toffoli and Hadamard are Quantum Universal, Dorit Aharonov, 2003, https://arxiv.org/pdf/
quant-ph/0301040.pdf
14. Limits on the ability of quantum states to convey classical messages. Ashwin Nayak, Julia Salzman, January 2006,
http://www.math.uwaterloo.ca/~anayak/papers/NayakS06.pdf
15. Quantum Communications and Network Project, NIST: https://www.nist.gov/programs-projects/quantum-
communications-and-networks
16. Argonne National Laboratory reports Quantum Teleportation across 52 miles. http://news.uchicago.edu/story/
argonne-uchicago-scientists-take-important-step-developing-national-quantum-internet
Quantum Communications
6
“Cheshire Puss,” she began, rather timidly, as she did not at all know whether it would like
the name: however, it only grinned a little wider. “Come, it’s pleased so far,” thought
Alice, and she went on. “Would you tell me, please, which way I ought to go from here?”
“That depends a good deal on where you want to get to,” said the Cat.
“I don’t much care where—” said Alice.
“Then it doesn’t matter which way you go,” said the Cat.
“—so long as I get somewhere,” Alice added as an explanation.
“Oh, you’re sure to do that,” said the Cat, “if you only walk long enough.”
― Lewis Carroll, Alice’s Adventures in Wonderland.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 235
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_6
236 6 Quantum Communications
A couple of properties of quantum mechanics are a bit of a deviation from classical theories. The first
property is Heisenberg’s principle of uncertainty (Sect. 1.6.3). The uncertainty principle forbids
certain sets of observables to be measured with accuracy simultaneously. As an example, the position
and momentum of a quantum system cannot be measured accurately at the same time. The second
property is entanglement. Assume that Alice and Bob are far apart, but they have access to a source
that produces entangled photons (Sect. 6.4.2). The source creates a pair of entangled photons and
sends one entangled photon to both Alice and Bob. Since the photons are entangled, they share the
same wavefunction, even after being far apart. If Alice measures her photon and finds it vertically
polarized ↕, Bob will find his photon polarized in the horizontal $ direction and vice versa.
Measuring one of the photons determines the other’s state, despite the distance and
no-communication between the photons. This behavior is called a non-local phenomenon.
Einstein called this “spooky action at a distance,” as it seemed to violate relativity. In 1935,
Einstein, Boris Podolsky, and Nathan Rosen proposed a thought experiment called the “EPR
Paradox.” Einstein proposed that hidden variables and certain unknown properties of quantum
systems are necessary to make quantum mechanics a complete theory so that the spooky action is
not necessary.
In 1964, the Irish physicist John Stewart Bell developed a set of inequalities that represent how
two particles’ measurements would distribute if they weren’t entangled [1]. There is a lot of
experimental evidence that the Bell inequalities are violated, which means that quantum entangle-
ment does indeed occur.
In this section, we examine this subject!
In Chap. 5, we derived the four Bell states given by Eqs. (5.121), (5.122), (5.123), and (5.124). The
general form of the Bell state equations is stated by the following equation.
B xy ¼ p1ffiffiffi ðj0yi ð1Þx j1yiÞ, where y is the complement of y ð6:1Þ
2
Supposing, if we are given a Bell state B xy , we can use the circuit described in Fig. 6.1 to
measure it.
In this quantum circuit, the application of the CNOT gate converts the system into a “separable”
state as follows:
CX q0, q1 1
! pffiffiffi ðj0yi ð1Þx j1yiÞ
2
ð6:2Þ
1
! pffiffiffi ðj0i ð1Þx j1iÞ jyi
2
Upon applying the H gate to the qubit q0, from Eqs. (5.18) and (5.19),
H q01
! pffiffiffi ðj0i ð1Þx j1iÞ jyi ! jxijyi ð6:3Þ
2
Exercise 6.1
If the input to this circuit is not a Bell state, calculate the probability of measuring a certain
x and y.
◄
In classical physics, realism means that the properties of objects have definite values before
measurement, whether we measure them or not, that is, measurement just revealed the already
existing property. Also, the measurement of property A of the system does not interfere with the
measurement of another property B. If we measure B simultaneously, the results do not change, that
is, the measurement of A does not depend on the context of the measurement. Therefore, we can say
that the properties of the object exist independently of the experimental setup, especially the property
we choose to measure.
Furthermore, consider two objects A and B, which are spatially separated. In this setup, if we
! !
measure object A, it does not affect the other object B instantaneously, that is, r A r B > ct, where
c is the speed of light, and t is the time between measuring A and B. The second principle is called
locality. This classical scenario defined by Einstein–Podolsky–Rosen is known as local realism. Let
us now check how this principle relates to quantum mechanics.
Assume we are given a qubit in state jψi ¼ p1ffiffi2ðj0i þ j1iÞ. Measuring this qubit can give a value
0 or 1, each with a 50% probability. We know this property from the Born rule, and from the
histogram shown in Fig. 5.8. With this data, we cannot infer that, before measurement, the qubit was
in state 0 or 1 with a 50% probability.
The reason is quite simple. If we apply an H gate, we get Hjψi ¼ j0i. If the qubit was in state 0 or
1 with a 50% probability, we should have got either p1ffiffi2 ðj0i þ j1iÞ or p1ffiffi2 ðj0i j1iÞ, each with a 50%
probability.
Hence in quantum mechanics, we cannot assume the state of the system before measurement.
In quantum mechanics, simultaneous measurement is possible only if the system is in a simulta-
neous eigenstate of A and B. Therefore, in general, the outcome of measurement in quantum
mechanics depends upon the other commuting measurements.
Let us study these conclusions that led to the EPR Paradox briefly.
238 6 Quantum Communications
Classical
Channel
Quantum
Channel
Maximally
Entangled Photon
Source
|
ALICE BOB
Entangled photons
Fig. 6.2 Alice and Bob communicating on a quantum communication channel. A photon source sends them a series of
entangled photons. Note that Alice and Bob may have a classical communication channel as well
Assume that Alice and Bob have a source that produces singlet (entangled) states
jΨ i ¼ p1ffiffi2 ðj01i j10iÞ . The source sends Alice one of the entangled qubits, and Bob the other
qubit that is entangled with the qubit sent to Alice. Assume that Alice and Bob are far apart in the
opposite ends of the communication, as shown in Fig. 6.2. Let us also assume that both Alice and Bob
measure their qubits in the computational basis {j0i, j1i}.
Based on what Alice measures, we can predict what Bob shall measure. If Alice measures her qubit
in state j0i (with eigenvalue +1), Bob shall measure his qubit to be in state j1i (with eigenvalue 1),
and vice versa. Recall from our discussions in Chap. 3, Eq. (3.34), that this is true for any basis that
Alice and Bob may use. The only condition is that they both must use the same basis to measure their
qubits. Therefore, we can say that there is a strong correlation between the measurements.
Note that both Alice and Bob can perform rotational operations on their qubits, changing the
entangled state. For example, Z gate (Eq. (5.24)) can flip jϕ+i to jϕi, and vice versa. Application of
X gate flips jϕ+i to jψ +i, and vice versa.
Hence, we find that entangled states are inseparable. Even if the constituent states are separated by
a distance, the constituent states are affected by the action on each other. It looks as though they can
communicate instantaneously (but we cannot harness this communication to send information at
speeds higher than the speed of light).
These were the contradictions in the 1935 paper made by Einstein–Podolsky–Rosen, now called
the EPR Paradox. According to the paper, quantum mechanics is incomplete, and there must be some
hidden variables. The hidden variables should reveal the state of the system before measurement.
If Bob decides to measure his qubit in the polar basis {j+i, ji}, his measurement outcome shall
be one of the states in the polar basis with a 50% probability in his reality.
There are a couple of assumptions here—realism and locality. The first assumption is that, at the
time when Alice measures her qubit, Bob’s system is in a reality that is independent of Alice. The
second assumption is that nothing changes Bob’s system when Alice measures her qubit.
Let us assume that the two qubits have some hidden variables associated with them. Since the
qubits are entangled and show a strong correlation, we should assume that these hidden variables are
related to each other. We shall use this to create a bound in the next section.
To continue with our experiment, the source keeps sending the entangled qubits to Alice and Bob.
Both Alice and Bob measure each of the qubits they receive on some basis and record the time, the
measurement basis used, and the outcome of the measurements. Later, when they both meet, they can
exchange notes and discover the correlation between their measurements.
6.1 EPR Paradox 239
Bell found that the EPR Paradox can be expressed in terms of assumptions that lead to falsifiable
predictions known as Bell’s inequalities. Bell’s inequalities enable the EPR Paradox to be experi-
mentally verified. With technological advancements, several experiments have been conducted on
these inequalities. Today we readily accept quantum entanglement and the non-locality of the
quantum phenomenon. In this section, we examine one of the inequalities.
Let us assume that Alice measures her qubits a and b using measurement operators Z ¼ σ z and
X ¼ σ x. She measures her observables on the σ z basis if she applied a Z gate and on the σ x basis if
she applied an X gate. Similarly, Bob measures his qubits c and d using measurement operators
C ¼ p1ffiffi2 ðσ z σ x Þ and D ¼ p1ffiffi2 ðσ z σ x Þ: There can be four possible combinations of experiments
we can perform with the qubits a, b, c, d. The respective expectation values of the outcomes of these
experiments are given in the following equations.
1
hΨ jZCjΨ i ¼ haci ¼ pffiffiffi ð6:4Þ
2
1
hΨ jZDjΨ i ¼ hadi ¼ pffiffiffi ð6:5Þ
2
1
hΨ jXCjΨ i ¼ hbci ¼ pffiffiffi ð6:6Þ
2
1
hΨ jXDjΨ i ¼ hbdi ¼ pffiffiffi ð6:7Þ
2
These expectation values can be derived as follows. We can easily show that:
1 1 1 1
ðσ z σ x Þ ¼ and ðσ z σ x Þ ¼ : By applying this,
1 1 1 1
" # " #
1 1 1 0 1 1
ZC ¼ σ z pffiffiffi ðσ z σ x Þ ¼ pffiffiffi
2 2 0 1 1 1
2 3
1 1 0 0
6 7 ð6:8Þ
6 7
1 6 1 1 0 0 7
¼ pffiffiffi 6 7
26 4 0 0 1 1 7 5
0 0 1 1
By referring to Eq. (2.133), we can derive the expectation value haci ¼ hΨ j ZCj Ψ i. For the
sake of simplicity, we can derive this in two steps using matrix methods.
240 6 Quantum Communications
2 3
1 1 0 0
6 7
6 0 7
1 6 1 1 0 7 1
ZCjΨ i ¼ pffiffiffi 6 7 pffiffiffi ðj01ij10iÞ
26 4 0 0 1 1 7
5 2
0 0 1 1
2 3 2 3 2 3 ð6:9Þ
1 1 0 0 0 1
6 7 6 7 6 7
6 0 7 6 1 7 6 1 7
1 6 1 1 0 7 1 6 7 1 6 7
¼ pffiffiffi 6 7 pffiffiffi 6 7¼ 6 7
26 4 0 0 1 1 75 2 6 1 7 2
4 5
6 1 7
4 5
0 0 1 1 0 1
2 3
1
6 7
1 1 6 1 7 1
hΨ jZCjΨ i ¼ pffiffiffi ½0 1 1 0 6 7 ¼ pffiffiffi ð6:10Þ
2 2 4 1 5 2
1
Similarly, we can derive the other expectation values and arrive at Eqs. (6.5), (6.6), and (6.7). The
sum of the expectation values is:
1 1 1 1
haci þ hbci þ hbdi hadi ¼ pffiffiffi þ pffiffiffi þ pffiffiffi þ pffiffiffi
2
pffiffiffi
2 2 2 ð6:11Þ
¼2 2
Since the measurement outcomes can take only values 1, the terms in the sum can only take
values +1 and 1 for the hidden variable λ. Therefore, we see that C(λ) + D(λ) ¼ 0 shows zero
correlation and C(λ) D(λ) ¼ 2 shows a strong correlation. With this assumption, we can bind this
integral:
6.2 Density Matrix Formalism 241
ð
pðλÞ½ XðλÞ ðCðλÞ þ DðλÞ Þ þ Z ðλÞðCðλÞ DðλÞÞ dλ 2 ð6:15Þ
This inequality is known as CHSH inequality, named after Clauser, Horne, Shimony, and Holt.
CHSH inequality is one of the Bells Inequalities.
By comparing Eqs. (6.15) and (6.11), we find that quantum mechanics violates the bound we
derived for the local hidden variable. Therefore, it is clear that local hidden variable theories cannot
explain the statistics of certain quantum mechanical experiments.
The CHSH inequalities are the simplest and widely studied. There could be many other Bell’s
inequalities. The inequalities assume a local hidden value model to describe the correlation between
the measurement outcomes at different locations. In multi-partite systems, the inequalities are bound
in the region of experimentally observable probabilities accessible by the local variable models. We
can characterize this space if we find a minimal set of Bell’s inequalities that are complete. The
completeness here means iff the correlations permit a local hidden variable model. This is a problem
we can readily solve in lower dimensions. However, it is generally a problem that is
computationally hard.
Let us assume that we set up thousands of computers isolated from each other to emulate the Bell
experiments classically. We then setup the different experiments the computers should emulate.
Collectively the classical computers cannot simulate the quantum experiment! This inability is one
proof that quantum computers can do certain things that classical computers cannot do.
Note that the correlations produced by quantum entanglement are not correlations that can be used
to signal parties like that in a classical communication channel. If we must explain the correlations
classically, we need to have communication to establish the correlations. We shall explore this topic
shortly.
So far, we have been assuming pure states, which are isolated quantum systems. The quantum
systems are usually interacting with other systems, which could be larger, with many degrees of
freedom. It shall be advantageous if we could describe a quantum system without going into many
details of the larger system. Such systems are in mixed states. The density matrix representation is
something we could use here. The density matrix representation also helps us understand why Bob
cannot learn anything about the basis Alice used to measure her qubits. This formalism can also
explain why Alice cannot use entanglement to transmit information to Bob at speeds greater than the
speed of light c.
Consider a system of photons emanating from a table lamp. These photons are polarized in random
directions. This is because of the random orientation of atoms in the lamp’s filament. For example, if
25% of the photons are polarized vertically, 25% of the photons are polarized diagonally to the left,
25% polarized diagonally to the right, and 25% of the photons are polarized horizontally, we cannot
describe them as 0.25j↕i + 0.25j$i + 0.25j⤡i + 0.25j⤢i. The reason is the equal distribution of 25%
represents the probabilities and not the probability amplitudes. Here, the probability pi represents the
occurrence of the state jψ ii in the ensemble.
This ensemble of photons is an excellent example of a mixed state which can be described as an
P
ordered pair {(jψ 1i, p1), (jψ 2i, p2), . . .}, where the probabilities pi ¼ 1: We can think of the pure
i
state as a degenerate case of a mixed state with probability 0 or 1. Note that the different probability
distribution of the pure states gives rise to the same mixed state.
242 6 Quantum Communications
Recall that every vector jψi 2 Hn can be represented as a matrix A 2 ℂn n, which is an inner
product space. We can describe this mapping as a density matrix defined by the following equation
for mixed states.
X
n
ρ¼ pi j ψ i i h ψ i j ð6:16Þ
i¼1
The density matrix is the sum of the projections on to the vector space spawned by jψ ii weighted
by the corresponding probabilities pi. The density matrix of a mixed state is a Hermitian operator, and
its trace is 1. Note that, if the vectors jψ ii do not form an orthonormal basis, then we must find the
orthonormal basis vectors before calculating the trace.
P
The density matrix for a pure state jψ i ¼ ai jvi i is given by:
i
2 3
a1 a 1 a1 a 2 ⋯ a1 a n
Xn 6 a a a2 a 2 ⋯ a2 a n 7
6 2 1 7
ρ¼ pi jψihψj ¼ 6 7 ð6:17Þ
i¼1
4 ⋯ ⋮ ⋮ ⋮ 5
an a 1 a2 a 2 ⋯ an a n
This is a Hermitian matrix with a trace of 1. The density matrix for a pure state is simply a
projection operator ρ ¼ jψihψj.
Now, let us look at some example states. The density matrices of basis states are:
1 0 0 0
j0ih0j ¼ and j1ih1j ¼ ð6:18Þ
0 0 0 1
If we have an equal mixture (that is, p ¼ 12) of them, then the density matrix is:
2 3
1
j0ih0j þ j1ih1j 0
6 7 1
¼ 42 5¼ I ð6:19Þ
2 1 2
0
2
Similarly, the density matrices of the pure states are:
2 3 2 3
1 1 1 1
62 27 6 2 2 7
jþihþj ¼ 4 5 and jihj ¼ 4 5 ð6:20Þ
1 1 1 1
2 2 2 2
6.2 Density Matrix Formalism 243
If we have an equal mixture of the pure states, then the density matrix of that state is:
2 3
1
jþihþj þ jihj 0
6 7 1
¼ 42 5¼ I ð6:21Þ
2 1 2
0
2
Note that the density matrix is the same for the equal mixture of states (j0i, j1i) and (j+i, ji). The
density matrix should be the same for any orthogonal basis Alice chooses, which is an important
observation. It follows that, if Alice is changing the measurement basis, it does not affect Bob’s
density matrix!
States with the density matrix 12 I are also known as a maximally mixed state.
Note that measuring ρ on a given basis, gives an outcome jii on that basis with a probability given
by the following equation.
This equation means the diagonal elements of the density matrices represent probabilities.
The following equation defines the action of a unitary U on the density matrix ρ.
X X
Uρ¼U pi jψ i i hψ i j ¼ pi ðUjψ i iÞðUjψ i iÞ{
i i
X
¼ pi ðUjψ i iÞ hψ i j U{ ð6:23Þ
i
¼ UρU {
Recall from Eq. (2.146) that the density matrix ρ can be written as:
ρjψi ¼ λjψi, where jψi are eigenvectors and λ is some eigenvalue: ð6:24Þ
Therefore,
hψ i jρjψ i i ¼λi ð6:26Þ
Here the λi sum up to the trace of the density matrix, which is 1. This way, we can derive the
eigenvalues and eigenvectors.
244 6 Quantum Communications
We can use density matrices to verify whether a state is entangled or whether it is a product state. Let
us start with a simple product state of two qubits A and B denoted by the following equation, which is
familiar to us now.
j ψ i ¼ j ψ A ij ψ B i ð6:27Þ
For the qubit A, one of the eigenvalues of the density matrix is 1, and the rest are all 0. If more than
one of the eigenvalues are positive, then this represents a mixed state. The other way to check this is to
take the density matrix square and check its trace.
2 X 2
Tr ρA ¼ λ ,
i i
ð6:28Þ
where ρA is the mathematical notation that denotes the density matrix of A, 0 λi and ∑iλi ¼ 1.
P
Hence i λ2i 1: Now we have two cases. The first case is when one of the λi is equal to 1, and the
rest is equal to 0. The second case is not restricted, and the λi must be positive and in the range.
(
A 2 ¼ 1 for product states
Tr ρ ! ð6:29Þ
< 1 for entangled states
Let A and B be two qubits in the Hilbert spaces H A and H B : The composite state of these two quantum
systems is described by the state jψi ¼ HA HB. The density matrix of the composite system is
ρAB ¼ jψihψj. From this, there is no direct way of deriving the pure state for subsystem A, but we can
define a reduced density matrix ρA as a partial trace over B. This is done as follows.
X
ρA ¼ hiB jðjψihψjÞjiB i ¼ Tr B ρAB ð6:30Þ
i
Let us apply this logic to a Bell state. The density matrix for the Bell state jϕ+i described in
Eq. (5.121) is as follows.
Similarly,
1 1
ρB ¼ ðj0ih0j þ j1ih1jÞ ¼ I ð6:35Þ
2 2
The reduced density matrices again prove that, say if we measure qubit A, we shall measure
j0i with a probability of 12 and j1i with a probability of 12, irrespective of the basis in which the qubit is
measured. Due to this randomness, by simply measuring the qubits A or B locally, we gain no
information about the state they were prepared.
According to the no-communication theorem [3, 4], if Alice and Bob share an entangled state, any
operation performed by Alice does not change the density matrix of Bob. Therefore, it is not possible
to send classical information using the entangled state instantaneously.
Assume that Alice and Bob share an entangled state jϕ+i. The probability of Alice measuring a
1 0 0 0
j0i is Pðj0iÞ ¼ j0ih0j ¼ and Pðj1iÞ ¼ j1ih1j ¼ .
0 0 0 1
In this experimental setup, the density matrix of the qubit shared with Bob is given by the
Eq. (6.35).
Alice now measures her qubit. This act collapses the system. The density matrix of Bob’s qubit in
the post-measurement scenario can be calculated as follows.
X
ρ0B ¼ i
PðjiiÞ ρB PðjiiÞ ð6:36Þ
1 1 0 1 0 1 0 1 0 0 1 0 0 0
¼ þ ð6:37Þ
2 0 0 0 1 0 0 2 0 1 0 1 0 1
We find that the density matrix of Bob’s qubit is not altered by the measurement of Alice’s qubit.
Hence, the information one of them changes is something the other person cannot read.
Exercise 6.2
Prove that the density matrix of Bob does not change if Alice performs a unitary on her qubit.
◄
The term entropy was coined by the German physicist Rudolf Clausius, from the Greek words “en,”
and “tropē” meaning change within. Entropy is the measure of the energy contained in a physical
system that could not be used to do work. It is also interpreted as the measure of disorder or randomness
in the system. Clausius postulated that the entropy of a closed system cannot decrease, which is the
second law of thermodynamics. However, Clausius did not provide an explaination. Ludwig
Boltzmann provided an interpretation of this postulate using statistical mechanics in later years.
Consider a large isolated system of N identical particles. Each of these particles occupies one of
the energy levels E1 < E2 < . . . < Em. The particles exchange energy among themselves. Hence the
system achieves a thermal equilibrium over time. If there are N1 particles with energy E1, N2 particles
with energy E2, and so on, the total number of particles is N ¼ ∑iNi, and the total energy of the system
is E ¼ ∑iNiEi. The Ni are also referred as the occupancy numbers in literature.
Supposing that if we partition the system and put the N1, N2, . . ., Nm particles into m microstates
corresponding to the energy levels. The number of ways the N particles can be arranged is
N!
number of microstates ¼ ð6:39Þ
N 1 !N 2 ! . . . N m !
This is the number of ways in which the microstates can be put together to realize the large system.
It is also the probability of the microstates being equal. The most probable microscopic state can be
obtained by maximizing Eq. (6.39) for E.
The probability of the microstate to be in state i can be defined as: pi ¼ NNi : Using Stirling’s
approximation1 of the factorials,
1 N!
log ¼ H ðpi Þ þ O N 1 log N , ð6:40Þ
N N 1 !N 2 ! . . . N i !
According to Shannon, Eq. (6.41) is the measure of ignorance before the experiment. It is also the
information gathered by experimenting. The outcome of the experiment is maximum if pi are equal.
In quantum mechanics, we associate statistical operators with system states. Von Neumann
introduced the density matrix or the density operator formalism to represent the statistical state of
quantum systems. The statistical description of quantum systems is useful in describing system
evolution and entanglement. In these problems, each subsystem can be represented as density
matrices, even though the entire system can be in a pure state.
Based on the principles of thermodynamics, von Neumann associated entropy with a statistical
operator D. Von Neumann assumed a system of gas with N molecules. If the system can be compared
1
In the limit N ! 1, Stirling’s asymptotic expansion is: ln N!
N ln N N + O(N ).
6.3 Von Neumann Entropy 247
to a quantum system, it can be described by a statistical operator D. Assume that the gas is a statistical
mixture λjφ1ihφ1j + (1 λ)jφ2ihφ2j), where λN molecules are in pure state φ1 and (1 λ)N molecules
are in pure state φ2. Assuming φ1 and φ2 are orthogonal, von Neumann described a thought
experiment in which the molecules φ1 and φ2 can be separated adiabatically without any work
being done. The entropy of the original gas described by D must be equal to the sum of the entropies
of φ1 and φ2. If the gases φ1 and φ2 are compressed to volumes λV and (1 λ)V, keeping the
temperature of the system T constant, the change in the entropy is kλN log λ and k(1 λ)N log λ,
respectively, where k is Boltzmann’s constant2. The following relation must hold good:
S0 ðφ1 , λN Þ þ S0 ðφ2 , ð1 λÞN Þ ¼ S0 ðD, N Þ þ kλN log λ þ kð1 λÞN log λ, ð6:42Þ
where S0 is the entropy function of a given gas. If S0 is proportional to N, then dividing the equation
by N, we get:
where S is a thermodynamic entropy. Instead of a mixture of two components φ1 and φ2, if we assume
an infinite mixture, von Neumann concluded that:
X X X
S λ jφ
i i i
i h φ i j ¼ λ Sðjφi ihφi jÞ k i λi log λi
i i
ð6:44Þ
Recall that the density matrix of a quantum system in a pure state has only one element in its
diagonal. The value of this element is 1, and the values of the rest of the diagonal elements are 0. The
square of the trace of the density matrix is 1. The eigenvalues of the density matrix are the
probabilities. A quantum state ρ can be written as a spectral decomposition. From Eq. (6.25),
X
ρ¼ λi jψ i ihψ i j, ð6:45Þ
i
where λi is an eigenvalue of ρ and jψ iihψ ij is the projection of λi. If λi is degenerate, the spectral
decomposition can be decomposed into one-dimensional projections called Schatten Decomposition,
X
ρ¼ λi jφi ihφi j, ð6:46Þ
i
where jφiihφij is the one-dimensional projections of λi. The degeneracy of λi equals the dimension of
jφiihφij. The Schatten decomposition is not unique if λi is degenerate. If λi is degenerate, then the
corresponding eigenvectors can be chosen in several ways. If the entropy S(D) is to be independent of
the Schatten Decomposition, then S(jφiihφij) must be independent of the state vector jφii. With this
assumption, the von Neumann entropy for a pure state can be written as a function of the density
matrix as follows:
!
X X
S λi jφi ihφi j ¼ Tr ð ρ log ρÞ ¼ λi log λi , ð6:47Þ
i i
where λi are the eigenvalues of the density matrix ρ. The logarithm is taken to base n, the dimension of
the Hilbert space.
The eigenvalues (or the probabilities) do not change if we change the basis. Hence, the entropy
itself is invariant. From Eq. (6.16),
2
Boltzmann Constant 1.380649 1023 J/K is a physical constant that relates the kinetic energy of a gas with
respect to its thermodynamic temperature.
248 6 Quantum Communications
q = QuantumRegister(2, 'q')
qc = QuantumCircuit(q)
#
# Setup some initial states,
# but ideally we start with |0>
backend = Aer.get_backend('statevector_simulator')
job = execute(qc, backend).result()
qc_state = job.get_statevector(qc)
dm_start = DensityMatrix(qc_state)
q = QuantumRegister(2, 'q')
qc = QuantumCircuit(q)
qc.initialize(qc_state, q)
qc.x(q[1])
qc.h(q[0])
qc.h(q[1])
qc.cx(q[0], q[1])
qc.h(q[0])
qc.h(q[1])
plt.xlabel('Time')
plt.ylabel('Entropy')
plt.title('von Neumann Entropy')
plt.plot(time_range, entropy_list, color='black')
plt.show()
X
n
ρ¼ pi j ψ i i h ψ i j ð6:48Þ
i¼1
Note that von Neumann’s entropy equals Shannon entropy. Consider the following definition of a
density matrix for a Bernoulli distribution with probabilities {p, 1 p} of a quantum system being
in state j0i or j1i.
The von Neumann entropy describes the randomness of a quantum state. Von Neumann entropy
quantifies the amount of information present in a system. It also signifies the amount of correlations
between quantum systems.
Von Neumann entropy is used in the concept of quantum compression. According to Schumacher’s
compression theorem, if ρ is the density operator of the quantum information source, then the von
Neumann entropy S(ρ) is the smallest achievable rate R for quantum data compression: inf3 {R: R is
achievable} ¼ S(ρ)
Assume that Alice sends Bob a message of n letters. She chooses a random set of pure states, which
are not necessarily orthogonal. The density matrix of the n letters is given by:
ρ ¼ ρ1 ρ 2 . . . ρ n ð6:52Þ
The best possible compression we can achieve using Schumacher’s compression theorem, assum-
ing n ! 1, is compression to Hilbert’s state H :
log ðdimðH ÞÞ ¼ nSðρÞ ð6:53Þ
If we use n photons to send the message, we can compress the message to m ¼ nS(ρ).
In this subsection, we shall return to the Bloch sphere briefly. Recall from Eq. (2.83), that any matrix
can be written as a linear combination of the identity matrix and the Pauli matrices. We can apply that
logic to density matrices as well:
1
ρ¼ I þ xσ x þ yσ y þ zσ x ð6:54Þ
2
1 !!
ρ¼ Iþ r σ , ð6:55Þ
2
!
where r is the Bloch vector. The radial distance of the Bloch vector from the origin is given by
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
r ¼ jxj2 þ jzj2 þ jzj2 : The Bloch vector is the expectation value of the Pauli matrices.
!
! !
r ¼ σ ¼ Tr ρσ ð6:56Þ
Also, the determinant of the density matrix has a relation to the radius of the Bloch vector,
1
detðρÞ ¼ 1 r2 ð6:57Þ
4
!
The density matrices of qubits lie within or on the Bloch sphere, whose radius is r ¼ 1: The length
of the Bloch vector is 1 for pure states, and it is <1 for mixed states.
3
Inf – the infimum is the greatest lower bound of a set. In a set A ¼ {1, 5, 3, 7}, the infimum is 1.
6.3 Von Neumann Entropy 251
We shall now derive an alternate interpretation of the von Neumann entropy in terms of the Bloch
vector for single qubits. Let λ1, λ2 be the eigenvalues for the density matrix ρ. Since the trace of the
density matrix is 1, we can say that λ2 ¼ 1 λ1. Also, det(ρ) ¼ λ1λ2. Connecting these values with the
above equation, we can derive that:
1þr 1r
λ1 ¼ and λ2 ¼ ð6:58Þ
2 2
With this information, we can define the von Neumann entropy as a function of r:
h i
1þr 1þr 1r 1r
Sð ρÞ ¼ log þ log ð6:59Þ
2 2 2 2
A pure quantum system state jψi can be written as a separable tensor product decomposition
jψi ¼ jψ 1i jψ 2i . . . jψ ni. If this is not possible, then the state jψi is entangled. For example,
the state jψ i ¼ p1ffiffi2 ðj00i þ j11iÞ is maximally entangled. From Eqs. (6.34) and (6.35), we know that
the trace over the density matrix of each qubit is a mixed state 12 I: Notably, this state has the highest
von Neumann entropy between two qubits. There is no correlation between the qubits in an
unentangled state, and the von Neumann entropy is zero. The trace over gives a pure state. Thus,
we can use von Neumann entropy as a measure of entanglement between two qubits.
Schmidt’s theorem decomposes a vector as a tensor product of two inner produce spaces. Hence,
Schmidt decomposition is a good tool in analyzing bipartite pure states. It can be used to decompose
bipartite pure states into the superposition of constituent states.
X
d1
jψ iAB λi jiiA jiiB , ð6:60Þ
i¼0
where the Schmidt coefficients λi are strictly positive valued real numbers and normalized (that is,
P
λi ¼ 1Þ constants. The states jiiA and jiiB form the orthonormal basis for the states A and B. d, the
i
Schmidt rank or the Schmidt number, is the number of Schmidt coefficients counted with
multiplicity. d min ðdimðH A Þ, dimðH A ÞÞ:
Proof
In an orthonormal basis jjiA and jkiB, we can write jψiAB as:
dX X
A 1 d B 1
where αj, k are some amplitudes corresponding to the orthonormal basis. dA and dB are the dimensions
of the respective Hilbert spaces. The matrix formed by the coefficients αj, k can be written as follows.
252 6 Quantum Communications
The matrix A can be decomposed in terms of unitary matrices U, Σ, V, whose dimensions are
mentioned as subscripts in the following equation.
A ¼ U dA dA Σ dA dB V dB dB ð6:63Þ
Assuming Σ is a diagonal matrix of dimension d d, with λi as its diagonal elements, we can write
αj, k as follows:
X
d1
α j,k ¼ u j,i λi vi,k ð6:64Þ
i¼0
! d 1
dP
A 1 P
B
If u j,i j jiA and vk,i jkiB form an orthonormal basis, we can rewrite the equation as
j¼0 k¼0
follows, proving the theorem.
dX X
A 1 d B 1
Returning to the bipartite pure systems, let us assume that jψiAB is a bipartite system A B. The
density matrix for jψiAB can be written in terms of the Schmidt decomposition as follows.
d1 X
X d1
ρ ¼ jψ iAB hψjAB λi λ j jiiA h jjA jiiB h jjB ð6:68Þ
i¼0 j¼0
Tracing over the terms for the qubits B and A, we can write the density matrices for the individual
qubits as:
X
d1
ρA ¼ λi 2 jiiA hijA
i¼0
ð6:69Þ
X
d 1
ρ ¼
B
λi jiiB hijB
2
i¼0
6.3 Von Neumann Entropy 253
The von Neumann entropy can be derived from Eq. (6.47) as follows.
X
d1
S ρA ¼ λi 2 log λi 2
i¼0
ð6:70Þ
X
d1
S ρB ¼ λi 2 log λi 2
i¼0
We find that S(ρA) ¼ S(ρB), which also gives the degree of entanglement between the bipartite pure
states.
6.3.4 Purification
Consider the system state given in Eq. (6.67). Assume that the two qubits A and B are shared by Alice
and Bob, respectively. If Alice measures her qubit, the outcome of the measurement j with probability
α jk i
P( j) ¼ jαj,kj2. The state for Bob is pj,kffiffiffiffiffiffiffi. Bob’s density matrix is:
PðkÞ
dP
B 1 dP
B 1
α j,k jki α j,k0 hk0 j
dP
A 1
k¼0 k0 ¼0
ρ ¼
B
PðkÞ pffiffiffiffiffiffiffiffiffi pffiffiffiffiffiffiffiffiffi
j¼0 PðkÞ PðkÞ ð6:71Þ
dP
B 1 dPB 1 dP
A 1
α j,k α j,k0 jkihk0 j ¼ ðα{ αÞ
T
¼
k¼0 k0 ¼0 j¼0
It is easy to prove that, if Bob measures first, the density matrix of Alice will be (αα{). So we can
P
say TrðρA Þ ¼ Trðαα{ Þ ¼ jα j,k j2 ¼ 1. Such states jψiAB are called the purification of the density
j, k
matrix.
Example 6.1
A system of two qubits is described by jψi ¼ 10
3
j00i þ 10
1
j11i. Calculate the density matrices of the
qubits. What are the coordinates of the qubits on the Bloch sphere? Also, calculate the von Neumann
entropy of the system.
Solution:
The density matrix is given by:
pffiffiffiffiffi
pffiffiffiffiffi
6 28 6 28
ρ¼ j00i þ j11i h00j þ h11j
8 8 8 8
pffiffiffiffiffi pffiffiffiffiffi
36 6 28 6 28 28
¼ j00ih00j þ j00ih11j þ j11ih00j þ j11ih11j
64 64 64 64
pffiffiffiffiffi pffiffiffiffiffi
36 6 28 6 28 28
¼ ðj0ih0j j0ih0j Þ þ ðj0ih1j j0ih1jÞ þ ðj1ih0j j1ih0jÞ þ ðj1ih1j j1ih1j Þ
64 64 64 64
Tracing over B for A,
254 6 Quantum Communications
2 3
36
0
36 28 6 7
ρA ¼ j0ih0j þ j1ih1j ¼ 4 64 5
64 64 28
0
64
Using Eq. (2.63),
1 1
ρA ¼ Iþ Z
2 8
Hence, the coordinates of the qubit A are 0, 0, 18 . We can similarly derive for the qubit B.
Von Neumann entropy is:
SðρA Þ ¼ 36
64 log 64 þ 64 log 64
36 28 28
6.4 Photons
Photons are the means of quantum communication. In this section, we examine how polarized light
can encode quantum information. We also learn about the process of creating entangled photons
using nonlinear optics.
6.4.1 Polarization
Bell’s inequality experiments are usually done with photons. Photons are spin-1 particles. Hence, we
use polarization to measure their states. The spin angular momentum of circularly polarized photons
is ħ. It is positive for left polarized photons and negative for right polarized photons by convention.
The spin of the photons is measured along the direction of propagation z called helicity.
Photons have some other interesting properties. They have zero mass, and stable mean lifetime.
Photon–photon interaction can happen only with large energies. Hence, they can be safely transferred
over vast distances using fiber optics. The fiber-optic cables use a glass fiber core and cladding with
different refractive indices. These two materials are chosen in such a way that the light gets bent at a
certain angle due to total internal reflection. The photons reflect off the core and cladding in a series of
zig-zag bounces and zip along the fiber’s length. Today, telecommunication and internet backbone
are on fiber optics. Fiber optics is a proven technology we can use in quantum communications.
6.4 Photons 255
The light emanating from lamps vibrates in random directions. This light is unpolarized. Using
polaroid filters, we can filter out vibrations in directions that are not needed. The polaroid filters use
long-chain molecules that absorb components of light vibrating in the direction they are stretched. We
can also change the direction of polarization by passing light through half-wave and quarter-wave
plates. To measure the polarization of light, we pass the light through a polaroid filter and then use a
photodetector to measure the intensity of light coming out of the filter.
Vertically polarized photons j↕i correspond to the state j0i in the computational basis. Likewise,
the horizontally polarized photons j$i correspond to the state j1i in the computational basis. Photons
can also be polarized diagonally. The following equation describes the representation of diagonally
polarized photons.
1 1
j⤢i ¼ pffiffiffi ðj↕i þ j$iÞ, and j⤡i ¼ pffiffiffi ðj↕i j$iÞ ð6:72Þ
2 2
A right-hand circular (RHC) polarized light has equal amplitudes polarized in vertical or horizon-
tal directions, which are 90 apart, which also applies for the left-hand circular (LHC) polarized light.
In the polar basis, the state of the photons in RHC or LHC polarization can be written in equal
superposition states as:
1 1
pffiffiffi ðj↕i þ ij$iÞ ¼ jþi, and pffiffiffi ðj↕i ij$iÞ ¼ ji ð6:73Þ
2 2
This method is one way of producing entangled photons and widely used in EPR experiments. The
other method we shall brief in this book uses nonlinear optics.
to conserve energy and momentum, we must “phase match,” and only certain triplet frequencies
work. Phase matching is typically done in nonlinear crystals. There are three types of Spontaneous
Parametric Down Conversion (SPDC).
• If the pump, signal, and idler photons have the same polarization, it is type-0.
• If the signal and idler photons have the same polarization and orthogonal to the pump photon’s
polarization, it is type-I.
• If the signal and idler photons are polarized in orthogonal directions, it is type-II.
Beta-barium borate (BBO) crystals exhibit type-II behavior. When we direct a laser beam (pump)
on a BBO crystal, most photons pass through. However, some photons undergo spontaneous
parametric down conversion. Their trajectories are constrained along the edges of the signal and
idler cones. The crystal is cut in such a way that the cones are symmetrical to the incident beam. Since
momentum and energy are to be conserved, the correlated photons always move along the lines where
the two cones intersect. Figure 6.5 illustrates the type-II SPDC.
6.6 The Quantum Channel 257
Quantum communication is perhaps the first quantum computing technology to be adopted by the
industry. The necessary pieces of technology required for quantum communication exist today. It is
just a matter of time before commercial-grade systems are built. A reasonable understanding of
quantum communications can be useful. The quantum communication system has three parts. There
must be a source (usually Alice) preparing the qubits (usually photons) and encoding information on
them. This is the first part. The second part is the transmission medium, such as the fiber optics. The
third part is the recipient (Bob), who receives the photons and decodes them to retrieve the
information.
Photons are prepared using one of the methods described in the previous section, and information
is encoded on them by rotating the direction of polarization. At the receiving end, Bob uses polaroid
filters and photodetectors to identify the direction of polarization of the photons.
Superdense coding, quantum entanglement, and quantum teleportation are some methods used in
quantum communications. There are some error correction schemes available to detect and correct
channel errors.
There could be some eavesdroppers (Eve) in the system who want to tap into the quantum channel
and steal information. Eavesdropping on the quantum system requires measurement of the qubits, and
it is an irreversible transformation. Hence, we can detect this with a high probability due to the way
the quantum systems work.
Quantum communication offers additional security. Say, for example, Alice sends her qubit A to
Bob. The transmitted qubit has the density matrix ρA ¼ 12 I: It carries no other information. The
information is encoded in the correlation between the qubits A and B. Hence, unless Eve gains control
over both the qubits, she cannot gather knowledge of the transmission. Hence, if Alice encodes a
secret key on a series of entangled photons and sends them over to Bob in a quantum communication
channel, Eve cannot learn anything about the secret key.
Quantum Channels transmit classical or quantum information from point A to B. The input to the
quantum channel is the system state before transmission, and the output to the quantum channel is
the system state after transmission. The quantum channel under discussion in this text is discrete and
memoryless. It is discrete in the sense that it transforms a quantum system whose state vector is in a
finite-dimensional Hilbert space. The memoryless property means that the output of the quantum
channel is determined by the current input. We measure the quality of a noisy quantum channel by
two parameters: channel capacity and channel fidelity.
Figure 6.6 illustrates communication through a quantum channel. The input to the communication
block is an ensemble of n qubits in the pure state jφi with the density matrix ρ ¼ jφihφj . The encoder
maps the qubits into m > n intermediate states, which may or may not be qubits. This forms the input
to the m quantum channels characterized by the superoperator ε , a trace-preserving completely
positive linear map. The superoperator maps the input states with the density matrix ρ into the output
states with the density matrix ρ0 ¼ εðρÞ: At the receiving end, the decoder transforms the mixed states
into n qubits defined by the density matrix ρ00. The fidelity of the quantum communication is
F ¼ hφj ρ00j φi.
The quantum channel capacity Q is the highest rate at which quantum information can be
transmitted from Alice to Bob over a noisy quantum channel. It can be defined as the largest number
258 6 Quantum Communications
Fig. 6.6 Diagram illustrating communication through a quantum channel, from Dan C. Marinescu and Gabriela
M. Marinescu
Q such that: the transmission rate R < Q, the error term E > 0, and the fidelity F > (1 E). The quantum
channel can transmit both classical and quantum information. Depending upon the nature of the
information, the channel capacity is defined as follows:
Channel fidelity is defined as the probability that the output of the quantum channel is the same as
the input. If ρA and ρB be the density matrices of the input and output states of a quantum communi-
cation channel, then the channel fidelity F(ρA, ρB) is defined as follows:
For pure states jφAi and jφBi:
F ρA , ρB ¼ jhφA jφB ij2 ð6:75Þ
F ρA , ρB ¼ Tr ðρA Þ1=2 ρB ðρA Þ1=2 ð6:76Þ
Quantum Key Distribution (QKD) is the protocol used to exchange security keys and other
important information that needs protection. In 1984, Charles Henry Bennett and Gilles Brassard
published the first QKD protocol called BB84. Since its publication, a number of QKD protocols have
been announced, and most of them are built upon on the concepts of BB84. E91 or Ekert 91 is a
protocol published by Artur Ekert in 1991 and uses quantum entanglement.
6.7 Quantum Communication Protocols 259
Under the QKD protocols, Alice transmits a secret key to Bob by encoding the key in photons’
polarization. Eve cannot trap these photons and transmit them back to Bob without changing the
photon’s state. The no-cloning theorem prevents the photons from being cloned. Also, measuring the
photon’s state and creating a new photon in the measured state is impossible unless Eve knows the
basis in which Alice prepared the photons. Alice and Bob can detect noise in the channel by
introducing enough check-bits in the string, indicating a weak channel or the presence of Eve.
In this book, we shall study BB84 and Ekert 91 protocols from the theoretical perspective.
Implementing these protocols in software using any of the quantum computing frameworks available
today is a good exercise.
Assume that Alice and Bob are two parties in communication. Alice intends to send a security key of
length m bits of a large prime number N. Alice and Bob share a quantum communication channel.
They also have a classical communication channel. Eve is an eavesdropper who tries to tap into the
channel to learn about the security key transmitted. The BB84 protocol can be used to securely
exchange the key. The m bits are embedded inside the string a described below.
The BB84 protocol is outlined in the following steps.
1. Alice chooses two strings a and b, each of length (4 + δ)n classical bits. The string a embeds the
secret key that is to be transferred. The string b is randomly chosen. She then encodes them in
blocks of (4 + δ)n photons. The resultant state is a tensor product of (4 + δ)n states, with each state
representing the ith bit of a and b in the string.
jψ i ¼ jψ a b ið4þδÞn ð6:77Þ
jψ 00 i ¼ j0i; ai ¼ 0, bi ¼ 0
jψ 01 i ¼ j1i; ai ¼ 0, bi ¼ 1
ð6:78Þ
jψ 10 i ¼ jþi; ai ¼ 1, bi ¼ 0
jψ 11 i ¼ ji; ai ¼ 1, bi ¼ 1
This encodes the photons a based on b, either on the computational basis (Z ) or on the Hadamard
basis (X). With this encoding, the photons cannot be identified without the knowledge of b. Alice now
sends the photons jψi to Bob over the quantum channel. Photons encoded in the X basis are polarized
in vertical or horizontal directions. The photons encoded in the Z basis are polarized in diagonal or
antidiagonal directions, as shown in the fragment below.
⤢ ↔ ↕ ⤡ ↕ ⤢ ⤡ ↔ ↕ ⤢ ↕ ⤡
2. Let ε represent the quantum channel, which may include the channel noises and the effect of
intruders like Eve. In that case, the set of photons received by Bob is εðjψ ihψjÞ. At this step, Bob
constructs a random bit string b0 of length (4 + δ)n and measures the photons in the X or Z basis
depending upon the value of b0 for each corresponding bit position and stores the measured results
in a0.
260 6 Quantum Communications
Basis:
Z Z Z X Z Z X X Z X X Z
3. At this stage, Bob requests Alice to disclose b over the classical communication channel.
Z X X Z X Z Z X X Z X Z
Bob checks which photons are agreeing and decodes them.
Agreed basis:
⤢ ⤢ ↔ ↔ ⤡
Decoded Photons:
1 1 0 0 0
At this point, Alice and Bob require at least 2n bits to be kept. By choosing a large value for δ, this
is possible. If there are less than 2n bits, the protocol is aborted and repeated for a different value of b.
4. Now, Alice and Bob must perform several tests to confirm the channel noise and any
eavesdropping on the channel. They divide the 2n bits into two subsets of n bits each. The first
subset serves as the check-bits, and the second subset contains the secret key that is exchanged.
Alice announces the position and value of the check-bits over the classical communication
channel.
1 0 0
Bob compares the check-bits, and if there are more than t bits that do not agree, the protocol is
aborted and retried.
5. Alice and Bob perform information reconciliation and privacy amplification [5] to arrive at the
final list of m bits, representing the secret key.
The BB84 protocol is well studied, and the proof of security has been established [6].
The Ekert 91 protocol uses a workflow similar to the BB84 protocol. Instead of a stream of photons
encoded in Z or X basis, the E91 protocol uses entangled photons generated by a third-party source.
Figure 6.2, illustrates this setup.
Since this protocol is based on entanglement, the correlation is not affected if Alice and Bob use an
orthogonal basis for measurement. The E91 protocol requires Alice to perform the measurement in
Z basis but with one of the rotational angles 0 , 45 , 90 . Bob is also required to measure the photons
in the same but with one of the rotational angles 45 , 90 , 135 .
The protocol requires the photons to be measured in two ways. The first set of photons is measured
on the same basis by Alice and Bob. The second set of photons are measured in random.
Eavesdropping can be detected by computing the correlation coefficients between the measurement
6.8 RSA Security 261
pffiffiffi
basis used by Alice and Bob. Recall from Eq. (6.11) that the correlation coefficient is 2 2 for
maximally entangled photons. If not, we can conclude that either the photons were not entangled or
Eve has introduced local realism to the system, violating Bell’s Theorem. If the protocol is successful,
the first set of photons can be used to arrive at the keys.
For a detailed description of this protocol, refer to Nikolina Ilic’s article [7].
Encryption is the science of converting information into a form that is readable only by the recipient.
Humans have always been interested in protecting intellectual property: from protecting the art of
making pottery and silk to military secrets. With the advent of the internet and social media, this has
extended into protecting the privacy and personal information. Today, we do not do any transaction
that is not protected. From the period (1900 BC), when the scribes in Egypt used non-standard
hieroglyphs to record secret information, cryptography has come a long way. The notable ones in the
history of cryptography are the shift by three substitution ciphers used by Julius Caesar in the 1st
century BC, the substitution cipher created by Gabrieli di Lavinde in 1379, the first cipher disk by
Leon Battista Alberti in 1466, and so on. A good number of treatises on cryptography were also
written during the medieval period.
In 1585, the French diplomat Blaise de Vigenère wrote a book on ciphers. For the first time, this
book described a plaintext and ciphertext based autokey system. Nevertheless, who shall forget “The
Enigma Machine” used during World War II? In the United States, the confederation, and union
armies used “Cipher Disks” to protect communication (Fig. 6.7).
In modern times, the Data Encryption Standard (DES) was invented by IBM in 1976. It was
broken in 1997. DES used a 56-bit symmetric-key algorithm, which means the same key is used to
encrypt the plaintext and decrypt the cyphertext. As the internet bloomed and e-commerce got
popular, DES was replaced by Advanced Encryption Standard (AES) in 2001. AES is a block
cipher algorithm, which can be implemented efficiently in hardware or software. The algorithm uses a
substitution–permutation network, which is a series of linked mathematical operations. Decryption
is performed by reversing the order of the network. The standard we shall explore in this section is the
RSA algorithm, which was invented in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman.
RSA is an asymmetric block cipher, and it is a popular public-key based cryptographic system. RSA
is a crucial component of the public key infrastructure on which most transactions on the internet
are done.
The public-key cryptographic systems help reliably transmit information on the network, which
may be prone to attack. It is also used to authenticate entities using digital certificates. Being
asymmetric, RSA has two dissimilar keys—the private key and the public key. The public key can
be published. RSA remains secure, as long as the parties can keep the private key safe. Using RSA is
simple—Alice encrypts her message, the plaintext m using the public key, and sends the encrypted
message, the cyphertext c to Bob. Bob uses the private key to decipher the message.
The premise for the security of RSA comes from the fact that given a very large composite integer
number N, it is considered a hard problem determining its prime factors ( p and q ). The General
Number Field Sieve (GNFS) algorithm is the fastest well-known classical integer factorization
algorithm. The GNFS algorithm, when performed on an AMD 2.2 GHz Opteron Processor with
2 GB of RAM takes the following time to factorize integers:
The steps outlined in Fig. 6.8 illustrates the workflow for the RSA algorithm.
Assume a large composite integer number N with two distinct primes p and q, such that N ¼ p q.
Then, according to the number theory, there exists a periodic function F ðxÞ with period r, such that,
F ðxÞ ¼ ax mod N, where a is an integer, a 6¼ N, coprime with p or q and coprime with N. The period
r ¼ lcmð ð p 1 Þ, ð q 1 Þ Þ is defined by Carmichael’s Totient function. Here lcm stands for
least common multiple.
Step - 2
secure.
Let N ¼ 21, p ¼ 7, q ¼ 3
Then, N ¼ p q ¼ 7 3 ¼ 21
ð6:79Þ
r ¼ lcmðð7 1Þ, ð3 1ÞÞ ¼ lcmð6, 2Þ ¼ 6
Assume, a ¼ 5
For the above values, Table 6.1 lists the first three periods of the periodic function. This table can
be verified easily in WolframAlpha.
From the table, the period r ¼ 6, as we calculated in Eq. (6.79). Now that we are clear about the
periodic function, let us perform the inner workings of the RSA by taking slightly large numbers.
Now, we have the public exponent e ¼ 19, and the private exponent d ¼ 139. With this, we can try
to perform an encryption and decryption operation of the alphabet “A.”
• If p and q are known, it is easy to find r. But if only N is known, it is a hard problem. The hard
problem of finding the period r of F ðxÞ ¼ ax mod N ensures the security of RSA.
• Once r is known, it is easy to calculate the Private Exponent d using the formula d ¼ e1 mod r,
and the RSA security is broken (where e is the Public Exponent. It is part of the Public Key
{ e, N }, and usually 65537.)
• Finding the value of r is called order finding or period estimation. Shor’s algorithm (c. 1994) is a
Quantum version of period estimation. We shall study Shor’s algorithm in the next chapter.
6.9 Summary
This chapter focused on quantum communications. We learned about EPR Paradox, density matrix
formalism, von Neumann entropy, creation of entangled photons, quantum communication protocols,
and RSA security.
In this chapter, some concepts like Bell measurement, Bell’s inequalities, verification of entangle-
ment, reduced density matrices, and no-communication theorem were explored. This chapter also
focused on Schumacher’s compression and Schmidt decomposition.
We shall return to RSA security in the following chapter, which focuses on quantum algorithms.
Practice Problems
1. Differentiate between pure and mixed states. How are the density matrices defined for pure and
mixed states?
2. Establish that the density operator and the partial trace are independent of the orthonormal basis
used to calculate them.
3. Prove that the tensor product of two density operators is also a density operator.
4. Develop a quantum circuit to verify the GHZ state.
5. Explain whether the Bell state is a mixed state or a pure state? Using reduced density operators,
establish that one of the qubits is in a mixed state.
6. What is the Schmidt number of a product state? Explain your answer.
7. Calculate the degree of entanglement between two qubits described by the quantum state
jψ i ¼ 14 j00i þ 14 j01i þ 14 j10i þ 14 j11i:
8. A qubit in state jψi ¼ aj0i + bj1i starts to decohere. If τ is its decoherence time, what is its density
matrix.
9. Explain quantum teleportation. How is it different from sending classical bits over large distances
on the internet? Can information be sent at speeds higher than the speed of light?
10. Simulate a quantum communication channel by implementing the BB84 Protocol as a hybrid
software that runs partially on a classical computer and partially on a quantum computer.
11. In the above experiment, assume that Eve tries to listen to the communication between Alice and
Bob. Eve uses a fixed basis to measure the qubits in transmission. She then prepares new qubits in
the measured state and puts them in the transmission channel. How much of information can Eve
retrieve at each stage in the protocol? How does this disrupt the communication between Alice
and Bob?
References 265
References
1. Physics: Bell’s theorem still reverberates, https://www.nature.com/news/physics-bell-s-theorem-still-reverberates-1.
15435
2. Polarization Correlation of Photons Emitted in an Atomic Cascade, Kocher et al, Physical Review Letters, 10 April
1967.
3. The Non-Signalling theorem in generalizations of Bell’s theorem. J Walleczek and G Gr€ ossing 2014 J. Phys.: Conf.
Ser. 504 012001. https://iopscience.iop.org/article/10.1088/1742-6596/504/1/012001/pdf
4. https://en.wikipedia.org/wiki/No-communication_theorem
5. https://en.wikipedia.org/wiki/Quantum_key_distribution#Information_reconciliation_and_privacy_amplification
6. Simple Proof of Security of the BB84 Quantum Key Distribution Protocol, Peter W. Shor and John Preskill, Physical
Review Letters, 10 July 2000, http://www.theory.caltech.edu/~preskill/pubs/preskill-2000-proof.pdf
7. The Ekert Protocol, Nikolina Ilic, Journal of Physics, July 22, 2007, https://www.ux1.eiu.edu/~nilic/Nina’s-article.
pdf
8. Factorization of a 768-bit RSA modulus, Version 1.4, February 18, 2010, Thorsten Kleinjung et al, https://eprint.iacr.
org/2010/006.pdf
9. https://www.digicert.com/blog/moving-beyond-1024-bit-encryption/
Quantum Algorithms
7
This chapter focuses on exploring some of the fundamental quantum algorithms. We start this chapter
by building a simple ripple adder circuit, an extension to the full adder circuit we learned in Chap. 5.
The purpose of introducing the ripple adder circuit is to increase our exposure in building layered
quantum circuits. The underlying math work helps us understand how to apply unitary
transformations in each stage—qubit by qubit, and evolve the final quantum state.
After completing this exercise, we learn about the quantum Fourier transform (QFT), an essential
milestone in our learning. After that, we learn about oracle functions and study a few oracle-based
algorithms such as the Deutsch–Jozsa algorithm, Bernstein–Vazirani problem, and Simon’s algo-
rithm. We then return to QFT and apply it to perform arithmetic! Grover’s search algorithm is an
interesting concept, which employs amplitude magnification. After exploring Grover’s search, we
learn about Shor’s algorithm and factor the number 15 using a fixed quantum circuit. We then build a
quantum version of the k-means algorithm, widely used in unsupervised machine learning. Another
concept introduced in this chapter is quantum phase estimation and its application in solving linear
equations.
Throughout this chapter, we mix theory, math, and practice. Step-by-step derivation of the math is
provided to help improve understanding. Working codes accompany the algorithms explained in this
chapter. Experiment with the code, analyze, optimize, measure, and find bugs!
We complete this chapter by looking at the complexity theory.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 267
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_7
268 7 Quantum Algorithms
In Chap. 5, we implemented a quantum full adder circuit. In this section, we shall extend that concept,
and implement a reusable in-place ripple adder that adds two 2-bit positive integers. The logic
outlined in this section [1] can be extended to add two integers of any size. The total number of
qubits required is 2n + 2, where n is the number of bits required to represent the unsigned integers.
We are not using any sign bits in this exercise. Implementing sign bits is left as an exercise. Adding
numbers is not the best use of quantum computers. We shall use this as an exercise to learn the
construction of complex circuits.
Let us assume two n-bit positive integers with the binary representation, a ¼ an 1. . .a2a1a0 and
b ¼ bn 1. . .b2b1b0. Let us also define the carry c ¼ cn 1. . .c2c1c0. At a given level i, the circuit
adds the corresponding bits ai, bi, ci and produces the carry ci + 1,and the sum si. The carry bit
generated at level i is an input to the next level i + 1. This cycle repeats through all the bits. Hence, this
circuit is called the “ripple adder.” From Chap. 5, Eqs. (5.102) and (5.103), we can define the sum
and carry as follows:
s i ¼ ai bi c i ð7:1Þ
At the start of the circuit, we apply a CNOT gate to the target qubit bi with ai as the control qubit.
The new state is:
ψ ¼ jci ijai bi ijai i ð7:4Þ
The next step is to apply a CNOT gate to the target qubit ci with ai as the control qubit.
ψ ¼ jai ci ijai bi ijai i ð7:5Þ
The final step is to apply a Toffoli gate to qubit ai, with qubits ci and bi as the control qubits.
The third term in this equation can be written as (for brevity, we skip this step, but it can be easily
worked out):
By comparing the last column of Table 7.1 with the last two columns of Table 5.4 the truth table
of the full adder in Chap. 5, we can infer that the third term in Eq. (7.7) calculates the ci + 1 of this
step. We can, therefore, rewrite Eq. (7.7).
The unmajority-sum (UMS) function performs the in-place addition, and it is implemented, as
shown in Fig. 7.2.
The first step is to perform a Toffoli gate on the third qubit, with the first and second qubits as the
control qubits. To make the math understandable, we must expand the third term in Eq. (7.7) and
apply the Toffoli operation.
This equation simplifies to (this can be worked out easily on an online Boolean expression
evaluator [2]) the following:
ψ ¼ j ai c i i j ai bi i j ai i ð7:10Þ
The second step is to perform the CNOT of the first qubit, with the third qubit as the control. We
get,
The third step is to perform a CNOT of the second qubit, with the first qubit as the control. We can
write Eq. (7.12) as:
By comparing this equation with Eq. (5.102), we can write the next step:
ψ ¼ j c i i j s i i j ai i ð7:14Þ
We note that this method calculates the sum si in place of bi and retrieves ci and ai.
We can create a ripple adder by connecting the MAJ and UMS functions in a sequence. The bit c0
can be set as “0” if there is no incoming carry. It can be set as “1,” if there is an incoming carry. The
outgoing carry can be calculated by performing a CNOT of the output qubit z with cn + 1.
Assume two 2-bit numbers A and B. Their binary representations are described by qubits q[1]
q[2] and q[3]q[4].
For number A: the qubit q[2] is the least significant qubit (i ¼ 0), and the qubit q[1] is the most
significant qubit (i ¼ 1).
For number B: the qubit q[4] is the least significant bit (i ¼ 0), and the qubit q[3] is the most
significant bit (i ¼ 1).
Assume q[0] represents CIN (that is, c0) and q[5] represents COUT. Figure 7.3 illustrates the
construction of the 2-bit adder using the MAJ and UMS functions.
This circuit can be implemented in any of the development platforms. Type the code frag-
ment from Listing 7.1 in a new cell on your Jupyter Notebook for Qiskit. Copy the import sections
from previous work. Use “qasm_simulator” as your backend.
In this code fragment, we are creating two composite gates. These two composite gates are
implemented as independent quantum circuits. The ‘to_instruction()’ method helps the composite
gates to be appended as instructions to the target circuits. This level of modularization helps us
develop and manage code easily.
Fig. 7.3 The 2-bit ripple adder circuit with the MAJ and UMS functions
7.1 Quantum Ripple Adder Circuit 271
Exercise 7.1
1. Write unit testing code to prove that this function works.
2. Extend this function to support 8-bit positive integers.
3. Extend this function to support negative integers.
4. What is the circuit depth?
◄
272 7 Quantum Algorithms
qc.cx(q[1], q[5])
qc.measure(q[4], c[0])
qc.measure(q[3], c[1])
qc.measure(q[5], c[2])
return counts
The Fourier transform is a reversible linear transformation function. It converts a signal g(t) in the
time domain into a signal G( f ) in the frequency domain. Due to this property, the Fourier transform
has several applications in signal and image processing. The Fourier transforms are key components
7.2 Quantum Fourier Transformation 273
Fig. 7.4 The quantum circuit for the 2-bit adder, as constructed using Qiskit
in period finding (which we shall apply in a later section) application and RF signal receivers.
Equation (7.15) describes the Fourier transform for aperiodic signals. Aperiodic signals are signals
that don’t repeat itself after a period of time, but they can also be signals with an infinite period, that
is, a signal is periodic if x(t) ¼ x(t + T0), where T0 is the period.
ð þ1
XðωÞ ¼ F ½xðtÞ ¼ xðtÞeiωt dt, ð7:15Þ
1
where ω ¼ 2πf, f is the frequency, and t is the time. This equation is also known as the forward
transform.
The inverse of the Fourier transform is described in the following equation: inverse transform.
ð
þ1
1
xðtÞ ¼ F ½ X ð ωÞ ¼ XðωÞeiωt dω ð7:16Þ
1
By comparing the exponential term with the Euler’s formula1 e jωt ¼ cos ωt + j sin ωt, we can
conclude that complex sinusoidal functions are the basis functions of the signal. This term can also be
considered as a unit vector rotating in a complex plane at a rate of ω radians per second. Figure 7.6
illustrates this concept. Note that cosωt and sinωt are projections of this vector along the real and
imaginary axes. From these two equations, we can interpret x(t) as the weighted sum X(ω) of
e jωt components of frequencies ω.
The Discrete Fourier Transform is equivalent to the Continuous Fourier Transform described in the
previous section. However, it applies to N samples of the signals taken at T time intervals. Figure 7.5
illustrates the DFT of a sinusoidal function with a period t into its constituent frequency.
Let us assume x(t) be the continuous signal under consideration. We take N samples of
this signal x[0], x[1], x[2], . . ., x[k], . . ., x[N 1]. Each sample x[k] is taken after a time T from
the previous sample x[k 1]. The signal is periodic. Hence, we can assume that the data in the range
1
Between literature, the unit imaginary number may be represented as i or j, interchangeably.
// Implement the Majority function
// q0 : Input c
// q1 : Input b
// q2 : Input a
ResetAll(q);
}
x[0], . . ., x[N 1] are the same as the data in the range x[N], . . ., x[2N 1]. Since this is a
sampled data, it exists only at specific times. Hence, we can write Eq. (7.15) as:
ð ÞT
ðN1
X ð ωÞ ¼ xðtÞeiωt dt ð7:17Þ
0
The sample data are periodic. Hence, we should calculate the DFT for the fundamental frequency
2π
NT rad/sec and its harmonics, that is, the values of ω we should evaluate are:
2π 2π 2π 2π
ω ¼ 0, 1, 2, . . . , n, . . . , ð N 1Þ ð7:20Þ
NT NT NT NT
Applying this in Eq. (7.19), we get after normalization,
1 X
ðN1Þ
x½kei N nk , n ¼ 0 : N 1
2π
X½n ¼ pffiffiffiffi ð7:21Þ
N k¼0
X[n] is called the Discrete Fourier Transform of the sampled data sequence x[k]. The sampling is done
at uniform intervals of time t ¼ 0, 1, 2, . . ., N 1. The output X[n] is a vector of complex numbers that
encodes the amplitude and phase of a sinusoidal wave of frequency Nn : The DFT can be written in a
matrix form as follows:
2 3 2 0 32 3
X ½ 0 ω ω0 ω0 ⋯ ω0 x ½ 0
6 7 6 0 76 7
6 X ½ 1 7 6ω ω1 ω2 ⋯ ωðN1Þ 76 x½1 7
6 7 6 76 7
6 X½2 7 ¼ p1ffiffiffiffi 6 ω0 ω2 ω4 ⋯ ω2ðN1Þ 7 6 x ½ 2 7 , ð7:22Þ
6 7 6 76 7
6 7 N 6 0 76 7
4 ⋮ 5 4ω ⋮ ⋮ ⋯ ⋮ 54 ⋮ 5
X ½ N 1 ð Þ ð Þ ð Þ ð Þ x ½ N 1
ω ω
0 N1
ω 2 N1
⋯ ω N1 N1
π
where ω ¼ ei N . Note that ei2 ¼ i: The term p1ffiffiNffi is a normalization constant, and the DFT matrix is
2π
unitary.
The Inverse Discrete Fourier Transform is given by the following equation:
1 X
ðN1Þ
2π
x½k ¼ X½nei N nk , n ¼ 0 : N 1 ð7:23Þ
N k¼0
Example 7.1
A sine wave is sampled every 0.25 seconds. The samples are {0, 1, 0, 1}. Calculate the DFT.
◄
7.2 Quantum Fourier Transformation 277
Solution
Using Eq. (7.22), we can write
2 3 2 32 3 2 3 2 3
X½0 1 1 1 1 0 0 0
6 7 6 76 7 6 7 6 7
6 X½1 7 6 i 1 i 7 6 7 6 7 6 7
6 7 1 61 76 1 7 1 6 2i 7 6 i 7
6 7 ¼ pffiffiffi 6 76 7¼ 6 7¼6 7 ð7:24Þ
6 X½2 7 46 1 1 7 6 7 26 0 7 6 0 7
4 5 41 1 54 0 5 4 5 4 5
X½3 1 i 1 i 1: 2i i
Recall from our discussions in the earlier section that the Discrete Fourier Transform takes a vector
x[N] 2 ℂN and maps it into a vector X[N] 2 ℂN. Similarly, the Quantum Fourier Transform acts on a
P
N1 P
N1
quantum state jxi ¼ xi jii and maps it into a state Xi jii: This transformation is given by the
i¼0 i¼0
following equation:
1 X
ðN1Þ
Xk ¼ pffiffiffiffi xn ωkn
N , k ¼ 0 : N 1, ð7:25Þ
N n¼0
2πi
where ωN ¼ e N , which is called the primitive Nth root of unity. Note that we are using a phase factor
with a positive sign, and it is similar to the Inverse Discrete Fourier Transform. Assuming jxi is a
basis state, the QFT can be written as the following mapping:
1 X xy
ðN1Þ
jxi ¼ pffiffiffiffi ωN jyi ð7:26Þ
N y¼0
1 X X xy
N 1 N 1
UQFT ¼ pffiffiffiffi ωN jyi hxj
N x¼0 y¼0
2 3
1 1 1 1 ⋯ 1
6 7
6 1 ω1 ω2 ω3 ⋯ ωðN1Þ 7
6 7
6 7 ð7:27Þ
6 ω2 ω4 ω6 ⋯ ω2ðN1Þ 7
1 6 1 7
¼ pffiffiffiffi 6 7
N6 6 1 ω3 ω6 ω9 ⋯ ω3ðN1Þ 7
7
6 7
6⋮ ⋮ ⋮ ⋮ ⋮ ⋮ 7
4 5
1 ωðN1Þ ω2ðN2Þ ω3ðN1Þ ⋯ ωðN1ÞðN1Þ
1 00 01
X0 ¼ pffiffiffi a e2πi 2 þ a e2πi 2 , k ¼ 0, N ¼ 2
2
1
¼ pffiffiffi a e0 þ b e0 ð7:28Þ
2
1
¼ pffiffiffi ða þ bÞ
2
1 10 11
X1 ¼ pffiffiffi a e2πi 2 þ a e2πi 2 , k ¼ 1, N ¼ 2
2
1
¼ pffiffiffi a e0 þ b eπi , we know that eπi ¼ 1, e0 ¼ 1: ð7:29Þ
2
1
¼ pffiffiffi ða bÞ
2
We can prove that this operation is equal to an H gate operation on the qubit. From Eq. (5.9), we
can write the following operation:
j0i þ j1i j0i j1i
H jψ i ¼ p ffiffi
ffi h 0j þ p ffiffi
ffi h1j a j0i þ b j1i
2 2
1
¼ pffiffiffiffi ðaðj0i þ j1iÞ þ bðj0i j1iÞÞ ð7:31Þ
2
1
¼ pffiffiffiffi ðða þ bÞj0i þ ða bÞj1iÞ
2
By comparing the above two equations, we can conclude that the H gate performs a QFT on N ¼ 2
states.
Recall that the H gate transforms the Z basis (the computational basis) into the X basis (the polar
basis, or the {j+i, ji} basis). Similarly, we can define the QFT as the transformation from the
computational basis to the Fourier basis. With this assumption, we can rewrite Eq. (7.30) as:
Expanding this for y in the computational basis {0, 1}, the range of the sum becomes
y1, y2. . .yn 2 {0, 1}n. Also, we can write y as a binary number:
7.2 Quantum Fourier Transformation 279
The exponential of the sum over k can be rewritten as the product of exponentials:
X
1 2πix nk
¼ pffiffiffiffinffi nk¼1 exp 2 y jy i ð7:35Þ
2 2n k k
y1 , y2 ...yn 2f0, 1g
After this step, we can proceed to expand the tensor product as follows:
1 x
¼ pffiffiffiffinffi j0i þ exp 2πi 1 j1i
2 2
x
j0i þ exp 2πi 2 j1i
2
ð7:38Þ
x
j0i þ exp 2πi 3 j1i ⋯
2
x
j0i þ exp 2πi n j1i
2
Let us analyze the exponent part of Eq. (7.37) separately, by expanding x as a binary number.
Pn nl
x 2 xl
exp 2πi k ¼ exp 2πi l¼1 k
2 2
! ð7:39Þ
Xn
¼ exp 2πi 2 nkl
xl
l¼1
The summation on the exponential can be split into two parts. This helps us in separating the
integer and fractional parts, and solve them separately.
280 7 Quantum Algorithms
!
X
nk X
n
¼ exp 2πi 2 nkl
xl þ 2πi 2 nkl
xl
l¼1 l¼nkþ1
! ! ð7:40Þ
X
nk X
n
¼ exp 2πi 2nkl xl exp 2πi 2nkl xl
l¼1 l¼nkþ1
Comparing the above two equations, we can rewrite the Eq. (7.37):
1
QFTN jxi ¼ pffiffiffiffinffi nk¼1 ½ j0i þ exp ð2πi ð0:xnkþ1 xnkþ2 xnkþ3 . . . xn ÞÞj1i ð7:44Þ
2
The exponents evaluate to 2-power roots of unity, and the terms are equivalent to the Hadamard
transformation. Note that the last qubit depends upon all qubits in the system. As we progress towards
the first qubit, the dependency reduces to itself. With this knowledge, we can construct the QFT
circuit.
Consider the 4-qubit quantum circuit shown in Fig. 7.7. This circuit uses H gates and controlled
rotations.
q[0]
q[1]
q[2]
q[3]
Recall from Eq. (5.14), that the H gate can be written as follows:
1 x
H jxi ¼ pffiffiffi j0i þ exp 2πi 1 j1i ð7:46Þ
2 2
1 0
RðkÞ ¼ 2πi ð7:47Þ
0 e 2k
π
Note that, in the quantum circuit, this rotation can be implemented as a U1 gate with λ ¼ 2π 2k
¼ 2k1 :
Let us define a controlled version of this R gate (CR). Assume a two-qubit state jxkxji with xk as the
control qubit and xj as the target qubit. The action of the CR gate on this 2-qubit state can be defined as
follows:
CR j0ix j ¼ j0ix j
2πi E ð7:48Þ
CR j1ix j ¼ j1ie 2k x j
With this definition, let us start working with our quantum circuit. The initial state of the system is
as follows:
jψi ¼ jx1 i jx2 ijx3 i jx4 i ð7:49Þ
We begin the circuit by applying an H gate to qubit x1. The resultant state can be written as
follows:
We then apply a CR gate to the qubit x1 with the qubit x2 as the control qubit.
1 x2 x1
¼ pffiffiffi j0i þ exp 2πi 2 þ 2πi 1 j1i jx2 i jx3 i jx4 i ð7:51Þ
2 2 2
The next step is to apply a CR gate to the qubit x1 with the qubit x3 as the control qubit.
1 x3 x2 x1
¼ pffiffiffi j0i þ exp 2πi 3 þ 2πi 2 þ 2πi 1 j1i jx2 i jx3 i jx4 i ð7:52Þ
2 2 2 2
The final step with qubit x1 is to perform a CR gate with it using the qubit x4 as the control
qubit.
1 x4 x3 x2 x1
¼ pffiffiffi j0i þ exp 2πi 4 þ 3 þ 2 þ 1 j1i jx2 i jx3 i jx4 i ð7:53Þ
2 2 2 2 2
We can now take the qubit x2, apply an H gate first, a controlled rotation with qubit x3 as the
control qubit, and then another controlled rotation with qubit x4 as the control qubit
282 7 Quantum Algorithms
1 x4 x3 x2 x1
¼ pffiffiffi j0i þ exp 2πi 4 þ 3 þ 2 þ 1 j 1i
2 2 2 2 2
1 x x x
pffiffiffi j0i þ exp 2πi 43 þ 2πi 32 þ 2πi 21 j1i ð7:54Þ
2 2 2 2
jx3 i jx4 i
The next step is to take the qubit x3, apply an H gate, and then a controlled rotation with x4 as the
control qubit.
1 x4 x3 x2 x1
¼ pffiffiffi j0i þ exp 2πi 4 þ 3 þ 2 þ 1 j 1i
2 2 2 2 2
1 x x x
pffiffiffi j0i þ exp 2πi 43 þ 32 þ 21 j1i ð7:55Þ
2 2 2 2
1 x x
pffiffiffi j0i þ exp 2πi 42 þ 2πi 31 j1i jx4
2 2 2
The final step is to apply an H gate with the qubit x4 and rearranging the terms inside the
exponents.
1 x1 x2 x3 x4
¼ p ffiffi
ffi j0i þ exp 2πi 1 þ 2 þ 3 þ 4 j 1i
2 2 2 2 2
1 x x x
pffiffiffi j0i þ exp 2πi 21 þ 32 þ 43 j 1i
2 2 2 2
ð7:56Þ
1 x x
pffiffiffi j0i þ exp 2πi 31 þ 42 j1i
2 2 2
1 x
pffiffiffi j0i þ exp 2πi 41 j1i
2 2
Comparing the fractional series inside the exponents with Eq. (7.43), we can rewrite the above
equation:
1 ðj0i þ expð2πi ð0:x1 x2 x3 x4 ÞÞ j1iÞ ðj0i þ expð2πið0:x2 x3 x4 ÞÞ j1iÞ
¼ pffiffiffi ð7:57Þ
2 ðj0i þ expð2πið0:x3 x4 ÞÞ j1iÞ ðj0i þ expð2πi ð0:x4 ÞÞ j1iÞ
By comparing this equation with Eq. (7.45), we can conclude that the 4-qubit circuit performs
Quantum Fourier Transform. However, the order of the terms is reversed. This can be corrected by
performing SWAP operations between the qubits pairs (x1, x4) and (x2, x3).The following Eq. (7.58)
describes the final state of the system.
1
jψi ¼ pffiffiffi ððj0i þ expð2πi ð0:x4 ÞÞ j1iÞ
2
ðj0i þ expð2πið0:x3 x4 ÞÞ j1iÞ ð7:58Þ
ðj0i þ expð2πið0:x2 x3 x4 ÞÞ j1iÞ
ðj0i þ expð2πi ð0:x1 x2 x3 x4 ÞÞj1iÞ Þ
This algorithm runs in polynomial time in n, that is, O(n2). The best estimate for classical Discrete
Fourier Transform runs in an exponential time O(n2n). We can construct this circuit using nðnþ1
2
Þ
n
Hadamard and controlled U1 gates, and 2 swap gates. The QFT does provide exponential speedup
7.2 Quantum Fourier Transformation 283
Fig. 7.8 Inverse Quantum Fourier Transform of 4-qubit registers. Note the order of the gates and the negative
rotational angles
over classical DFT, but it works on the probability amplitudes of the quantum states. The classical
Fourier transforms work on the complex vectors. Hence, not all applications that use DFT can benefit
from QFT.
The inverse QFT is defined as follows:
ðN1Þ
1 X
xn ¼ pffiffiffiffi Xn ωkn
N ,n ¼ 0 : N 1 ð7:59Þ
N k¼0
The Inverse QFT QFT1 or IQFT can be implemented by reversing the order of the gate
operations and by negating the rotational angles. The circuit diagram shown in Fig. 7.8 illustrates
the U{QFT .
Note that the Quantum Fourier Transform is unitary, and it satisfies the relation UQFT U{QFT ¼
U {QFT U QFT ¼ I, where U {QFT is the Hermitian adjoint of UQFT and U {QFT ¼ U 1
QFT :
Let us develop the code that performs the forward and inverse QFT for an arbitrary size of qubits.
Open your Jupyter notebook and enter the code from Listing 7.4 that imports the needed libraries and
sets up the Qiskit.
We then develop two helper functions that swap the qubit registers and initialize the qubit registers
based on the input. Enter the code for the two helper functions provided in Listing 7.5 in a new cell in
your Jupyter notebook.
With these two helper functions available, we can create the code that constructs the forward QFT.
We use two loops to create the circuit iteratively. The size of the qubit is taken directly from the
quantum circuit. Hence, this function can create a QFT circuit of any size (Listing 7.6).
The inverse QFT must be defined backward and by using negative angles. Listing 7.7 demonstrates
how to build the inverse QFT.
The QFT works on the amplitudes of the quantum states. Hence, we cannot compare QFT and DFT
with a set of test data. To verify QFT, we construct a back to the back circuit of QFT and QFT1.
Since QFT1 is the Hermitian adjoint of QFT, cascading these two circuits should return the qubits to
the initial state. The code snippet in Listing 7.8 illustrates this.
This circuit uses a 4-qubit QFT with an initial value of 7. Executing this circuit gets the histogram
shown in Fig. 7.9. The circuit’s output is the binary pattern “1110,” and this is what we expected.
284 7 Quantum Algorithms
# Setup the qubits according to the bit pattern of the input number
# qc – the quantum circuit
# input – the input number whose binary pattern
# is to be encoded in the qubits
# Forward QFT
# qc – the quantum circuit
# input – the input number to be transformed.
# ensure sufficient number of qubits are allocated.
#
# Inverse QFT
# qc – the quantum circuit
# do not forget the negative sign before math.pi
q = QuantumRegister(numberofqubits , 'q')
c = ClassicalRegister(numberofqubits , 'c')
qc = QuantumCircuit(q, c)
qft_fwd(qc, number )
swap_reg(qc)
qft_inv(qc)
qc.measure_all()
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=shots)
counts = job.result().get_counts()
plot_histogram(counts)
Exercise 7.2
1. Try this code with all possible inputs (in the range of 0. . .15 for 4 qubits) and confirm the circuit
works as intended on the simulator.
2. Try this code on a backend. Are you getting the same results? If not, where is the problem?
3. Reduce the circuit to using 3 qubits (change the inputs to the range 0...7) and retry the experiment
on the backend. What do you observe now?
4. Compare this code with the QDK version. What differences do you see between the systems?
◄
Code example for QDK is included in the Appendix.
7.3 Deutsch–Jozsa Oracle 287
Given a function f : {0, 1}! {0, 1}, the oracle determines whether the function is constant or
balanced. The function is constant if f(0) ¼ f(1). It is balanced if f(0) 6¼ f(1), that is, if the function
returns the same value {0, 1} irrespective of the input {0, 1}, it is a constant function. It is a balanced
function if it returns different values.
Constant functions
f ð0Þ ¼ 0, f ð1Þ ¼ 0
f ð0Þ ¼ 1, f ð1Þ ¼ 1
Balanced functions
f ð0Þ ¼ 0, f ð1Þ ¼ 1
f ð0Þ ¼ 1, f ð1Þ ¼ 0
The Deutsch–Jozsa oracle is a generalization of the Deutsch oracle for a string of n bits. Given a
function f : {0, 1}n ! {0, 1}, the oracle determines whether the function is constant or balanced. The
function is balanced if it returns 0 for half of the arguments and returns 1 for the other half of the
arguments. For a function that is neither constant nor balanced, Deutsch-Jozsa oracle is not of
much help.
Classically, it is easy to solve this problem. By repeatedly calling the function f with inputs
{0, 1}n, we can determine the nature of this function. We must call the function for half of the inputs
and for an additional time to ascertain whether it is a constant or a balanced function. For half of the
inputs, if we get a 0 (or a 1), then we need to call the function one more time to make sure it returns a
1 (or a 0) to be a balanced function. So we have to call the function 2n1 + 1 times to get 100%
confidence.
Let us now look at the quantum version. Figure 7.11 illustrates how we construct the quantum
circuit for the Deutsch–Jozsa algorithm.
This circuit uses an n qubit data register and an ancilla qubit. The black box Uf implements the
oracle function y f(x). We start the system with the data register and the ancilla qubit initialized to
state j0i.
jψi ¼ j0in j0i ð7:60Þ
The next step is to apply an X gate to the ancilla qubit. This gate flips its state to j1i.
Recall from our discussion on Walsh–Hadamard Transform equation (5.167), that the simulta-
neous application of H gates on n qubits prepared at state j0i can be written as the following
summation:
1 X
2n 1
n n
H j0i ¼ pffiffiffiffinffi jxi ð7:62Þ
2 x¼0
Getting back to our circuit, we apply H gates to both the data register and the ancilla qubit. The H
gates put the system in a single-large-equal superposition state. By referring to the Eq. (7.62), we can
write the system state as:
2X
n
1
1
H n j0in Hj1i ¼ pffiffiffiffiffiffiffiffiffi jxi ðj0i j1iÞ ð7:63Þ
2nþ1 x¼0
By applying the oracle function y f(x) into the ancilla qubit, we get:
1 X
2n 1
¼ pffiffiffiffiffiffiffiffiffi jxi ððj0i j1Þ f ðxÞÞ
2nþ1 x¼0
2X
n
1
1
¼ pffiffiffiffiffiffiffiffiffi jxi ðj0 f ðxÞi j1 f ðxÞiÞ ð7:64Þ
2nþ1 x¼0
1 X
2n 1
¼ pffiffiffiffiffiffiffiffiffi jxi ðjf ðxÞi j1 f ðxÞiÞ
2nþ1 x¼0
We find that the state of the ancilla qubit remains unchanged after the application of the oracle
function. We can drop the ancilla qubit from our discussion as we are not going to use this qubit
anymore. The final step in the compute stage is to apply H gates to the data register. By referring to
Eq. (5.16), we get:
1 X
2n 1
¼ pffiffiffiffinffi ð1Þ f ðxÞ H n jxi
2 x¼0
ð7:66Þ
1 X 1 X
2n 1 2n 1
f ðxÞ
¼ pffiffiffiffinffi ð1Þ pffiffiffiffinffi ð1Þx:y jyi
2 x¼0 2 y¼0
At this stage, we are ready to measure the data register. All we need to be sure of is that the data
register projects into j0in, that is, when jyi ¼ j0in. For this case y ¼ 0,therefore, x y ¼ 0 Hence, the
probability amplitude associated with this state is given by:
1 X
2n 1
ð1Þ f ðxÞ ð7:68Þ
2n x¼0
We can, therefore, confirm that the algorithm works. Let us verify this algorithm by implementing
a quantum circuit with a 4-qubit data register and an oracle function.
Let us first examine the oracle function. A balanced function can be constructed using a set of
CNOT gates. In this function, each qubit in the data register serves as the control qubit, and the ancilla
qubit serves as the target qubit. This part of the circuit is given in Fig. 7.12. By referring to Sect. 5.4.
6.1 on the CNOT gate, we can write the truth table of this setup as shown in Table 7.2.
From the truth table, we can find that this function produces an equal number of j0is and j1is.
Hence, we can say that this function is balanced.
It is relatively easy to construct a constant function. If we need the function to output a j1i, we must
apply an X gate to the ancilla qubit. If we need the function to output a j0i, we do not do any
operation. To try the Deutsch–Jozsa algorithm on the IBM Q, start with the Listing 7.9 which
contains the import functions.
290 7 Quantum Algorithms
q[1]
q[2]
q[3]
q[4]
import qiskit
import math
from qiskit import *
from qiskit import IBMQ
from qiskit.visualization import plot_histogram, plot_gate_map
from qiskit.visualization import plot_circuit_layout
from qiskit.visualization import plot_bloch_multivector
from qiskit import QuantumRegister, ClassicalRegister, transpile
from qiskit import QuantumCircuit, execute, Aer
from qiskit.providers.ibmq import least_busy
from qiskit.tools.monitor import job_monitor
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
Listing 7.10 implements balanced and constant functions. It also includes the Deutsch–Jozsa algorithm.
# The balanced function
# qc – the quantum circuit
# n – number of bits to use
# input – the input bit string
q = QuantumRegister(numberofqubits , 'q')
c = ClassicalRegister(numberofqubits , 'c')
qc = QuantumCircuit(q, c)
deutsch_jozsa(qc, numberofqubits-1, number,"constant", True)
#qc.draw('mpl')
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=shots)
counts = job.result().get_counts()
plot_histogram(counts)
Finally use Listing 7.11 to set up the quantum circuit, execute the algorithm, and measure the final
state.
Executing this code produces the histograms shown in Fig. 7.13 for the balanced and constant
functions. The function produces a “1111” with 100% confidence (or in other words measuring a
“0000” is 0% probability) for the balanced function, and it produces a “0000” with 100% confidence for
the constant function. This result is what we expected, and it aligns with Eq. (7.69) (Figs. 7.14 and 7.15).
The code that runs on the Q# QDK is given in Listing 7.12.
The helper functions that build the balance and constant functions are provided in Listing 7.13.
To make our discussions complete, we shall derive the math for the circuit we constructed. We
begin the quantum system with the qubits initialized to the default state. We also skip the
computation steps for the hidden string for the sake of simplicity. Verification of the hidden
string is left as an exercise.
7.3 Deutsch–Jozsa Oracle 293
Fig. 7.13 The histogram for the balanced and constant functions, each producing 100% confidence
q[0]
q[1]
q[2]
q[3]
q[4]
Fig. 7.14 Deutsch–Jozsa algorithm with a balanced function of 4-qubit data register (q0. . .q3) and an ancilla qubit
(q4). The hidden string is applied before and after the oracle function
q[2]
q[3]
q[4]
jψ i ¼ j0000ij0i ð7:70Þ
jψ i ¼ j0000ij1i ð7:71Þ
H gates are applied to the system to put the qubits in a large superposition state.
/// # Summary
/// Implements the Deutsch-Jozsa Algorithm
///
/// # Inputs
/// input: a number whose' binary form represents a hidden string
/// functionType: 0 - Constant function, 1 - Balanced function
/// constant: {0,1} - The value the constant function need to\
output
///
/// # Returns
/// The measured value denoting the probability of measuring all
0s.
/// Should be returning all 1's or all 0's indicating the\
probability
/// all 1's for balanced and all 0's for constant functions
using ( q = Qubit[n+2] )
{
// Set the ancilla qubit
X(q[n+1]);
if ( 0 == functionType)
{
// Constant function
ConstantFunction(q, n, constant);
}
else
{
BalancedFunction(q, n,input);
}
ResetAll(q);
}
return r;
}
Listing 7.12 (continued)
1 1
¼ pffiffiffiffiffi ðj0000i þ j0001i þ . . . þ j1111iÞ pffiffiffi ðj0i j1iÞ ð7:72Þ
24 2
The next step is to apply the oracle function to the ancilla qubit. The oracle function y f(x) is
implemented using CNOT gates with the data registers as the control qubits and the ancilla qubit as
the target. This step is an excellent example of how quantum parallelism works. Each state of the data
register needs to be CNOT with the states of the ancilla qubit. The new state of the system can be
written as:
1
¼ pffiffiffiffiffi pffiffiffi ½j0000i ðj0 0 0 0 0i ðj1 0 0 0 0iÞÞ
4
2 2
þj0001iðj0 0 0 0 1i ðj1 0 0 0 1iÞÞ
þ...þ
þj1111i ðj0 1 1 1 1i ðj1 1 1 1 1iÞÞ
Applying XOR operations to the second term, this equation reduces to the following equation:
1
¼ pffiffiffiffiffi pffiffiffi j0000i½ ðj0i j1iÞ j0001i ðj0i j1iÞ j0010iðj0i j1iÞ
24 2
ð7:74Þ
þ j0011iðj0i j1iÞ þ . . . þ j1111iðj0i j1iÞ
// # Summary
/// Implements the balanced function.
///
/// # Inputs
/// q - an array of qubits
/// n - the total number of qubits in the data register.
/// The ancilla qubit is just next to
/// input - a number whose binary form is the hidden string
/// # Summary
/// Implements the constant function. Sets the ancilla qubit to 1,
/// if we have to output 1. No actions, otherwise.
///
/// # Inputs
/// q - an array of qubits
/// n - the total number of qubits in the data register.
/// The ancilla qubit is just next to this
/// constant - 0 - No actions, 1 - if we have to output 1.
Listing 7.13 The helper functions implementing the balanced and constant functions
7.4 The Bernstein–Vazirani Oracle 297
1 1
¼ pffiffiffiffiffi ½j0000i j0001i j0010i þ j0011i þ ⋯ þ j1111i pffiffiffi ðj0i j1iÞ ð7:75Þ
24 2
The kets belonging to the data register can be split, and this equation can be rewritten.
1 1 1 1
¼ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ
2 2 2 2
ð7:76Þ
1
pffiffiffi ðj0i j1iÞ
2
When we measure the data register, it is projected to the state “1111” deterministically (see
Fig. 7.13), indicating that it is a balanced function. We ignore the ancilla qubit.
This algorithm was first proposed in 1992 by the British physicist David Deutsch and the
Australian mathematician Richard Jozsa. The Deutsch–Jozsa algorithm is of no practical use but
is a good example where quantum parallelism is used. Besides, this algorithm is also an excellent
example of a deterministic quantum algorithm. The classical method requires 2N-1 + 1 evaluations,
whereas the quantum method can perform the same evaluation with one evaluation. Deutsch–Jozsa
algorithm demonstrates an exponential speedup that quantum computing can offer.
Exercise 7.3
1. Try this code on a backend.
2. Derive the equations for a constant function.
3. Derive the equations with the hidden string in use and prove that it still works.
◄
Now that we have learned about the oracle functions, we can focus on a couple of more such
problems. The next in line is the Bernstein–Vazirani Oracle. This oracle is similar to the Deutsch–
Jozsa problem, and it is defined as follows:
Given a function f : {0, 1}n ! {0, 1}, with the oracle function f(x) ¼ a ∙ x, where a is a constant
vector of {0, 1}n. a ∙ x is a scalar product of a and x. The goal of the oracle is to find the hidden bit
string a.
A classical solution to this problem requires n steps. We can retrieve the hidden string
a (a0a1a2. . .an 1) by querying the oracle with a value of x, such that each query returns one of the
bits in the hidden string. For example (note that the bits are reversed in the argument to the function):
298 7 Quantum Algorithms
f ð0001Þ ¼ a0
f ð0010Þ ¼ a1
ð7:79Þ
f ð0100Þ ¼ a2
f ð1000Þ ¼ a3
After querying all the bits, we can stitch the results and obtain the hidden string (a0a1a2a3).
There are a few ways to solve this problem on a quantum computer, and we can get the answer in
one step. In this exercise, we solve this in a similar way to the Deutsch–Jozsa problem. The block
diagram for the solution to the Bernstein–Vazirani oracle is given in Fig. 7.16.
We can implement the oracle function as a set of CNOT gates, with the ancilla qubit as the target
and the data register qubits corresponding to the bit value of the hidden string a as the control qubits.
Figure 7.17 illustrates this for a hidden string 10 ¼ 1010b. Upon executing this circuit, we get the
histogram, as shown in Fig. 7.18.
Let us prove that the circuit works as intended.
Like the Deutsch–Jozsa algorithm, we start the system state with both the data register and the
ancilla qubit initialized to j0i.
jψ i ¼ j0000ij0i ð7:80Þ
q[0]
q[1]
q[2]
q[3]
q[4]
jψ i ¼ j0000ij1i ð7:81Þ
H gates are applied to the system to put the qubits in a single large superposition state.
1 1 1
¼ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i þ j1iÞ
2 2 2
ð7:82Þ
1 1
pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2
After this step, we apply the CNOT gates. But not for all qubits in the data register. We apply them
for the qubits q[3] and q[1], representing the binary pattern 1010b, equivalent to decimal number 10.
For easy understanding, let’s first apply the CNOT between q[1] and the ancilla qubit. The system
state becomes:
CNOTð1, ancÞ 1 1
! pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2
CNOTð1, ancÞ
h i
1
! ðj00i j01i þ j10i j11iÞ
2 ð7:83Þ
1
¼ ðj00i j01i þ j11i j10iÞ
2
1 1
¼ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i j1iÞ
2 2
Note that the operation did not change the state of the ancilla qubit. We can write the next step after
applying the same logic to the qubit q[3], and combining all states in the right order.
1 1 1
¼ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2 2
ð7:84Þ
1 1
pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2
The final step is to apply H gates to the data register. We can safely ignore the ancilla qubit.
300 7 Quantum Algorithms
4 1 1 1 1 1
¼H pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ pffiffiffi ðj0i þ j1iÞ pffiffiffi ðj0i j1iÞ
2 2 2 2 2
1
¼ j1i j0i j1i j0i pffiffiffi ðj0i j1iÞ
2
ð7:85Þ
Upon measuring the data register, we get a “1010b” as expected, and it matches with the histogram
Fig. 7.18. Hence, we can confirm that the algorithm works with one step.
Code snippets are provided in Listing 7.14 for Qiskit and Listing 7.15 for QDK.
qc.barrier()
qc.barrier()
qc.barrier()
ResetAll(q);
}
Message($"The measured value is: {r} ");
return r;
}
Listing 7.15 (continued)
Ethan Bernstein and Umesh Vazirani first proposed this algorithm in 1992. This algorithm is
another example where we create a superposition of 2nstates. For the vector jai, the probability
amplitudes interfered constructively. For all other values, the probability amplitudes interfered
destructively, and their values are 0. The quantum version of this algorithm gets a linear speed up
advantage.
It is believed that Daniel Simon was analyzing the reported quantum algorithms, and he was not
satisfied that any of them gave an impressive speedup. Simon thought that there must be a theoretical
limit that prevents anyone from getting the much-promised exponential speedup. In a quest to find
that limit, in 1994, he ended up finding an oracle-based function with an exponential speedup [3]. The
Quantum Fourier Transform and Shor’s algorithm were invented around the same time.
Simon’s algorithm uses quantum parallelism and quantum interference. Hence, a study of Simon’s
algorithm helps in understanding complex algorithms such as Shor’s. Therefore, our next step is to
explore Simon’s algorithm. Here is the definition of Simon’s problem, to start with:
Assume we have an oracle function that maps n-bits to n-bits, that is, f : {0, 1}n ↦ {0, 1}n. Also,
assume that the oracle function is guaranteed to satisfy the condition: f(x) ¼ f( y) ⟺ y ¼ x a.
Simon’s problem is then querying the oracle function and determining whether the hidden string
a ¼ 0n or a 6¼ 0n.
If a ¼ 0n, then the oracle function is a one-to-one function (Table 7.3). If a 6¼ 0n, then the function
is a two-to-one function. A one-to-one function produces a unique output for each input. A two-to-one
function produces a unique output for two inputs (Table 7.4).
Table 7.4 illustrates a two-to-one function. By examining this table, we can trace four distinct
values: 000, 001, 010, 011. Each distinct value is repeated twice. Let us choose one of these distinct
values: 011. The corresponding x values are 000 and 011. The hidden string a ¼ 000 011 ¼ 011.
We can verify this for other distinct values. From the table, we can recognize the following property.
f ð x Þ ¼ f ð x aÞ ð7:86Þ
f ð x Þ ¼ f ð x aÞ ¼ f ð x a aÞ ð7:87Þ
This equation means f(x) is periodic with the period a, in bitwise mod 2 operation. We shall use this
property in later sections.
Solving Simon’s problem classically is somewhat challenging. One way to determine the hidden
string a, is to keep calling the oracle function until we find two repeat values. Let us assume that we
had to call the oracle function i times to detect a repeat value. The number of pairs we may have
compared is iði1 Þ
2 2 . This is the minimum number of pairs
n
that need to be examined before
n
determining a. The complexity of this classical method is O 22 , exponential to n. Therefore, the
number of times we call the oracle function grows exponentially with n, the number of bits in the
hidden string a.
Figure 7.19 shows the block diagram of the quantum circuit that solves Simon’s problem.
In this circuit, we use two sets of quantum registers: REG 1 and REG 2. We use a Walsh–
Hadamard transform on REG 1 before it is connected to the oracle function. At the output section of
the oracle function, we first measure REG 2. We apply a Walsh–Hadamard transform on
REG 1 before it is measured.
Like the previous algorithms, we start the system with REG1 and REG2 in state j0i.
where x 2 {0, 1}n denotes an n-bit string. The summation is over 2n such strings. The next step is to
perform the oracle function on REG 2. This task is performed in one step using quantum parallelism.
1 X
jψi ¼ pffiffiffiffinffi jxi j0 f ðxÞin
2 x2f0, 1gn
ð7:90Þ
1 X
¼ pffiffiffiffinffi jxi jf ðxÞin
2 x2f0, 1gn
304 7 Quantum Algorithms
Now, we have two options, if a ¼ 0n, then each value of f0(x) is unique. This means, the first
register jxi has an equal probability of being in any state over x 2 {0, 1}n.
If a 6¼ 0n, then from our definition of the problem, the function f0(x) can have two possible values
of x, which we can denote as x0 and x0 a.
Thus, the act of measuring REG 2 has a side effect on REG 1. REG 1 collapses into a superposition
state of jxin for which f(x) has two solutions x0 and x0 a. This is an example of quantum
interference. The terms which are not the probable solutions are canceled out due to destructive
interference. The probability amplitudes of the states, which are probable solutions, are increased due
to constructive interference. The new state of the system is as follows.
1
jψ i ¼ pffiffiffi jx0 in þ jx0 ain ð7:93Þ
2
This new state has an equal probability for all possible strings x0 2 {0, 1}n. Note that we have
omitted REG 2 as it is measured, and we do not need it anymore. We proceed with our examination of
this algorithm by taking up the second case. We shall return to the first case a ¼ 0n towards the later
stage of our discussion.
The next step is to apply a Walsh–Hadamard transform to REG 1.
1 X
H n jxin ¼ pffiffiffiffinffi ð1Þxy jyin ð7:94Þ
2 y2f0, 1g n
In this equation, y 2 {0, 1}n denotes an n-bit string. The summation is over all possible n-bit
strings. x ∙ y represents the bitwise inner product mod 2 defined as x y ¼ x0 y0 x1 y1 x2 y2
⋯ xn1 yn1 .
Applying this in Eq. (7.93) and omitting REG 2, we get:
1
jψi ¼ pffiffiffi H n ðjx0 in þ jx0 ain Þ
2
X ð7:95Þ
1
¼ pffiffiffiffiffiffiffiffiffi ð1Þx0 y þ ð1Þðx0 aÞy jyin
2nþ1 y2f0, 1gn
At this stage, let us focus on the term ð1Þx0 y þ ð1Þðx0 aÞy . From Boolean algebra, recall that
(x0 a) y ¼ (x0 ∙ y) ⨂ (a y).
Applying this logic and rewriting the terms, we get:
1 X
jψi ¼ pffiffiffiffiffiffiffiffiffi ð1Þx0 y ð1 þ ð1Þay Þ jyin ð7:96Þ
2nþ1 y2f0, 1g n
7.5 Simon’s Algorithm 305
By examining this equation, we can conclude a few points. The amplitude ð1Þx0 y ð1 þ ð1Þay Þ
is non-zero, only if a ∙ y ¼ 0. Besides, each of these amplitudes has an equal magnitude pffiffiffiffiffiffi
1 ffi
nþ1
. This
2
means, when we measure REG 1, we uniformly get randomized bit strings y, such that a ∙ y ¼ 0. Now,
we have a set of strings y, such that a ∙ y ¼ 0. The question is, how do we find a from this.
We run this function n times and get n strings: y1y2y3. . .yn. With these n strings, we have
n equations: a. y1 ¼ 0; a. y2 ¼ 0;. . . a. yn ¼ 0. If y1y2y3. . .yn are linearly independent, then we can
quickly solve this system of equations, and the total number of possible substrings is 2n. Say, if we
tried this algorithm for a few times more than n, then the probability of getting n linearly independent
strings is:
1 1 1 1
Pr ¼ 1 1 1 2 ... 1 n > ð7:97Þ
2 2 2 4
If we are not finding the set of linearly independent string yi, we can keep calling the function
beyond the n attempts, until we can determine a. If we totally cannot get the required set of linearly
independent strings, then it means a ¼ 0n. The probability of this occurrence is given by:
1 4x
Pr ¼ 1 < ex ð7:98Þ
4
If we try this for x ¼ 10 times, the error rate is approximately 1 in 10000. The advantage of this
algorithm is that the number of times we need to try beyond n is not dependent on n. The classical
n
algorithm requires 22 steps, whereas the quantum version requires a little over n steps, which is an
exponential advantage.
Figure 7.20 shows the histogram and Fig. 7.21 shows the quantum circuit that implements Simon’s
algorithm for the hidden string 011b ¼ 3.
Listing 7.16 implements Simon’s algorithm in Qiskit. Listing 7.17 puts the code together and
plots the output.
We can obtain the value of the hidden string from the output a ¼ 3 ¼ 011b. Let us conclude this
section by deriving the math for the circuit, shown in Fig. 7.21. We begin the system with the registers
REG 1 and REG 2 initialized to the default state.
jψ i ¼ j000ij000i ð7:99Þ
q[0]
q[1]
q[2]
q[3]
q[4]
q[5]
Fig. 7.21 The Simon’s algorithm for the hidden string 011b
# Simons function
# qc – the quantum circuit
# a – the hidden string
qc.barrier()
q = QuantumRegister(numberofqubits , 'q')
c = ClassicalRegister(numberofqubits , 'c')
qc = QuantumCircuit(q, c)
simons_func(qc, a)
qc.draw('mpl')
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=shots)
counts = job.result().get_counts()
Listing 7.17 Code fragment to plot the histogram for REG 1 alone
1
¼ pffiffiffiffiffi ðj000i þ j001i þ j010i þ j011iþ
23 ð7:101Þ
j100i þ j101i þ j110i þ j111iÞ j000i
1
¼ pffiffiffiffiffi ðj000ij000i þ j001ij000i þ j010ij000iþ
23
ð7:102Þ
j011ij000i þ j100ij000i þ j101ij000iþ
j110ij000i þ j111ij000iÞ
We now apply the oracle function to REG 2. This applies the value of f(x) for the corresponding
value of x, from Table 7.4 for the two-to-one function. The new system state is as follows.
1
¼ pffiffiffiffiffi ðj000ij011i þ j001ij010i þ j010ij010iþ
23
ð7:103Þ
j011ij011i þ j100ij000i þ j101ij001iþ
j110ij001i þ j111ij000iÞ
308 7 Quantum Algorithms
Let us analyze this state carefully. When we measure REG 2, it has an equal probability of
measuring one of the following values: 000, 001, 010,011. If we assume that we measured REG 2 as
011, then the state of REG 1 collapses to the following state due to quantum interference.
1
¼ pffiffiffi ð j000i þ j011iÞ ð7:104Þ
2
We can now apply the second Walsh–Hadamard transform to REG 1. To make our understanding
easier, we can apply the H transforms qubit by qubit and expand the equation.
Applying the H gate on the first qubit, we get:
1
¼ pffiffiffiffiffi ð j000i þ j100i þ j011i þ j111i Þ ð7:105Þ
22
We can now apply the H gate on the second qubit, expanding the system state as follows:
1
¼ pffiffiffiffiffi ð j000i þ j010i þ j100i þ j110i þ j001i j011i þ j101i j111iÞ ð7:106Þ
23
Finally, we apply the H gate on the third qubit.
1
¼ pffiffiffiffiffi ðj000i þ j011i þ j010i þ j011iþ
24
j100i þ j101i þ j110i þ j111iþ ð7:107Þ
j000i j001i j010i þ j011iþ
j100i j101i j110i þ j111iÞ
Due to quantum interference, opposite terms cancel out. This equation reduces to the following:
1
¼ ð j000i þ j011i þ j100i þ j111i Þ ð7:108Þ
2
Let us rewind a bit to Eq. (7.103) and check what would happen if we measured other values in
REG 2. For example, if we measured 001 in REG 2, REG 1 collapses as follows:
1
¼ pffiffiffi ð j101i þ j110iÞ ð7:109Þ
2
We now apply the H transforms. Applying the H gate on the first qubit,
1
¼ pffiffiffiffiffi ð j001i j101i þ j010i j110i Þ ð7:110Þ
22
Applying H gate on the second qubit,
1
¼ pffiffiffiffiffi ð j001i þ j011i j101i j111i þ j000i j010i j100i þ j110iÞ ð7:111Þ
23
Applying H gate on the third qubit,
1
¼ pffiffiffiffiffi ðj000i j011i þ j010i j011i
24
j100i þ j101i j110i þ j111i ð7:112Þ
þ j000i þ j001i j010i j011i
j100i j101i þ j110i þ j111i
7.6 Quantum Arithmetic Using QFT 309
This equation reduces to the following. We can safely ignore the negative phase factors.
1
¼ ð j000i j011i j100i þ j111i Þ ð7:113Þ
2
Therefore, when we measure REG 1, it can be projected to one of the following values with equal
probability: 000, 011, 100, 111. We can readily solve these values for a ¼ 011 using classical methods.
Code example for QDK is included in the Appendix.
In Sect. 7.1, we learned about constructing a simple ripple adder. In this section, we shall learn about
using QFT to do arithmetic [7]. When we compare with classical methods, these are not efficient ways
of doing arithmetic. However, these methods are used in modular exponentiation and similar
algorithms requiring number work with superposition states. The first circuit we shall build is a
simple QFT adder, followed by a controlled QFT adder, and a QFT-based quantum multiplier circuit.
The algorithm for the QFT-based adder was introduced by Draper in 2000 and optimized the number
of qubits required to perform the addition. The algorithm takes two numbers, a and b, as the inputs
and computes QFT(b) as the first step. The number a is added to this by the application of a set of
rotations, moving the system state to QFT(a + b) in the Fourier basis. Finally, an inverse QFT
transforms the system state to (a + b), which is the desired output in the computational basis.
Recall the 4-qubit QFT shown in Fig. 7.22. We have just swapped the order of the transform, to
avoid the additional swap operations. Referring to Eq. (7.58), we can write the system’s state with a
bit of shorthand.
1
QFTjbi ¼ jϕðbÞi ¼ pffiffiffi j0i þ eð0:b4 Þ j1i
2
ðj0i þ eð0:b3 b4 Þ j1iÞ ðj0i þ eð0:b2 b3 b4 Þ j1iÞ ð7:114Þ
ðj0i þ eð0:b1 b2 b3 b4 Þj1iÞ
Fig. 7.23 The adder circuit sandwiched between QFT and inverse QFT layers
This circuit adds a systematic set of controlled U1 rotation gates to the quantum register b, which
is now in a Fourier basis, due to the action of the earlier QFT stage. The controlled U1 gates add a
phase factor to the register b.
From Eq. (5.49), and Sect. 5.4.6.6, the action of the cU1 gate on a system jaiN|biN can be
written as:
cU1ðπÞjaiN jbiN ¼ e jaiN jbiN
i2πab
N ð7:115Þ
For now, let us drop the superscript notation and rewind a bit to apply the QFT on the register jbi.
Register jbi is now in the Fourier basis jϕ(b)i
1 X i2πbk
N 1
QFTðbÞ
jaijbi ! pffiffiffiffi e N jaijki, ð7:116Þ
N k¼0
1 X i2πbk
N 1
i2πak
CU1ðλ, a, bÞ pffiffiffiffi e N e N jaijki
! N k¼0
ð7:117Þ
1 X i2πðaþbÞk
N 1
! pffiffiffiffi e N jaijki
N k¼0
By applying an inverse QFT, we can transform the system into the computational basis.
1 X i2πðaþb
N 1
Þk i2πkl
IQFT e N e N jaijli
! N k, l¼0 ð7:118Þ
! jaijða þ bÞ mod N i
n -= 1
qc.barrier()
qft_cct(qc, b, n)
add_cct(qc, a, b, n)
iqft_cct(qc, b, n)
Fig. 7.24 Part of a controlled adder circuit. Note that this circuit is sandwiched between a QFT and inverse QFT parts
Before developing the multiplication algorithm, we must construct the controlled QFT adder.
Consider the adder circuit shown in Fig. 7.24. This circuit is implemented using a doubly controlled
U1 gate (ccu1). Note that the development environments do not readily support the ccu1 gates.
However, we can construct a ccu1 unitary ourselves.
This circuit has a property of providing the following output ja + b + si. If we start jsi in a state of
j0i, it produces an output of ja + bi. Similarly, we can produce controlled versions of QFT and IQFT
operations as well. The source code for implementing the doubly controlled U1 gate is provided in
Listing 7.19.
# Implements a doubly controlled U1 gate.
# qc - quantum circuit
# theta - angle of rotation.
# q0 - Control qubit #1
# q1 – Control qubit #2
# q2 – Target qubit
# qc - quantum circuit
# b - the target register
# offset - the starting qubit in register b to work from
# control - the control qubit.
# n - number of qubits in the register
We can use the doubly controlled U1 gate to build a controlled adder circuit as a reusable block.
The function c_add_qft in the Listing 7.19 explains the sequence of instructions needed to build this
block. We begin with a controlled QFT and then apply the controlled addition, followed by the
controlled inverse QFT.
Type the following code into a new cell in the Jupyter notebook. The code developed earlier can be
reused to import the required components and set up IBM Q. The method “c_add_qft” is called to
perform the controlled addition. Developing a unit testing code to verify whether the controlled
addition works is a good exercise.
We all know that multiplication is nothing but repeated addition. By stacking up a series of controlled
QFT adder blocks, we can implement a multiplication module. Consider the block diagram illustrated
in Fig. 7.25.
The above quantum circuit multiplies two n-bit numbers a and b by performing n successive
controlled QFT additions. The result is stored in the register s with size 2n.
The first controlled QFT adder block, labeled as 20∑, has the least significant qubit of register an as
the control qubit. Register s is initially prepared in the state j0i. The adder block first performs a QFT
on register s, producing the state jϕ(0)i. After this, the 20∑ block applies a series of conditional phase
rotation gates to evolve the state into jϕ(0 + b)i. This block is controlled by the least significant qubit
of register a. So the state can be written as jϕ(0 + an20b)i. Finally, the block applies an inverse QFT,
moving the system state to j0 + an20bi.
The qubit an 1 controls the second controlled QFT adder 21∑. The scale factor for the phase
addition at this level is 21. We can calculate the output state of this stage to be j0 + an20b + an 121b i.
We continue to apply the rest of the controlled QFT adder blocks in the circuit. When all the blocks
are added, the output state becomes:
¼ 0 þ an 20 b þ an1 21 b þ . . . þ a1 2n1 b
¼ j0 þ a b i ð7:119Þ
¼ j a bi
The code in Listing 7.20 can be used to test the Quantum Multiplier. Use the import modules from
previous exercises. Use the controlled adder function “c_add_qft,” and the set register function
“set_reg” from previous exercises.
a = QuantumRegister(n , 'a')
b = QuantumRegister(n , 'b')
s = QuantumRegister(n*2 , 's')
c = ClassicalRegister(n*2 , 'c')
qc = QuantumCircuit(a, b, s, c)
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=shots)
counts = job.result().get_counts()
#print (counts)
if (1 < len(counts)):
print("More than one result!")
else:
scounts = str(counts)
myproduct = \
int("0b"+scounts[scounts.index("{")+2:scounts.index(":")-1], 2)
#print(myproduct)
Listing 7.20 The quantum multiplier and code to test its function.
7.7 Modular Exponentiation 317
return myproduct
#
# Test the multiplier and confirm it works…
#
for i in range (7):
print("testing in the range of: ", i)
for j in range (7):
res = test_mult(i,j, 4)
if ( res != (i*j)):
print ("error, got", res, "expected:", i*j)
print("done")
Listing 7.20 (continued)
Exercise 7.4
1. Implement a quantum subtraction circuit.
2. Implement a generic quantum adder/subtractor that can handle overflows/underflows and nega-
tive integers.
3. Implement a quantum divider circuit.
◄
Note: Reading Sect. 6.8 on RSA security may be helpful to read the following section
in this chapter.
In the previous chapter, we learned about modular exponentiation when we discussed the RSA
security. Recall from section 6.8.1 that modular exponentiation calculates the remainder, when an
integer a raised to the xth power (that is, ax) is divided by a positive integer N, called the modulus.
Using symbols, we can write this as c ¼ ax mod N: Table 7.5 illustrates this operation by assuming
a ¼ 2 and N ¼ 15.
We can calculate this using the direct method—calculate ax first, and then perform mod N, using a
calculator.
If we can state x in its binary form (xn 1xn 2xn 3. . .x0), we can expand the modular
exponentiation as follows:
0 x0 1 x1
ax mod N ¼ a2 mod N a2 mod N ⋯
n1 xn1 ð7:120Þ
a2 mod N mod N
318 7 Quantum Algorithms
q[0]
REG 1 q[1]
q[2]
q[3]
REG 2 q[4]
q[5]
q[6]
This can be constructed as a circuit using controlled multiplier blocks, as shown in Fig. 7.26.
In this circuit, each of the controlled multiplier blocks performs a multiplication of the input REG
i
2, by a constant function a2 mod N. Each of these controlled multiplier blocks is controlled by the
respective qubit xi in REG 1. If we assume jx i as the control qubits (REG 1) and jy i as the target
qubits (REG 2), this operation produces:
i x
CU a2i jx ijy i ¼ jx i a2 y mod N ð7:121Þ
Let us calculate the inner workings of this circuit with an example that performs 2x mod 15 .
Consider the circuit shown in Fig. 7.27. In this circuit, REG 1 is formed by qubits q[0] to q[2]. REG
2 is formed by qubits q[3] to q[6].
7.8 Grover’s Search Algorithm 319
We can write the state of the system after application of the Walsh–Hadamard transform and the X
gate as follows:
0 1
j000ij0001i þ j001ij0001i þ j010ij0001i
1 B C
jψ i ¼ pffiffiffi B
@ þj011ij0001i þ j100ij0001i þ j101ij0001i þ j110ij0001i C A
8 ð7:122Þ
þj111ij0001i
The application of the first block of multiplier converts this state as follows:
0 1
j000ij0001i þ j001ij0010i þ j010ij0001iþ
1 B C
¼ pffiffiffi B@ j011ij0010i þ j100ij0001i þ j101ij0010iþ C A
8 ð7:123Þ
j ij
110 0100 þ
i j 111 ij 0010 i
After the application of the second block:
0 1
j000ij0001i þ j001ij0010i þ j010ij0100iþ
1 B C
¼ pffiffiffi @ j011ij1000i þ j100ij0001i þ j101ij0010iþ A ð7:124Þ
8
j110ij0100i þ j111ij1000i
At this stage, if we measure REG 2 (that is, the qubits q[3] to q[6] in the diagram), we can find that
the system is projected to the following states: 0001, 0010, 0100, 1000 with equal probability. By
comparing these values with Table 7.5, we can conclude that this circuit has performed modular
exponentiation.
Exercise 7.5
1. Implement this circuit using Qiskit and QDK.
2. Design a circuit for 4x mod 15:
Grover’s algorithm [10] uses amplitude amplification, an interesting technique we have not seen so
far. This algorithm was introduced by Lov Grover [9] in 1996. Notably, this algorithm exhibits
quadratic speedup.
320 7 Quantum Algorithms
Imagine that we have access to a phone directory. We are given a phone number and asked to find
to whom the phone number is associated. Phone directories are usually not arranged by the phone
number. We have to go through each entry in the phone directory to determine whom the phone
number belongs. At an average, it may take N2 attempts to find the right answer, which is somewhat
difficult if the phone book is large.
Grover’s algorithm solves the problem of unstructured search. The search is called unstructured
because we do not have any guarantee that the database is sorted in some fashion. The Grover’s
algorithm takes a number corresponding to an entry in the database as its input and performs a test to
pffiffiffiffi
see if this is the special value ω being searched for. This search is done in about π4 N steps, a
quadratic speedup compared to the classical algorithm described above. The Grover’s search is
defined as follows.
Given a set of N elements forming a set X ¼ {x1, x2, x3, . . ., xN}, and given a Boolean function
f : X ! {0, 1}, the goal is to find an element ω in X such that f(ω) ¼ 1.
Before solving the problem, let us make some assumptions.
• The element ω, which satisfies the equation f(ω) ¼ 1, is unique. We shall relax this condition at the
end of the discussion.
• The size of the database is a power of 2, that is, N ¼ 2n. Some padding may be required to
achieve this.
• The data are labeled as n-bit Boolean strings {0, 1}n.
• The Boolean function f maps {0, 1}n to {0, 1}.
Let us assume that we define an oracle function O b which produces a transformation function:
O jxi ! jf ðxÞi. Unfortunately, this is not unitary, as it takes an n-bit string and produces a single bit
as an output. The solution is to use an oracle black-box function, as shown in Fig. 7.10, which is quite
familiar to us from our past exercises. Let us now define the oracle function O, b acting on the n-qubit
input register jxi.
(
b jxi ¼ ð1Þ f ðxÞ jxi if f ðxÞ ¼ 0
O jxi ¼ ð7:126Þ
jxi if f ðxÞ ¼ 1
Consider the block diagram shown in Fig. 7.28. In this diagram, we start the system with all qubits
initialized to state j0i. We then apply a Walsh–Hadamard transform to put the qubits in an equal
superposition state. The state of the system can be written as follows:
1 X
jψi ¼ pffiffiffiffi jxi ð7:127Þ
N x2f0, 1gn
All the qubits have the same amplitude p1ffiffiNffi at this stage. We can plot this in a bar graph, as shown in
Fig. 7.29.
b The oracle function negates the amplitude of the state ω. The
The next step is to apply the oracle O.
rest of the states remain unaffected by the oracle. Equation (7.128) shows the new system state. We
can graph the amplitudes of all possible states, and this is shown in Fig. 7.30.
7.8 Grover’s Search Algorithm 321
Fig. 7.29 Bar graph showing the amplitudes of the possible systems states at Stage-1, using a 3-qubit system for
illustration
1 1 X
jψi ¼ pffiffiffiffi jωi þ pffiffiffiffi jxi ð7:128Þ
N N x 2 0, 1 n
f g
x 6¼ ω
Now that the amplitude of the state jωi has changed, let us calculate the mean of the amplitudes to
ascertain we are on the right path. The mean of the amplitudes μ is given by the following standard
equation for calculating mean from a set of values
1 X
μ¼ ax , ð7:129Þ
N
x2f0, 1gn
322 7 Quantum Algorithms
Fig. 7.30 Bar graph after applying the oracle function. Note that the amplitude of ω is negated. The amplitude of rest
of the states remains almost the same
where ax is the amplitude of a given x in the range {0, 1}n. We can expand this equation to calculate
the value of μ at this stage. The mean of the amplitudes is now given by the following equation:
1 ð 2n 1Þ 1 2n 2
μ¼ pffiffiffiffi pffiffiffiffi ¼ pffiffiffiffi
N N N N N
ð7:130Þ
N 1
pffiffiffiffi ¼ pffiffiffiffi
N N N
Hence, the amplitude for most terms is approximately p1ffiffiNffi . We see that the amplitude has not
significantly changed, and the term p1ffiffiffi is relatively insignificant for large values of n.
N
We can now proceed with the next stage. The next stage in the quantum circuit is called the
Grover diffusion operator (also called amplitude purification). The Grover diffusion operator
performs the following mapping:
X X
ax jxi↦ ð2μ ax Þjxi ð7:131Þ
x2f0, 1gn x2f0, 1gn
We can plot the bar graph of the system states to get an understanding of this operator. Figure 7.31
illustrates the system state at this stage.
From the graph, we find that the system states almost remain the same, except for the state ω. The
amplitude of ω gets amplified by a factor of about 3:
The combination of these two steps – the oracle function and the Grover Diffusion Operator – is
called Grover Iteration.
To amplify ω further, let us apply the Grover Iteration one more time. Figure 7.32 illustrates the
state of the system after the second iteration.
By studying the graph, we can conclude that the amplitude of ω gets magnified linearly ptffiffiNffi with
pffiffiffiffi
each iteration (being the number of solutions.) By applying this cycle for O N times, the amplitude
of ω should exceed a threshold value. Beyond that point, the large negative amplitude of ω (when the
7.8 Grover’s Search Algorithm 323
Fig. 7.31 Bar graph at Stage-3. Note that the amplitude of state ω is amplified greatly, while the amplitude of the rest
of the states remains almost the same
oracle O b flips it) can reduce the overall mean value causing a reduction in the amplitude when the
Grover Diffusion Operator is applied.
Note that Grover’s algorithm magnifies the amplitude and not the probability amplitude. With
pffiffiffiffi
O N iterations, the Grover algorithm solves the problem, whereas a classical solution requires
O(N ) steps. This quadratic speedup is because quantum parallelism computes f(x) for all the N ¼ 2n
pffiffiffiffiffiffiffiffiffi
states in parallel. If in case there are multiple solutions k to the problem, we would need O N=k
iterations.
Let us now implement a 3-qubit version of Grover’s algorithm based on the oracle function and the
Grover diffusion operator defined by C. Figgatt [8] et al.
324 7 Quantum Algorithms
b that acts on an
The goal of the oracle function is to implement a unitary transformation function O
n-qubit input register and a 1-qubit output register. The function applies an X gate to the output
register when the input register is equal to ω. We can write this transformation as follows:
bjxin jyi ¼
O jxin jy f ðxÞi ð7:132Þ
This function can be implemented as a multi-control Toffoli gate. Figure 7.33 illustrates a 3-qubit
oracle with a hidden value of ω ¼ 010.
The Toffoli gate switches the target (that is, the output register), when all control registers are in
state j1i. For the circuit shown in Fig. 7.33, this is when the jxi ¼ 010.
The quantum circuit for implementing the Grover Diffusion Operator is given in Fig. 7.34.
The code fragments implementing the three control Toffoli gate and Grover’s oracle are provided
in Listing 7.21.
The CCZ gate shown in the circuit is not a standard implementation. We must implement it as a
compound gate. The code snippet implementing this circuit is given in Listing 7.22 for quick
reference.
Listing 7.23 puts all components together. Note that we must repeat the Grover Iteration three
times to get the desired output.
We find that after the third iteration ω is amplified to the desired level. It is a good exercise to
change the number of iterations and observe this growth. The histogram at the end of the cycle is
shown in Fig. 7.35.
To complete our discussion on this section, we can derive the underlying math. We start the system
with jxi3jyi in state j0i.
We then apply a Walsh–Hadamard transform to put the system in an equal superposition state.
7.8 Grover’s Search Algorithm 325
Listing 7.21 Code implementing the Grover’s oracle and a 3 control Toffoli gate
1
¼ pffiffiffi j000i þ j001i þ j010i þ j011i þ j100iþ
8
ð7:135Þ
1
j101i þ j110i þ j111i Þ pffiffiffi ðj0ij1iÞ
2
At this stage, we proceed with the application of the first Grover Iteration. The oracle function flips
the state of ω. The resultant state can be derived by applying the gates, step by step.
1
jψ i ¼ pffiffiffi ð j000i þ j001i j010i þ j011i þ j 100i þ j101i þ j110i þ j111iÞ
8
1
pffiffiffi ðj0i j1iÞ ð7:136Þ
2
The next step is to apply the Grover Diffusion operator, which amplifies each state by a factor
(2μ ai). The action of the H gate on register jyi changes it to state j1i. Since μ ¼ p1ffiffi8, we find that the
amplitudes of all states remain the same. However, the state of ω becomes p3ffiffi. The new state can be
8
written as:
1 3
jψ i ¼ pffiffiffi ðj000i þ j001i þ j011i þ j100i þ j101i þ j110i þ j111iÞ þ pffiffiffi j101i j1i ð7:137Þ
8 8
For the rest of our discussions, let us assume μ ¼ p1ffiffi8 . For large values of n, the changes to μ is
insignificant. At the end of the second iteration, the system changes to the following state.
326 7 Quantum Algorithms
1 5
jψ i ¼ pffiffiffi ðj000i þ j001i þ j011i þ j100i þ j101i þ j110i þ j111iÞ þ pffiffiffi j101i j1i
8 8
ð7:138Þ
Finally, at the end of the third state, the system changes to:
1 7
jψ ¼ pffiffiffi ðj000i þ j001i þ j011i þ j100i þ j101i þ j110i þ j 111iÞ þ pffiffiffi j101i j1i ð7:139Þ
8 8
From Eq. (7.139) we find that the amplitude of ω is magnified to p7ffiffi . This proves Grover’s
8
algorithm.
7.8 Grover’s Search Algorithm 327
#
# Grover's algorithm
#
shots = 1024
q = QuantumRegister(3 , 'q')
t = QuantumRegister(2 , 't')
c = ClassicalRegister(3 , 'c')
qc = QuantumCircuit(q,t, c)
qc.h(q[0])
qc.h(q[1])
qc.h(q[2])
qc.h(t[0])
qc.measure(q[0],c[0])
qc.measure(q[1],c[1])
qc.measure(q[2],c[2])
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=shots)
counts = job.result().get_counts()
plot_histogram(counts)
Exercise 7.6
1. Derive the complete math and workout changes to μ.
2. What happens when you perform a fourth iteration?
3. Develop a generic code that works for any value of n.
4. In what other systems could you implement Grover’s algorithm?
◄
Note: Reading Sect. 6.8 on RSA security may be helpful to read the following section
in this chapter.
In the previous chapter, we learned about the factorization of integers and RSA security. We
learned how the period r of a function f(x) ax mod N could be used to factorize an integer N into two
prime numbers p and q, such that N ¼ p q. Recall that a is a number that is coprime with N, and that
ar mod N ¼ 1.
In 1994, the American mathematician Peter Shor proposed a novel quantum algorithm for
factorizing large integers [11], which runs on a polynomial-time. Shor’s algorithm is not just
theoretical work. There is some experimental proof that Shor’s algorithm does work. In 2001, a
group of scientists at IBM factorized the integer 15, using Nuclear Magnetic Resonance (NMR). In
2012, the integer 21 was factorized, as of 2020, this is the most significant number to have been
factorized using Shor’s algorithm [4]. When large-scale quantum computers with error-corrected
qubits are available, we may be able to factorize large integers [5]. We shall factorize 15 later in this
section.
Shor solved the problem of factorizing integers by shifting the problem domain to finding the
period of the modular exponentiation function. Shor’s problem is stated as follows.
Given an integer N, and two prime numbers p and q such that N ¼ p q. Let a 2 ℤN. Let a
modular exponentiation function fa : ℤ+ ! ℤN defined as fa(x) ¼ ax mod N satisfy the condition,
f(x) ¼ f(x0) ⟺ x ¼ x0 + kr, where r is the period of fa, and k is an integer. Shor’s problem is
determining the period r by querying fa.
The block diagram of Shor’s algorithm is given in Fig. 7.36.
The block diagram pretty much looks like Simon’s algorithm, and it uses steps familiar to us
now—modular exponentiation and inverse QFT.
An interesting feature of Shor’s algorithm is the usage of inverse QFT to find the period r of the
equation f(x) ax mod N. The period r can be used to find the factors of N.
The algorithm uses two banks of qubit registers. The upper bank is called the source register, and
the lower bank is called the target register. The oracle function performs modular exponentiation on
7.9 Shor’s Algorithm 329
the source register and stores the values in the target register. This process is done in one step using
quantum parallelism.
The number of qubits s in the source, and target registers must be in the following range:
N 2 2s 2N 2 ð7:140Þ
s
From this range, 2r > N and it guarantees that when estimating the period r, N terms are
contributing to the probability amplitude, even if r is close to N2. This assumption creates a sufficiently
large state-space in the source register, which can contain even the longest periods. By having a large
value of s, we can explore a dense solution space, and the period r can be estimated as accurately as
possible. The modular exponentiation circuits require additional qubits to store intermediate infor-
mation. Hence, we have selected that the target register is also made of s qubits.
Before proceeding with the algorithm, we must perform some preprocessing tasks. First, we need
to check whether N is a prime number. There are some classical methods to do the primality check,
and it can be done efficiently on a classical computer. The second task is to identify a and confirm that
N and a are coprime. The third task is to determine the number of qubits required. After completing
these steps, the circuit can be constructed for execution.
Having constructed a quantum circuit, as shown in Fig. 7.36, let us examine the inner working of
this algorithm. As usual, we start the system with both the registers initialized to state j0i. The
following equation describes the system state at this stage.
We then apply a Walsh–Hadamard transformation to the source register, transforming the source
register into a single large superposition state comprising of all possible states of jxi from j000. . .0i to
j111. . .1i, including all the states in between.
The next step is to apply the modular exponentiation. For all states of the source register, we
calculate y f(x) and store in the target register jyi. We explained the concept of modular
exponentiation in Sect. 7.7.
1 X
2s 1
¼ pffiffiffiffis jxi f ðxÞj0is
2 x¼0
1 X
2s 1
¼ pffiffiffiffis jxijy f ðxÞi ð7:143Þ
2 x¼0
1 X
2s 1
¼ pffiffiffiffis jxi jf ðxÞi
2 x¼0
After performing the modular exponentiation, we measure the target register. Let us assume that
the target register projects to some value f(x0). Measuring the target register has a side effect of
collapsing the superposition state of the source register to the states for which f ðx0 Þ ¼ ax0 mod N.
Since f(x) is periodic in r, the possible values are of the form (x0 + kr). Note that x0 is the least x such
that f(x) is what was measured in the target register. This ensures k is strictly nonnegative. The new
state of the system is as follows:
2s
r 1
1 X
¼ q ffiffiffi jx0 þ krijf ðx0 Þi ð7:144Þ
s
2 k¼0
r
s
Since the period of f(x) is r, the measurement reduces the range of the source register to 2r . There
s
are 2s states. Hence, the maximum number of periods we can have is 2r , which is the range the system
collapses to when we measure the target register. At this stage, if we measure the source register, the
probability of getting a particular state is shown in Fig. 7.37. These states are the ones for which
f(x) ¼ f(x0) when we measured the target register. Hence, when we measure the source register, we
may get one of the values of (x0 + kr) for some value of k. Since we do not know the value of x0, it is
impossible to determine the value of r at this stage. Hence, we apply an inverse QFT to identify the
period. We can drop the terms pertaining to the target register, as it is measured, and we do not need it
anymore.
As discussed, the next stage is to apply an inverse QFT to the source register. From Eq. (7.59),
1 X 2πiN xy
ðN1Þ
jxi ¼ pffiffiffiffi e jyi, x ¼ 0 : N 1 ð7:145Þ
N y¼0
Applying the inverse QFT in Eq. (7.144) and dropping the term pertaining to the target register, we
get:
1 X X 2πi ðx20s þkrÞ y
ðQ1Þ ð2 1Þ s
1
jψi ¼ pffiffiffiffis pffiffiffiffi e jyi, ð7:146Þ
2 Q k¼0 y¼0
s
where Q ¼ 2r . The exponentials can be expanded now.
ðQ1Þ ð2 1Þ
1 X X
s
1 2πix0 y 2πikry
jψi ¼ p ffiffiffiffi p ffiffiffi
ffi e 2 s
e 2 s
jyi ð7:147Þ
2s Q k¼0 y¼0
Interested readers can derive the next step in detail and obtain Eq. (7.148). In this equation, we
have changed the order of the summation
ð2X
1Þ ðQ1Þ
2πix0 y X
s
1 2πiry k
jψi ¼ pffiffiffiffiffiffiffi
s
ffi e 2s e 2s jyi ð7:148Þ
2 Q y¼0 k¼0
The summation on the right-hand side is a geometric series. The sum of this term is non-zero, iff
2πiry
e 2s¼ 1: This is possible iff 2rys is an integer. This implies that the values of y, which are multiples of
s
2 2s
r , can have non-zero amplitudes. In other words when r is an integer, due to constructive quantum
interference, there is a peak in the value of y.
We can now calculate the probability of measuring a certain value y.
Q1 2
1 X 2πi2skr y
Pð y Þ ¼ s e ð7:149Þ
2 Q k¼0
ry
From our discussions above, when 2s is an integer, the exponentials add up nicely, and the
phase is ¼1.
r 2s 2s 1
PðyÞ ¼ ¼ : ð7:150Þ
2s 2s r r r
Let us now return to Eq. (7.148). The summation on the right-hand side reduces to a set of r values
due to the quantum interference and the equation contracts.
Assume that we measure the source register, and it projects y into the classical register c. The
s s
classical register then reads a value, which is a multiple of 2r , that is, c ¼ z 2r , where z is a random
variable in the range 0. . .r 1. With a little bit of derivation, the new system state can be written as
the following equation:
1 X 2πixr 0 z 2s
ðr1Þ
jψi ¼ pffiffi e z r ð7:151Þ
r z¼0
332 7 Quantum Algorithms
z 0 ¼ a0
r0 ¼ 1
z 1 ¼ a0 a1 þ 1
ð7:155Þ
r 1 ¼ a1
zn ¼ an zn1 þ zn2
r n ¼ an r n1 þ r n2
For each value of zi and ri, we check whether gcd(zi, ri) ¼ 1. After verifying this, we calculate the
function f(x) ¼ ax mod N by substituting x with ri. If f(ri) ¼ 1, it means the period of the function f(x) is
ri. If not, we go back and repeat the algorithm with another value of a or repeat the experiment.
Shor’s algorithm runs partly on a classical computer and partly on a quantum computer. Primality
check of N, choosing a value for a, and determining whether N and a are coprime are done as a
preprocessing step on a classical computer. Continued fractional expansion and verification of r are
done as postprocessing steps. Once r is known, one of the factors of N can be calculated from
gcd ðar=2
1, NÞ.
The fastest known classical algorithm that can factor large integers is the General Number Field
1 2
Sieve algorithm [12], which works in a sub-exponential time of O e1:9ð log NÞ3 ðloglog NÞ3 : According
to a study done in 2010 [13], factoring a 768-bit RSA modulus using the number sieve can take about
1,500 years on a system with 2.2 GHz Opteron AMD processor with 2GB of RAM. Shor’s algorithm
solves this in polynomial time of O((logN )2(log log N )(log log log N )), and it is an example of
Bounded-error Quantum Polynomial (BQP) problem [15–18].
In this section, we try to factorize 15 using Shor’s algorithm. Here are the preprocessing steps.
• Select the number of qubits. 24 > N. So let’s select two sets of 4-qubit registers. Ideally, we should
go for 8-qubit registers, but since the range is small, 4-qubit registers should be sufficient.
After the preprocessing steps are completed, the quantum circuit is constructed, and we start the
system by initializing both the registers to j0i.
1 X
15
jψi ¼ pffiffiffiffiffi jkij0000i ð7:157Þ
16 k¼0
k 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
f(k) 1 13 4 7 1 13 4 7 1 13 4 7 1 13 4 7
From this table, we can easily find that the period is 4. But, let us continue with the algorithm and
verify this at the end,
1 X
15
jψ i ¼ pffiffiffiffiffi j k ij f ðk Þi
16 k¼0
1
¼ pffiffiffiffiffi ðj0ij f ð0Þi þ j1ij f ð1Þi þ . . .Þ
16
0 1
j0ij1i þ j1ij13i þ j2ij4i þ j3ij7i þ j4ij1iþ ð7:158Þ
B C
B j5ij13i þ j6ij4i þ j7ij7i þ j8ij1i þ j9ij13iþ C
1 B C
¼ pffiffiffiffiffi B
B
C
C
16 B j10ij4i þ j11ij7i þ j12ij1i þ j13ij13iþ C
@ A
j13ij4i þ j15ij7i
At this stage, we measure the target register. The target register can measure any of the 4 possible
states – j1i, j13i, j4i, j7i which are in equal probability.
Assume that we got a “7.” This collapses the superposition state of the source register into the
states for which f(x) ¼ 7. The target register is measured. We don’t need it anymore. Hence it is
dropped from the equation. The new system state is as follows, after normalization.
rffiffiffiffiffi
4
jψ i ¼ ðj3i þ j7i þ j11i þ j15iÞ ð7:159Þ
16
When we solve this, we get an equal probability 14 for the 4 states j0i, j4i, j8i, j12i. The rest of the
states evaluate to zero probability. Interested readers can compute this in WolframAlpha at the link
below.
https://www.wolframalpha.com/
Let’s assume that we measured 12 with the source register. This means 12r ¼ 16k, k ¼ 3.
Therefore r = 4.
In this section, we construct a quantum circuit and demonstrate that Shor’s algorithm works by
factorizing 15. This circuit is based on the work done by Lieven M.K et al. in 2001 using Nuclear
Magnetic Resonance [14]. Reading this early pioneering research paper can be an enchanting
experience!
The circuit shown in Figure 7.38 finds the period of the function f(x) ¼ 7x mod 15. This circuit is an
optimized version that uses 3 qubits for the source register. Since the period of this function is
relatively smaller, the choice of 3 qubits holds good.
We start this circuit by preparing the source register in an equal superposition state. Modular
exponentiation is done for all the states of the source register and stored in the target register. After
this stage, we perform the inverse QFT and measure the source register. The X gate in qubit q[6] in
the diagram provides for the phase kickback.
Let us now verify the modular exponentiation circuit in this implementation. The system state after
the initialization stage is:
0 1
j000ij0001i þ j001ij0001iþ
1 B C
jψ i ¼ pffiffiffi B
@ j010ij0001i þ j011ij0001i þ j100ij0001iþ C A ð7:162Þ
8
j101ij0001i þ j110ij0001i þ j111ij0001i
After preparing the register to the initial state, we apply a series of CNOT and CCNOT gates to
perform the modular exponentiation. Here are the steps that perform this task.
Fig. 7.38 Quantum circuit that factorizes 15. Based on the research by Lieven M.K et al. in 2001 using Nuclear
Magnetic Resonance
7.9 Shor’s Algorithm 335
STEP 1: The first CNOT gate uses q[2] as the control qubit and q[4] as the target qubit
0 1
j000ij0001i þ j001ij0101i þ j010ij0001iþ
1 B C
¼ pffiffiffi B
@ j011ij0101i þ j100ij0001iþ C
A ð7:163Þ
8
j101ij0101i þ j110ij0001i þ j111ij0101i
STEP 2: The second CNOT gate uses q[2] as the control qubit and q[5] as the target qubit.
0 1
j000ij0001i þ j001ij0111i þ j010ij0001iþ
1 B C
¼ pffiffiffi B
@ j011ij0111i þ j100ij0001iþ C
A ð7:164Þ
8
j101ij0111i þ j110ij0001i þ j111ij0111i
STEP 3: The third CNOT gate with q[6] as the control and q[4] as the target.
0 1
j000ij0101i þ j001ij0011iþ
B C
B C
1 B j010ij0101i þ j011ij0011iþ C
¼ pffiffiffi B C ð7:165Þ
8 B
@ j100ij0101i þ j101ij0011iþ A
C
j110ij0101i þ j111ij0011i
STEP 4: CCNOT gate with q[1] and q[5] as the control gates and q[3] as the target qubit.
0 1
j000ij0101i þ j001ij0011i þ j010ij0101iþ
1 B C
¼ pffiffiffi B
@ j011ij1011i þ j100ij0101iþ C
A ð7:166Þ
8
j101ij0011i þ j110ij0101i þ j111ij1011i
STEP 5: The fourth CNOT gate with q[3] as the control and q[5] as the target.
0 1
j000ij0101i þ j001ij0011i þ j010ij0101iþ
1 B C
¼ pffiffiffi B
@ j011ij1001i þ j100ij0101iþ C
A ð7:167Þ
8
j101ij0011i þ j110ij0101i þ j111ij1001i
STEP 6: CCNOT gate with q[1] and q[4] as the control and q[6] as the target.
0 1
j000ij0101i þ j001ij0011i þ j010ij0100iþ
1 B C
¼ pffiffiffi B
@ j011ij1001i þ j100ij0101iþ C
A ð7:168Þ
8
j101ij0011i þ j110ij0100i þ j111ij1001i
STEP 7: The fifth CNOT gate with q[6] as the control and q[4] as the target.
0 1
j000ij0001i þ j001ij0111i þ j010ij0100iþ
1 B C
¼ pffiffiffi B
@ j011ij1101ij100ij0001iþ C
A ð7:169Þ
8
j101ij0111i þ j110ij0100i þ j111ij1101i
After performing the modular exponentiation, the target register is in equal probability with the
states: j1i, j7i, j4i, j13i. This result very well aligns with the modular exponentiation shown in
336 7 Quantum Algorithms
Eq. (7.170). We readily see that the period r is 4. Nevertheless, let us continue testing this circuit and
validate this later.
70 mod 15 ¼ 1
71 mod 15 ¼ 7
72 mod 15 ¼ 4 ð7:170Þ
7 mod 15 ¼ 13
3
74 mod 15 ¼ 1
The final step of Shor’s algorithm is to perform the inverse QFT on the source register and measure
it. When we do this experiment with 1,024 shots, we get a distributed measurement of states j0 i, j2 i,
j4i, j6i with almost equal probability. The outcome of this experiment is shown in the histogram
Fig. 7.39.
By analyzing the distribution pattern, we can figure out that the periodicity in the amplitude of jyi
3
is 2. Therefore, we can calculate r as r ¼ 22 ¼ 4, which we saw when we performed the modular
exponentiation in Eq. (7.170). Now since r is known, we can calculate the factors of N using the brute
force method.
We conclude that the factors of 15 are 5 and 3. Shor’s algorithm indeed works!
Listing 7.24 provides the source code to construct Shor’s algorithm factorizing 15 using Qiskit. A
version that runs on Q# or other systems can be easily constructed based on the logic developed.
Code example for QDK is included in the Appendix.
7.9 Shor’s Algorithm 337
# Measure
qc.measure(q[0], c[0])
qc.measure(q[1], c[1])
qc.measure(q[2], c[2])
The k-means algorithm is perhaps the widely used unsupervised machine learning algorithm. Given
input vectors vi ¼ ℝd; i 2 [N], the algorithm partitions the inputs into k clusters according to a
similarity measure. The similarity measure (aka, the distance function) refers to the Euclidean
distance between the data elements. Data elements are assigned to the nearest cluster according to
the distance function used. The algorithm produces k cluster centers, called mean or centroid of the
data elements in the cluster.
The general workflow for the classical k-means algorithm is as follows:
The centroids are updated so that the new centroid is the average of all points assigned to that
cluster:
1 X
ctþ1
j ¼ v
i2ctj i
ð7:174Þ
ctj
The loss function we are trying to minimize in this algorithm is the Residual Sum of Squares, and it
is defined as follows:
X X 2
RSS≔ j2½k i2C
d c j , vi ð7:176Þ
j
K-means is an example of an NP-hard problem. Each iteration runs with a complexity of O(kNd). The
pffiffi
Recall the following equation that calculates the Euclidean distance between two points p and q.
qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
jj q p jj ¼ jj p jj2 þ jj q jj2 2p q
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð7:177Þ
¼ 2 2 hp, qi
¼ dðp, qÞ
The goal of the quantum distance estimation circuit is to arrive at a state similar to the above
equation. Consider the quantum circuit shown in Figure 7.42.
340 7 Quantum Algorithms
This circuit uses two qubits to store the point and the centroid, for which the distance is to be
estimated. There is an ancilla qubit that is used to perform the swap test. The swap test determines
how much two quantum states differ. Let us now calculate the inner workings of this circuit. As usual,
we begin the system with the 3 qubits initialized to state j0i.
The next step is to apply an H transform to the ancilla qubit. The new system state is:
H½anc 1
jψ i ! j0ij0i pffiffiffi ðj0i þ j1iÞ ð7:179Þ
2
We then apply a U3 rotation to the qubits representing the point and the centroid. The rotational
angles correspond to the coordinates of the points. Assume that jii and jji are the resultant state of the
point and centroid qubits after the rotations.
U3 1
jψ i ! jiij ji pffiffiffi ðj0i þ j1iÞ
2
ð7:180Þ
1
! pffiffiffi ðj0ijiij ji þ j1ijiij jiÞ
2
The next step is to perform a controlled swap of the point and centroid qubits using the ancilla
qubit as the control. The system state now becomes:
1
swap
! pffiffiffi ðj0ijiijji þ j1ijjijiiÞ ð7:181Þ
2
it means the qubits jp i and jc i are close to each other. Note that the probability of measuring a “0” in
the ancilla qubit is 12, if the qubits jpi and jci are in orthogonal states.
Let us calculate the probability of measuring a “1” in the ancilla qubit.
1
jh1jψij2 ¼ jjiji jjiij2
4
1
¼ ½ðhijj hjijÞ ðjiji jjiiÞ
4 ð7:185Þ
1
¼ ½2 hijjjii hjijiji
4
1
¼ ½2 2jhijjij2
4
This equation is similar to Eq. (7.177), which describes the Euclidean distance between two points.
By comparing Eqs. (7.177) and (7.185), we can say that the probability of measuring a “1” in the
ancilla qubit is proportional to the square of the distance between the qubits jpi and jci:
By repeating the experiment several times, we can approximate that the more the number of 1’s we
get, the farther the qubits are.
The code snippet Listing 7.25 implements the quantum distance estimator circuit.
Listing 7.26 contains the source code for the core algorithm that implements the k-means.
The code fragment in Listing 7.27 generates a random data set and invokes the QuantumKMeans
method.
Executing this code generates the scatter plot, shown in Fig. 7.43a.
We can verify this with the Scikit-learn [20]. Type the code provided in Listing 7.28 in a new cell
in the Jupyter Notebook and execute it. Note that we are using the data generated previously.
Upon executing the code in Listing 7.28, we get a scatter plot, as shown in Fig. 7.43b.
Note that both the scatter plots are similar. A good exercise is to verify the deviation between the
quantum algorithm and the scikit-learn code programmatically and experiment with the threshold
value, and the rotational angles.
This algorithm was first published by S Lloyd as an IEEE paper in 1982, “Least Squares
Quantization in PCM.”
The quantum version runs in time O kN log E
d
:
342 7 Quantum Algorithms
phiPointB = (pointB[0]-1) * pi / 2
thetaPointB = (pointB[1]-1) * pi /2
return job.result().get_counts(qc)
k = len(centroids)
results = []
for i in range(k):
counts = QuantumFindDistance( point, centroids[i], \
processor, shots,
jobMonitor)
return results
threshold = 0.04
iteration = 0
distancefromcenters = []
for x in X:
distancefromcenters.append(QuantumDistanceEstimator(x, \
centroids, processor, shots, jobMonitor
))
import numpy as np
from numpy import pi
from copy import deepcopy
from matplotlib import pyplot as plt
from sklearn.datasets import make_blobs
from sklearn.cluster import KMeans
from sklearn.preprocessing import MinMaxScaler
backend = Aer.get_backend('qasm_simulator')
QuantumKMeans(backend)
(a) (b)
Fig. 7.43 The output of K-means algorithms for 3 clusters of 100 samples. (a) The quantum version. (b) The Scikit-
learn version
346 7 Quantum Algorithms
for i in range(n):
plt.scatter(X[i, 0], X[i, 1], s = 10, color =
colors[int(y[i])])
plt.scatter(C[:, 0], C[:, 1], marker='*', c='g', s=150)
Given an eigenvector jψi of a unitary operator U, such that Ujψi ¼ e2πiθjψ i, 0 θ 1, the goal of the
quantum phase estimation algorithm is to find the eigenvalue e2πiθ of jψi. This operation is equivalent
to finding the phase θ to a certain accuracy. The phase estimation algorithm is used in Shor’s
algorithm and in solving system of linear equation, etc. The block diagram shown in
Fig. 7.44 illustrates the quantum phase estimation procedure. The quantum phase estimation proce-
dure is similar to the method we used to perform arithmetic in the Fourier basis. Each of the
successive blocks of the controlled U gates kickbacks a phase 2θn into the upper block, called the
counting register. The counting register sums up to a value proportional to the phase factor e2πiθ. An
inverse QFT is applied to the counting register to convert this to the computational basis, which we
can measure and post-process (Fig. 7.44).
The system is started with the registers in the default state.
A Walsh–Hadamard transform is applied to the counting register to put that in an equal superpo-
sition state.
Hðcounting registerÞ 1
! pffiffiffiffinffi ðj0i þ j1iÞn jψi ð7:187Þ
2
n n1 n2 1 0
Since U is an unitary operator, U 2 jψi ¼ U2 e2πiθ jψi ¼ U 2 e2πiθ2 e2πiθ2 jψi: Applying this
logic into the previous equation,
" n1 n2
#
1 ðj0i þ j1iÞe2πiθ2 jψ i ðj0i þ j1iÞe2πiθ2 jψ i . . .
! pffiffiffiffinffi 1 0
ð7:188Þ
2 . . . ðj0i þ j1iÞe2πiθ2 jψ i ðj0i þ j1iÞe2πiθ2 jψ i
1 X 2πiθk
2n 1
! pffiffiffiffinffi e jki jψi, ð7:190Þ
2 k¼0
where k is a binary expansion. Applying an inverse QFT to the counting registers, we get
1 X 2πiθk 1 X 2πiky
2n 1 2n 1
! pffiffiffiffinffi e pffiffiffiffinffi e 2n jyi jψ i
2 k¼0 2 y¼0
1 X X 2πiθk 2πiky
2n 1 2n 1
! n e e 2n jyi jψ i ð7:191Þ
2 y¼0 k¼0
1 X X 2πik
2n 1 2n 1
e 2n ðy2 θÞ jyi jψ i
n
!
2n y¼0 k¼0
A close examination of the above equation reveals that when y ¼ 2nθ, the exponential term
evaluates to 1 and a measurement results in:
! j2n θi jψi ð7:192Þ
From this value, θ can be estimated. Let us now calculate the accuracy to which the phase
estimation can be done. Since the measurement is done in the computational basis, we can add a
correction parameter Δθ, which rounds off 2nθ to get a {0,1}. Equation (7.191) can be written as:
1 X X 2πik
2n 1 2n 1
e 2n ðy2 θÞ e2πikΔθ jyi jψi
n
jψi ! n ð7:193Þ
2 y¼0 k¼0
q[0]
COUNTING q[1]
REGISTER
q[2]
ANCILLA q[3]
c
Fig. 7.45 Quantum circuit for performing Phase Estimation. Shown here is the circuit for the S gate which performs
π/2 rotation
When Δθ ¼ 0, we measure this with the highest probability. When Δθ 6¼ 0, the above equation
reduces to:
2
1 1 e2πi2 Δθ
n
Pð2n θÞ ¼ 2n
2 1 e2πiΔθ
2
1 sin π2n Δθ
¼ 2n
2 sin πΔθ ð7:195Þ
1 j2 2n Δθj
2
2n
2 jπΔθj2
4
¼ 2 ¼ 40:5%
π
Thus, the phase estimation can be done to an accuracy of about 40.5% (Fig. 7.45).
We can try this algorithm with the S gate from Sect. 5.4.1.6, which performs a π2 rotation about the
π
z-axis. From Eq. (5.27), the S gate adds the phase ei2 when the qubit is at state j1i, hence we must
apply an X gate to the ancilla qubit at the initialization state. Construct the quantum circuit for phase
estimation, using Listing 7.29.
Executing the code generates the histogram shown in Figure 7.46.
From the histogram, we find that we measured 2 with a 100% probability. The circuit was
constructed with three qubits. Therefore, n ¼ 3. So 23θ ¼ 2. Hence, θ ¼ 14 : For the S gate, the
π
phase is e2πiθ ¼ ei2 . θ ¼ 14 in this equation. This matches with our observation from the experimental
results. Hence we can say that the QPE algorithm works. Note that the algorithm will work only if the
ancilla qubit, that is, jψi is an eigenstate of the rotational operator.
Code example for QDK is included in the Appendix.
The HHL algorithm is due to Aram Harrow, Avinatan Hassidim, and Seth Lloyd. The goal of the
! ! ! !
problem is given a matrix A and a vector b , to find a vector x such that A x ¼ b . The HHL algorithm
uses the QPE to perform matrix inversion. The algorithm needs three sets of qubit registers. A single
qubit ancilla, an n qubit register to store the eigenvalues of A and a quantum memory register of size
! !
O(log(N)) to store b and then evolve x .
# Inverse QFT code
def qft_inv (qc, n_qubits):
for i in range (n_qubits - 1, -1, -1):
for qubit in range (i, n_qubits-1):
# for inverse transform, we have to use negative angles
qc.cu1( - math.pi / 2** ( qubit + 1 - i ), qubit + 1, i)
# the H transform should be done after the rotations
qc.h(i)
qc.barrier()
countingRegister = 3
q = QuantumRegister(countingRegister + 1 , 'q')
c = ClassicalRegister(countingRegister , 'c')
qc = QuantumCircuit(q, c)
# Inverse QFT
qft_inv(qc, countingRegister)
#fig = qc.draw('mpl')
#fig.savefig('qpe.svg', bbox_inches='tight', dpi=300)
backend = Aer.get_backend("qasm_simulator")
job = execute(qc, backend=backend, shots=1024)
counts = job.result().get_counts()
fig = plot_histogram(counts)
fig.savefig('qpe_histogram.svg', bbox_inches='tight', dpi=300)
2 1 ! x ! 15
A¼ b¼ x ¼ ð7:196Þ
3 1 y 5
2x þ y ¼ 15
ð7:197Þ
3x y ¼ 5
0 0 A 0 0 0 x
A ¼ {
, b ¼ , x ¼ ð7:198Þ
A 0 b 0
! ! ! !
A x ¼ b implies that x ¼ A1 b ð7:199Þ
! !
Assume that the vectors b and x are encoded as normalized quantum states as follows.
2
A sparse matrix is a matrix with most elements zero. An s-sparse matrix has at most s nonzero entries per row. For a
given row i and column j, the entries Aijcan be computed in time O(s).
3
Singular values of an M N matrix A is defined as the square roots of the eigenvalues of the symmetric N N matrix
ATA arranged in decreasing order.
7.12 HHL Algorithm for Solving Linear Equations 351
PN1 PN1
j¼0 b j j ji j¼0 x j j ji
j bi ¼ P
N1
and j x i ¼ P
N1
ð7:200Þ
j¼0 b j j ji j¼0 x j j ji
where λj is the jth eigenvalue of the corresponding eigenvector juji. We can define the inverse matrix
of A as follows:
XN 1
A1 ¼ λ j 1 u j u j ð7:202Þ
j¼0
With these definitions, in the eigenbasis of A, we can write the following equations:
X
N 1
j bi ¼ b j u j ð7:203Þ
j¼0
X
N 1
jxi ¼ A1 jbi ¼ λ j 1 b j u j ð7:204Þ
j¼0
Figure 7.47 illustrates the HHL algorithm. The algorithm requires a procedure for state preparation
and encoding the coefficients into jbi. For brevity, this step is not detailed in this section. We assume
that there is a unitary B that prepares the state jbi.
Given jbi, our goal is to find jxi ¼ A1jbi. Therefore, we need to find an efficient method for
determining A1. From Eq. (7.202), we can infer that if we can find the mapping u j ! λ1j u j 8u j ,
we can say that we have found A1.
The first block of registers – the input register – nb contains the vector solution. The second block
of registers – the clock register – ne is used to store the binary representation of the eigenvalues of A.
The ancilla qubit is used to perform the eigenvalue inversion. Let us assume that N ¼ 2nb.
The system starts with all qubits initialized to the default state. To keep the math less cluttered, we
will bring the ancilla qubit into the equation a little later.
X
N 1
¼ j0ine b j u j nb
j¼0
ð7:207Þ
X
N1
¼ b j j0ine u j nb
j¼0
In this equation jujinb represents the jth eigenvector of the matrix A. To this state, we apply the QPE
P iλ j t
N1
algorithm, with the unitary U ¼ eiAt ¼ e u j u j . The QPE algorithm first applies the Walsh–
j¼0
Hadamard transform on the clock register.
Hne X 1 X
N 1 2ne 1
! b j pffiffiffiffiffiffi
ne
ðj0i þ j1iÞne u j nb ð7:208Þ
j¼0 2 l¼0
P
N1
Applying the controlled U gate eiλ j t u j u j , we get:
j¼0
X
N 1
1 X
2ne 1 ne
! b j pffiffiffiffiffiffi j0i þ eiλ j t j1i u j
ne nb
j¼0 2 l¼0
ð7:209Þ
X
N 1
1 X iλ j t
2ne 1
! b j pffiffiffiffiffiffi e jli u j nb
j¼0 2ne l¼0
The process of applying eiAt, given matrix A, is known as Hamiltonian simulation. This method
applies eiAt to the input jbi over a period t and decomposes jbi into the eigenbasis of A to find the
corresponding values of λj using phase estimation.
The next step is to apply the inverse QFT.
QFT1 X 1 X X iλ j lt 2πilk
N 1 2ne 1 2ne 1
! b j ne e e 2ne jkine u j nb ð7:210Þ
j¼0
2 k¼0 l¼0
P
2ne 1
eil½λ j t2ne , then we can write the above equation as:
2πk
If we assume αkjl ¼ 21ne
l¼0
X
N 1 2X
ne
1
! bj αkjl jkine u j nb ð7:211Þ
j¼0 k¼0
In the scenario where the phase estimation is perfect λ j t ¼ 2πk2ne , and αk j l ¼ 1. If we set set k ¼ 2ne ,
k
then λ j ¼ 2πk
t : Hence, jkine jujinb ¼ jλjine jujinb. The ket jkine at this stage contains the amplitudes of
7.12 HHL Algorithm for Solving Linear Equations 353
the basis states after the Fourier transform. λj represents the jth eigenvalue of the matrix A. With this,
we can rewrite the above equation.
X
N1
! b j λ j ne u j nb , ð7:212Þ
j¼0
where jλjine contains the eigenvalue estimate. At this stage, we can introduce the ancilla qubit into the
equation. Performing a conditional rotation with the jλjine qubit as the control qubit, we get the
following system state
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi !
X
N 1 C2 C
jψ i !
b j λ j ne u j nb 1 2 j0i þ j1i , ð7:213Þ
j¼0 λj λj
where the normalization constant C ¼ O 1k : The rotation finds the inverse of the eigenvalues λj.
The next step is to uncompute jλjine by performing an inverse QPE operation. The resultant system
state is given below:
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi !
X
N1 C 2
C
jψ i ! b j j0ine u j nb 1 2 j0i þ j1i ð7:214Þ
j¼0 λj λj
Now, if we measure a j1i at the ancilla qubit, the resultant state of the system is given by:
0 1
B CX
B 1 C N1 c b j
B
jxi B s ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi C
C j0ine u j nb ð7:215Þ
@ PN1 c2 jb j j2 A j¼0 λ j
jλ j j
j¼0 2
Up to a normalization factor, this equation corresponds to Eq. (7.204). The state of the nb register
P
N1
is b j λ j 1 u j nb up to a normalization factor which is equal to the solution jxi we are looking for.
j¼0
Finally, the qubits nb are measured. The expectation value of this measurement M, hxjMjxi
!
corresponds to the x we wanted to compute.
Several improvements have been suggested to the HHL algorithm, which includes amplitude
amplification [23–26]. A detailed error analysis is provided in the original research publication [22].
Let us study a pedagogical example of the HHL algorithm using a 2 2 matrix. The example we
are studying is a simplified version, which performs a direct phase estimation using the knowledge of
the eigenstates of the matrix A.
Consider the following system of linear equations:
2 3
3 1
! ! 6 4 4 7 x1 2
A x ¼ b : 4 5 ¼ ð7:216Þ
1 3 x2 0
4 4
By finding the inverse of matrix A, we can rewrite the above equation as follows to find the
classical solution:
354 7 Quantum Algorithms
2 3
3
1
! 1
! 6 2 7 2 3
x ¼A b: 4 5 ¼ ð7:217Þ
1
3 0 1
2
!
We can create a normalized ket kjjbbiik from the classical vector b and solve the above equation in
quantum mechanics.
A1 jbi 1 3
jxi ¼ pffiffiffiffiffi
A1 jbi ¼ 10 1 ð7:218Þ
From the above equation, it can be found that, up to a factor, the classical solution and the quantum
solution are the same. In the following part of this section, we shall apply the HHL algorithm to the
linear system of equations defined in (7.126). We shall also construct a quantum circuit to compare
experiment with theory.
Let us begin with the definition of A and jbi.
2 3
3 1
64 47 1
A¼4 5 and jbi ¼ ðafter normalizationÞ ð7:219Þ
1 3 0
4 4
With some math work or using an online tool, the eigenvalues of the matrix A can be calculated as
λ1 ¼ 1 and λ2 ¼ 12 . Let us assume t ¼ 2 2π and C ¼ 2. With these assumptions, we can calculate
λ1 t λ2 t
2π ¼ 2 and 2π ¼ 1. These two values correspond
1 1
eigenvectors of the A matrix are ju1 i ¼ p1ffiffi2 and ju2 i ¼ p1ffiffi2 in the matrix form. We can
1 1
P1
define the ket jbinb ¼ jui inb . Figure 7.48 illustrates the quantum circuit we construct to imple-
j¼0
ment the simplified version of the HLL algorithm.
The state of the system after the QPE stage can be written as:
1 1
jψ i ¼ pffiffiffi j01ine ju1 inb þ pffiffiffi j10ine ju2 inb ð7:220Þ
2 2
Fig. 7.48 A simplified quantum circuit implementing the HLL algorithm for a 2 x 2 matrix
7.12 HHL Algorithm for Solving Linear Equations 355
The next step is to perform the rotations of the ancilla, the system state after the rotations can be
written as:
0sffiffiffiffiffiffiffiffiffiffiffiffiffi 1
2
1 2 2
jψ i ¼ pffiffiffi j01ine ju1 inb @ 1 2 j0i þ j1iA
2 1 1
0 1 ð7:221Þ
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
1 B 2 2
2 C
þ pffiffiffi j10ine ju2 inb @ 1 2 j0i þ j1iA
2 1 1
2
2
This equation reduces to the following:
pffiffiffiffiffiffiffi
1
jψ i ¼ pffiffiffi j01ine ju1 inb 3j0i þ 2j1i
2
pffiffiffiffiffiffiffiffiffi ð7:222Þ
1
þ pffiffiffi j10ine ju2 inb 16j0i þ 4j1i
2
After performing the rotations, we put the system through an inverse QPE. The resultant state can
be written as:
pffiffiffiffiffiffiffi
1
jψ i ¼ pffiffiffi j00ine ju1 inb 3j0i þ 2j1i
2
pffiffiffiffiffiffiffiffiffi ð7:223Þ
1
þ pffiffiffi j00ine ju2 inb 16j0i þ 4j1i
2
Now, if we measure a j1i in the ancilla qubit, the system collapses to:
1 1
pffiffiffi j00ine ju1 inb 2j1i þ pffiffiffi j00ine ju2 inb 4j1i
2sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
2
! ffi
2 2
pffiffi
1
2 þ 2 pffiffi
1
4 2
2 2 ð7:224Þ
2 4
pffiffiffi ju1 inb þ pffiffiffi ju1 inb
2 pffiffiffiffiffi 2
¼
10
This result is the same as the Eq. (7.218). Listing 7.30 contains the source code that implements the
quantum circuit in qiskit.
356 7 Quantum Algorithms
q = QuantumRegister(4 , 'q')
c = ClassicalRegister(4 , 'c')
qc = QuantumCircuit(q, c)
# QPE
qc.h(q[3])
qc.cx(q[3], q[2])
qc.cx(q[2], q[1])
qc.x(q[2])
qc.swap(q[2], q[1])
qc.barrier()
# Lambda inverse
qc.cu3(math.pi, 0,0,q[2], q[0])
qc.cu3(math.pi/3, 0,0,q[1], q[0])
qc.barrier()
# Inverse QPE
qc.swap(q[2], q[1])
qc.x(q[2])
qc.cx(q[2], q[1])
qc.cx(q[3], q[2])
qc.h(q[3])
qc.barrier()
#qc.draw('mpl')
backend = Aer.get_backend('statevector_simulator')
job = execute(qc, backend=backend, shots=1024).result()
statevector = job.get_statevector()
Listing 7.30 Source code for the HLL algorithm shown in Fig. 7.48.
7.13 Quantum Complexity Theory 357
Upon executing the circuit, we get the following result. Note that the circuit may need to be tried a
few times to get the correct result.
|x> using HLL algorithm: [ 3.+0.j -1.+0.j]
The result matches the theoretical value. Hence, we can say that the HHL algorithm works. The
algorithm works well for the matrices with a relatively less condition number. However, the authors
of the original research paper have given some methods to handle ill-conditioned matrices. The
performance of the run time is k2 log (N )/E, where E is the additive system error. In cases where k and
1/E are polylog(N ), the algorithm exhibits exponential speedup [22]. The algorithm requires O(log N)
qubits if direct phase estimation and Hamiltonian evolution are used.
A number of applications have been reported for the HHL algorithm, which is an essential
milestone in the discovery of quantum algorithms. Extensions in solving nonlinear differential
equations have also been reported [28].
Code example for QDK is included in the Appendix.
The extended Church-Turing thesis states, “Any physically-realistic computing device can be
simulated by a deterministic (or maybe probabilistic) Turing machine, with at most polynomial
overhead in time and memory.” This thesis forms the basis for all complexity theories.
The Quantum Complexity Theory focuses on the study of quantum complexity classes and the
degree of hardness of computational problems between the classical and quantum implementations.
Let us begin our discussions in this section by recalling the classical complexity classes (Fig. 7.49).
NP-Complete
NP
P
358 7 Quantum Algorithms
Given a string x and a decision problem L, the prover sends a string π 2 {0, 1}n to a deterministic
polynomial algorithm called a verifier V. V (x, π) runs in polynomial time and returns “1” if x is a
YES-instance and “0” if x is a NO-instance.
The complexity class NP is defined as follows:
NP ¼ [ NTIME nk , ð7:226Þ
k2N
where NTIME(nk) is the set of decision problems that can be solved by a nondeterministic Turning
machine in time O(nk).
Note that the class of P problems also belongs to the class of NP. However, this is an unsolved
problem in computer science, whether P ¼ NP.
NP-Complete
The class of decision problems for which the solutions can be verified for correctness by a polynomial
algorithm is known as NP ‐ Complete. The traveling salesman problem, bin-packing problem,
knapsack problem are examples of problems belonging to this class.
A problem belongs to NP ‐ Complete, if it belongs to NP, and there exists a problem in class NP in
polynomial time that can be reduced to it.
NP-Hard
The term NP ‐ Hard means nondeterministic polynomial acceptable problems. These are decision
problems that are intrinsically harder than those that can be solved using a nondeterministic Turing
machine in polynomial time. Some search and optimization problems belong to this class. A problem
is said to be NP ‐ Hard, if there exists a problem in class NP ‐ complete that can be reduced to it in
polynomial time.
EXPTIME (EXP)
EXP represents the class of decision problems solvable by a deterministic turning machine in O(2p(n))
time, where p(n) is a polynomial function of n.
7.13 Quantum Complexity Theory 359
PSPACE
PSPACE is the set of all decision problems that can be solved by a Turing machine in polynomial
complexity.
The BQP class is somewhat equivalent to the BPP class, as the problems of this class can be solved
by probabilistic Turing machines.
The following properties are applicable to the BQP class.
• P ⊆ BQP. This draws from the fact that we can simulate all classical circuits in quantum.
• BPP ⊆ BQP, but BPP 6¼ BQP and BQP ⊈ BPP The first part is true because the quantum systems
are probabilistic. Hence, quantum computers can solve any classical probabilistic problem. The
second and third parts are because we still cannot prove that the quantum computer is better than
the classical computer.
• BQP ⊆ PSPACE. Quantum computers can efficiently solve all problems solved by deterministic
classical computers. This set does not include problems with polynomial complexity that cannot
be solved by classical computers.
7.14 Summary
This chapter was another milestone in our learning—quantum algorithms. We started by building a
ripple adder circuit. Quantum Fourier Transform was a significant concept we learned in this chapter
and applied it in Shor’s algorithm, quantum phase estimation, and HHL algorithm. We learned
several oracle-based algorithms—Deutsch–Jozsa, Bernstein–Vazirani, and Simon’s. Grover’s search
was another algorithm that taught us about amplitude magnification. Quantum k-means was yet
another algorithm, which used the swap test.
References 361
Practice Problems
1. Design a quantum circuit to measure the decoherence of qubits. (Hints: Flip the qubit using an X
gate, apply a certain number of Identity gates and measure.) Perform this with a number of
backends available.
2. Develop a modular exponentiation circuit to factorize numbers 21 and 35.
3. Develop a quantum comparator circuit which can compare two n bit unsigned integers and
determine which number is larger. Extend this logic for signed integers.
4. Design and develop a quantum divider circuit. Develop unit testing code to verify that the circuit
works.
5. Satisfiability problems can test whether a given Boolean expression can evaluate true for a given
set of input values. For example, the problem f(x, y, z) ¼ (x ^ Ø y _ z) ^ (Øx ^ y
_ Ø z) ^ (x ^ y ^ z) ^ (Øx _ y Ø z) is a 3-SAT problem with four clauses (the brackets) and
three literals (variables inside the brackets). The symbol Ø denotes a NOT operation. ^ is an
AND operation and _ is an OR operation. Evaluate for what values of x, y, z, the function
f(x, y, z) evaluates TRUE. Use Grover’s algorithm to solve this problem.
6. In literature [21], it is known that Grover’s Algorithm can be used in minimizing Quadratic
Unconstrained Binary Optimization Problems (QUBO.) Use this method to optimize
2x + 4y + x2 + y2.
7. An oracle function implements a secret key k 2 {0, 1}n which opens a secret locker in the
national bank. Implement a quantum circuit that can reveal the secret key in one step.
8. Develop a working code to implement the Group Leader Optimization Algorithm [27, 28], to
decompose unitary matrices into quantum circuits. Verify the code with the unitary matrix of the
Toffoli gate and compare it with the literature.
9. Improve the HHL example discussed in Sect. 7.12 using amplitude amplification. Explore
implementing the method using Hamiltonian simulation.
10. Implement the HHL procedure outlined in [23] to solve a linear system that can be described
using a 4 4 matrix.
11. Measure the state vector of the qubits, at each step of the Grover’s iteration and plot a graph. For
measuring the state vector, you may use the code example from the HHL algorithm.
References
1. Addition on a Quantum Computer, Thomas G. Draper, June 15, 2000, https://arxiv.org/pdf/quant-ph/0008033.pdf
2. For evaluating Boolean expressions, the following website comes handy: https://www.dcode.fr/boolean-
expressions-calculator
362 7 Quantum Algorithms
27. Group Leaders Optimization Algorithm, Anmer Daskin, Sabre Kais, 26-Jan-2011, https://arxiv.org/pdf/1004.2242.
pdf
28. Further reading on HHL algorithm and derivate work. (a) Decomposition of Unitary Matrices for Finding Quantum
Circuits: Application to Molecular Hamiltonians, Anmer Daskin, Sabre Kais, 23-Feb-2013, https://arxiv.org/pdf/
1009.5625.pdf. (b) Concrete resource analysis of the quantum linear system algorithm used to compute the
electromagnetic scattering cross section of a 2D target, Artur Scherer et al, 27-July-2016, https://arxiv.org/pdf/
1505.06552.pdf. (c) Quantum algorithms and the finite element method , Ashley Montanaro and Sam Pallister,
25-Feb-2016, https://arxiv.org/pdf/1512.05903.pdf. (d) A quantum algorithm to solve nonlinear differential
equations, Sarah, K Leyton and Tobias J. Osborne, 23-Dec-2008, 337
Adiabatic Optimization and Quantum
Annealing 8
“Would you tell me, please, which way I ought to walk from here ?”
“That depends a good deal on where you want to get to,” said the Cat.
“I don ‘t much care where——” said Alice.
“Then it doesn’t matter which way you walk,” said the Cat.
“ ——so long as I get somewhere,” Alice added as an explanation.
“Oh, you ‘re sure to do that,” said the Cat, “if you only walk long enough.”
― Lewis Carroll, Alice’s Adventures in Wonderland
Note: Reading Sect. 3.6 on quantum tunneling may be helpful to read this chapter.
Adiabatic quantum computing (AQC) is an alternate quantum computing method based on the
quantum adiabatic theorem [2]. A related concept is quantum annealing. In an AQC based computa-
tion [1, 3], an initial Hamiltonian in its ground state is evolved slowly to a final Hamiltonian whose
ground state encodes the solution to the problem. AQC is used in solving optimization problems [4, 5]
and developing heuristic algorithms.
The quantum adiabatic theorem was first introduced by the German physicist Max Born and the
Soviet physicist Vladimir Fock in 1928. The adiabatic theorem is stated formally as follows:
The instantaneous state of a quantum system that begins in the nondegenerate ground state of a time-dependent
Hamiltonian will remain in its ground state, provided the Hamiltonian changes sufficiently slowly. However, the
wavefunction may pick up a phase.
Imagine that an equestrian is riding a horse with a glass full of wine in his/her hand. If the horse
animates sufficiently slowly, the equestrian can continue to hold the glass without the wine spilling!
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 365
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_8
366 8 Adiabatic Optimization and Quantum Annealing
In quantum mechanics, we are generally interested in the time evolution of the quantum states.
Following the Hamiltonian is a way to generate the time evolution of the quantum states. If jψ(t)i is
the state of the system at time t, then the general form of the Schr€
odinger equation is given as follows:
∂
i jψ ðtÞi ¼ H jψ ðtÞi ð8:1Þ
∂t
The solution to this equation at time t ¼ 0 is straightforward, especially if the Hamiltonian is time-
independent. The eigenstate of the Hamiltonian simply acquires a phase.
iHt
jψ ðtÞi ¼ e ħ jψ ð0Þi ð8:2Þ
If the Hamiltonian is dependent on time, then the eigenfunction and the eigenvalues are dependent
on time. Assume a spin qubit in its initial state jψ(0)i ¼ j0i, pointing to the +z direction (see
Fig. 3.11). Suppose, if we apply an X rotational field that slowly rotates the qubit to point to the
z direction. The spin starts to precess about the direction of the rotational field, slowly moving
towards the z-axis. If the time T is made sufficiently large, the rotational field changes its direction
at an infinitesimally slower rate. We can say that the spin simply tracks the field and remains in its
ground state H(t). If we assume j0i ! eiα j1i and j1i ! eiβ j0i, the instantaneous Hamiltonian for the
X rotation is given by the following equation [13]:
πħ 1
H ðtÞ ¼ N ½ cos ðγ Þ σ x þ sin ðγ Þ σ z , ð8:3Þ
T 2
where N is an arbitrary constant and γ ¼ (α + β)/2.
If the time T is arbitrarily large, then H(t) varies arbitrarily slowly as a function of t. The evolution
of the initial quantum state jψ(0)i can be written as follows:
∂
i jψ ðtÞi ¼ H ðtÞjψ ðtÞi ð8:4Þ
∂t
Let us assume that the nondegenerate ground state ψ(0) is the eigenstate of H(0). Let s 2 [0, 1]. Let
H(s) varies smoothly as a function of s, such that s ¼ t/T. If the ground state of H(s) is nondegenerate
for all s 2 [0, 1], then according to the adiabatic theorem, in the limit T ! 1, the final state jψ(T )i
will be in the ground state of H(1).
Note: Readers can skip the equations and read the text without compromising the
understanding.
Since Bohr and Fock, several authors have provided proof for the adiabatic theorem. We follow a
pedagogical method for its simplicity. Let us start with the instantaneous nondegenerate eigenstates:
H ðtÞjψ n ðtÞi ¼ En ðtÞjψ n ðtÞi, ð8:5Þ
Continuing our discussions from the previous section, since the Hamiltonian changes with time,
the corresponding eigenfunctions and eigenvalues are time-dependent. Nevertheless, at any given
instant, they form a complete orthonormal set.
The solution to Eq. (8.4) can be written as a linear combination of an orthonormal set.
X
jψ ðtÞi ¼ cn ðtÞ jψ n ðtÞi, ð8:7Þ
n
where cn(t) is a function of time that needs to be determined. Substituting Eq. (8.7) in Eq. (8.4), we
get:
X X
iħ c_n jψ n ðtÞi þ cn jψ_ n ðtÞi ¼ cn En ðtÞjψ n ðtÞi ð8:8Þ
n n
The dot accent ð _ Þ denotes the time derivative. By taking an inner product with ψ m and using the
orthonormality,
X
iħ c_m þ cn hψ m jψ_ n i ¼ cm Ek ð8:9Þ
n
Note that we are dropping ‘(t)’ for now to make the equations simple. We shall reintroduce this
once the equation simplifies.
X
iħc_m ¼ Em cm iħ hψ m jψ_ n icn ð8:10Þ
n
Upon rewriting,
X
iħc_ m ¼ Em iħ hψ m jψ_ m i cm iħ hψ m jψ_ n icn ð8:11Þ
n6¼m
Or,
_ ni
hψ m jHjψ
hψ m jψ_ n i ¼ ð8:15Þ
ðEn Em Þ
Applying adiabatic approximation, if H_ is infinitesimally small, the second term vanishes, and
jcmj ¼ 1. Hence,
ðt
1
cm ðtÞ ¼ cm ð0Þ exp ðEm ðt0 Þ iħ hψ m jψ_ m iÞ dt0
iħ
0
1
ðt Ð
t
ð8:18Þ
¼ cm ð0Þexp Em ðt0 Þdt0 Þ exp i ihψ m jψ_ m i dt0
iħ
0 0
where the dynamic phase θm(t), and geometric phase γ m(t) are defined as:
ðt
1
θm ðtÞ Em ðt0 Þdt0
ħ
0
Ð
t
ð8:19Þ
If the quantum system started in the nth eigenstate, cn(0) ¼ 1, and cm(0) ¼ 0 for m ¼ 6 n, the
Eq. (8.7) becomes,
X
jψ n ðtÞi ¼ cn ðtÞ eiθn ðtÞ eiγn ðtÞ jψ n ðtÞi þ cm ðtÞ eiθm ðtÞ eiγm ðtÞ jψ m ðtÞi ð8:20Þ
m6¼n
This means the system remains in the nth eigenstate up to a global phase. Hence, the proof.
QED.
Note that in Eq. (8.19), the geometric and dynamic phases are real quantities, as long as the
Hamiltonian is real. Let us assume that the Hamiltonian changes with time, due to a generalized
parameter λ that changes with time. The geometric phase can then be written as follows.
ð t2 D E ð t2
∂
γ m ¼ i ψ m ψ m dλ ¼ f ðλÞdλ ð8:22Þ
t1 ∂λ t1
During the system evolution, if λ changed as a set of values λ ¼ (λ1, λ2, . . .), then the above
equation becomes:
ð t2 ð t2
γ m ¼ i hψ m j∇λ jψ m idλ ¼ f ðλ1 Þdλ1 þ f ðλ2 Þdλ2 þ . . . ð8:23Þ
t1 t1
8.3 Adiabatic Optimization 369
Suppose if the system returned to the original state it started with, the total geometric phase
acquired must be zero. From the above equation, it is evident that the geometric phase is not
necessarily zero, unless ∇λ f ¼ 0.
The geometric phase of an adiabatic system in a closed loop is known as Berry phase. The Berry
Phase can be written as:
I
γ m ðCÞ ¼ i hψ m j∇λ jψ m idλ, ð8:24Þ
C
where λ is an adiabatic process following a cyclic path C. It is the phase acquired by slow moving
systems.
Berry phase has applications in condensed matter physics and quantum computing.
The objective of an optimization problem is to find the best solution from a set of feasible solutions. In
a finite-dimensional optimization problem, the choices are from a set of real number variables, called
decision variables. The decision variables are labelled x1, x2, . . ., xn. Each possible choice is a point
x ¼ (x1, x2, . . ., xn) in the solution space ℝn. The feasible set is a subset C ⊂ ℝn containing the
choices x ¼ (x1, x2, . . ., xn). The objective function f(x) is to be minimized or maximized over C, that
is, for all x 2 C, f(x0) f(x) for a minimizing function and f(x0) f(x) for a maximizing function. In
other words, the objective function determines how good a choice is. Optimization problems may
have constraints, which are conditions that specify the feasible set. For example, the range is a
constraint.
The quantum adiabatic theorem is used in solving optimization problems. The solutions to the
minimizing problem are encoded in the ground state of a Hamiltonian. The goal of the algorithm is to
adiabatically evolve into this ground state from a known ground state. According to the adiabatic
theorem, if the evolution is sufficiently slow, the probability of finding the solution close to the
ground state is very high.
Consider the following Hamiltonian with eigenvalues h(z):
X
HP ¼ hðzÞjzi hzj ð8:25Þ
s2f0, 1gn
We call this the problem Hamiltonian. It is defined in the computational basis as a diagonal matrix.
The ground state of this Hamiltonian contains the states z, such that h(z) is minimized.
We define a beginning Hamiltonian HB, whose ground state can be prepared relatively easily. Let
HD(t) be a smooth varying time-dependent driver Hamiltonian such that HD(0) ¼ HB, and HD(T) ¼ HP,
where T is a sufficiently large evolution time. The goal is to evolve the system adiabatically from HB
to HP. The gradual change of the Hamiltonian can be described by a smooth monotonic function f(x)
(called schedule or annealing schedule) such that f(0) ¼ 0 and f(1) ¼ 1. The Hamiltonian at the time
t is given by:
t t
H D ðt Þ ¼ 1 f HB þ f HP ð8:26Þ
T T
Note that HD(0) ¼ HB and HD(1) ¼ HP. Hence, f(x) must vary from 0 to 1 as time t changes from
0 to T. The choice of the initial Hamiltonian and the final Hamiltonian is given in the following
equation.
370 8 Adiabatic Optimization and Quantum Annealing
X
n
HB ¼ Xi
i¼1
X
n X
n ð8:27Þ
HP ¼ H Ising ¼ hi X i J ij Zi Z j ,
i i, j
where X and Z are Pauli operators acting on the ith qubit. hi is the external transverse magnetic field.
Jij is spin-spin interaction energy between nearest qubits i and j, respectively. The Hamiltonian HP
represents an Ising model in a transverse field. The first term represents the interaction between the
applied field and the qubits. The second term represents the interaction energy needed to bring about
an ordered state.
In the computational basis, the quantum state of n qubits prepared in the ground state is described
as follows. We should be familiar with this expression by now.
1 X n
2n 1
jψð0Þi ¼ pffiffiffiffinffi jxi ð8:28Þ
2 x
This system of qubits evolves as per the Schr€odinger Eq. (8.4) from time t ¼ 0 to t ¼ T. The time T
is chosen in such a way that the changes in ψ(t) are slow relative to the inverse of the minimum energy
gap of H(t) with the instantaneous eigenspectrum defined by Eq. (8.5). The minimum energy gap
△min is defined as the energy difference between the instantaneous ground state and the first excited
states. If the time T △a min for a ¼ 2, 3, then the qubits remain in the ground state of the
instantaneous Hamiltonian. At the end of the evolution H(T ) ¼ HP.
After the preparation of the final state ψ(T ), the qubits are measured in the computational basis.
Note that HP is diagonal in the computational basis. Hence, the measurement results correspond to the
ground state, which is the solution to the problem.
A numerical simulation example given in the reference [6] is a good starting point.
Quantum annealing [8–10] is closely related to a method used in solving combinatorial optimization
problems in discrete search spaces where there are many local minima. The search attempts to find a
fairly good solution to the problem, but not necessarily the most optimal one. The traveling salesman
(TSP) is an example of such a problem. The annealing process draws from naturally occurring
phenomena, such as the formation of diamonds over millennia, and freezing water. When water is
frozen slowly, the resulting ice crystals are almost perfect than those formed by rapid cooling. The
reason is that those ice crystals cooled slowly are in a lower energy meta-state, a natural process of a
system minimizing its free energy. Diamonds are formed when carbon-rich rocks deep beneath the
earth’s surface are put through heat and pressure for thousands of years. This is a slow geological
process that produces a highly ordered crystalline structure of the diamond. Anything short term can
only produce coal! Annealing is a widely used manufacturing process, for example, in the steel
forging industry. Annealing improves the machinability of steel by softening it for cold working.
Steel is first heated to a specific temperature and held at that temperature for a while. This
recrystallizes steel, which helps in the formation of a new grain-free structure and makes it defect
free. After this stage, steel is cooled slowly in a controlled environment. Cooling steel in a controlled
environment results in a refined microstructure ensuring softness and ductility.
8.4 Quantum Annealing 371
Energy
Quantum Tunneling(QA)
System State
The classical simulated annealing (SA) is an equivalent process and uses the classical Monte Carlo
sampling (of thermodynamic systems) based on the Metropolis-Hastings Algorithm. Simulated
annealing works by increasing the energy of the system and allowing it to cool down gradually. The
thermal fluctuations lead the system to transit between states over intermediate energy barriers to
search for the lowest energy state possible. The system anneals reaching a solution state, through free
energy minimization:
F½pðxÞ ¼ E½pðxÞ TS½pðxÞ, ð8:29Þ
where the thermodynamic potentials F- free energy, E-inner energy, S-entropy are functions of the
probability distribution of the system states x. When the temperature is high, the free energy F is
minimized for maximum entropy S, a maximally mixed state p(x) of a wide range of possible minima.
As the system cools down, E modifies the entropy such that the initial p(x) settles down in a fairly
good solution to the optimization problem.
However, this method doesn’t find the local minima in scenarios where there may be a high energy
barrier preceding the lowest energy state.
Quantum annealing is similar to simulated annealing (SA) but uses quantum tunneling. Quantum
tunneling (Sect. 3.6) is a consequence of quantum mechanics, where a particle can tunnel through a
potential barrier and appear on the other side with the same energy.
Figure 8.1 illustrates the simulated annealing and the quantum annealing. As illustrated in the
diagram, SA requires the system to overcome energy barriers. QA uses quantum tunneling.
Quantum annealing proceeds by replacing the current state (a candidate solution) with a randomly
chosen neighbor state for which the target function computes the least energy. The quantum field
strength controls the exploration of the neighborhood, also called the quantum tunneling width. At
first, the tunneling radius is so vast that the neighborhood contains the entire search space. As the
system evolves, the neighborhood gets gradually shrunk until the current state is not too variant from
a randomly chosen neighbor state. Quantum annealing converges at this stage.
Assume that the solution to the problem is encoded in the ground state of an Ising Hamiltonian in a
transverse field described by the following equation. The quantum Ising model [11] describes a lattice
structure whose nearest-neighbor interactions are due to the alignment or antialignment of the spins
along the z-axis and the external magnetic field along the x-axis (the transverse field.)
X
n X
n X
n
HIsing ¼ Ji Zi J ij Zi Z j J ijk Zi Z j Z k . . . ð8:30Þ
i i, j i, j, k
In this equation, Z is the Pauli operator σ z. The subscripts i, j, k refer to the lattice sites. J represents
the coupling between adjacent qubits. n is the number of spins. The eigenvalues of the Pauli operators
372 8 Adiabatic Optimization and Quantum Annealing
are
1, which correspond to the Ising spin states. An optimization problem is coded into the Ising
Hamiltonian by mapping binary variables into spin states. To induce quantum annealing, a time-
dependent transverse field is applied to the system.
X
n
H TF ðtÞ ΓðtÞ Xi , ð8:31Þ
i¼1
where Γ(t) is the transverse field, and X is the Pauli operator σ x. The total Hamiltonian of the system
can be written as:
The transverse field causes quantum fluctuations between two spin states with eigenvalues Zi ¼ + 1
and Zi ¼ 1, which induces the quantum search of the phase space.
When the algorithm starts, Γ(t) is chosen with a very high value, such that in Eq. (8.32) the second
term is the most significant. This state corresponds to the high-temperature state of SA. A high-
temperature value is chosen because a high-temperature state in SA is a mixture of all possible states
that are almost equally probable. As the computation proceeds, the transverse field Γ(t) is adiabati-
cally reduced to ‘0’, at this point HIsing is the most significant parameter in the equation.
The system state follows the Schr€odinger Eq. (8.4), evolving from the trivial initial ground state
described by the transverse field Hamiltonian Eq. (8.31) to the non-trivial Ising Hamiltonian
described by Eq. (8.30), which encodes the solution to the problem.
Note that some quantum systems may still have entropy even at absolute zero because of the zero-
point energy. Due to this reason, the adiabatic evolution must be slow enough. However, too slow
annealing comes at the cost of computing, so in practice, a balance between the quality of annealing
and the computing time should be sought. If the annealing is rapid, it is possible that some interstate
energy barriers may cause quantum jumps leading to the algorithm getting stuck at a local minimum.
So, it is important to decrease Γ(t) in such a way that the system state is close to the instantaneous
ground state of the total Hamiltonian Eq. (8.32).
8.5 Summary
In this chapter, we learned about adiabatic quantum computing, an alternate form of quantum
computing, and quantum annealing a closely related method. The advantage of quantum annealing
over simulated annealing is evident from numerous studies [7], and there is proof that the probability
of the system being in the lowest state is high for quantum annealing. This does not mean that all
NP-Hard problems can be efficiently performed using quantum annealing, and there is no evidence of
quantum supremacy in this space yet. However, the use cases for QA are in plenty. A number of
combinatorial optimization problems can be readily solved using QA.
D-Wave Google
MDR MIT Lincoln Lab
NEC Northrop Grumman
Qilimanjaro
There is much activity in this base, both in the industry and in academia. The above table illustrates
the list of organizations involved in developing adiabatic/annealing methods [12].
References 373
Practice Problems
0 a
1. The Hamiltonian of a qubit in initial state j0i is given by H ¼ . What is the probability of
a 0
the qubit to be in state j1i at time t > 0.
ħω 0
2. The Hamiltonian of a hypothetical qubit is defined by the matrix H ¼ , where ω is
0 ħω
the qubit frequency. The qubit is prepared in the equal superposition state initially, that is,
jψ ð0Þi ¼ p1ffiffi2 ðj0i þ j1iÞ. Evolve the system from time t ¼ 0 to t ¼ 2τ. At the end of the evolution,
the qubit is measured using a basis {j+i, ji} defined by jþi ¼ p1ffiffi ðj0i þ j1iÞ and ji ¼ p1ffiffi
2 2
ðj0i j1iÞ: Find the probability of measuring the qubit in one of the states. (Hints: use:
iHt
jψ ðtÞi ¼ e ħ jψ ð0Þi and P(a) ¼ jhaj ψij2.)
3. Can a pure state (adiabatically) evolve into a mixed state? Explain your answer.
4. Adiabatic invariants are the properties of a physical system, that remain constant when a change
occurs. Prove that ωE of a simple harmonic oscillator is adiabatically invariant.
5. What happens to von Neumann’s entropy under an adiabatic evolution? Explain your answer.
References
1. Adiabatic Quantum Computing, Tameem Albash et al, 2-Feb-2018, https://arxiv.org/pdf/1611.04471.pdf
2. Geometry of the adiabatic theorem, Augusto C’esar Lobo et al, 8-Jun-2012, https://arxiv.org/pdf/1112.4442.pdf
3. Notes on Adiabatic Quantum Computers, Boaz Tamir, Eliahu Cohen, 7-Dec-2016, https://arxiv.org/pdf/1512.
07617.pdf
4. Designing Adiabatic Quantum Optimization: A Case Study for the Traveling Salesman Problem, Bettina Heim et al,
21-Feb-2017, https://arxiv.org/pdf/1702.06248.pdf
5. Experimental implementation of an adiabatic quantum optimization algorithm, Matthias Steffen et al, 14-Feb-2003,
https://arxiv.org/pdf/quant-ph/0302057.pdf
6. Adiabatic Quantum Optimization for Associative Memory Recall, Seddiqi and Humble, 12-Dec-2014, https://arxiv.
org/pdf/1407.1904.pdf
7. Study of Optimization Problems by Quantum Annealing, Tadashi Kadowaki, 5-May-2002, https://arxiv.org/pdf/
quant-ph/0205020.pdf
8. Solving Optimization Problems Using Quantum Annealing, Motasem Suleiman and Nora Hahn, December
20, 2018, http://www.henryyuen.net/fall2018/projects/annealing.pdf
9. Mathematical Foundation of Quantum Annealing, Satoshi Morita and Hidetoshi Nishimori, 11-Jun-2008, https://
arxiv.org/pdf/0806.1859.pdf
10. An introduction to quantum annealing, Diego de Falco et al, 5-Jul-2011, https://arxiv.org/pdf/1107.0794.pdf
11. Transverse Ising Model, Glass and Quantum Annealing, Bikas K. Chakrabarti and Arnab Das, 15-May-2006,
https://arxiv.org/pdf/cond-mat/0312611.pdf
12. https://quantumcomputingreport.com/qubit-technology/
13. Hamiltonians for Quantum Computing, Vladimir Privman et al, 13-May-1997, https://arxiv.org/pdf/quant-ph/
9705026.pdf
Quantum Error Correction
9
“I’m sure I ‘m not Ada,” she said, “for her hair goes in such long ringlets, and mine
doesn’t go in ringlets at all; and I ‘m sure I can ‘t be Mabel, for I know all sorts of things,
and she, oh! she knows such a very little! Besides, she’s she, and I’m I, and—oh dear, how
puzzling it all is! I ‘ll try if I know all the things I used to know. Let me see: four times five is
twelve, and four times six is thirteen, and four times seven is—oh dear! I shall never get to
twenty at that rate! However, the Multiplication Table don’t signify: let’s try Geography.
London is the capital of Paris, and Paris is the capital of Rome, and Rome—no, that’s all
wrong, I ‘m certain! I must have been changed for Mabel! I’ll try and say ‘How doth the
little— ’” and she crossed her hands on her lap, as if she were saying lessons, and began to
repeat it, but her voice sounded hoarse and strange, and the words did not come the same
as they used to do.
― Lewis Carroll, Alice’s Adventures in Wonderland
In previous chapters, we learned that the qubits undergo a process called “decoherence.” By
interacting with the environment, the qubits systematically lose information. Some of the codes
that we developed run successfully on the simulators, but they do not run quite well on the backends,
especially the algorithms with an extended circuit depth. In this chapter, we explore the practicality of
quantum computation. The primary learning in this chapter is about the kinds of quantum errors that
can typically occur and the measures to correct them. Our exploration starts with a review of the
classical error correction methods and proceeds with correcting bit and phase errors. After building a
basic theoretical framework, this chapter introduces the concept of stabilizer formalism on which the
Gottesman–Knill theorem is based. The stabilizer formalism is quite a deviation from the amplitude
formalism we have been using so far. The usefulness of the stabilizer formalism is seen when we
apply Shor’s nine-qubit code and Steane’s seven-qubit code in correcting quantum errors. The last
few sections of this chapter focus on surface codes and protected qubits, which protect the qubits at
the physical level. Before concluding this chapter, we explore a scheme that helps in solving
measurement errors.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 375
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_9
376 9 Quantum Error Correction
Ever since John Bardeen, Walter Brattain, and William Shockley invented the first transistor in
1947, electronics has far advanced and greatly influenced our lives. No other technology has
revolutionized the way we live, transact, socialize, and feel secure. The first transistor was about
the size of our palm. Since then, the circuit sizes have shrunken to the range of 7–10 nm. Communi-
cation has evolved from two-way radios and fixed telephones to the intranet that connects everyone in
the world. Today, we can transfer terabits of data in seconds.1 As more things get packed at the circuit
level, and the more we exploit communication channels, the more prone to errors our transactions are.
The classical errors are due to electromagnetic interference, design problems, signal attenuation over
distance, and inherent material deficiencies. Classical circuits employ several schemes to overcome
these errors, and we shall see a few of them briefly in this section.
In 1927, Ralph Hartley at Bell Labs proposed that the number of digits required to represent a
message can be expressed in terms of logarithms. By 1940, Shannon recognized the relationship
between the thermodynamic entropy and informational entropy. He called the negative logarithm of
the probability of an event as the entropy.
Let p be the probability of an event. We wish to use a message to communicate the occurrence of
this event. Let the measure 1p represents the “surprise” brought by the communication of this event. If
the event p is composed of two independent events q and r, such that p ¼ qr, then the following
inequality is true:
1 1 1
6¼ þ ð9:1Þ
p q r
If we measure the surprise by the logarithm of 1p , then the following equality is true:
1 1 1
log ¼ log þ log ð9:2Þ
p q r
We can extend this to a probability distribution of various events ∑ipi ¼ 1. The uncertainty in this
P
distribution is equal to the average surprise i pi log 1p.
1
May 22, 2020, researchers have reported data rate of 44.2 Terra bits per second (Tbps) from a single light source. Ref:
https://www.sciencedaily.com/releases/2020/05/200522095504.htm
9.1 Classical Error Correction 377
In Information Theory, entropy (or Shannon’s Entropy) is the measure of uncertainty of the
outcomes of a random variable. If we are given a random variable X, with a possible outcome xi, each
with a probability pX(xi), the entropy H(X) is defined as follows:
X
HðXÞ ¼ pX ðxi Þ log pX ðxi Þ ð9:3Þ
i
On a classical channel, the original message goes through an information encoding process. It is
encoded at the source and decoded at the destination. The information encoding process helps in
performing critical tasks such as error correction, compression, and security. Information coding
happens at two levels, source coding and channel coding, as explained in the sections below.
Source Coding
A source may be producing a continuous stream of messages composed of the source alphabet. The
source encoder splits the messages into blocks of fixed size. The source decoder assembles the blocks
in the right order and delivers the output message in the output alphabet.
Channel Coding
This process is responsible for transmitting the message generated by the source through the channel.
The channel encoder accepts input messages of fixed length and maps the source alphabet into a
channel alphabet. It then adds a set of redundancy symbols (usually error correction codes, timing
signatures, packet numbers, etc.) and sends the message through the channel. The channel decoder at
the receiving end first determines if the message has any errors, and performs the error correction. It
then removes the redundancy symbols and maps the channel alphabet into the source alphabet.
Finally, it sends the message to the source decoder. This workflow is illustrated in Fig. 9.1.
Shannon experimented with entropy to parametrize communication. He used entropy to explain
the limit to which information can be losslessly compressed on a perfect lossless channel. This
formed his famous source coding theorem. According to this theorem, if lX(n) be the number of bits
required to encode n symbols, then lX(n) is in the following range:
1
H ð X Þ l X ð nÞ ¼ H ð X Þ þ ð9:4Þ
n
He also proposed the noisy-channel coding theorem (or Shannon’s theorem or Shannon’s
limit), which proved that on a noisy channel, it is possible to transmit digital data error-free up to a
computable maximum rate.
ABCD… ABCD…
Source Source
Sender Receiver
Encoder Decoder
41424344… 41424344…
Channel Channel
Classical Comm Channel
Encoder Decoder
0111001100101001101011010
• Let X be the input alphabet. The input symbol x 2 X is modeled by the random variable X, with the
probability density function pX(x).
• Let Y be the output alphabet. The input symbol y 2 Y is modeled by the random variable Y, with the
probability density function pY( y).
• Let the probability of observing the output y for the input x be defined as p(yjx).
If we assume that the channel is memoryless (that is, output depends upon input), then the channel
capacity can be defined as C ¼ max I ðX; Y Þ, where I(X; Y ), the mutual information is the mutual
pX ðxÞ
dependency between the two random variables.
The channel coding theorem guarantees that on a noisy channel with capacity C, with 0 < ε < 1,
there exists a coding scheme to transmit information with a rate close to C, with a probability of error
less than ε.
The capacity of a noisy channel is represented as C ¼ B log 1 þ signal noise , and measured in
decibels (dB.) Here, B is the bandwidth (maximum transmission rate), signal is the average power
of the signal, and noise is the average power of the noise.
P pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
The fidelity of the channel is defined as FðpX ðxÞ, pY ðxÞÞ ¼ x pX ðxÞpY ðxÞ.
Parity
Parity is an example of a systematic code, where the information symbols are embedded into the
codeword. Implementing a parity check is easy. Say, for example, on an 8-bit system, we add an
additional bit to ensure that the total number of 1s is even. For example, the alphabet “A” is
represented by the 8-bits “01000001” in the ASCII encoding system. The number of 1s in the
8-bits is 2. Hence, we add a 9th bit, which is zero. The resultant codeword is “010000010.” At the
receiving end, this can be checked easily.
Unfortunately, parity does not correct bit errors, and it cannot detect if more than one bit has errors.
Block Code
Block codes use a Hamming distance to identify errors. A block code C of length n over the alphabet
A with q symbols is a set of M codewords (or n-tuples). Each of these codewords uses symbols from
A. Hamming distance is defined as the number of positions by which two codewords differ. For
example, if x ¼ (0, 1, 0, 1) and y ¼ (1, 1, 0, 0), the Hamming distance d(x, y) ¼ 2. Hamming weight
is defined as the distance from a position 0. In our example, wt(x) d(x, 0) ¼ 2. Note that
d(x, y) ¼ wt(x + y).
A block code with a block length of n bits, k information symbols (message length), and Hamming
distance d is denoted as [n, k, d]. Here, M ¼ qk. The rate of a block code R is defined as the ratio
between the message length and block length, that is, R ¼ k/n.
9.1 Classical Error Correction 379
A small subset of codewords with Hamming codes is inserted into the transmission. We can detect
errors by checking whether the Hamming codes are received or not. The error correction codewords
are chosen in such a way that the hamming distance is large enough, and it is not possible for a valid
codeword to transform into another valid codeword. The error correction code is used to fix the
corrupted codewords.
Linear Code
A linear code encodes k bits of information in an n bit code space. The code space is defined by an
n k generator matrix G whose elements are {0, 1}. The matrix G maps messages into an encoded
form. The k bit message x is encoded as Gx . For example, G ð0Þ ¼ ð0, 0, 0Þ and G ð0, 1Þ ¼
ð0, 0, 0, 1, 1, 1Þ. The generator matrix for the repetition code described in Sect. 9.2.1 can be written
as follows:
2 3
1
6 7
G ¼ 415 ð9:5Þ
1
The repetition code is an example for a [3,1] code, and it requires 3 bits (n) to encode 1 bit (k)
of information. Linear codes are also used to create parity check matrices. An [n, k] code has
n-element vectors x in {0, 1}. It is defined as follows:
Hx ¼ 0, ð9:6Þ
where H is an (n k) n matrix called the parity check matrix. To generate H, we need to choose
(n k) linearly independent vectors orthogonal to G and set them as the rows of H. For the repetition
code, we choose two linearly independent vectors [1] (0,1,0) and (0,1,1). The party check matrix is:
0 1 0
H¼ ð9:7Þ
0 1 1
We can easily verify that Hx ¼ 0 for the codewords x ¼ (0, 0, 0) and x ¼ (1, 1, 1).
Error Syndrome
Given an [n, k] linear code C with the parity check matrix H, the error syndrome S of the n-tuple v is
defined as:
The syndrome is used to determine if there is an error, and if so, the syndrome identifies the bit in
error.
Generator Matrix
The generator matrix of a [n, k] linear code C is a k n matrix. Its elements are the coefficients of a
generator polynomial g(x). It is explained in the below equation:
380 9 Quantum Error Correction
2 3
gðxÞ
6 7
6 x gð x Þ 7
6 7
6 2 7
G ¼ 6 x gð x Þ 7
6
7
6 7
6 ⋮ 7
4 5
x gð x Þ
k1
2 3 ð9:9Þ
g0 g1 ⋯ gnk1 gnk 0 ⋯ 0
6 7
6 0 g0 g1 ⋯ gnk1 gnk ⋯ 0 7
6 7
6 7
¼66 0 0 g0 g1 ⋯ gnk1 ⋯ 0 7
7
6 7
6⋮ ⋮ ⋮ ⋯ ⋮ ⋮ ⋯ ⋮ 7
4 5
0 0 0 ⋯ g0 ⋯ gnk1 g nk
Example 9.1
Given n ¼ 7 and g(x) ¼ 1 + x + x2 + x3, calculate the generator matrix. Encode the message
y ¼ (1101) using the generator matrix.
Solution:
Here, n k ¼ 3. Since n ¼ 7, we can say that k ¼ 4. From Eq. (9.9), we can write the following
matrix:
2 3
1 1 1 1 0 0 0
60 1 1 1 1 0 07
6 7
G¼6 7 ð9:10Þ
40 0 1 1 1 1 05
0 0 0 1 1 1 1
Dual Code
Given an [n, k] linear code C, the orthogonal complement or the dual of C, denoted as C ⊥ consists of
vectors (or n-tuples) orthogonal to every vector in C : Note that, the generator matrix of C ⊥ is the
parity check matrix of C :
Hamming Code
Hamming codes are linear codes that can detect 2-bit errors and correct 1-bit errors. Assume an
integer r 2. There exists a code with block length n ¼ 2r 1 and message length k ¼ 2r r 1. The
parity check matrix [2r 1, 2r r 1 ] of a Hamming code is constructed with columns of length r,
which are non-zero. Any two columns are linearly independent, therefore d ¼ 3. The number of parity
check symbols are m ¼ n k. Such Hamming code [n, n r, d] are also known as Binary Hamming
9.2 Quantum Error Codes 381
Code. The following is a Hamming code [7, 4, 3] of order r ¼ 3. This Hamming code can check
single bit errors.
2 3
0 0 0 1 1 1 1
6 7
H ¼ 40 1 1 0 0 1 15 ð9:12Þ
1 0 1 0 1 0 1
Supposing if we received a vector x ¼ [1 1 1 0 1 1 0], the error syndrome S(x) ¼ HxT can be
calculated as follows. Note that the arithmetic is to be done in modulo 2.
2 3
1
6 7
617
2 36 7 2 3
0 0 0 1 1 1 1 6 617
7 0
6 76 7 6 7
SðxÞ ¼ 4 0 1 1 0 0 1 1 5 6 0 7 ¼ 4 1 5 ð9:13Þ
6 7
1 0 1 0 1 0 1 617 6 7 1
6 7
415
0
This matches with column 3 of the parity check matrix, indicating that the third bit is in error.
Since this is a classical bit, we can conclude that the third bit is toggled, and correct the received
vector as x ¼ [1 1 0 0 1 1 0].
Hamming Sphere
The n-tuples have 2n elements. We can partition them into 2k disjoint sets called Hamming spheres,
each with a radius t. Thus, we can encode 2k messages. The center of the spheres forms codewords of
a (2t + 1) error-correcting code. Erroneous codewords will be inside or on the surface of a Hamming
sphere. Therefore, the codewords inside a Hamming sphere of radius t can come from a maximum of
t errors. This helps in identification of code words that can be corrected with error correcting codes.
Cyclic Codes
Cyclic codes use circular shifts of the codeword. Each shifted codeword generates another codeword
of the alphabet. Cyclic codes are efficient ways of checking and correcting errors. Cyclic codes can
correct single or double errors. They can also correct burst errors.
In the previous section, we learned that errors do happen in classical systems and that they are
efficiently handled. The quantum error correction [8] draws from classical error correction. However,
we have fundamental challenges. Because of the way the quantum systems work, the qubits
382 9 Quantum Error Correction
eventually interact with the environment, resulting in decoherence and decay of the encoded quantum
information. Quantum gates are unitary transformations that cannot be implemented perfectly at the
physical systems. All these effects accumulate, causing erroneous computation. So, we must combat
against decoherence and gate errors.
In the following sections of this chapter, we discuss how quantum information can be efficiently
encoded in a noisy environment, error corrected, and retrieved.
Assume a quantum system A jφAi in the presence of noise. Let us define another quantum system B
jφBi, prepared in the state j0i. Let there be an encoding E, which maps the joint state of A and B into a
new state:
jφA i jφB i ! φEAB ¼ EðjφA i jφB iÞ ð9:14Þ
A decoding operator E{ will be able to recover jφAi and reconstruct the state A, iff:
Ey φEAB ! jφA i jφB i ð9:16Þ
The goal of quantum error correction is to identify an encoding E, such that the set of correctable
errors S ¼ {es} are the most likely errors that can happen. In this definition, we assume that there are
no errors caused during the operation of E or E{. This is possible, only if the quantum circuits
performing the operations E or E{ are ideal.
Let us now include another quantum system, ancilla jφCi, prepared in the state j0Ci. If we can
identify a recovery operator R, which transfers the noise to the ancilla without decoding the state of
A and B.
R es φEAB j0C i ! φEAB jSC i 8es 2 S ð9:17Þ
We shall apply this formalism in subsequent sections. Let us now look at the error correction
process.
Figure 9.2 illustrates the quantum error correction process. The quantum error correction code
ðkÞ
encodes k-qubits in state ρi into n-qubits of state ρ(n)(0). These n-qubits then go through a noise
process. At time t, their state is ρ(n)(t). The n-qubits are then decoded into k-qubits ρðokÞ .
As an example, the quantum state jψi ¼ aj0i + bj1i can be encoded as jψi ¼ aj000i + bj111i. The
set of 3-qubits j000i and j111i are called codewords. This type of encoding is known as “repetition
code,” as we encode the message by repeating it many times. The decoder can use a simple error
correction scheme such as the “majority rule.” The decoder can correct j100i as j000i, and j101i as
j111i.
A quantum error occurs due to the interaction of the qubits with the environment. Assume an error
operator E, which transforms an initial state jψi to jφi through the mapping:
If we can correct some arbitrary errors Ea and Eb, then we should be able to correct linear
combinations of them E ¼ aEa + bEb. Recall from our earlier discussions that we can distinguish
only orthogonal states, that is, hψ ij ψ ji ¼ 0; i 6¼ j.
Applying this logic to errors Ea and Eb, we should be able to distinguish the states resulting from
the application of these error operators, that is, Eajψ ii and Ebjψ ji. This requires that these two error
states must be orthogonal, that is,
ψ i jEa y Eb jψ j i ¼ 0 ð9:19Þ
If we measure the states jψ ii or jψ ji, the system collapses. Hence, we gather information about
jψ ii by measuring hψ ij Ea{ Ebj ψ ii. This is possible if hψ ij Ea{ Ebj ψ ii is a constant for all basis states,
that is, for all i 2 2k basis vectors of the quantum code [n, k, d]. This can be summarized as the
necessary condition for a quantum code.
ψ i jEa y Eb jψ j i ¼ Ci,j δi,j , where C is a constant of i and j: ð9:20Þ
Assume that we have a quantum error correction code with k ¼ 1, which maps one logical qubit
into n physical qubits in Hilbert space H 2n (we discuss this in Sect. 9.3 on the stabilizer formalism,
see Eq. (9.40)):
X X
j0i L ¼ ai jii and j1i L ¼ bi jii; L stands for logical qubits ð9:21Þ
i i
These two logical qubits are entangled in Hilbert space H 2n : The quantum error correction code
must coherently map the 2D space spanned by j0i L and j1i L into the 2D Hilbert spaces required to
correct the three types of errors (bit-flip, phase-flip, and a combination of both, which we discuss in
the next section) for each of the n physical qubits. The Hilbert space H 2n must be sufficiently large to
contain two sets of (3n + 1) mutually orthogonal 2D subspaces for the syndromes (one for the
subspace without errors, and 3 2D subspaces for bit-flips, phase-flips, and bit and phase-flip errors) for
the n-qubits. The two sets required are for each of the logical qubits. This requirement defines the
quantum Hamming bound as the inequality: 2(3n + 1) 2n.
From this inequality, we can say that five qubits are required at a minimum to encode the logical
qubits j0i L and j1i L to recover them from one of the error types.
384 9 Quantum Error Correction
No Errors:
We can use σ I to describe the scenario when there is no error on the qubit.
1 0 a a
σ I jψi ¼ ¼ ¼ aj0i þ bj1i ð9:22Þ
0 1 b b
The Pauli matrices have interesting properties. Two Pauli matrices are equivalent by a factor of
1
or
i or by a complex number of unit magnitude. The set of Pauli matrices along with their
multiplicative factors
1 or
i is called the 1-qubit Pauli Group G 1 .
G 1 ¼
σ I ,
iσ I ,
σ x
iσ x ,
σ y ,
iσ y ,
σ z ,
iσ z
ð9:26Þ
¼hX, Y, iI i,
Exercise 9.1
Prove that the generator of G 1 is hX, Y, iIi.
◄
Figure 9.3 illustrates the general steps followed in correcting single bit-flip errors.
The parity check matrix for this repetitive code is:
0 1 1
H¼i ð9:27Þ
1 0 1
To this state, we apply two CNOT gates. Both the CNOT gates have q[0] as the control qubit and
q[1], q[2] as the target qubits, respectively. Application of the CNOT gates changes the system state
to the following:
CNOT1,2 CNOT1,3 jψi ! aj000i þ bj111i ð9:29Þ
These four possible scenarios are called syndromes. Unfortunately, we cannot detect which qubit
is flipped without doing a measurement. Performing a measurement will collapse the system state,
and that is not what we want. Hence, we must seek alternatives. One way to solve the problem is to
store the syndromes in ancilla qubits.
Fig. 9.5 Circuit showing the ancilla qubits transferring the syndrome. The noisy process may flip one of the bits of the
codeword
9.2 Quantum Error Codes 387
ψ
CODEWORD
0 ψ
0
ANCILLA
Recall from Eq. (9.24) that a phase-flip error is a σ z rotation. The classical bits do not have any phase.
Hence, they do not undergo phase errors. One way to correct a phase-flip is to convert the basis into
the polar basis {j+i, ji}, using H gates. After the basis is converted, we can use the same logic
developed in correcting the bit-flips to correct the phase-flips. Recall from our earlier discussions on
H gates. From Eqs. (5.11) and (5.12), Eqs. (5.18) and (5.19), the action of the H gate on pure states can
be summarized as follows:
H j1i ¼ jþi H j0i ¼ ji H jþi ¼ j1i Hji ¼ j0i ð9:31Þ
We can apply this logic to the encoder circuit in Fig. 9.4. Consider the circuit shown in Fig. 9.7.
The four possible syndromes from this circuit are summarized in the following equation:
qc.barrier()
qc.barrier()
qc.cx(q[0], a[1])
qc.cx(q[2], a[1])
qc.barrier()
# Perform recovery
qc.cx(a[1], q[0])
qc.cx(a[0],q[1])
qc.ccx(a[0], a[1], q[0])
qc.ccx(a[0], a[1], q[1])
qc.ccx(a[0], a[1], q[2])
Recovery is made by applying Hadamard conjugation. From Eq. (5.86), we know the following
identities. The error correction circuit applies this logic to return the qubits to the original basis.
HXH ¼ Z HZH ¼ X ð9:33Þ
The quantum circuit shown in Fig. 9.8 illustrates the phase-flip error correction code.
Source code for implementing the phase-flip correction circuit is provided in Listing 9.2.
9.3 Stabilizer Formalism 389
= 0 + 1
CODEWORD
0 = ++ + + −− −
0
ANCILLA
ψ
CODEWORD
0 ψ
0
ANCILLA
0
ENCODING TRANSFER SYNDROME
The stabilizer formalism was introduced by Daniel Gottesman, and helps us to define quantum codes
as quantum operators that correct all possible errors occurring on the codewords. Assume that we
have n-qubit registers in state jψ ii representing m codewords of a quantum code Q. Let there be Mi
operators, which can detect errors occurring on the codewords. Assume that the operators can find
whether any of the codewords contained errors. If the errors can be defined by Pauli matrices, as seen
in the previous section, we can define a stabilizer S as a subgroup of G n , that is, S ⊂ G n : The
generators of the subgroup can be defined as:
M ¼ fM 1 , M 2 , . . . g ð9:34Þ
The eigenvalues of the generators are +1, if they are codewords of Q and 1, if they are affected by
errors, that is, Mijψ ii ¼ jψ ii for the codewords Q. If there were some errors such that jφii ¼ Ejψ ii,
then we can say Mijφii ¼ jφii. In this definition, S is the stabilizer of Q.
Let us explain this with the help of an EPR state.
1
jϕþ i ¼ pffiffiffi ðj00i þ j11iÞ ð9:35Þ
2
q = QuantumRegister(3, 'q')
a = QuantumRegister(2, 'a')
c = ClassicalRegister(3, 'c')
qc = QuantumCircuit(q,a,c)
qc.barrier()
# use one of the following to simulate noisy process
#qc.z(q[0])
#qc.z(q[1])
#qc.z(q[2])
qc.barrier()
qc.h(q[0])
qc.h(q[1])
qc.h(q[2])
qc.barrier()
%matplotlib inline
qc.draw(output="mpl")
This means jϕ+i is an eigenvector of Mx and Mz. The corresponding eigenvalue is +1, and these
two generators commute.
The errors E ¼ {E1, E2, . . ., Ee} occurring on the m codewords is also a subgroup of G n , that is,
E ⊂ G n : Each operator Ei in this set is a tensor product of the Pauli matrices, with its weight equal to
the number of errors in the codeword. The error operators anticommute with the generators G n. If we
compute the eigenvectors of the generators, those with an eigenvalue of 1 have errors.
In a [n, k, d] code C , the cardinality of M is n k and the cardinality of the stabilizer S is 2n k.
The weight of M 2 S is the number of elements of M different from I. Here, I refers to σ I. If any of
the elements (other than I) of the stabilizer S has a weight less than d, then the stabilizer code is said to
be degenerate.
The GHZ and Bell states are good examples of stabilizer states. The GHZ state described by
Eq. (5.158) can be described by the following linearly independent generators of the jGHZi3 stabilizer
group:
M1 ¼σ x σ x σ x XXX
M2 ¼σ z σ z σ I ZZI ð9:37Þ
M3 ¼σ I σ z σ z IZZ
M1 ¼ ð1Þa XX
ð9:38Þ
M2 ¼ ð1Þb ZZ, where ½a, b ¼ f0, 1g
The stabilizer formalism helps design correction circuits and identifies the logical operations that
can be applied directly to encoded data. In multi-qubit systems, the stabilizer states are defined as a
subspace within the larger Hilbert space of a multi-qubit system. For example, 2-qubit systems
require four dimensions in the Hilbert space. If two ZZ operators can represent them, then we need
only two orthogonal states to represent the system:
1 1
j0iL pffiffiffi ðj00i þ j11iÞ j1iL pffiffiffi ðj00i j11iÞ ð9:40Þ
2 2
This reduces to a logical qubit. Effectively, multi-qubit systems can be represented as single qubit
systems for convenience sake, by reducing the dimensionality of the associated Hilbert space.
The stabilizer formalism can also be used to describe quantum gates such as the H gate, phase
gates, and the CNOT gate. We shall look here an example interpretation from Nielsen and
Chuang [1].
392 9 Quantum Error Correction
Let U be a unitary operator of the quantum code Q that is stabilized by S. Assume that jψ ii be a
state of Q, and let gi be an element of S. We can then write:
We can therefore say UgiU{ is the stabilizer of Ujψ ii. We can as well expand this and say that
USU{is the stabilizer of UQ. As an application of this concept, let us look at the Hadamard
conjugation of Z, that is, HZH{ ¼ X. We can interpret the conjugation as follows: the Hadamard
gate applied to the state stabilized by Z (say for example j0i) is the state stabilized by X (in this case it
is j+i. ) This interpretation can be expanded to n-qubits. If we have stabilizers hZ1, Z2, . . ., Zni for the
state j0i n, the Hadamard gates transform them to a state with stabilizers hX1, X2, . . ., Xni. Note that,
this is a compact notation when compared with the equal superposition state described by 2n states.
From the above argument, if we must simulate a quantum computation on a classical computer, it is
sufficient if we update the generators of the stabilizers as the system evolves unitarily. State
preparation, Clifford group, controlled operations, and measurements can be performed in O(n2)
steps. If we have m operations on n qubits, this is done in O(m n2) steps. These are some tasks
classical computers can easily perform. Therefore, according to Gottesman–Knill theorem [4–7],
some basic tasks like quantum entanglement, superdense coding, quantum teleportation, can be
efficiently performed on a classical computer. Formally, the theorem states that:
A classical computer can efficiently simulate a quantum circuit based on the following elements:
Gottesman–Knill theorem shows us that simply having a system in an entangled state is not
enough to give quantum speedup. However, not all quantum computations can be efficiently
described by the stabilizer formalism. The system state properties that are not described by polyno-
mial sized stabilizers seem to have exponential speedup [2]. Besides, it just seems to be the formalism
that is chosen—amplitude formalism or stabilizer formalism.
The classical computer is a classical physical system whose parts interact with one another in a
locally causal, spatiotemporally continuous way. Thus, a description of a classical computer simula-
tion of a quantum system, even when it involves communication, is a local hidden variables
description of the problem [3].
This is a subject for study. Nevertheless, there is much more to quantum computing than the power
of entanglement [1].
In the preceding sections, we saw single-qubit error correction codes for bit and phase-flips. Peter
Shor devised a 9-qubit error correction code that can correct bit-flip, phase-flip, or a combination of
both on a single qubit. The algorithm is quite simple. We first encode the codewords for phase-flip
recovery and then encode each qubit for bit-flip recovery. Consider the quantum circuit shown in
Fig. 9.10. This circuit is known as “concatenation” as it encodes using a hierarchy of levels. The
9.3 Stabilizer Formalism 393
phase-flip circuit encodes the qubits as: j0i ! j+ + +i and j1i ! j i. The second part of the
circuit is the bit-flip circuit, which encodes the states as follows: jþi ! p1ffiffi2 ðj000i þ j111iÞ and
ji ! p1ffiffi ðj000i j111iÞ.
2
The resultant encoding of the 9-qubits are the following codewords:
Shor’s 9-qubit code can fix one bit-flip in any of the three circuit blocks and a single bit phase error
in any of the nine qubits. If there is a combination of a bit-flip and a phase-flip occurring on a qubit,
the bit-flip correction circuit fixes the bit-flip error while the phase-flip corrects the phase-flip errors.
Figure 9.9 illustrates the Shor’s 9-qubit encoder.
Source code for the circuit in Fig. 9.10 is provided in Listing 9.3. Readers can introduce single-
qubit errors and verify the circuit works. Readers can also set the initial system state to basis state or
pure state, and try various combinations.
The parity check matrix for Shor’s code is:
2 3
0 0 0 0 0 0 0 1 1
60 0 0 1 1 1 1 0 07
6 7
H¼6 7 ð9:43Þ
40 1 1 0 0 1 1 0 05
1 0 1 0 1 0 1 0 1
The logical operators X and Z for Shor’s encoded qubits are defined as follows:
X Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9
ð9:44Þ
Z X1 X2 X3 X4 X 5 X 6 X 7 X 8 X 9
q = QuantumRegister(9, 'q')
c = ClassicalRegister(1, 'a')
qc = QuantumCircuit(q,c)
qc.h(q[0])
qc.h(q[3])
qc.h(q[6])
qc.cx(q[0], q[1])
qc.cx(q[0], q[2])
qc.cx(q[3], q[4])
qc.cx(q[3], q[5])
qc.cx(q[6], q[7])
qc.cx(q[6], q[8])
#qc.x(q[1])
#qc.z(q[0])
qc.barrier()
qc.cx(q[3], q[4])
qc.cx(q[3], q[5])
qc.ccx(q[5], q[4], q[3])
qc.cx(q[6], q[7])
qc.cx(q[6], q[8])
qc.ccx(q[8], q[7], q[6])
qc.barrier()
# Error recovery
qc.h(q[0])
qc.h(q[3])
qc.h(q[6])
qc.cx(q[0], q[3])
qc.cx(q[0], q[6])
qc.ccx(q[6], q[3], q[0])
qc.measure(q[0], c[0])
%matplotlib inline
qc.draw(output="mpl")
1
M1 j0L i ! pffiffiffi ðZj0ij0iZj0i þ Z j1ij1iZ j1iÞ I 3 ðj000i þ j111iÞ I 3 ðj000i þ j111iÞ
8
1
! pffiffiffi ½ðj0ij0ij0i þ ðj1ij1i j1iÞÞ ðj000i þ j111iÞ ðj000i þ j111iÞ
8
1
! pffiffiffi ½ðj0ij0ij0i þ j1ij1ij1iÞ ðj000i þ j111iÞ ðj000i þ j111iÞ
8
! j0L i
1
ð9:45Þ
M1 j1L i ! pffiffiffi ðZj0ij0iZj0i Z j1ij1iZ j1iÞ I 3 ðj000i j111iÞ I 3 ðj000i j111iÞ
8
1
! pffiffiffi ½ðj0ij0ij0i ðj1ij1i j1iÞÞ ðj000i j111iÞ ðj000i j111iÞ
8
1
! pffiffiffi ½ðj0ij0ij0i j1ij1ij1iÞ ðj000i j111iÞ ðj000i j111iÞ
8
! j1L i
We can similarly prove for the other operators. Hence, the eigenvalue of these operators for
uncorrupted states is +1.
Let us look at the action of an error operator on the first qubit of Block-I.
Ex ð0Þ ¼ X0 I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 ð9:46Þ
This operator performs a bit-flip operation on the first qubit. We can easily prove that this operator
anticommutes with the stabilizer M1.
M1 Ex ð0Þ ¼ ðZ0 Z 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 Þ
ðX 0 I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 Þ
¼ ðZ 0 X 0 Þ I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 ð9:47Þ
¼ ðX 0 Z 0 Þ I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8
¼ Ex ð0Þ M1
The anticommuting property means Ex(0) is an eigenvector of the stabilizer M1with an eigenvalue
1. Hence, if the eigenvalue of the stabilizer is 1, it indicates the presence of error E in the
codeword. Note that M1 can detect the presence of a bit-flip error in the second qubit. However, M1
cannot detect the bit-flip errors in other qubits (because it commutes with the error operator of those
9.3 Stabilizer Formalism 397
qubits). We can similarly prove for a phase-flip, with operator M7, for example, with the first two
blocks of qubits.
To conclude our discussions on this topic, let us recap how this works. Assume the following state:
1
j0iL ! pffiffiffi ½ððj000i þ j111iÞÞ ðj000i þ j111iÞ ðj000i þ j111iÞ ð9:48Þ
8
Assume that an electromagnetic interference sets the second qubit with a bit-flip and phase-flip
error. The new state of the system is as follows:
1
! pffiffiffi ½ððj010i j101iÞÞ ðj000i þ j111iÞ ðj000i þ j111iÞ ð9:49Þ
8
We apply the bit-flip stabilizers M1. . M6 first. From Table 9.2, we can say that stabilizer M1 returns
1, while all other stabilizers return +1. We can conclude that the second qubit has a bit-flip error and
an I0 X1 I2 I3 I4 I5 I6 I7 I8 transform can be applied to correct this error. After this
correction, the state of the system is as follows:
1
! pffiffiffi ½ððj000i j111iÞÞ ðj000i þ j111iÞ ðj000i þ j111iÞ ð9:50Þ
8
At this stage, the phase-flip stabilizers M7 and M8 are applied. From Table 9.2, we can also say that
both the stabilizers return 1, which means, the first block has a phase error. The phase error can be
corrected by applying a Z gate to the qubits in the first block.
Figure 9.11 shows the implementation of the stabilizer circuit, and it is based on Table 9.2.
STABILIZERS 4
5 M
BLOCK - I
BLOCK - II
BLOCK - III
398 9 Quantum Error Correction
Robert Calderbank, Peter Shor, and Andrew Steane invented the CSS codes. The CSS codes are a
type of stabilizer codes. In this section, we shall provide the definition [9] of the CSS codes. In the
next section, we shall study Steane’s 7-bit code as a case of CSS codes.
Let C be a linear [n, k, d] code of a field F n2 (a binary field of n dimensions.) This code can
correct t ¼ d1
2 errors. The generator matrix G is a k n matrix. The rows of this matrix are
independent n-tuples spanning the code C . The parity check matrix H is a (n k) n matrix, such
that HcT ¼ 0; 8c 2 C. The code C is spanned by k independent n-tuples, that is, the cardinality of C is
k. Code C has 2k codewords.
Let C ⊥ be the dual code of C, that is, the n-tuples of C ⊥ are orthogonal to the codewords of C : C ⊥ is
spanned by (n k) independent n-tuples, that is, the cardinality of C ⊥ is (n k.) Code C ⊥ has
2n k codewords.
The parity check matrix H of C is the generator of C ⊥ .
The generator G of C is the parity check matrix of C ⊥ .
If C ⊥ ⊂ C , then C is weakly self-dual.
The quantum code Q for the weakly self-dual classical code C is defined by creating superpositions
of the codewords of C .
We first construct a c-basis, as follows:
k
X
jcw i ¼ 2 2 ð1Þvþw jvi; w 2 F n2 , ð9:51Þ
v2C
Phase errors j0i ! j0i and j1i ! j1i in the c-basis become bit errors in the s-basis. After
applying the change of basis to each qubit in jcwi, the new state is:
kn
X
jsw i ¼ 2 2 ju þ wi; w 2 F n2 ð9:53Þ
u2C ⊥
CODEWORD
CORRECTED
Codeword
H gates H gates
with error
Correct
Compute Compute Correct
bit-flip
Syndrome Syndrome Phase-flip
errors
Ancilla
qubits
Fig. 9.12 Diagram illustrating the workflow for CSS Code. (From Dan C. Marinescu and Gabriela Marinescu)
9.3 Stabilizer Formalism 399
The cardinality of the quantum code Q is k (n k) ¼ 2k n. So, the quantum code Q has
22k n codewords.
To summarize, in this scheme, we first correct bit-flip errors in the c-basis. We then change the
system to s-basis. The change in basis causes the phase-flip errors to become bit-flip errors. They can
now be corrected as bit-flip errors. We can correct at most t bit-flip and phase-flip errors with the
CSS code.
Steane’s 7-qubit error correction code is based on a [7,4,3] Hamming code C. Its generator matrix is
given by:
2 3
1 0 0 0 0 1 1
60 1 0 0 1 0 17
6 7
Gc ¼ 6 7 ð9:54Þ
40 0 1 0 1 1 05
0 0 0 1 1 1 1
Note that the generator matrix is composed of a 4 4 identity matrix, and the matrix
2 3
0 1 1
61 0 17
6 7
A¼6 7:
41 1 05
1 1 1
In this error correction code, there are 2k ¼ 24 ¼ 16 codewords. The codewords are generated by
multiplying the 4-tuples with the generator matrix (Table 9.3).
The following equation shows the parity check matrix:
2 3
0 1 1 1 1 0 0
6 7
H ¼ AT I nk ¼ AT I 3 ¼ 4 1 0 1 1 0 1 0 5 ð9:55Þ
1 1 0 1 0 0 1
The codewords of C ⊥ can be derived from the H matrix. Note that the H matrix is the generator of
C , and we get the codewords by multiplying the n-tuples of C ⊥ with the H matrix. We advise our
⊥
Fig. 9.13 Steane’s 7-qubit encoder circuit. Note that the ordering of the qubits. The topmost qubit is the first qubit q[0],
and the bottom-most qubit is the seventh qubit q[6]
h
1
j0iL ! pffiffiffi j0000000iþj0001111iþj0110011iþj0111100iþj1010101iþj1011010iþ
8 ð9:56Þ
i
j1100110iþj1101001i
Similarly, the logical one (j1iL) qubit is defined by the superposition of all odd codewords of the
Hamming code.
h
1
j1iL ! pffiffiffi j0010110iþj0011001iþj0100101iþj0101010iþj1000011iþj1001100iþ
8 ð9:57Þ
i
j1110000iþj1111111i
Figure 9.13 illustrates the circuit that encodes the Steane’s 7-qubit code. Let us look at the inner
workings of this circuit. We use two CNOT gates to encode the initial state into the superposition state
of the Hamming codewords. We used this technique in our earlier circuits as well. Then, we use three
H gates to prepare the last three qubits in an equal superposition state. The system state at this stage
can be written as:
h i
1
jψiL ! aj000i þ bj111i j0i pffiffiffi j0i þ j1i j0i þ j1i j0i þ j1i ð9:58Þ
8
The first block of CNOTs gates is applied with q[4] as the control qubit and q[1], q[2], q[3] as the
target qubits. This operation transforms the equation as:
CNOTð4!1, 2, 3Þ1
! pffiffiffi að j0000000 i þ j0000001 i þ j0000010 i þ j0000011 i þ j0111100 i
8
þj0111101 i þ j0111110 i þ j0111111 iÞþ
ð9:60Þ
1
pffiffiffi bð j1110000 i þ j1110001 i þ j1110010 i þ j1110011 i þ j1001100 i þ j1001101 i
8
þj1001110 i þ j1001111 iÞ
The second block of CNOTs is applied with q[5] as the control qubit and q[0], q[2], q[3] as the
target qubits. The new system state is:
CNOTð5!0, 2, 3Þ1
! pffiffiffi að j0000000 i þ j0000001 i þ j1011010 i þ j1011011 i þ j0111100 i
8
þj0111101 i þ j1100110 i þ j1100111 iÞþ
ð9:61Þ
1
pffiffiffi bð j1110000 i þ j1110001 i þ j0101010 i þ j0101011 i þ j1001100 i þ j1001101 i
8
þj0010110 i þ j0010111 iÞ
The third block of CNOTs gates is applied with q[6] as the control qubit and q[0], q[1], q[3] as the
target qubits:
CNOTð6!0, 1, 3Þ1
! pffiffiffi að j0000000 i þ j1101001 i þ j1011010 i þ j0110011 i þ j0111100 i
8
þj1010101 i þ j1100110 i þ j0100111 iÞþ
ð9:62Þ
1
pffiffiffi bð j1110000 i þ j0011001 i þ j0101010 i þ j1000011 i þ j1001100 i þ j0100101 i
8
þj0010110 i þ j1111111 iÞ
This equation establishes that the circuit works as intended. We can now apply the stabilizer
formalism to Steane’s code. The generators of the stabilizer code are defined in Table 9.5.
The stabilizers of the Steane’s code are a balanced group. The stabilizers have a uniform weight of
4 and distance 3. The single-qubit errors that can happen in this code are summarized in Table 9.6.
The Pauli operators Z and X for the encoded states in Steane’s code are as follows, and they are
written as the operators of the unencoded qubits.
Z Z1 Z2 Z3 Z4 Z5 Z6 Z7
ð9:64Þ
X X 1 X 2 X 3 X 4 X5 X6 X7
Exercise 9.2
Develop a complete quantum circuit that implements Steane’s code.
◄
It is needless to say that the classical computing industry has grown exponentially because of the fault
tolerance of the transmission and computing systems. Errors do occur in these systems routinely, but
they are detected and corrected efficiently. Communication protocols and hardware designs have
implemented elements to effectively perform error detection and recovery schemes with very high
reliability that under ordinary usage, we do not encounter them at all.
Therefore, quantum error correction is critical for mass adoption of quantum computing and
quantum communication. As we have seen in the past chapters, quantum errors can happen at various
levels. Any circuit we build is no exception to these errors!
While we can learn a lot from the classical error correction schemes, we cannot apply them
directly to quantum error correction, because of how quantum systems work.
9.4 The Path Forward: Fault-Tolerant Quantum Computing 403
• Classical error correction schemes have some levels of redundancy. We cannot have redundancy
in quantum systems, because qubits in arbitrary unknown states cannot be cloned.
• We can distinguish with certainty only orthogonal quantum states. If the errors push the system
into nonorthogonal quantum states, we cannot distinguish the states. Hence, errors cannot be
corrected. This problem is not there in classical systems as the state of the bits can be distinguished
correctly.
• In a quantum system, measurement causes the system to collapse. So without collapsing the
system, we cannot detect errors. In classical bits, information can be read from the bit any number
of times. Hence, it is easy to detect and correct errors.
• Qubits can undergo bit-flip, phase-flip, or a combination of both. The error states of quantum
systems are complex when compared to classical bits. Classical bits can only undergo bit-flip.
• In the case of multi-qubit entanglement, errors can happen with some of the entangled qubits
alone. This poses additional challenges.
• Quantum errors can keep adding up from erroneous qubits and erroneous gates.
Quantum error correction comes handy. QEC schemes we have come across can be used to correct
errors as they dynamically evolve at every level in the system. The quantum accuracy threshold
theorem states that arbitrarily long computation can be carried out reliably, provided all sources of
noise acting a quantum computer are weaker than the accuracy threshold pc. A lower bound on this
threshold is E > 1.9 104.
The QEC schemes use syndrome circuits to get as much information as possible about the quantum
error. Once the syndrome is determined, it is used to relate the error to a superposition of the Pauli
operators or the identity matrix so that the erroneous qubits can be corrected by applying Pauli
rotations. However, the issue with QEC is that the error correction circuits itself can introduce errors
into the encoded qubits. So, the error correction circuits must be designed specifically that they do not
introduce many errors into the encoded data [15].
In a fault-tolerant procedure, we replace each qubit in the original circuit with an encoded block of
qubits, which are error corrected. The gate operations in the original circuit need to be replaced with
encoded gates. The encoded gates must be properly designed so that they do not propagate errors.
Even, if they propagate, it should be to a small subset of qubits in the encoded blocks in such a way
that the errors can be isolated and removed. Let us examine this possibility in some detail by creating
encoded gates of the Clifford group.
From Eq. (5.86), we can say that the Z and X gates can be interchanged under H gate conjugation.
By referring to Eq. (9.64), and by drawing a parallel, we can create an encoded Hadamard gate for the
Steane’s 7-qubit code as H H 1 H 2 H 3 H 4 H 5 H6 H 7 . This encoded gate can be implemented as a
parallel circuit H ¼ H 7 (Fig. 9.14).
Let us assume that while performing this operation, we over- or under-rotated a qubit (which is an
example of a gate error) or an electromagnetic interference happened on a qubit. Let us assume that
the error can be modeled as a phase error. We can write this incidence as HZ XH. This is
equivalent to applying an H gate first and then an X gate. In other words, we can say that following a
perfect H gate, a noise occurred on a qubit. This modeling is an example of a fault-tolerant process.
The reason being, the error that happened on the faulty qubit did not propagate to other qubits. It just
resulted in one error in the block of qubits. Besides, this single-qubit error can easily be corrected.
404 9 Quantum Error Correction
CONTROL BLOCK
q[2]
q[3]
q[4]
q[5]
q[6]
q[0]
q[1]
TARGET BLOCK
q[2]
q[3]
q[4]
q[5]
q[6]
The process of implementing an encoded gate using bitwise operations is called the transversality
of an encoded gate. From Eq. (9.64), encoded Pauli operators X and Z are implemented as transverse
operations. If we must make the encoded gates universal, we must implement the rest of the Clifford
group. This compliance requires us to develop encoded S, T, and CNOT gates. From Sect. 5.4.8.2,
SXS ¼ Y, SYX ¼ X, SZS ¼ Z. We can implement an encoded S gate S S1 S2 S3 S4 S5 S6 S7, which is
transversal. The conjugation of Y yields X. The negative phase in the conjugation of Y can be
corrected with an iZ gate. Therefore, we can confirm that ZS 7 implements an encoded S gate.
Implementing an encoded CNOT gate is straight forward. Before describing that, let us briefly look at
how a CNOT gate can propagate errors.
The CNOT gate has a control qubit and a target qubit. The state of the target qubit is altered
depending upon the state of the control qubit. The error propagates in the forward direction to the
target qubit, if the control qubit is in error. Now consider the circuit shown in Fig. 5.30, and the
Eq. (5.101). In this circuit, we showed how the roles of the target and control qubits could be reversed.
The H gates rotate the basis in such a way that a bit-flip error is transformed into a phase-flip error.
Hence, if a phase error happens in the target qubit, the error can propagate backwards to the control
qubit!
Returning to our discussions, consider the circuit shown in Fig. 9.15, which implements the
encoded CNOT gate.
9.4 The Path Forward: Fault-Tolerant Quantum Computing 405
Assuming Steane’s 7-qubit QEC code, the encoded CNOT gate uses seven controlled-NOT
operations working on two blocks. Assume that one of the CNOT gates fail. Even if we implement
the circuit in parallel, the CNOT gates couple only two qubits. In our example, the faulty CNOT gate
couples one qubit from the control block into another qubit in the target block. This coupling results in
one error in both the blocks, irrespective of the direction of propagation of the error. Again, this is a
single-qubit error that can be efficiently corrected using the QEC schemes.
Recall the T gate from our discussions in Sect. 5.4.2.4. The T gate performs a π4 rotation about the
z-axis. Our next goal is to implement an encoded T gate to make our discussions complete on
the universality of encoded gates. Once universality is achieved, fault-tolerant quantum circuits can
be constructed with a combination of the encoded gates.
Figure 9.16 explains how we may construct a fault-tolerant T gate.
For the sake of simplicity, the diagram shows only one block of the T gate. It should be constructed
in a block of seven for the Steane’s code. Let us derive the inner workings of this circuit for one block.
The derivation can be extended to the rest of the blocks. We start the second qubit in a state of j0i and
apply an H gate, which is followed by a T gate. The first qubit is in a state of aj0i + bj1i. The resultant
state of the system can be written as follows:
1 iπ
ðaj0i þ bj1iÞ pffiffiffi j0i þ e 4 j1i
2
h i ð9:65Þ
1 iπ iπ
! pffiffiffi aj0ij0i þ aj0ie 4 j1i þ bj1ij0i þ bj1ie 4 j1i
2
Now, there are two possibilities. If we measure a j0i with qubit q[0], then the second qubit is in a
iπ iπ
state aj0i þ e 4 bj1i, which is Tjψi. If we measure a j1i, then the second qubit is in a state bj0i þ e 4 aj1i,
to this state, we apply an XS gate. If we ignore a global phase that builds up, this operation is equivalent
to a Tjψi gate (this can be verified easily.) There are some challenges with this circuit, however. The
second qubit must be prepared in a perfect j0i state, and the measurement needs to be perfect. Errors
happening in the first qubit do not impact the measurement. So, we apply the XS gate depending upon
the measurement. A single-qubit error occurring on the second qubit propagates to one qubit in each of
the two blocks, causing a single error in the output of the encoded gate.
Periodic error correction still needs to be performed on the encoded states to prevent errors from
building up. From the implementation of the T gate, it is evident that similar procedures for state
preparation and measurement are needed as well!
406 9 Quantum Error Correction
Consider the circuit in Fig. 9.17, which can perform a projective measurement into the eigenvalues
(
1) of a Pauli operator that squares to the identity matrix.
The system shown in the diagram starts with the first qubit q[0] in state j0i and the second qubit
q[1] in state jφi ¼ aj0i + bj1i. The collective state is given by:
Note that this circuit does not alter the state of the second qubit, but performs a projective
measurement of the input register onto the Pauli operator’s eigenvalues. The circuit measures 0 for
the eigenvalue +1 and 1 for the eigenvalue 1. Readers can try this logic with other Pauli operators
that square to identity and different input states. Let us try to apply this logic to measure a transverse Z
gate on Steane’s code. The circuit for this measurement is shown in Fig. 9.18.
This circuit does not work as expected. Any error occurring on the ancilla qubit will propagate to
all of the encoded qubits, which is not in agreement with our criteria for fault-tolerance. We expect at
most single-qubit errors in a code block. So, this circuit is not fault-tolerant.
The solution to this problem is to create n number of cat states (n ¼ 7 for Steane’s code)
p1ffiffi ð0 n þ 1 n Þ, and then kick back the phase of the Pauli measurement operator into the measurement
2
circuit. Recall our discussion of the cat state in Sect. 3.4.1.1. When we make the final measurement,
the system collapses into one of the cat states: p1ffiffi2 ð0 n þ 1 n Þ or p1ffiffi2 ð0 n 1 n Þ. We can achieve the
9.4 The Path Forward: Fault-Tolerant Quantum Computing 407
cat states with the help of ancilla qubits. Figure 9.19 illustrates this concept in detail. For the sake of
simplicity, the circuit is shown with three encoded data qubits. Recall that we need a minimum of five
qubits. Ideally, Steane’s 7-qubit code is used.
In this circuit, the top three qubits are the ancilla qubits. We prepare these qubits in the cat state by
preparing the first qubit in an equal superposition state with the help of an H gate. Then, two
successive CNOT gates put the ancilla qubits into the cat state.
H ð 0Þ 1 CNOTð0!1,2Þ 1
! j000i ! pffiffiffi ðj000i þ j100iÞ ! pffiffiffi ðj000i þ j111iÞ ð9:72Þ
2 2
The next stage is to verify the cat state. We can verify the cat state with the help of three parity
check qubits. We do this with the help of two CNOT gates with two ancilla qubits serving as the
control qubit. Let us illustrate how this works by evaluating the first parity check operation.
1 CNOTð0!3Þ 1
pffiffiffi ðj000ij0i þ j111ij0iÞ ! pffiffiffi ðj000ij0i þ j111ij1iÞ
2 2
ð2!3Þ
ð9:73Þ
CNOT 1
! pffiffiffi ðj000ij0i þ j111ij0iÞ
2
408 9 Quantum Error Correction
From the above equation, if we measure the parity qubit, it should return a state j0i. All parity
check qubits are measured and verified that they return j0i. If any of the parity qubits return a state j1i,
we can conclude that there is a problem with the cat state preparation. We can then discard the
preparation and start all over again. Note that this circuit is not implemented in a fault-tolerant way,
the CNOT gates can fail due to bit-flips, phase-flips, or a combination of both.
Any phase error occurring in the parity qubits can propagate forward into the ancilla qubits and
cause phase errors in two ancilla qubits. Although the phase-flips do not propagate to the encoded data
qubits, there is a possibility that the final measurement can get affected. We can solve this problem by
repeating the measurement three times and taking a majority vote. This additional step gives us a
possibility to reduce the probability of error to O( p)2, if we assume that the circuit can fail at most two
times.
The bit-flip or the combination of bit-phase flips can propagate to the encoded data. However, after
the cat state verification, there can be at most only one of these errors. Hence, the overall implemen-
tation is fault-tolerant.
After the verification of parity, we perform the controlled execution of the M gates (Z in the
circuit.) The cat state ensures that the errors occurring in any of the M gates do not propagate to the
other gates. Therefore, there can at most be one error in the encoded data. Finally, we “un-do” the cat
state with the series of CNOT gates in the ancilla qubit, followed by an H gate in the first ancilla qubit.
We measure a 0 or 1, depending upon the eigenvalue, the encoded data produces with the measure-
ment operator M.
The experiment is repeated three times, and a majority vote is taken. This gives us an option to
reduce the probability rate of error to O( p)2. Note that this logic works for fault-tolerant state
preparation as well.
From the discussions so far, it is well understood that to perform reliable quantum computation, we
need to reduce the error rate to the threshold level. Implementing the QEC schemes discussed so far is
one way to increase fault tolerance. However, QEC schemes come at the cost of increased physical
qubits. The more the physical qubits are, the more error-prone the circuit is. Assume that the
probability that an individual qubit (or a quantum gate/preparatory circuit/measurement circuit)
may fail is p, then the probability of an encoded operation failing is cp2, where c is a constant. If
p 1c, then the probability gets lower than p. We use concatenation to reduce this further. Concate-
nation, in this context, works by taking the original circuit and concatenate with itself. By doing so,
we make the circuit at the second level operated by the fault-tolerant operation of the first level of
encoding. Concatenation causes the probability of failing to reduce from cp2 to c(cp2)2. If we
l
concatenate l times, then the number of qubits in the circuit is nl and the error rate is E ¼ 1c cp2 :
When the number of qubits increases exponentially in l, the error rate decreases doubly exponentially
in l. If there are d operations in a fault-tolerant procedure, then the size of the circuit is given by the
following equation.
1
d ¼ O poly log ð9:74Þ
cE
Note that each gate has to be implemented with an accuracy of nEl : If the probability of error is less
than 1c , then we can perform robust quantum computation. The increase in the circuit size is
polylogarithmic in the accuracy with which we want to perform the computation.
9.5 Surface Codes 409
While the error rate goes down rapidly when compared with the number of qubits, this is still not
realistic [10]. We need physical qubits with error rates significantly less than the threshold value. In
the next section, we discuss another novel and emerging error correction scheme—surface codes.
Surface codes are stabilizer circuits known for the tolerance to local errors (deformations). Alexei
Kitaev first proposed a surface model to describe topological order using qubits placed on the surface
of a toroidal geometry. The toric code is pedagogical, and included in this chapter for its sheer
elegance in describing topological protection against local deformations. The planar code evolved
from the works of Michael H. Freedman, David A. Meyer [12], and Sergey B. Bravyi and Alexei
Kitaev [13].
Note: Reading Chap. 4 may be helpful to read the following section in this chapter.
Toric code is a toy model proposed by Alexei Kitaev. We can obtain a toric code of genus 1 (the genus
is the number of holes in the torus) by taking a square lattice with periodic boundary conditions, and
joining the top and bottom edges, left and right edges. This process embeds the n edge graph Γ of the
square lattice into the torus 2 (Fig. 9.20).
A qubit is placed at each edge of the graph, the states of which form the codewords. The total
number of qubits in the lattice is 2n2.
For each vertex v of the graph Γ, let us define an operator Av (v denotes vertex) as a tensor product
of Pauli X matrices and Identity matrices, such that Av performs a Pauli X gate on each of the four
qubits corresponding to the four edges adjacent to v. Otherwise, Av acts as an identity gate. Similarly,
we define one more operator Bp ( p denotes plaquette) such that for each of the four qubits enclosing
the plaquette, Bp performs a Pauli Z gate. Otherwise, Bp acts as an identity gate. Thus, the stabilizers
are defined as the loops around each of the vertices or plaquettes of the lattice:
Av ¼ X1 X2 X3 X4 and Bp ¼ Z 1 Z 2 Z 3 Z 4 ð9:75Þ
For two vertices v, v0 , and for two plaquettes p, p0, we can say that ½Av , Av0 ¼
Bp , Bp0 ¼ 0 , 8v, v0 , p, p0 , since the Pauli operators commute with each other and with the identity.
If v and p are not adjacent, then Av and Bp naturally commute. If they are adjacent, they share two
qubits, and hence they still commute, that is, [Av, Bp]¼ 0, 8v, p. Hence, we can create a subgroup of
commuting generators.
S ¼ Av1 , Av2 , Av3 , . . . , Bp1 , Bp2 , Bp3 , . . . ð9:76Þ
We have n edges in the lattice, so there are n qubits. However, it is a characteristic of the torus that
we have n2 plaquettes and n2 vertices. So, there is actually n2 Av and n2 Bp operators. Therefore, S is a
generator of n2 Av and n2 Bp operators of size n. However, they are not entirely independent generators.
The eigenvalues of Av and Bp are
1. So, we have,
ΠAv ¼ ΠBp ¼ þ1 ð9:77Þ
v p
Note that, each qubit is included in two vertices and two plaquettes. Due to this property, one of Av
and one of Bp must be linearly dependent on all others, and we lose two degrees of freedom from the
n generators.
The size of the code space is 2n k ¼ 2n (n 2) ¼ 22 ¼ 4. So, we can say that the toric code is a
2
[n , 2, n] stabilizer code. Hence, we can have two data qubits in a system of n physical qubits. The
Hamiltonian of the toric code is derived from the interaction terms of the vertices and plaquettes,
X X
H ¼ Av Bp ð9:78Þ
v p
The ground state jξi is a common eigenstate +1 of Av and Bp 8v, p. In the computational Z-basis,
the ground state can be written as [11]:
1
jξi ¼ Π pffiffiffi ðI þ Av Þj000 . . . 0i, ð9:79Þ
v 2
where the ket j000. . .0i is the superposition of a ground state stabilized by Bp, and (I + Av) projects
that state to the ground state of Av.
In the computational basis, the ground state constraint of Bp is:
X
φp jzi i ¼ jz1 i þ jz2 i þ jz3 i þ jz4 i ¼ 0 , ð9:80Þ
i2Cp
where Cp is the boundary of a plaquette p. Similarly, we can define the ground state constraint for an
adjacent plaquette p0 .
X
φp 0 jzi i ¼ jz2 i þ jz5 i þ jz6 i þ jz7 i ¼ 0 ð9:81Þ
i2Cp 0
Fig. 9.21 Merging adjacent plaquettes and expanding into the entire lattice
Note that we have removed jz2i. We can expand this procedure to encapsulate the entire lattice
(Fig. 9.21).
X
φ jzi i ¼ zedge1 þ zedge2 þ zedge3 þ zedge4 ¼ 0 ð9:83Þ
i2C
When we introduced the lattice Γ, we said that it is bound by periodic boundary conditions. The
boundary conditions lead to the fact that jzedge1i ¼ jzedge3i and jzedge2i ¼ jzedge4i.
Therefore, the ground state can be characterized by two independent quantities describing the four
degenerate states.
ξ1 ¼ Π Zi ¼
1 and ξ2 ¼ Π Zi ¼
1 ð9:84Þ
i2edge1 i2edge2
The ground state jξi corresponds to the vacuum (that is, absence of anyons) state 1, and the lattice
is a source of e(X), m(Z) anyons, and E fermions. Let us assume that we apply a Z gate to a qubit on an
edge. This creates a pair of quasiparticle excitations in two adjacent vertices. If we measure the Av
operator on the two adjacent vertices, we get a 1 eigenstate. The quasiparticles created in this
process are called e anyons. Similarly, we can create pairs of m anyons in the plaquette Bp using an X
gate. Composite E anyons can be created by the action of Z and X gates. If we apply the same gate two
times, the overlapping anyon fusion results in the eigenstate of +1, which is the vacuum. The fusion
rules are:
We can detect the presence of the e, m, E anyons by measuring the eigenvalues of the operators Av
and Bp.
By applying Z rotations to consecutive qubits, we can move the anyons. This creates an open path,
with the e anyons at the boundaries. If the path is closed, the anyons annihilate. Let us create a loop
operator ZC that performs this task.
Note that the loop operator ZC measures the fusion outcome of m anyons. A loop around a
plaquette is the operator Bp, and larger loops can be split into plaquettes with overlapping edges.
Hence, we can generalize ZC as follows:
412 9 Quantum Error Correction
Z C ¼ Π Bp ð9:87Þ
p2C
We can try the same process using X rotations, but it does not work as expected, as the X operator
does not commute with some of the Bp operators. One way to solve this problem is to introduce the
concept of a dual lattice Γ0. The dual lattice has its vertices in the center of the plaquettes of the first
lattice, and its plaquettes aligned with the vertices of the first lattice. With this arrangement, applying
X rotations to consecutive qubits can create a closed-loop in the dual lattice, which causes the
m anyons to annihilate. The loop operator corresponding to the successive X rotations is:
X C0 ¼ Π 0 X i ð9:88Þ
i2C
Here again, we can say that the loop operator XC measures the fusion outcome of e anyons. In other
words, the loop operators measure the parity of e or m anyons inside the loop. Following our previous
argument, we can generalize XC as:
X C0 ¼ Π 0 A v ð9:89Þ
v2C
Note that ZC and XC are contractible operators in the sense that they don’t loop around the torus
in either of the directions.
If in case, the loop encircles the torus horizontally, then it is equivalent to the noncontractible
operator ξ1. Similarly, if the loop encircles the torus vertically, it is equivalent to the non-contractible
operator ξ2. This is evident from the edges these two operators work on from Eq. (9.84).
For simplicity, let us label the horizontal and vertical trajectories as 1 and 2, respectively. We can
also name the horizontal Z-loop operator as Z1 and the vertical Z-loop operator as Z2, with
eigenvalues
1, as this naming convention is easy to use. Since [Z1, Z2] ¼ 0, the four combinations
of the eigenvalues are representative of the possible two-qubit manifold in the torus.
Following the above argument, let us create a horizontal X-loop operator X1, and a vertical X-loop
operator X2, with eigenvalues
1.
In a scenario where we have Z1 and X1loops in the torus, [X1, Z1] ¼ 0. The reason is we can
displace one of the loops so that they do not have to share a common edge. The same logic holds good
for Z2 and X2 loops, and [X2, Z2] ¼ 0.
However, if we have a combination of Z1 and X2, or Z2 and X1, the two loops must share one edge.
If we can label the common edge as 0, then the anticommutators are:
fX1 , Z2 g ¼ σ x0 , σ y0 ¼ 0 and fX2 , Z1 g ¼ σ x0 , σ y0 ¼ 0 ð9:90Þ
From the above logic, we can deduce the correspondence with the logical Pauli operators on the
torus,
X1 ! σ x2 X2 ! σ x1
ð9:91Þ
Z 1 ! σ z1 Z 2 ! σ z2
Note that the horizontal and vertical trajectories 1 and 2 are noncontractible. Since the anyons
annihilate at the end of these loops, there are no resultant excitations. Therefore, they should represent
ground states. The four ground states can be defined as follows:
jψ 1 i ¼ jξi jψ 2 i ¼ Z 1 jξi
ð9:92Þ
jψ 3 i ¼ Z 2 jξi jψ 4 i ¼ Z 1 Z 2 jξi
9.5 Surface Codes 413
Fig. 9.22 The fourfold degeneracy of the ground state of the toric code. (a) ground state. Note that the noncontractible
loops in (b) and (c) can be displaced. The loops in (d) share one edge in common
Since jψ 1i starts at the ground state jξi, the Z1 and Z2 operators act on jξi and create e anyons that
move along the paths 1 and 2, respectively, to get annihilated at the end of the loops. The four states
are linearly independent and correspond to the winding directions of the torus. From this, we can
create linearly dependent states that use the loop operators corresponding to the e or m anyons. Hence,
the torus represents a 4D Hilbert space, encoding two qubits. Figure 9.22 illustrates the fourfold
degeneracy of the ground states, where information can be encoded.
Using the ground state degeneracy, the four different states of the two logical qubits can be defined
as follows:
Note that the loops 1 and 2 can be displaced, as long as they go around the torus.
Since we have established the ground state degeneracy, one important property we must explore is
how the ground state degeneracy is topologically protected.
Consider a local operator that operates on a random sequence Ο XiZjZk. . ., on nearby sites i, j,
k. . . Let us define some noncontractible loops C1, C2, C0 1, C0 2 with corresponding operators Z1, Z2, X1,
X2. If we choose the operators in such a way that they do not share a common edge with Ο, then we
can say that [Ο, X1] ¼ [Ο, X2] ¼ [Ο, Z1] ¼ [Ο, Z2] ¼ 0.
From Eq. (9.91), we know that the operators X1, X2, Z1, Z2 correspond to Pauli rotations σ x and σ y.
This means Ο commutes with the Pauli operators. From Example 2.8, we know that this is possible
only if Ο is a multiple of I.
From Eq. (9.79), we know that the ground state jξi is a superposition of all possible elementary
loops such as C1, C2, C0 1, C0 2. Hence, the application of the contracting local operator Ο on the ground
state gives rise to a multiple of the same state. We can ignore the multiple, as the loops can be
displaced. Due to this reason, the excited state is an equal superposition state of all possible paths that
connect the anyons. Hence, the ground state degeneracy is topologically protected (Fig. 9.23).
Errors on the toric code are caused by stray operators, which can cause anyonic excitations. One
bit-flip error creates a pair of anyons, causing a path along two consecutive edges of the dual lattice—
the endpoints of the path project to eigenvalue 1. The eigenvalue of a normal plaquette is +1, so a
change in this is an error. Hence, by measuring the stabilizers, we can easily find the error states and
their locations. Once the location is identified, we can use Z or X gates to move the anyons along the
414 9 Quantum Error Correction
shortest path and annihilate them, thereby returning the system to the ground state. The error
correction works if the error path is < n2, where n is the linear length of the torus. If the path is > n2,
the correction path may be equivalent to a noncontractible path of a logical gate. However, with large
torus sizes, we can prevent the error paths from going around the torus [11] (Fig. 9.24).
9.5.1.1 Summary
The logical gates encoded by the torus provide only phase information. Hence, the anyonic toric code
is not suitable for developing universal quantum gates. Furthermore, irrespective of the torus’ size,
they can store only two qubits that are topologically protected. Due to this reason, the toric code has a
very low code rate of 2n : For large values of n, this is not so useful. However, the toric code is a very
good candidate for developing quantum memories. The toric code is still an experimental model.
There is a possibility of implementing toric code using arrays of Josephson junctions.
Z Z Z Z Z Z Z Z Z Z Z
Z X Z X Z X Z X Z X Z
Z Z Z Z Z Z Z Z Z Z Z
Z X Z X Z X Z X Z X Z
Z Z Z Z Z Z Z Z Z Z Z
Z X Z X Z X Z X Z X Z
Fig. 9.26 Surface code cycles. (a) X-measurement and (b) Z-measurement
Z ¼ Za Zb Zc Z d and X ¼ Xa Xb Xc Xd ð9:94Þ
Due to this arrangement, any error occurring on a data qubit reflects on two adjacent X-measure-
ment qubits and two adjacent Z-measurement qubits. Note that the lattice terminates with
X boundaries at the top and bottom and Z boundaries on the left and right. The X boundaries are
known as smooth boundaries, and the Z boundaries are known as rough boundaries.
The measurement qubits operate on the data qubits in a specific order. The X-measurement starts at
state j0i, and performs an H gate on the measurement qubit. Then, four CNOT operations are
performed on the neighboring data qubits with the measurement qubit as the control qubit. After
performing the CNOT gates, another H gate is applied to the measurement gate, before it can be
measured. The Z-measurement starts first by initializing the measurement qubit to state j0i, and then
performing an I gate. The I gate provides for the necessary waiting time for the H operation to
complete on the X-measurement. After the I gate, four CNOT gate operations are performed with the
neighboring data qubits serving as the control qubits. Finally, an I gate is applied to the measurement
qubit, before it can be measured. This sequence is shown in the quantum circuits featured in Fig. 9.26.
The measurement operation is performed for all measurement qubits in the lattice. This task
projects the data qubits into a quiescent state, which is not a fully entangled state of the lattice. While
some of the local qubits may be highly entangled, a small degree of entanglement may be present with
distant qubits.
If the measurement is repeated the quiescent state should remain the same, unless perturbed by a
bit-flip, phase-flip, or a combination of both occurring on one or more qubits. Let us assume that a
416 9 Quantum Error Correction
phase-flip occurs on a qubit a. This error causes the quiescent state to project to jψi ! Zajψi. If we
repeat the measurement, there is a possibility that the lattice returns to the original state jψi erasing
the error. Let us examine the second possibility with X and Z stabilizers.
XðZa jψ iÞ ¼ Z a ðXjψ iÞ
ð9:95Þ
¼ Z a jψ i
This equation means Zajψi is an eigenstate of the stabilizer X, with an opposite sign.
Z ðZa jψ iÞ ¼ Z a ðZjψ iÞ
ð9:96Þ
¼ Z a jψ i
Thus, the error in the data qubit does not change the outcomes of the Z-measurement. These results
apply for both the sets of adjacent Z or X-measurement qubits. Since the phase error reflects on the
two adjacent X-measurement qubits, we should be able to identify the qubit a. We can fix this by
applying Za to the affected qubit. However, the fix is done in the classical governing software by
flipping the sign of the corresponding X-measurement qubits in subsequent operations. Doing this in
software avoids additional error injection by an error-prone Za gate. Bit-flip errors are handled by
flipping the sign of the neighboring Z-measurement in software. If both bit-flip and phase-flip errors
occur simultaneously, it is reflected in both the two neighboring Z- and X-measurement qubits.
If an error occurs in the measurement process, it should vanish in the subsequent cycle. There is a
possibility that the measurement error can repeat for the same qubit in the subsequent cycle, but with
a lower probability. For the following measurements, the probability should be further reduced.
Therefore, we need several surface code cycles to identify single and sequential measurement errors.
from the stabilizer measurements. The stabilizers form a linearly independent set. Hence, the 2 40
constraints are linearly independent. The remaining two unconstrained degrees of freedom can be
used to construct a logical qubit using the logical operators XL and ZL shown in the diagram.
Consider an operation X1 on the leftside of the boundary. This change is detected by the
Z-measurement qubit on the right-hand side of this data qubit that is bit-flipped. If we perform an
X2 operation on the qubit to the right, we can say that the first Z stabilizer commutes with the two
X operations. Now, the Z-measurement to the right of this finds a change, and we add an X3 operation
to this. We can repeat this cycle until we reach the right side boundary with the X5 operation. With
this, we have created a concurrent operator XL ¼ X1X2X3X4X5, which connects the two X-boundaries.
We find that every other Z-measurement in the lattice interacts with the data qubits along XL, to which
it commutes. Hence, XL forms one of the degrees of freedom. It can be shown that any other operator
X0L which we may create, similarly, can be written as XL multiplied by the product of X stabilizers
used. Hence, there can be only one linearly independent XL operator of the lattice. Similarly, we can
create another operator ZL ¼ Z6Z7Z3Z8Z9, as shown in the diagram.
The two logical operators XL and ZL anticommutes (we leave it to our readers to work this out) just
like the physical qubit gates X and Z do. We can show that X2L ¼ Z 2L ¼ I , and we can create the
sequence YL ¼ ZLXL. Therefore, we can say that the lattice behaves like a logical qubit.
In our example, the number of data qubits was higher than the number of stabilizer qubits. Hence,
the quiescent state jψi, as we have seen, is not fully constrained. We can, therefore, describe the
quiescent state as jψi ¼ jQijqLi. Here, jQi represents a constrained state in the Hilbert space of
N dimensions, determined by the N stabilizer measurement outcomes. The remaining degrees of
freedom are with jqLi. The stabilizers have no effect on jqLi, and the operators XL and ZL have no
effect on jQi. The eigenstates of ZL are jqLi ¼ j0Li, and jqLi ¼ j1Li. The eigenstates of XL are
jqLi ¼ j
Li. Therefore, we can use a computational basis or polar basis for the logical qubit jqLi.
Similarly, we can create more than one logical qubit in the lattice by creating additional degrees of
freedom. Each logical qubit added to the system increases the dimensionality of the Hilbert space by
two. In a system of n qubits, the dimensionality of the Hilbert space is 2n. For the lattice shown in
Fig. 9.27, jqLi is in a 2D Hilbert space defining a single qubit.
Additional degrees of freedom are created by turning off an intermittent Z-measure qubit (called
Z-cut-hole), which creates two additional degrees of freedom. Logical qubits created using this
method are called smooth defect or dual defect qubits in literature. Similarly, we can create an
X-cut-hole by turning off an intermittent X-measure qubit. Logical qubits created using this method
are called rough defect or primal defect qubits. It is also possible to create double Z-cut or double
X-cut logical qubits [10].
rates p < Pth, numerical simulations indicate that PL pde [10]. The error dimension de for odd d is
given by de ¼ (d + 1)/2, and for even d, it is de ¼ d/2. With this, the logical error rate is approximated
as [10]:
de
p
PL ffi 0:03 ð9:97Þ
Pth
We find that nq increases rapidly as p approaches Pth. If we set a target for the gate fidelity to be
above 99.9% that is, p≲103 , the number of physical qubits required to form a logical qubit is in
the range 103 to 104. This brings the logical error rates below to the range 1014 to 1015. When the
error rate is brought down to this level, complex algorithms such as Shor’s can be run with a good
success.
9.5.3 Summary
The tolerance of the surface code to errors for each step of the operation is about 1%. Steane and
Bacon-Shor codes in 2D lattices with nearest-neighbor coupling configurations require a per-step
threshold of 2 105. This requirement is higher than the surface codes by order of three magnitudes
[10]. The less stringent requirement for error tolerance and the ability to do a 2D layout with nearest-
neighbor coupling makes the planar code (or the surface code, interchangeably) the most realistic of
the surface code family.
However, this comes at the cost of the number of physical qubits required. We need a minimum of
13 physical qubits to implement one logical qubit. For a reasonable fault-tolerant logical qubit on a
surface code, we need about 14,500 physical qubits for an error rate, which is 1/10th of the threshold
rate (0.75% per operation.)
Quantum computers with error-corrected qubits that can perform complex tasks such as the integer
factorization are not too far from now! In the following section, we examine some of the emerging
qubit designs with inbuilt fault-tolerance. Hope is not yet crushed!
Note: Reading Chap. 4 may be helpful to read the following section in this chapter.
We learned that the surface codes implement quantum error correction using stabilizer circuits,
confining the system state into a subspace protected from local noises. Such schemes are stepping
stones toward fault-tolerant quantum computing. However, from the preceding arguments, we need
physical qubits with error rates less than a threshold value to implement fault-tolerant quantum
computers. Therefore, it is essential that fault tolerance should stem from physical qubits. In this
section, we shall explore a few selected protected qubit designs with inbuilt fault-tolerance, which
have been reported by researchers in recent times. A study of these designs should give an idea, where
qubit technologies are heading to and re-emphasize the promise of quantum supremacy [14].
9.6 Protected Qubits 419
The 0 π qubit is an intelligent design that uses a two-lead superconducting device, whose energy is
minimized when the superconducting phase between the leads is either 0 or π (and hence the name.)
Due to the design, the 0 π qubits have a higher barrier that prevents bit-flips. The degeneracy of the
basis states suppresses the phase-errors. The potential to minimize the effects of local noises provides
the necessary protection to the encoded quantum information. The 0 π qubit design is due to Peter
Brooks, Alexei Kitaev, and John Preskill. This section is a condensed version of the original
research paper. We first establish that the energy stored in a system of two identical Josephson
circuits connected by a capacitor is a function of the phases and then apply the concept to a qubit
design by rewiring the circuit. We finally demonstrate how a protected phase gate can be constructed
by coupling the qubit with an oscillator.
Q 2 φ2
H¼ þ , ð9:99Þ
2C 2L
where Q ¼ 2e q
, 2e is the Cooper pair charge, and φ ¼ 2e
ħ Φ is the superconducting phase. The phase
φ ¼ 2π corresponds to 2e h
of the magnetic flux.
pffiffiffiffiffiffi
The ground state of the Hamiltonian has the energy E0 ¼ 12 LC. Its wavefunction can be described
in terms of the Gaussian function:
φ2
rffiffiffiffi!
h φ2 i
1 L
h cos φi ¼ e 2 ¼ exp : ð9:101Þ
4 C
qffiffiffi
If L
C
1, the phase φ has large fluctuations in the ground state, and the ground state of the
wavefunction is broad. The above function averages out, except for a small exponential correction
factor.
Let us examine the sum and difference of the superconducting phases at the leads now.
The phase φ+ ¼ (φ1 + φ2)/2 is not dependent on C1, and it is called the “light” variable with large
fluctuations. The phase φ ¼ (φ1 φ2) is dependent on C1, and it is a localized “heavy” variable. If
the phase-slip2 between the inductors is suppressed, φ
are real variables.
From the circuit, the effective capacitance controlling the phase φ+ is 2C, and the effective
inductance is L/2. Therefore,
rffiffiffiffi
2 1 L
φþ ¼ and ð9:102Þ
4 C
rffiffiffiffi!
1 L
cos φþ ¼ exp : ð9:103Þ
8 C
qffiffiffi
If L
C
1, this is an ignorable value. Hence, we need to rely on the dynamics of the heavy
variable φ, which can be written as a function of the external phases of the leads:
where the correction term is insignificant. Hence, the energy of the circuit is a function of the phase
difference θ2 θ1with a period π. This function has two minima at θ ¼ 0 and θ ¼ π, which can be
considered as the basis states {j0i, j1i} of an encoded qubit (Fig. 9.30).
Kitaev theorized that by replacing the inductance with a long chain of Josephson junctions, the
phase fluctuations along the chain are distributed across many junctions. Hence, the information
about the basis states is not locally accessible. The chain of Josephson junctions is shown in Fig. 9.31.
2
Quantum phase-slip is a phenomenon that occurs in superconducting nanowires. It is a process in which the
superconducting phase difference between two superconducting regions changes by 2π in a short time.
9.6 Protected Qubits 421
9.6.1.2 Measurement
Z-measurement can be performed by connecting the two leads of the qubit with a Josephson junction
and applying a 14 of a flux quantum through the loop. The current through the circuit is proportional to
sin θ2 θ1 π2 . By measuring the direction of the current through the circuit, we can determine
whether the qubit is in state j0i or j1i.
For X-measurement, the suggestion is to break the circuit at the connection between θ1 and θ3 and
measure the charge θ1 θ3. The charge is an even or odd multiple of 12 , depending upon the
eigenvalue of the measurement.
422 9 Quantum Error Correction
Fig. 9.33. Diagram illustrating the grid state of the oscillator, when the Josephson coupling J(t) is turned on: (a) when
the qubit is in state j0i and (b) when the qubit is in state j1i
9.6 Protected Qubits 423
Q2 φ2
H ðtÞ ¼ þ J ðtÞ cos ðφ θÞ, ð9:107Þ
2C 2L
where J(t) is the time-dependent Josephson coupling, θ is the phase difference across the qubit, and φ
is the phase difference across the inductor. If the qubit is in state j0i, the phase θ is zero. If the qubit is
in state j1i, the phase θ is π. Hence, the above equation reduces to:
Q2 φ 2
H ðt Þ ¼ þ ∓JðtÞ cos ðφÞ, ð9:108Þ
2C 2L
When the Josephson coupling J(t) is turned on, the initial state of the oscillator becomes a grid
state—a superposition of narrowly peaked functions governed by a broad envelope function, as
shown in Fig. 9.33.
If the qubit is in state j0i, the narrow peaks on the grid state occur when φ is an even multiple of π.
We can denote this grid state as j0Ci of the code.
If the qubit is in state j1i, the narrow peaks on the grid state occur when φ is an odd multiple of π.
We can denote this grid state as j1Ci of the code.
If the initial state of the qubit is aj0i + bj1i, then the combined state of the qubit and the oscillator
evolves as follows when J(t) is turned on:
ðaj0i þ bj1iÞψ IN ¼ aj0i j0C i þ bj1i j1C i , ð9:109Þ
J(t) starts at zero, ramps up, and maintains a steady-state J0 for a period t ¼ Lπet , where e t is a
rescaled time variable. J(t) then ramps down. When J(t) is at the steady-state, each of the narrow
peaking function is stabilized by the cosine potential. However, the state is modified by the Gaussian
function eiet 2π . As t increases, the oscillator states j0 i and j1 i evolve, but when e
φ2
C C t ¼ 1, the oscillator
states return to the initial states, excepting for a geometric phase. For the oscillator state j0Ci, peaks in
φ occur at φ ¼ 2πn. This change is trivial. For the oscillator state j1Ci, peaks in φ occur at φ ¼
2π n þ 12 , which modifies the phase by i. The new state is:
When E E down, the coupling turns off, and the oscillator states j0Ci and j1Ci have evolved
J(t) ramps
fin
to ψ 0 and ψ fin1 , respectively. The joint state of the qubit and the oscillator can be written as:
E E
! j0i ψ fin
0 i bj1i ψ fin
1 ð9:111Þ
Thus, a phase gate exp i π4 Z has been applied to the qubit. Under appropriate conditions, we can
insist that hψ fin fin
1 jψ 0 i 1, which means that the phase gate is perfect.
Gate errors may occur, if the coupling between the qubit and the oscillator remains on for a too
3 qffiffiffi
shorter or longer time, (that is, ~t ¼ 1 þ E). If jEj < 2π CL 4 , the gate error is exp 14 CL þ Oð1Þ
and the timing errors do not affect the performance of the gate [16].
Due to the degradation of the oscillator, errors may happen due to slight over or under rotation of
the qubit. However, this may not change the sensitivity of the final state of the oscillator to the qubit
and thus may not reduce the fidelity of the gate.
Both these two types of errors can be characterized, and the qubit calibrated for near- perfect
performance.
424 9 Quantum Error Correction
We have essentially embedded a qubit with 2D Hilbert space in a harmonic oscillator with an
infinite-dimensional Hilbert space. The position φ and momentum operator Q of the oscillator
satisfies [φ, Q] ¼ i. The code space of the setup can be described in terms of the commuting
generators of the stabilizer group:
MZ ¼ e2iφ
ð9:112Þ
MX ¼ e2πiQ
Z ¼ eiφ
ð9:113Þ
X ¼ eπiQ
It can be verified that the Pauli operators commute with the generators and anticommute among
themselves. The eigenstate Z ¼ 1 represents j0Ci and requires that φ be an integer multiple of 2π.
MX ¼ 1 requires that the codeword is invariant under the displacement of φ by 2π. Hence, j0Ci can be
described in the code space of the position eigenstates φ as integer multiples of 2π.
X
1
j 0C i ¼ jφ ¼ 2πni ð9:114Þ
n¼1
Similarly, we can define for the eigenstate Z ¼ 1 as j1Ci ¼ Xj0Ci as displacements of π in the
code space.
X1 E
1
j1C i ¼ φ ¼ 2π n þ ð9:115Þ
n¼1
2
The eigenstates X ¼
1 correspond to j
Ci and are invariant under the displacement Q ¼ 2. In
the code space of the momentum eigenstates Q, they can be written as follows:
X
1
jþC i ¼ jQ ¼ 2ni
n¼1
1 E ð9:116Þ
X 1
jC i ¼ Q ¼ 2 n þ
n¼1
2
paper. In this section, we establish that the two degrees of freedom of the qubit design can be used to
protect against charge and flux decay and dephasing simultaneously.
Xh i
2 ϕ þ
H¼ 4EC n ng jnihnj EJ cos σn þ σ
n
2
n ð9:117Þ
2 E
4ECL ∂ϕ þ L ðϕ φext Þ2 ,
2
q þ
where φext ¼ 2πΦ Φ0 , ng ¼ 2e , n is the number of Cooper pairs in the CPB island, σ n ¼ jn þ 1ihnj, and
ext g
þ y
σ
n ¼ σn :
For the rest of the discussions, let us consider the regime EC
EJ.
If the offset charge ng is set near an integer N, the CPB degree of freedom is “frozen” close to the
charge state that minimizes the kinetic-energy term in Eq. (9.117). In this case, the circuit Hamilto-
nian is reduced to a 1D fluxonium-like Hamiltonian with a normalized Josephson energy E2J =4EC .
The bifluxon qubit can be operated in the protected regime by setting the offset charge as half
integer ng 12. If we consider a 2D subspace j0i and j1i corresponding to the computational basis for
the CPB, the Hamiltonian in this protected 2D subspace is:
1 ϕ x
H r ¼ 4EC ng σ z EJ cos σ
2 2
ð9:118Þ
2 EL 2
4ECL ∂ϕ þ ðϕ φext Þ ,
2
where σ z ¼ j1ih1j j0ih0j and σ x ¼ σ + + σ . If ng ¼ 12, the above equation is diagonal in the σ x basis.
Hence, the lowest energy eigenstates can be factorized as the tensor product of charge and flux
components of the wavefunctions jψ ni jψ ϕi. The charge-like component results in states j
n i ¼
p1ffiffi ðj0i þ j1iÞ. The flux like component has a 1D Hamiltonian that has a potential energy that is
2
dependent on the charge state.
2
H
¼ 4ECL ∂ϕ þ V
ϕ E ð9:119Þ
V
¼∓EJ cos þ L ðϕ φext Þ2 :
2 2
The local minima of this fluxonium3 like potential are centered around ϕm ¼ 2πm, where m is an
integer, which is even for V+ and odd for V. The wavefunction of the fluxon4 excitation can be
written as follows, which is essentially a harmonic oscillator.
rffiffiffiffiffiffiffiffi
1 EJ 2
ψ m ðϕÞ ffi exp ðϕ ϕm Þ ð9:120Þ
4 ECL
The wavefunction localized at the mth minimum can be associated with a fluxon jmi. In the fluxon
representation, the eigenstates of Eq. (9.118) can be written as jmi ¼ {j2ki} [ {j2k + 1i}, where
E E
j2ki ¼ þn , ψ ϕ2k and j2k þ 1i ¼ n , ψ ϕ2kþ1 are the even and odd number of fluxons that may be
present in the loop.
3
Fluxoniums are anharmonic artificial atoms which use an array of Josephson Junctions to shunt the CPB for protection
against charge noise.
4
Fluxons are the quantum of electromagnetic flux. Fluxons are formed as a small whisker of normal phase surrounded
by superconducting phase in a type-ii superconductor when the magnetic field is between HC1 and HC2. Supercurrents
flow around the center of a fluxon.
9.6 Protected Qubits 427
The fluxon energy bands of neighboring fluxons intersect at half-integer intervals of φ2πext : This
essentially preserves the fluxon-parity. Therefore, when ng ¼ 12, the design is a fluxonium qubit made
up of a 4π-periodic Josephson element. Hence, the qubit is called “bifluxon.”
9.6.2.2 Protection
The symmetry of the wavefunction forbids the single phase-slip processes (SPS) connecting jmi and
jm + 1i. The double phase-slip (DPS) processes mix fluxon states with the same parity jmi and jm + 2i
opening energy gaps in the spectrum.
Esps ¼ hmjH r jm þ 1i / hþn jn i ¼ 0
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ð9:121Þ
Edps ¼ hmjHr jm þ 2i ¼ ħ 8EJ ECL exp π 2 2EJ =ECL
The symmetry of states with distinct fluxon parity makes the qubit immune to energy decay due to
both flux and charge noises. The researchers [17] observed a tenfold increase of the decay time, up to
100 μs by turning on the protection.
The weak sensitivity to charge noise can be suppressed by stronger localization of the single-well
excitations by increasing the EJ/ECL ratio. The charge–noise-induced dephasing time in the protected
state was found in excess of 1 μs [17].
The flux dispersion of the qubit can be reduced by increasing the superinductance value. This
enables wider delocalization of the qubit wavefunctions with different fluxon parities in disjoint
subspaces. Hence, the bifluxon qubit protects against flux-noise dephasing.
By design, the bifluxon is a charge-sensitive device, a single qubit does not offer a protection
against the charge–noise-induced dephasing. A small array of bifluxon qubits can provide a polyno-
mial increase of the dephasing time and help to overcome this limitation.
5
In the short-junction regime, the junction length L ξ, the superconducting coherence length.
428 9 Quantum Error Correction
ðkÞ
Andreev bound states (ABS),6 each characterized by a transmission coefficient T i : The energy-
phase relation of each JJ can be calculated by summing over the i energies of the bound states.
Xqffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
ðkÞ
ffi
U k ðφk Þ ¼ Δ 1 T i sin 2 ðφk =2Þ , ð9:122Þ
i
where Δ is the superconducting gap, and φk is the superconducting phase difference across the kth
JJ. The total Hamiltonian of the qubit is:
Φ
H ¼ 4 EC nb U1 ðφÞ U 2 φ 2π
2
, ð9:123Þ
Φ0
where Φ is the applied magnetic flux through the SQUID, and Φ0 is the superconducting flux
quantum.
When the applied magnetic flux is one half of the flux quantum (that is, Φ ¼ Φ20 ), the terms
U1 ðφÞ U2 φ 2π ΦΦ0 are suppressed, leaving cos2φ and its higher harmonics. This results in a
qubit with a π periodic potential with coherent transport across the SQUID occurring in pairs of
Cooper pairs (4e). Under this condition, the SQUID forms a symmetric double-well potential due to
the higher harmonics in the energy-phase relation. When the asymmetry between the JJs is increased,
the coupling between the potential wells is increased. This results in a potential like that of a flux
U 2 ð φÞ
qubit. When the asymmetry is strong, (that is, when U 1 ð φÞ ! 0), the potential is a single well and
resembles the transmon.
6
Andreev Bound States (ABS) are topologically trivial near-zero energy excitations. These states exhibit behavior
similar to Majorana Bound States (MBS), and arise in superconductor–semiconductor nanowires in the presence of a
smooth varying chemical potential.
Practice Problems 429
9.6.3.2 Protection
The qubit can be tuned into the protected qubit regime by adjusting the gate voltages to balance the
two junctions such that single-Cooper-pair transport across the SQUID is suppressed, forming a
double-well potential with minima separated by φ~π. In this balanced configuration, energy states are
strongly localized to each of the wells. This demonstrates the protection of coherence in the
symmetric regime.
At Φ ¼ Φ20 , the potential forms a double-well potential with minima at φ π2 with two nearly
degenerate ground states in the charge basis. This clearly shows the separation in parity with either
odd or even numbers of Cooper pairs, protecting the 4e-parity states of the qubit.
The researchers found a tenfold suppression of the relaxation in the protected regime [18].
9.6.4 Summary
This section came across some novel qubit designs that took existing designs and improved noise
suppression by adding new circuit elements. Further research may be required to stabilize the designs.
However, these emerging qubit designs have improved fault-tolerance at the physical design.
Undoubtedly, they provide the path toward fault-tolerant quantum computing.
Practice Problems
1. Can a quantum system be simulated by a probabilistic classical computer? Explain your answer
in terms of space and time complexity.
2. A hamming code encodes 1 bit of information into 2 bits. Generate the codeword.
3. Verify whether the code corresponding the following generator matrix is self-dual.
2 3
1 0 0 1 ω ω
6 7
G ¼ 40 1 0 ω 1 ω5
0 0 1 ω ω ω
4. Derive the minimum hamming distance for the code described by the following generator matrix.
2 3
1 0 0 0 0 1 1
60 1 0 0 1 0 17
6 7
G¼6 7
40 0 1 0 1 1 05
0 0 0 1 1 1 1
5. An electromagnetic interference accidentally applied an H gate to a qubit. Use the any of the error
correction codes to correct the error.
6. Explain whether Shor’s 9-qubit error correction code is degenerate or nondegenerate. Verify the
same for Steane’s code.
7. Develop a classical code that implements the surface cycle on a 16-qubit backend, which you can
logically wire on a 2D lattice.
8. Establish that it does not matter whether a qubit error occurs before or after a CNOT gate.
9. Compare the effects of a qubit error followed by a quantum gate with that of the quantum gate
followed by a qubit error.
430 9 Quantum Error Correction
10. Develop a concept how concatenated circuits and quantum repeaters can be used to transmit
quantum information over large distances. What is the error probability anticipated in your
design?
11. Which of the quantum gates would you implement in software? Why?
12. Create a logical qubit, using any of the methods described in this chapter using an available
backend.
13. Implement a fully fault tolerant Toffoli gate using the methods described in this chapter.
References
1. Quantum Computation and Quantum Information: 10th Anniversary Edition, Nielsen, and I Chuang.
2. On the role of entanglement in quantum computational speed-up, Jozsa and Linden, 8-Mar-2002, https://arxiv.org/
pdf/quant-ph/0201143.pdf
3. On the Significance of the Gottesman-Knill Theorem, Michael E. Cuffaro, http://philsci-archive.pitt.edu/12869/1/
sufficiency_of_entanglement.pdf
4. A Class of Quantum Error-Correcting Codes Saturating the Quantum Hamming Bound, Daniel Gottesman,
24-Jul-1996. https://arxiv.org/pdf/quant-ph/9604038.pdf
5. Stabilizer Codes and Quantum Error Correction, Daniel Gottesman, 28-May-1997, https://arxiv.org/pdf/quant-ph/
9705052.pdf
6. Fault-Tolerant Quantum Computation with Higher-Dimensional Systems, Daniel Gottesman, 2-Feb-1998, https://
arxiv.org/pdf/quant-ph/9802007.pdf
7. A Theory of Fault-Tolerant Quantum Computation, Daniel Gottesman, 18-Feb-1997, https://arxiv.org/pdf/quant-
ph/9702029.pdf
8. Quantum Error Correction for Beginners, Devitt et al., 21-Jun-2013, https://arxiv.org/pdf/0905.2794.pdf
9. From Classical to Quantum Information, Dan C. Marinescu and Gabriela M. Marinescu, March 30, 2010
10. Surface codes: Towards practical large-scale quantum computation, Austin G. Fowler et al., October 26, 2012,
https://arxiv.org/ftp/arxiv/papers/1208/1208.0928.pdf
11. Introduction to Topological Quantum Computation, Jiannis K. Pachos
12. Projective Plane And Planar Quantum Codes, Michael H. Freedman, David A. Meyer, https://arxiv.org/pdf/quant-
ph/9810055.pdf
13. Quantum codes on a lattice with boundary, Sergey B. Bravyi, Alexei Yu. Kitaev, https://arxiv.org/pdf/quant-ph/
9811052.pdf
14. Superconducting Qubits: Current State of Play, Morten Kjaergaard et al., 21-April-2020, https://arxiv.org/pdf/1905.
13641.pdf
15. Technical Roadmap for Fault-Tolerant Quantum Computing, Amir Fruchtman and Iris Choi, October 2016, https://
nqit.ox.ac.uk/content/technical-roadmap-fault-tolerant-quantum-computing
16. Protected gates for superconducting qubits, Peter Brooks, Alexei Kitaev, John Preskill, 17-Feb-2013, https://arxiv.
org/abs/1302.4122v1
17. Bifluxon: Fluxon-Parity-Protected Superconducting Qubit, Konstantin Kalashnikov et al., 9-Oct-2019, https://arxiv.
org/pdf/1910.03769.pdf
18. A Parity-Protected Superconductor-Semiconductor Qubit, T. W. Larsen et al., 31-Jul-2020, https://arxiv.org/abs/
2004.03975v2
Conclusion
10
“This here young lady,” said the Gryphon, “she wants for to know your history, she do.”
“I’ll tell it her,” said the Mock Turtle in a deep, hollow tone: “sit down, both of you, and
don’t speak a word till I’ve finished.”
So they sat down, and nobody spoke for some minutes. Alice thought to herself, “I don’t see
how he can EVER finish, if he doesn’t begin.” But she waited patiently.
― Lewis Carroll, Alice’s Adventures in Wonderland
From the definition of matter to creating surface codes and designing protected physical qubits, we
have traveled quite so far. We started this journey by asking a question, and we should probably end
this journey by answering some. Our journey will be unfinished if we do not find the answers to the
most frequently asked questions! The top three questions that come to our mind are—How many
qubits do we need? Can fault-tolerant quantum computers of commercial-grade be ever built? What
does the future hold? We have witnessed many technological revolutions, and we know that classical
computing did not reach its peak overnight. It took more than seven decades for classical computing
to reach the current level. The first transistor was about our palm’s size, and we did not build a
supercomputer with that. The first commercial device that rolled out with the transistor was a hearing
aid. With quantum computing, we are somewhat in an early transistor-like period. However, the great
thing is that a handful of quantum algorithms is already established, and there are quantum devices
currently available to experiment with. According to a 2019 interview statistics [1], about 110,000
users have run about 7 million experiments on the IBM Quantum Experience publishing about
145 research papers based on the research done on the devices. Given the complexity of the subject,
this outreach is phenomenal. With such large-scale research and commercial interest, it is natural that
this technology receives much endowment, accelerating further research and early
commercialization.
In this conclusion, we relook at the promise of quantum supremacy and the answer to the most
frequently asked questions.
Shor’s factoring algorithm is one extreme application for quantum computing. While it may be
fascinating to break cybersecurity, primetime quantum computing has several peaceful applications
that can help humanity—for example, molecular synthesis. The original idea of Feynman was to use
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 431
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0_10
432 10 Conclusion
quantum computers to simulate quantum systems. Simulating the molecular structure of experimental
drugs could be an extreme task for the supercomputers, as the variables grow exponentially with the
number of electrons in each molecule. Quantum computers do not suffer from this fate because the
internal state of a quantum system itself is exponentially large. Such applications have varying qubit
requirements—from a few qubits to a few hundred qubits. Listed in Table 10.1 is a study [2] done by
researchers at the University of Oxford. Table 10.1 provides the minimum number of qubits required
for some of the application areas, according to the study.
From Table 10.1, we can guess that the existing technology has the potential to be used in many
promising application areas. It is no wonder 110,000 researchers ran about 7 million experiments! We
cannot dismiss the thought that some of those experiments may have a near-commercial potential.
Let us return to Shor’s algorithm for a while and evaluate what it takes to implement it.
To factorize a 2000-bit number (600 decimal digits) using the Shor’s algorithm, we need about
4000 qubits. The 4000 logical qubits require 14500 4000 ¼ 58 million physical qubits. The heart of
Shor’s algorithm is the modular exponentiation. According to one estimate, 2.2 1012 states are
required by this circuit. Implementing this in the surface code requires about 800,000 physical qubits.
If we assume each state requires 100 μs to process, it takes about 26.7 hours to perform the modular
exponentiation [3]. Note that these estimates do not consider reuse of qubits and potential optimiza-
tion that could be done by transpilers.
Improving the error rate reduces the number of physical qubits required. For example, if we reduce
the error rate by 1/10th, the number of physical qubits required is about 130 million, although the
execution time remains the same. For a detailed calculation, please see Appendix M, Austin
G. Fowler [3].
We should also consider how fast we can perform the surface code using classical systems. High-
fidelity (99.7%) two-qubit gates with 60 ns gate timings have been reported recently [4]. If we assume
a gate time in the range of 10–100 ns, a surface code cycle at about 200 ns is a good target for the
current classical systems. Slower cycles will result in a higher qubit overhead. For example, if the
cycle time is 2 ms, factoring a 600-digit prime number will take 30 years! [3].
Another challenge is implementing the high-speed interconnects to the qubits. The cabling
requirements restrict the density of the qubits on an implement. In recent times, some progress has
been made in this area. An ultra-low-power CMOS-based quantum control platform that takes digital
commands as input and generates many parallel qubit control signals, removing the need for separate
control lines for every qubit has been reported [5].
With superconducting or semiconductor-based qubits, with the technology available today, we
should be able to fabricate a qubit in a cavity of 100 μm. If we can achieve this, implementing a
104 104 array of physical qubits needs a physical wafer of area 1 m2 [3], which can easily fit in a
dilution fridge! IBM Quantum Experience is edging forward with announcements of new generations
of quantum systems of the future. IBM’s future roadmap includes a promising growth of qubit count
10.3 Backends Today 433
Table 10.2 The number of qubits simulated by some of the TOP 500 classical systems today
System Memory (PB) Number of qubits
TACC Stampede 0.192 43
Titan 0.71 45
K Computer 1.4 46
APEX-2020 4–10 48–49
Acknowledgments: Mikhail Smelyanskiy, Nicolas P. D. Sawaya, and Alán Aspuru-Guzik
shortly: Eagle platform - 127 qubits by 2021, Osprey - 133 qubits by 2022, Condor - 1121 qubits by
2023, and 1K to 1M+ qubits moving forward through the year 2026 [14].
Therefore, we do have the technology that can scale-up soon.
We learned that quantum states could be efficiently simulated in the classical systems when we
discussed the Gottesman-Knill theorem. The natural question that comes to our mind is that if
classical computers can simulate quantum states, why all the trouble of creating error-prone qubits?
Could we run (at least some of the) quantum algorithms on classical simulators? The answer to this
question is evident from Table 10.2 [6]. Table 10.2 illustrates the number of qubits that some of the
TOP 500 classical computers available today can simulate.
From Table 10.2, we can infer that the amount of available memory limits the number of qubits
that can be simulated in a classical system, and it grows exponentially as more qubits are added. The
above numbers were taken with double-precision arithmetic. If more precision is required, the
number of qubits that can be simulated reduces considerably. On a quantum computer, the precision
depends on the instrumentation used to setup the rotational pulses and the measurement circuits. Also,
quantum computers can efficiently perform multi-qubit operations than simulators. Though we can
simulate quantum systems classically, it is not possible to scale that beyond a point. This threshold is
the operating ground where quantum supremacy sets in, where quantum computers outperform
classical computers.
Some of the backends available at this time of writing in 2020 have higher degrees of reliability and
repeatability [7]. Furthermore, several application areas promoting the usage of backends with real-
time data have been identified and published by organizations [8]. Such use cases can be tried by
anyone today on the available backends [9]. The tools and development frameworks are superior,
easy to use, and keep improving [10]. IBM Quantum Experience has recently announced
enhancements such as mid-circuit measurement, dynamic circuits that can implement the much-
awaited “if” statement, and a new quantum runtime, reducing the reentry queue wait-time. In
December 2020, an IBM engineer indicated that these enhancements helped cut down the total
execution time of a Lithium-Hydride chemical simulation to 16 hours from the previous benchmark
of 111 days [14]. All these possibilities are augmented by advanced technology research happening at
universities worldwide. In 2019 alone, 5,558 articles were published in arXiv on quantum physics
[11]. These advancements enable the NISQ processors available today to open the space for quantum
computing truly.
434 10 Conclusion
While quantum computing will be making a significant impact in the society, harnessing its disruptive
potential will take time until scalable systems are available. For the foreseeable future, small and
medium enterprises may not be able to buy quantum computers and install them in their campuses,
unless they have some mission-critical applications. Most organizations may be buying the comput-
ing time from a cloud provider such as Microsoft Azure Quantum [12] or the Amazon Braket [13].
The first quantum computing applications will probably be in the area of quantum communications
and post-quantum cryptography. There are many areas classical computers are good at, such as most
current enterprise applications, transactional databases, long-term storage, social media, and the
internet. Quantum computers will not replace classical computers in these areas. Nevertheless,
quantum computers have the potential to function as co-processors serving as the computing
workhorse beneath several such applications.
An important application is to use quantum computing for quantum chemistry. Quantum chemis-
try has some critical use cases in molecular synthesis, which can benefit humanity by discovering new
drugs, inventing new materials, and understanding chemical reactions that occur in nature. These are
hard problems even for the supercomputers of date. The number of variables grows exponentially that
classical computers cannot model even the simplest of the molecules.
While classical algorithms are improving, quantum computers can perform well in specific vital
applications such as signal processing, combinatorial optimizations, financial modeling, and artificial
intelligence. Research organizations are putting much work in developing solutions in these areas.
Most software algorithms we use today were invented as classical computers became available and
affordable. Similarly, many quantum algorithms are waiting to be discovered. The possibility always
exists that some of our readers may be able to discover new quantum procedures that can cleverly
solve classical problems, establishing quantum supremacy.
Such opportunities are available in plenty to the creative minds of our readers!
Now this is not the end. It is not even the beginning of the end. But it is, perhaps, the end of the
beginning.
― Sir Winston Churchill, “The end of the beginning”, November 10, 1942.
References
1. https://singularityhub.com/2019/02/26/quantum-computing-now-and-in-the-not-too-distant-future/
2. qHiPSTER: The Quantum High Performance Software Testing Environment, Mikhail Smelyanskiy et al,
12-May-2016, https://arxiv.org/pdf/1601.07195.pdf
3. Surface codes: Towards practical large-scale quantum computation, Austin G.Fowler et al, October 26, 2012,
https://arxiv.org/ftp/arxiv/papers/1208/1208.0928.pdf
4. Superconducting Qubits: Current State of Play, Morten Kjaergaard et al, 21-April-2020, https://arxiv.org/pdf/1905.
13641.pdf
5. A Cryogenic Interface for Controlling Many Qubits, S. J. Pauka et al, 3-Dec-2019, https://arxiv.org/pdf/1912.
01299.pdf
6. Technical Roadmap for Fault-Tolerant Quantum Computing, Amir Fruchtman and Iris Choi, October 2016, https://
nqit.ox.ac.uk/content/technical-roadmap-fault-tolerant-quantum-computing
7. For recent claims of high performing quantum computers, please refer to (a) https://quantumcomputingreport.com/
qubit-quality/. (b) https://www.honeywell.com/en-us/newsroom/news/2020/06/the-worlds-highest-performing-
quantum-computer-is-here. (c) https://newsroom.ibm.com/2020-08-20-IBM-Delivers-Its-Highest-Quantum-Vol
ume-to-Date-Expanding-the-Computational-Power-of-its-IBM-Cloud-Accessible-Quantum-Computers
8. https://quantumcomputingreport.com/a-quantum-computing-application-roadmap-from-ibm/
9. https://quantumcomputingreport.com/qubit-implementation-dashboard/
References 435
10. Overview and Comparison of Gate Level Quantum Software Platforms, Ryan LaRose, 20-Mar-2019, https://arxiv.
org/pdf/1807.02500.pdf
11. https://arxiv.org/year/quant-ph/19
12. https://azure.microsoft.com/en-us/services/quantum/
13. https://aws.amazon.com/braket/
14. https://quantumcomputingreport.com/ibm-introduces-new-capabilities-for-their-quantum-machines/
Appendix
Appendix
Braid words
By convention, the (i)th string passing below the (i + 1)th string is labelled σ 1
i : See Fig. 11.1 for an
example.
Aharonov–Bohm effect
Aharonov–Bohm effect is often called the seventh wonder of quantum mechanics. Aharonov–Bohm
effect is a quantum mechanical phenomenon, in which a particle experiences electromagnetic field,
even when traveling in a space where electric and magnetic potentials are zero. This effect can be
used to measure extremely small variations in magnetic flux.
U 1 ðλÞ ¼ Rz ðλÞ
π
U 2 ðϕ, λÞ ¼ Rz ðϕÞRy R ðλÞ
2 z
π π
U 3 ðθ, ϕ, λÞ ¼ Rz ðϕÞRx Rz ðθÞRx R ðλÞ
2 2 z
The HHL algorithm (Listing 11.8) illustrates implementing U3 and CU3 gates using the QDK.
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 437
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0
438 Appendix
Code example to perform QFT using QDK (Sect. 7.2.3) (Listing 11.1):
namespace Qft {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
// Swap registers
// q - array of qubits
// n - total number of qubits in the array
operation SwapReg(q:Qubit[], n:Int ):Unit {
for (i in 0..(n/2)-1)
{
SWAP(q[i], q[n-i-1]);
}
}
repeat {
H(q[i]);
set n = n - 1;
set i = i + 1;
using ( q = Qubit[n] ){
qft(q, n, input );
SwapReg(q,4);
qft_inv(q, n);
SwapReg(q,4);
for ( i in 0..n-1)
{
if (One == M(q[i])) { set r = r ||| (1 <<< i); }
}
ResetAll(q);
}
Message($"Input: {input} Measured: {r} ");
return r;
}
}
Code example for Simon’s problem in QDK (Sect. 7.5) (Listing 11.2):
namespace Simons {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
mutable n = Length(q)/2;
mutable reg1 = 0;
mutable reg2 = 0;
// Measure REG 2
for ( i in n..Length(q)-1){
if (One == M(q[i])) { set reg2 = reg2 ||| (1 <<< i); }
}
// Measure REG 1
for ( i in 0..n-1){
if (One == M(q[i])) { set reg1 = reg1 ||| (1 <<< i); }
}
ResetAll(q);
return reg1;
}
Message($"Test Simons");
using (q=Qubit[n])
{
for ( i in 0..shots-1){
set r = Simons(q,a);
set res w/= r <- res[r] + 1;
}
// Print the number of hits for each output states
Message($"Simons {res}");
}
}
}
QDK Code example for the simple QFT Adder in Sect. 7.6.1 (Listing 11.3):
namespace QftAdder {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
// Swap registers
// q - array of qubits
// n - total number of qubits in the array
operation SwapReg(q:Qubit[], n:Int ):Unit {
for (i in 0..(n/2)-1)
{
SWAP(q[i], q[n-i-1]);
}
}
// Adder circuit
// adds a to b in the Fourier basis
operation add_cct (a:Qubit[], b:Qubit[], m:Int):Unit {
mutable n = m;
repeat {
for (i in RangeReverse(1..n)){
Controlled R([a[i-1]], (PauliZ, PI() / PowD(2.0, \
IntAsDouble(n-i )), b[n-1]));
}
set n -= 1;
} until (n == 0);
}
// Inverse QFT
operation iqft_cct (t:Qubit[], n:Int):Unit {
for ( i in 0..n-1 ){
for ( j in 1..i) {
Controlled R([t[j-1]], (PauliZ, -PI() / PowD(2.0, \
IntAsDouble(i-j+1 )), t[i]));
}
H(t[i]);
}
}
// Forward QFT
operation qft_cct (t:Qubit[], m:Int):Unit {
mutable n = m;
repeat{
H(t[n-1]);
Listing 11.3 (continued)
444 Appendix
for (i in RangeReverse(1..n-1)){
Controlled R([t[i-1]], (PauliZ, PI() / PowD(2.0, \
IntAsDouble(n-i )), t[n-1]));
}
set n -= 1;
} until (n == 0);
}
set_reg(a, n, input1);
set_reg(b, n, input2);
qft_cct(b, n);
add_cct(a, b, n);
iqft_cct(b, n);
for ( i in 0..n-1)
{
if (One == M(b[i])) { set r = r ||| (1 <<< i); }
}
return r;
}
// Testing code
operation test_qftadder():Unit{
mutable r = 0;
mutable input1 = 7;
mutable input2 = 8 ;
using ( a = Qubit[4] ) {
using( b = Qubit[4] ) {
set r = add_qft(input1, input2, a, b, 4);
Message($"Inputs: {input1} + {input2} = output:
{r}");
ResetAll(a);
ResetAll(b);
}
}
}
}
Listing 11.3 (continued)
Appendix 445
QDK Sample code for the QFT Multiplier Sect. 7.6.3 (Also contains the controlled QFT Adder
in Sect. 7.6.2) (Listing 11.4):
namespace QftMultiplier {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
// Swap registers
// q - array of qubits
// n - total number of qubits in the array
operation SwapReg(q:Qubit[], n:Int ):Unit {
for (i in 0..(n/2)-1)
{
SWAP(q[i], q[n-i-1]);
}
}
//
// Controlled Addition and Multiplication
//
Listing 11.4 QFT Multiplier and the QFT Adder circuits for the QDK
446 Appendix
for ( i in 0..n-1)
{
if (One == M(b[i])) { set r = r ||| (1 <<< i); }
}
return r;
}
set_reg(a, n, input1);
set_reg(b, n, input2);
for (i in 0..n-1) {
set r = c_add_qft(b, s, i, a[i], n);
}
for ( i in 0..(n*2)-1)
{
if (One == M(s[i])) { set r = r ||| (1 <<< i); }
}
ResetAll(a);
ResetAll(b);
ResetAll(s);
return r;
}
// Testing code
operation testControlledMultiplier( ): Unit {
mutable n = 4;
mutable shots = 100;
mutable input1 = 5;
mutable input2 = 5;
mutable r = 0;
using (a = Qubit[n] ) {
using (b = Qubit[n] ) {
using (s = Qubit[n*2] ) {
set r = mult_cct(input1, input2, a, b, s, n);
}
}
}
Message($"{input1} * {input2} = {r}");
}
}
QDK Code Example for Grover’s search, from Sect. 7.8 (Listing 11.5):
namespace Grovers {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
using(q = Qubit[3]) {
using(t = Qubit[2]){
for ( j in 0..shots-1) {
H(q[0]);
H(q[1]);
H(q[2]);
H(t[0]);
for ( i in 0..2)
Listing 11.5 (continued)
Appendix 451
{
if (One == M(q[i])) { set r = r ||| (1 <<<
i); }
}
set res w/= r <- res[r] + 1;
ResetAll(q);
ResetAll(t);
}
}
Message($"Output of Grovers is: {res}");
}
}
}
Listing 11.5 (continued)
QDK code for Shor’s algorithm to factorize 15, using a fixed exponential modulation, Sect. 7.9.2
(Listing 11.6):
namespace Shors {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
// Inverse QFT
// t: qubit array for which IQFT is to be done.
// n: width of the array
operation iqft_cct (t:Qubit[], n:Int):Unit {
for ( i in 0..n-1 ){
for ( j in 1..i) {
Controlled R([t[j-1]], (PauliZ, -PI() / PowD(2.0,
IntAsDouble(i-j+1 )), t[i]));
}
H(t[i]);
}
}
using (q = Qubit[7]){
// Measure REG1
for ( i in 0..2)
{
if (One == M(q[i])) { set r = r ||| (1 <<< i); }
}
ResetAll(q);
}
return r;
}
for (i in 0..shots-1){
set r = Shors15();
set res w/= r <- res[r] + 1;
}
}
Listing 11.6 (continued)
Appendix 453
QDK code for Quantum Phase Estimation example, Sect. 7.11 (Listing 11.7):
namespace Qpe {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
using ( q = Qubit[4]) {
// Inverse QFT
qft_inv(q, 3);
// Measure
for ( i in 0..2)
{
if (One == M(q[i])) { set r = r ||| (1 <<< i); }
}
ResetAll(q);
}
return r;
}
// Test QPE
operation testQpe():Unit {
mutable res = new Int[8];
let shots = 100;
mutable r = 0;
for (i in 0..shots-1){
set r = QuantumPhaseEstimation();
set res w/= r <- res[r] + 1;
}
Message($"Output of QPE is: {res}");
}
}
Listing 11.7 (continued)
QDK code for HHL Algorithm, described in Sect. 7.12 (Listing 11.8):
namespace Hhl {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Diagnostics;
// Implements a U3 rotation
operation u3(theta:Double, phi:Double, lambda:Double,
target:Qubit): Unit {
Rz(phi, target);
Rx(-PI()/2.0, target);
Rz(theta, target);
Rx(PI()/2.0, target);
Rz(lambda, target);
}
using ( q = Qubit[4]){
// QPE, shortened version
H(q[3]);
CNOT(q[3], q[2]);
CNOT(q[2], q[1]);
X(q[2]);
SWAP(q[2], q[1]);
// Lambda inverse
cu3(PI(), 0.0, 0.0, q[2], q[0]);
cu3(PI()/3.0, 0.0, 0.0, q[1], q[0]);
ResetAll(q);
}
}
}
Listing 11.8 (continued)
456 Appendix
Executing the above code generates the following dump. Note that the dump could be slightly
different when executed at different times.
# wave function for qubits with ids (least to most significant): 0;1;2;3
|0〉: 0.000000 + 0.000000 i == [0.000000]
|1〉: -0.948683 + 0.000000 i == ******************* [0.900000]--- [ 3.14159 rad ]
|2〉: 0.000000 + 0.000000 i == [0.000000]
|3〉: 0.000000 + 0.000000 i == [0.000000]
|4〉: 0.000000 + 0.000000 i == [0.000000]
|5〉: 0.000000 + 0.000000 i == [0.000000]
|6〉: 0.000000 + 0.000000 i == [0.000000]
|7〉: 0.000000 + 0.000000 i == [0.000000]
|8〉: 0.000000 + 0.000000 i == [0.000000]
|9〉: 0.316228 + 0.000000 i == ** [0.100000]--- [ 0.00000 rad ]
|10〉: 0.000000 + 0.000000 i == [0.000000]
|11〉: 0.000000 + 0.000000 i == [0.000000]
|12〉: 0.000000 + 0.000000 i == [0.000000]
|13〉: 0.000000 + 0.000000 i == [0.000000]
|14〉: 0.000000 + 0.000000 i == [0.000000]
|15〉: 0.000000 + 0.000000 i == [0.000000]
0:948683
Ignoring the imaginary values, we can extract the results . When this is multiplied
0:316228
pffiffiffiffiffi 3
by the normalizer 10, we get the results . Up to a phase, this is the result we expected.
1
Index
# The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 457
V. Kasirajan, Fundamentals of Quantum Computing, https://doi.org/10.1007/978-3-030-63689-0
458 Index
G I
Gas, 4 IBM Q, 150–151
Gate fidelity, 114 ibmq_qasm_simulator, 162
Gate time, 114 IBM quantum experience, 150
Gauge bosons, 10 Identity gate, 166
Gauge invariant phase, 118 Implementing a CNOT gate with a square root of SWAP
General Number Field Sieve algorithm, 262, 332 gate, 211–212
Generator, 384 Independent events, 71
Generator Matrix, 379 Information theory, 377
Gerlach, W., 87 Inner product, 49
Germer, L., 18 Intersection, 71
GHZ state, 223 Intrinsic topological order, 132
Global phase, 191 Inverse of an operator, 55
Global phase and its irrelevance, 191–192 Inverse QFT, 283
Gluons, 9 Inverse transform, 273
God particle, 10 Ising anyons, 130–132
Golden ratio of the Fibonacci series, 129 Ising, E., 130
Goldstein, E., 8 Ivanovich, D., 7
Gottesman, D., 201
Gottesman–Knill theorem, 200–201, 392 J
Goudsmit, S.A., 89 Josephson junction, 116–119
Greenberger–Horne–Zeilinger state, 223–224 Jupyter notebook, 150
Green, D., 133 Jozsa, R., 297
Group leader optimization algorithm, 361
Grover diffusion operator, 322 K
Grover iteration, 322 Kickback, 228
Grover, L., 319 Kitaev, A., 123, 409
Grover’s search algorithm, 319–327 k-means, 338
Kosterlitz, J.M., 137
H Knill, E., 201
Hadamard gate, 167–172 Kronecker delta function, 50
Hadrons, 9
Haldane, M., 137 L
Half adder, 208 Left-hand circular, 255
Half metals, 133 Linear code, 379
Hall effect, 32 Linearly dependent, 48
Hamiltonian simulation, 352 Linearly independent, 48
460 Index