Quantum Computers - Theory and Algorithms by Belal Ehsan Baaquie Leong-Chuan Kwek (Springer 2023)
Quantum Computers - Theory and Algorithms by Belal Ehsan Baaquie Leong-Chuan Kwek (Springer 2023)
Leong-Chuan Kwek
Quantum
Computers
Theory and Algorithms
Quantum Computers
Belal Ehsan Baaquie · Leong-Chuan Kwek
Quantum Computers
Theory and Algorithms
Belal Ehsan Baaquie Leong-Chuan Kwek
Helixtap Technologies Centre for Quantum Technologies
Singapore, Singapore National University of Singapore
Singapore, Singapore
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature
Singapore Pte Ltd. 2023
This work is subject to copyright. All rights are solely and exclusively licensed 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 Singapore Pte Ltd.
The registered company address is: 152 Beach Road, #21-01/04 Gateway East, Singapore 189721,
Singapore
Preface
Quantum theory introduces a fundamentally new framework for thinking about nature
and entails a radical break from the paradigm of classical physics. In spite of the fact
that the shift of paradigm from classical to quantum mechanics has been ongoing
for more than a century, a complete conceptual grasp of quantum mechanics has till
today proved elusive. According to leading quantum theorist Richard Feynman, ‘It
is safe to say that no one understands quantum mechanics’ [1].
The idea of quantum computers was pioneered by Yuri Manin (1980) and Richard
Feynman (1981) when they discussed simulations that could not be carried out by a
classical computer—but only by a quantum computer. Feynman discussed the ideas
of quantum gates and quantum computers in [2]. In 1983, David Deutsch made a
crucial advance by proposing that the quantum qubit is the natural generalization
of the bit of classical computers [3]. The field over the last two decades has seen
phenomenal growth, and the development of a practical quantum computer is poised
to be game-changing technology of the twenty-first century.
This book is divided into the following four parts. The introduction in Part I gives
a more detailed discussion of these four parts.
1. The topics in Part I have been chosen to introduce non-specialists and newcomers
to this field.
2. Part II discusses in great detail some of the important special cases that illustrate
the workings of a quantum algorithm.
3. Part III discusses relatively more advanced topics as well as some important
applications of quantum algorithms.
4. The last part is a discussions of some of the general features of quantum
algorithms.
Hopefully, after reading this book, one can have a rudimentary understanding of
quantum algorithms.
v
vi Preface
References
vii
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Interview on Quantum Computers . . . . . . . . . . . . . . . . . . . . . . . . . . 4
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Part I Fundamentals
2 Binary Numbers, Vectors, Matrices and Tensor Products . . . . . . . . . 13
2.1 Binary Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Linear Vector Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3 N -Dimensional Complex Linear Vector Space . . . . . . . . . . . . . . . . 18
2.4 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Properties of N × N Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.1 Hermitian Conjugation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.6 Tensor (Outer) Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.7 Square Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.8 Dirac Bracket: Vector Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.9 Tensor and Outer Product: Strings and Gates . . . . . . . . . . . . . . . . . 31
2.9.1 3-Bits String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3 Classical Gates and Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1 Classical Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.2 Classical Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3 2-Bits String Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4 XOR Reversible Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.1 X OR : 3-Bits String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.5 3-Bits String: Toffoli Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.6 Unitary AND, NAND and NOT Gates for 3-Bits . . . . . . . . . . . . . . 52
3.7 Unitary OR and NOR Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.8 Classical Binary Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.9 Half-Adder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.10 Full-Adder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ix
x Contents
Part IV Summary
19 Efficiency of a Quantum Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
19.1 Quantum Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
19.2 Memory and Speed of Quantum Computations . . . . . . . . . . . . . . . 288
19.3 Where Does Quantum Computation Take Place? . . . . . . . . . . . . . . 290
19.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
About the Authors
xv
xvi About the Authors
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 1
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_1
2 1 Introduction
The focus of this introductory book is on the theoretical and algorithmic aspects
of quantum computers. A few algorithms are employed to illustrate the main ideas in
quantum algorithms. The main aim of this introductory text is to clarify precisely why
a quantum computer is so much more powerful than any possible classical computer.
The ideas that underpin a quantum computer are explained with a minimum
recourse to advanced mathematics, and wherever possible, quantum algorithm are
stated in a non-mathematical language. The physics of how to create a quantum
computer, the hardware, has been eschewed as it is not essential for understanding
the logic of quantum algorithms. This is similar to using a laptop without knowing
anything about electrical engineering.
The field of quantum computers is an emerging technology, and quantum algo-
rithms are codes that can vastly speed up information processing, far outpacing
currently used classical computers. Classical computers refer to computers that are
constructed with electronics circuits and are based on the existing paradigm of com-
puter science. Quantum computers have potential applications in a vast number of
fields, such as cryptography, manufacturing, information and communications tech-
nology, finance, autonomous vehicles, pharmaceuticals, energy, logistics, artificial
intelligence and so on. In recent years, there is hardly a day that goes by without
some articles touching on the potential importance of quantum computers, as well
as on the intense competition among various companies and countries that are trying
to take the lead in developing a practical quantum computing device.
What has really caught the imagination of the public at large is the term ‘quantum
advantage’. This is a project to develop programmable quantum codes that can solve
problems that a classical computer, including the fastest of the supercomputers, can
never beat or solve—even in principle, since for a classical computer, to solve these
computational problems would need a time longer than the age of the Universe. On
October 23, 2019, the Associated Press reported that ‘Google’s leaked paper showed
that its quantum processor, Sycamore, finished a calculation in three minutes and
20 s—and that it would take the world’s fastest supercomputer 10,000 years to do
the same thing’.1 Although this claim was contested by IBM and other groups, what
is clear is that it is just a matter of time that some form of quantum advantage (or
quantum supremacy) is established. On October 28, 2021, the mantle of quantum
advantage was claimed by Pan Jianwei and his group, with their quantum computing
system of ‘Jiuzhang’ carrying out large-scale photonic Gaussian Boson Sampling (a
model for quantum computing) machine 100 trillion times faster than the world’s
fastest existing supercomputer.2 Quantum advantage will probably be claimed by
other groups in the future as quantum computing is a rapidly evolving field.
All computing devices are based on the principles of quantum mechanics; in
particular, semiconductors run on the principles of quantum mechanics. The term
quantum computer does not refer to the hardware of a computer. Instead, it refers
1 https://www.marketwatch.com/story/google-touts-quantum-computing-milestone-2019-10-23.
The result has since been published [1].
2 https://english.cas.cn/newsroom/cas_media/202110/t20211028_289325.shtml#::text=Dec
%2005%2C%202020,tackle%20within%20a%20reas....
1 Introduction 3
Part III discusses some of the possible applications of quantum algorithms. Option
pricing is discussed in some detail as one expects that the first major application
of quantum algorithms are going to be in finance. Solving linear equations using
the HHL algorithm is discussed as well as quantum error correction and hybrid
algorithms.
Part IV is a summary of the subject, with a general analysis of some of the key
features and novel aspects of a quantum computer.
There are many references on quantum computers, both advanced and introduc-
tory, and the following are a few of them [2–9].
3 https://futureoffinance.biz/2021/07/13/where-quantum-computers-are-now-and-where-they-
are-going-next/.
1.1 Interview on Quantum Computers 5
Fig. 1.1 Interview on quantum computer’s prospects. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
Baaquie: The USA has invested US$1.2 billion in 2019 over five years, and China
is not far behind. The Singapore government has invested US$70 million in 2020 on
a one-year horizon. Venture capital has invested US$300 million in 2020 compared
to US$4 million in 2005: PsiQuantum has received US$215 million in investments
and Rigetti has received US$190 million. Why? Governments are probably driven
by geostrategic considerations, whereas venture capital investments show that the
market thinks a breakthrough in quantum computing applications is close.
Hobson: Quantum computers do not always give the right answer. Is that a fun-
damental problem or an engineering problem?
Baaquie: The error in a quantum algorithm is a fundamental engineering problem
that is linked to noise. For example, error correction can be achieved for a classical
computer by sending three bits of 0 and 1 instead of a single bit; on receiving three
bits, the average of the three bits is taken to correct for possible errors. There is also a
phase (sign) that is carried by qubits when they are superposed and could flip its sign
and needs to be corrected. So a quantum qubit would need 3×3 = 9 qubits for error
6 1 Introduction
4 https://www.visualcapitalist.com/global-debt-to-gdp-ratio/.
8 1 Introduction
events that for a portfolio are highly unlikely. The quantum computer can compute
the probability of the occurrence of these outliers—a computation that is beyond
the computing power of classical computers. Outliers are not important for arbitrage
but rather for risk management. Outliers can be useful for detecting financial fraud
as well, since the occurrence of a fraud would most likely violate the computed
likelihood of outliers.
The second application is arbitrage opportunities, based on the development of
advanced pricing models that can spot arbitrage opportunities. The options market,
in 2021, had a notional value of over US$600 trillion (with actual value of US$12
trillion) and to scan this market in real-time needs the computing power of a quantum
computer. There are many other fields of finance where quantum algorithms can make
a difference, such as the credit rating of customers, risk management and so on.
Hobson: Why is business so slow to invest in quantum computing?
Baaquie: The horizon of when one can get returns is not clear. Once there is a win-
ning application, it will open the floodgates for benefits to end-users and businesses—
and will lead to massive investment in this game-changing technology.
Hobson: Quantum computers can complete calculations that would otherwise be
impossible. What are the implications of that for current cryptographic methods?
Baaquie: The Sycamore (IBM 54 qubits) performed a calculation in 200 s that
would have taken the best supercomputers 10,000 years. So, clearly, the quantum
computer can perform computations that no classical computer can ever perform. A
quantum computer would need about 20 million qubits and eight hours (rather than
requiring 1 billion qubits as previously theorized) to break the 2048 RSA code, so
it is still quite a distant possibility. Shor’s algorithm has the potential to completely
overpower all classical encryption, but maybe not in the immediate future.
Hobson: Quantum computing has a flavor of the Manhattan Project about it. What
geopolitical concerns does it foster?
Baaquie: Quantum computers will impact all military technology, cybersecurity,
secure communications and so on. So leading nations in the world probably consider
quantum computers to be a strategic asset that needs to be mastered at any economic
cost.
Hobson: Does quantum computing create a risk that humanity is overwhelmed
by a Superintelligence?
Baaquie: Yes, surprisingly enough, quantum computers do pose a serious risk
to humanity for the following reason. Artificial intelligence (AI) is premised on
analyzing patterns in big data and then making predictions and taking decisions.
Technologies such as autonomous vehicles, cyberwarfare and so on will be greatly
enhanced by combining AI with quantum computers.
There are two kinds of AI algorithms. The first is artificial narrow intelligence
(ANI), which can carry out a task assigned to it such as driving an autonomous
vehicle. The second is artificial general intelligence (AGI), which can do a wide
range of tasks and can also decide by itself what task it will carry out. For example,
consider an AGI-empowered robotic soldier. This machine will decide on who lives
and who dies on the battlefield and maybe even off the battlefield. At present, AGI is
comparable to human intelligence, so human beings can create devices to manage and
References 9
References
1. Frank Arute, Kunal Arya, Ryan Babbush, Dave Bacon, Joseph C Bardin, Rami Barends, Rupak
Biswas, Sergio Boixo, Fernando GSL Brandao, David A Buell, et al. Quantum supremacy
using a programmable superconducting processor. Nature, 574(7779):505–510, 2019
2. Le Bellac Michel (2006) A short introduction to quantum information and computation.
Cambridge University Press, UK
3. Bernhardt Chris (2019) Quantum Computing for Everyone. MIT Press, USA
4. Kaye Phillip, Laflamme Raymond, Mosca Michele (2007) Introduction to Quantum Comput-
ing. Cambridge University Press, USA
5. McMahon David (2008) Quantum computing explained. MIT Press, USA
6. N. David Mermin. Quantum Computer Science. Cambridge University Press, UK, 2007
7. Michael A (2012) Nielsen and Isaac L. Chuang. Quantum Computation and Quantum Infor-
mation. Cambridge University Press, UK
8. Rieffel Eleanor G, Polak Wolfgang H (2011) Quantum Computing: A Gentle Introduction.
MIT Press, USA
9. Zygelman Bernard (2018) A First Introduction to Quantum Computing and Information.
Springer, UK
Part I
Fundamentals
Chapter 2
Binary Numbers, Vectors, Matrices
and Tensor Products
In this part of the book, we briefly reviewed the general mathematical framework
behind gates, bits and qubits. These topics form a recurring theme, and they are
employed in all the derivations of this book.
A fundamental bit of classical computers is a binary set {0, 1}, called a binary
number, and it is represented by two-dimensional vectors belonging to a linear vector
space; the n-bits are represented by vectors that are elements of an n-dimensional
vector space, which is isomorphic to the n-dimensional Euclidean space E n . With
this description, a quantum state built from n-bits (see discussion in Chap. 6) is an
element of a complex linear vector space, with vectors having a unit norm and is
called a Hilbert space.
All gates, both classical and quantum are in general N × N square matrices, with
the matrices having some special features. Tenor product of matrices and vectors is a
way of combining gates and bits and is discussed with especial emphasis on square
matrices. Tenor product of vectors of single bits can be used to form a system with
many bits.
A vector in this book is usually denoted by bold face notation v, as is the case in
most linear algebra textbooks. In quantum mechanics and for quantum computers, the
Dirac notation is used in which v ≡ |v. The Dirac notation for vectors and matrices
is discussed to foreground the use of this notation in the rest of the chapters. The
results of linear algebra are briefly reviewed using the conventional vector notation
based on v. A detailed mapping from v to |v is then discussed so that readers who
not familiar with the Dirac notation have clear idea of the mapping.
This chapter reviews the properties of binary numbers, vector space, matrices and
tensor products. The derivations are based on [1].
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 13
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_2
14 2 Binary Numbers, Vectors, Matrices and Tensor Products
Binary notation is based on representing all real numbers using the base 2 instead
of the decimal expansion that uses the base 10. If effect, all real numbers can be
represented by a series of 0’s and 1’s with an expansion similar to the decimal
expansion. As will become clear in this chapter, an arbitrary real number can always
be represented by
· · · 1000111010.00101010110111 · · ·
The input and output of an algorithm are strings of symbols. All symbols can be
mapped to the real numbers, and all real numbers are then represented by strings of
binary number 0’s and 1’s.
Every number has a binary expansion, similar to the usual expansion that has the
base 10. For example, consider the number 203; its base 10 expansion is given by
203 = 128 + 64 + 8 + 2 + 1 = 1 × 27 + 1 × 26 + 0 × 25
+ 0 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20
→ 11001011 : Binary representation (2.1)
Hence, in the binary representation, the number 203 is equal to 11001011. For a
general integer x that needs n binary bits, the leading (largest) binary term is x1 , and
the last term is xn . Hence, one has the following binary representation
x = x1 x2 x3 · · · x j · · · xn−1 xn
xi = 0 ⇒ x = 0
xi = 1
n
⇒x= 2n− j = 2n−1 + 2n−2 · · · + 2n−i + · · · + 21 + 20
j=1
= 2n − 1
Hence, the range of the integer x that can represent n-bits is given by
0 ≤ x ≤ 2n − 1 (2.3)
x = 0, 1, 2, · · · , 2n − 1
Hence, one can label the different binary strings by an integer x with range
0 ≤ x ≤ 2n − 1
For n bits, the number of different binary strings of length n is given by 2n ; a typical
n-bits binary strings are represented by Dirac’s ket vectors
For example,
For example
1 1 1 1
0 · 1011 = 1 · + 0 · 2 + 1 · 3 + 1 · 4 = 0.5 + 0.125 + 0.0625 = 0.6875
2 2 2 2
Note that
2m x = integer + 0 · xm+1 · · · xn
x = 0 · x1 x2 · · · xm · · ·
2k x = x1 x2 . . . xk .xk+1 xk+2 . . . xm . . .
= x1 x2 . . . xk + 0.xk+1 xk+2 . . . xm . . . . . .
= integer + 0.xk+1 xk+2 . . . xm . . . (2.6)
The result above is required for phase estimation and quantum Fourier Transform,
and is discussed in Chap. 8.
An arbitrary real number has the binary decimal expansion given by
x1 x2 · · · xk .xk+1 xk+2 · · · xn
Using the results given above, one has the following binary decimal expansion of
203.6875
0 0 1 1
⊕ 0 1 0 1
− − − −
0 1 1 10
Equivalently
0 ⊕ 0 = 0 ; 0 ⊕ 1 = 01 ; 1 ⊕ 0 = 01 ; 1 ⊕ 1 = 10 ;
Note there is a carry of 1 for the addition of 1 ⊕ 1 = 10, similar to ordinary arithmetic
with base 10. Using the above rules, we obtain the following binary addition
2.2 Linear Vector Space 17
Binary addition is discussed in great detail in Sect. 3.8 and its quantum general-
ization in Sect. 7.4 since the arithmetic operation reveals a lot of general features of
classical and quantum algorithms.
One can think of the vector w as the result of starting with vector u, with its base at
the origin, and then placing the vector v on the tip of vector u; the resulting vector
w starts at the origin, which recall is the origin of vector u, and ends at the tip of
vector v. In component notation, let
a c
u= ; v=
b d
(u + v) + w = u + (v + w) = u + v + w
• Scalar multiplication: for a real or complex number λ, one has a new vector w
given by
w = λv
Two vectors u, v having the same number of components can be combined using
the procedure of a scalar product; for the two-dimensional vectors, we have
∗
u† · v = a ∗ c + b∗ d = v† · u
n
∗
u† · v = u i∗ vi = v† · u
i=1
n
|u|2 = u† · u = u i∗ u i > 0 (2.9)
i=1
Note δn−m is the Kronecker delta function and has only integer arguments.
The basis states are linearly independent since
N
ai ei = 0 ⇒ ai = 0 for all i
i=1
The linear span of ei is all linear combinations of the basis vectors and covers the
entire space E N . To represent an arbitrary vector x in E N , the following notation is
used
⎡ ⎤
x(1)
⎢ .. ⎥
⎢ . ⎥
⎢ ⎥
x=⎢ ⎥ †
⎢ x(i) ⎥ ; ei · x = x(i) (2.13)
⎢ .. ⎥
⎣ . ⎦
x(N )
N
N
x= x(i)ei ; x† = x ∗ (i)ei†
i=1 i=1
N
N
N
x† · y = x ∗ (i)y( j)(ei† · e j ) = x ∗ (i)y( j)δi− j = x ∗ (i)y(i)
i, j=1 i, j=1 i=1
20 2 Binary Numbers, Vectors, Matrices and Tensor Products
A Hilbert space for N -dimensional linear vector space is defined to be the collec-
tion of N -dimensional vectors that have unit norm, namely
N
|u|2 = u† · u = u i∗ u i = 1 ; u ∈ Hilbert space (2.14)
i=1
The Hilbert space consists of vectors that lie of the N -dimensional sphere S N . For
N = 2, Hilbert space is the circle S 1 , and for N = 3, it is the two-dimensional surface
of a sphere S 2 .
2.4 Matrices
In general, a matrix is an array that consists of M-rows, that are arranged horizontally,
and N columns, arranged vertically. A typical M × N matrix A is given below.
⎡ ⎤
a11 a12 . . . a1N
⎢ a21 a22 . . . a2N ⎥
A=⎢
⎣ ...
⎥
⎦
a M1 a M2 . . . a M N
The individual entries of the matrix, denoted by amn , are the elements of the matrix.
The elements can be real or complex numbers. For matrix A, there are in total M N
elements.
A particular row for matrix A consists of N elements; for example, the second
row is given by
a21 a22 . . . a2N
One can think of a row as the transpose of a vector. Similarly, each column is given
by M elements and can be thought of as vector of length M. The second column for
matrix A is given by ⎡ ⎤
a12
⎢ a22 ⎥
⎢ ⎥
⎣ ... ⎦
a M2
2.4 Matrices 21
v(M)
One can see that v is equivalent to a M-dimensional vector and all vectors, in fact,
are special cases of matrices.
The following are some of the properties of matrices. Let A, B be M × N matrices.
Then
•
(A + B)v = Av + Bv
In components
N
N
N
[(A + B)v]i = (A + B)i j v( j) = Ai j v( j) + Bi j v( j)
j=1 j=1 j=1
(A + B) = A + B ⇒ (A + B)i j = Ai j + Bi j
The rule for matrix multiplication is that each row on the left, one by one multi-
plies, each column on the right, one by one. This is the same rule that was obtained
earlier in multiplying a matrix into a vector. The result depends on the dimensions
of the matrices. The rules obtained for the 2 × 2 matrices generalize to the case of
multiplying any two matrices.
Let A be a square M × M matrix and B be a M × L matrix, as given below
22 2 Binary Numbers, Vectors, Matrices and Tensor Products
⎡ ⎤ ⎡ ⎤
a11 a12 . . . a1M b11 b12 . . . b1L
⎢ a21 a22 . . . a2M ⎥ ⎢ ⎥
A=⎢ ⎥ ; B = ⎢ b21 b22 . . . b2L ⎥
⎣ ... ⎦ ⎣ ... ⎦
a M1 a M2 . . . a M M b M1 b N 2 . . . b M L
In vector notation
L
Bv = w ⇒ w(i) = bi j v( j) ; i = 1, . . . , M
j=1
The rest of the discussion will treat only N × N square matrices, as these matrices
play a specially important role in many problems. Let A, B, C be N × N square
matrices and let v be an N -dimensional vector.
• Matrix multiplication is not commutative and is given by
(AB)i j = Aik Bk j ⇒ AB = B A
k
Then
7 −5 9 17
AB = = BA = ⇒ AB − B A = 0
−8 23 4 21
(ABC)† = C † B † A† (2.17)
((A† )† ) = A
(v)† = v† ; ((v)† )† = v
Transforming the basis states can be obtained by analyzing the effect of a linear
transformation on the dual basis states e† . The change of volume is identical since both
24 2 Binary Numbers, Vectors, Matrices and Tensor Products
the vector and its dual provide an equivalent description of the linear transformation.
The dual basis vectors are transformed by the Hermitian conjugate of the linear
transformation given by
A† : C2 → C2
To express a matrix in terms of the basis states, one needs to evaluate the tensor
product of the basis states. Recall the scalar product of two vectors has been defined
by v† w. One can also define the tensor product or outer product of two vectors (and
of matrices in general). The outer product is defined by the symbol w ⊗ v† , with the
explicit component wise representation given by
⎡ ⎤
⎤ ⎡ w1 v1 w1 v2 . . . w1 v N
w1 ⎢ ⎥
⎢ w2 ⎥ ⎢ ... ⎥
⎢
w⊗v =⎣
† ⎥ v v
⊗ 1 2 . . . v ⎢
N ≡⎢ w v w v . . . w v
i N ⎥
⎥
... ⎦ i 1 i 2
⎣ ... ⎦
wN
w N v1 w N v2 . . . w N v N
For x y-basis states, one has the following four outer products
1 10 1 01
e1 ⊗ e†1 = ⊗ 10 = †
; e1 ⊗ e2 = ⊗ 01 =
0 00 0 00
and
0 00 0 00
e2 ⊗ e†1 = ⊗ 10 = †
; e2 ⊗ e2 = ⊗ 01 =
1 10 1 01
2.6 Tensor (Outer) Product 25
The tensor product of the basis states yields a basis for the 2 × 2 matrix since each
position in the matrix corresponds to one matrix with a nonzero entry only at that
position. For the N -dimensional case of E N , define the tensor product of any two
basis vectors by
ei ⊗ e†j ; i, j = 1, . . . , N
Note that
ei ⊗ e†j = e†j ⊗ ei ; i, j = 1, . . . , N
The fact that the tensor product of the basis vectors is sufficient to represent any
vector of of E N requires that the basis states must satisfy the completeness equation
given by
N
ei ⊗ ei† = I N ×N (2.19)
i=1
N
N
v = Iv = ei ⊗ (ei† · v) = vi ei (2.20)
i=1 i=1
where
vi = ei† · v : components of v
Note that
e†I Ae J = Ai j (e†I · ei ) ⊗ (e†j · e J ) = Ai j δ I −i δ J − j = A I J
ij ij
v
A 1 = Ai j ei ⊗ e†j · v(k)ek = Ai j ei vk δ j−k
v2
ij k i jk
= Ai j v j ei = wi ei (2.22)
ij i
where
w1 a a v1
w= wi ei = = Av = 11 12 (2.23)
w2 a21 a22 v2
i
Note that unlike the case of the ordinary product of two matrices, the order of the
tensor product of two matrices is not reversed under Hermitian conjugation and is
given by the following
†
A ⊗ B = A† ⊗ B †
2.7 Square Matrices 27
A number of properties of square matrices are given in Table 2.1. Based on these
properties, special square matrices can be defined that occur in many applications in
economics and finance.
Let A be a complex valued N × N square matrix. Suppose A is an invertible
matrix. The following are some of the matrices related to A, and given in the Table 2.1.
• Transpose: AiTj = A ji
• Complex conjugate: Ai∗j = (A ji )∗
• Hermitian conjugate: Ai†j = (Ai∗j )T = A∗ji
• Inverse:
1
Ai−1
j =
A ij
The following are some special N × N square matrices that have far-reaching appli-
cations.
• Symmetric matrix: S T = S ⇒ SiTj = S ji = Si j
• Hermitian matrix: H † = H ⇒ Hi†j = H ji∗ = Hi j
• Orthogonal matrix: O T O = I ⇒ O −1 = O T
• Unitary matrix: U † U = I ⇒ U −1 = U †
All quantum gates are unitary matrices, and hence, only these are of relevance for
quantum algorithms. The inverse of a unitary matrix U is U −1 = U † , and hence find-
ing the inverse, which requires major computational procedures for general matrices,
is trivial and almost available automatically. In drawing quantum circuits, the matrix
U † is sometimes replaced by its equivalent U −1 for notational convenience.
28 2 Binary Numbers, Vectors, Matrices and Tensor Products
Consider, for generality, a complex valued vectors v, wi that are represented by the
ket vector
v = |v ; wi = |wi
There is no need to make the symbol v, wi boldface inside the ket since the notation
makes it clear that it is a vector. Hermitian conjugation yields the dual bra vector that
is given by
v† = v|
ei = |i ; ei† = i|
u† = a ∗ v† + b∗ w† ⇒ u| = a ∗ v| + b∗ w|
where
v(i) = i|v
The two possible values {0, 1} of the classical bit, in Dirac’s notation, can be
represented by the two-dimensional column vectors. The two possible values of a
bit are represented by what are called ket vectors and their transpose, called bra
vectors, in the following manner:
1 0
|0 = ; |1 = : 0| = [1 0] ; 1| = [0 1] (2.26)
0 1
Note the important fact that each string is determinate, with each position in the ket
and bra vector having a definite value of either 0 or 1. Note that arithmetic operations
on bits is not the addition of the vectors that are used to represent binary numbers.
The representation of binary numbers in Eq. 2.26 is by a two-dimensional vector
that belongs to a two-dimensional linear vector space, which is the two-dimensional
Euclidean space E 2 . The n-binary numbers can be represented by an n-dimensional
vector, which is an element on the n-dimensional Euclidean space E 2 .
In Dirac’s notation, the scalar product is given by
Furthermore
The outer product is another notation for the tensor product and given by
u ⊗ v† = |u v|
Ai j = i|A| j (2.29)
30 2 Binary Numbers, Vectors, Matrices and Tensor Products
Note that the Dirac notation is a major innovation for the field of linear algebra
[2]. The ith component of the vector v is denoted by a subscript in ordinary vector
notation by v(i) and the i jth component of the matrix A is denoted by a subscript in
ordinary matrix notation by Ai j . In Dirac’s notation, the component label i and i j of
a vector and a matrix, respectively, are elevated to be on par with the vector and the
matrix itself, and are represented by bra and ket vectors. In particular
This notation brings much greater clarity on the use of indices since these are
being combined and transformed in most linear algebra calculations.
Matrix multiplication, using j|k = δ j−k , is given by
AB = Ai j Bk |i j|k | = Ai j Bk |iδ j−k |
ij kl ij kl
= Ai j B jk |i k| = Cik |i k| ; Cik = Ai j B jk (2.30)
i jk ik j
⇒ AB = C
N
N
I= e I ⊗ e†I = |I I | (2.31)
I =1 I =1
N
N
I= v I ⊗ v†I = |v I v I | (2.32)
I =1 I =1
N
N
S= λ I v I ⊗ v†I = λ I |v I v I | (2.33)
I =1 I =1
|e I = U † |v I ; e I | = v I |U ⇒ U|e I = |v I ; e I |U † = v I | (2.34)
2.9 Tensor and Outer Product: Strings and Gates 31
N
N
U SU =
†
λI eI ⊗ e†I = λ I |I I |
I =1 I =1
N
N
S= λ I U|e I e I |U † = λ I |v I v I | (2.35)
I =1 I =1
N
N
S =
2
λ I λ J |v I v I |v J v J | = λ2I |v I v I | (2.36)
I,J =1 I =1
N
Sn = λnI |v I v I | (2.37)
I =1
N
F(S) = F(λ I )|v I v I | (2.38)
I =1
In particular
N
exp(S) = exp(λ I )|v I v I | (2.39)
I =1
Starting from the single bit and gates acting on a single bit, the mathematics of
tensor and outer products allow us to construct n-bit strings and gates acting on these
multiple bit strings.
Consider a single bit; using Dirac’s notation, the bit is given by
1 0
|0 = ; |1 =
0 1
32 2 Binary Numbers, Vectors, Matrices and Tensor Products
Multiple bits are represented by the tensor product of the classical single bit. Tenor
products are a way of combining vectors and matrices to form other matrices.
For example, a 2-bit string is represented by the tensor product of two vectors and
is given by the following ⎡ ⎤
ac
a c ⎢ ad ⎥
⊗ =⎢ ⎥
⎣ bc ⎦
b d
bd
Using Dirac’s notation, the tensor product of two ket vectors is given by
⎡ ⎤
ac
a c ⎢ ad ⎥
|u = ; |v = ⇒ |u ⊗ |v = ⎢ ⎥
⎣ bc ⎦
b d
bd
Hence, 2-bit strings have a representation in terms of two 1-bits given as follows
⎡ ⎤
1
1 1 ⎢0⎥
|00 = ⊗ ⎢
=⎣ ⎥
0 0 0⎦
0
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
0 0 0
⎢1⎥ ⎢0⎥ ⎢0⎥
|01 = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣ 0 ⎦ ; |10 = ⎣ 1 ⎦ ; |11 = ⎣ 0 ⎦ (2.40)
0 0 1
Gates that act on a 2-bits string input are represented by the tensor product of the
matrices in the following manner. The NOT gate X acting on the n-bit string classical
string |c⊗n is given by a n-fold tensor product of matrices X ⊗n and given by
2.9 Tensor and Outer Product: Strings and Gates 33
X ⊗n ≡ X ⊗ X
· · · ⊗ X
n times
For the case of n = 2, the NOT gate acting on a 2-bit string is given as follows
⎡ ⎤
0 0 0 1
01 01 ⎢0 0 1 0⎥
X ⊗2 =X⊗X= ⊗ =⎢
⎣0
⎥ (2.41)
10 10 1 0 0⎦
1 0 0 0
To check the matrix notation and our intuition about the gates, one can check
whether the gate X ⊗2 does indeed reverse the value of the binary bits. The NOT gate
on a 2-bit string has the following action
Let |c, c = 0, 1 represent one classical bit {0, 1}. The n-bits strings {0, 1}n are
given by the n-fold tensor product and yields
|000 . . . 000, |000 . . . 001, |000 . . . 010, |000 . . . 011, . . . , |111 . . . 111
There are 2n number of distinct n-bits strings, and which are written in compact
notation as follows
|x ; x = 0, 1, 2, . . . , 2n − 1, (2.43)
For example
Recall that vectors are a special case of matrices, and the outer product of two vector
is the tensor product of two vectors.Consider two vectors
⎡ ⎤ ⎡ ⎤
v1 w1
⎢ v2 ⎥ ⎢ w2 ⎥
|v = ⎢ ⎥ ⎢ ⎥
⎣ · · · ⎦ ; |w = ⎣ · · · ⎦
vn wk
vn
⎡ ⎤
v1 w1∗ v1 w2∗ · · · vn wk∗
⎢v2 w ∗ v2 w ∗ · · · v2 w ∗ ⎥
=⎢ ⎣ ···
1 2 k⎥
⎦ (2.44)
vn w1∗ vn w2∗ · · · vn wk∗ n×k
Similarly, for 2-bits string, the outer product for example is given by
⎡ ⎤ ⎡ ⎤
1 01 0 0
⎢0⎥ ⎢0 0 0 0⎥
|00 01| = ⎢ ⎥ ⎢
⎣0⎦ ⊗ 0 1 0 0 = ⎣0 0
⎥ (2.45)
0 0⎦
0 00 0 0
Equation 2.45 above will be used in deriving the AND gate for a 2-bits string.
corresponding to
0; 1; 2; 3; 4; 5; 6; 7
respectively. In terms of Dirac’s notation for the state vectors for the 3-bits strings,
one has
|ABC ≡ |A ⊗ |B ⊗ |C : A, B, C = 0, 1
For example
⎡ ⎤
0
1 0 0 1 ⎢0⎥
|011 ≡ |0 ⊗ |1 ⊗ |1 = ⊗ ⊗ = ⊗⎢
⎣0⎦
⎥
0 1 1 0
1
T
= 00010000 (2.47)
where T stands for transpose, since for transpose is equal to Hermitian conjugation
for vectors with real components.
36 2 Binary Numbers, Vectors, Matrices and Tensor Products
References
1. Baaquie BE (2020) Mathematical methods and quantum mathematics for economics and
finance. Springer, Singapore
2. Mermin ND (2007) Quantum computer science. Cambridge University Press, UK
Chapter 3
Classical Gates and Algorithms
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 37
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_3
38 3 Classical Gates and Algorithms
All quantum gates are matrices, similar to classical gates, with one significant
difference, that all quantum gates are unitary. However, the practice gained from
studying classical gates carries over completely to quantum gates since the same
mathematics of linear algebra and tensor products are required in the study of both
classical and quantum gates. Hence, as a preparation for studying quantum qubits
and gates, this chapter goes into great detail in studying classical bits and gates.
The effect of classical gates on incoming bits is in general irreversible, in contrast
to quantum gates that in principle are reversible. By introducing auxiliary incoming
bits, the action of classical gates are extended to reversible gates, since these in turn
can be generalized to quantum gates.
The algorithm for adding two binary numbers is studied in great detail as it is an
exemplar of a classical algorithm that is realized by a classical circuit. Both the half-
adder and full-adder are analyzed and sets the stage for the quantum generalization
of the full-adder to its quantum algorithm, which adds two quantum bits (qubits).
The classical full-adder gates carry over unchanged from the classical addition
of two bits to the quantum addition of two qubits. What changes in going from the
classical to quantum addition is that the input and output states are qubits instead of
classical bits: the classical gates of the full-adder are unchanged in going from the
classical to the quantum case.
Quantum algorithms have no advantage over classical algorithms in arithmetic
operations. The reason that the classical problem is worth studying is because one
encounters all the mathematical ingredients that are required for defining quantum
algorithms in a simpler and more intuitively obvious context [1].
The input and output strings of a computer are binary numbers of the form
100110101011001 . . .. Note in the binary representation of a string, each position in
the string can be either 0 or 1. This is called a bit and is equal to the set {0, 1}. An
input depending on m bits is denoted by
Computer algorithm :
· · · 100011101010000111
· ·· → algorithm → · · · 111101001101000100
· ··
input string of length m output string of length n
3.2 Classical Gates 39
A classical computer, and this includes all computers today, is based on a defi-
nition of strings being determinate, and all algorithms transforming strings at every
stage of the computation are based on their determinate nature: at each step of the
computational process for a classical computer, the value of the string changes from
one determinate value to another determinate value. At any intermediate stage of
a classical algorithm, the state of the binary string can be observed. It is precisely
in the nature of the intermediate stage of the algorithm that a classical and a quan-
tum algorithm differ: only the initial and final state of the quantum algorithm can
be observed: any measurement carried out to determine the intermediate state of
the string, between the input and output state, will result in the termination of the
quantum algorithm.
A computer is essentially built from logical gates and circuits, which are physical
devices. A circuit is a collection of physical conducting wires with currents flowing
in the wires—and with the devices (gates) placed appropriately in the circuit. For
example, a binary circuit is one in which the current flowing in the circuit has only
two values, for instance the presence and the absence of a current. A gate is a physical
device that acts on the current to produce a result, which is a new current. Bits are
represented by lines and devices by various symbols. A circuit can have many bits as
inputs and outputs as well as many gates carrying out the operations of the algorithm.
For the purpose of discussing the logic of a computer, both classical and quantum,
the physical aspect of the device need not be discussed and the mathematical repre-
sentation of the device is sufficient for describing the algorithms being executed by
a computer.
A classical gate is a device that acts on one or more binary inputs and produces
a single or more binary outputs. A single binary bit has two possible states, a 0 (for
the absence of a current) and a 1 (for the presence of a current).
We study classical gates in great detail firstly, to recast classical gates in the for-
malism of quantum mechanics and secondly, and secondly to re-express all classical
gates as reversible gates. The reason being that classical reversible gates are identical
to similar quantum gates, so the classical gates foreground the discussion on quantum
gates. It should be noted that there are many quantum gates that have no counterpart
in classical gates.
As mentioned above, the real difference between classical and quantum algo-
rithms stem from the fact that the classical bit is replaced by the quantum qubit.
Classical reversible gates are augmented by many other quantum gates, and it is the
combination of qubits and quantum gates that allow computations that are beyond
the scope of classical computers.
Combinations of gates are used for carrying out the computer algorithm. With
a collection of gates, having one or more binary inputs, one can perform various
arithmetic operations on binary inputs. For a classical computation, a set of gates
40 3 Classical Gates and Algorithms
is universal if, for any positive integers n, m and function f : {0, 1}m → {0, 1}n , a
circuit can be constructed for computing f using only the gates from the universal
set. A universal gate is defined to be capable of realizing any computer gate. This
definition of a universal gate is based on the Church–Turing theorem [2].
There are seven basic logic gates, six of which are shown in Fig. 3.1, that are
sufficient for constructing a circuit for a classical computer; these gates are discussed
in books on classical computers. Combination of gates forms a circuit, with two
examples given in Fig. 3.2.
A Turing machine is realized in a classical computer by a combination of gates
composing a circuit, with the circuit being designed to execute a particular algorithm.
Two examples of a circuit are shown in Fig. 3.2.
Fig. 3.1 Logic gates used in a classical computer. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
Fig. 3.2 A circuit with a two and b three input bits and one output bit, with many gates between
the input and output. Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights
Reserved
3.2 Classical Gates 41
Fig. 3.3 Identity and NOT gate. Published with permission of © Belal E. Baaquie and L. C. Kwek.
All Rights Reserved
Two of the gates, namely the Identity and NOT gates, are shown in Fig. 3.3. Their
truth tables determine how the binary inputs are combined to give a single output
denoted by Z and are given by the following rules
• The identity gate makes no change in the input bit.
• The NOT gate acts on a single bit denoted by A, and the value of the output bit Z
is reversed.
The symbols for the Identity and NOT gates are given in Fig. 3.3, and the truth
table is given in Table 3.1; this provides a complete description of the Identity and
NOT gates—and is sufficient for building and programming a classical computer. For
a quantum computer, there are additional requirements linked primarily to making
the gates reversible. To foreground the discussion on qubits (quantum bits), the bits
and gates are represented in the framework of quantum mechanics.
The results obtained earlier in Sect. 2.9, in the context of the mathematical discus-
sion of vectors and matrices, are repeated here for completeness. Since a bit has two
possible values, 0 and 1, denote the two possible values by |0 and |1, respectively;
the bits can be represented by a two-dimensional vector and given by
1 0
|0 = ; |1 =
0 1
Let X represent the NAND gate. The truth table for the NAND gate is given in
Table 3.1 and is represented by and yields
The logic gates are represented by matrices acting on the vector representation
of the bits. The NOT gate can be represented by X : a 2 × 2 matrix given by the
following
01 1 0 0 1
X= ⇒ X = ; X =
10 0 1 1 0
The NOT is reversible since one bit goes into one bit and yields X 2 = X ; hence
X −1 = X
The truth table for the 2-bits strings is given in Fig. 3.4. The AND, NAND and XOR
gates are analyzed to illustrate how all gates can be represented by matrices.
Lines in the logic gates are incoming and outgoing bits, and the gate itself is
shown by various symbols. Note that all gates shown in Fig. 3.4 have two incoming
bits, but only one outgoing bit. All quantum gates have equal numbers of incoming
lines and outgoing lines. This is required for having unitary gates. To foreground
the discussion on quantum gates, the classical logic gates will be re-represented by
two incoming bits, which is the usual input but now with an auxiliary target bit as
another input bit; the effect of the gate is to produce two outgoing bits, with the
input bit being unchanged and the target bit being transformed into the output bit.
Since the input bit remained unchanged, it was not necessary to include it in
the truth table given in Fig. 3.4. However, quantum gates require equal number of
incoming and outgoing bits, and the input bit—although it is unchanged by the gate—
is also included in the outgoing lines for making the generalization of classical to
quantum gates more transparent.
Fig. 3.4 Truth tables for the logic gates. Published with permission of © Belal E. Baaquie and L.
C. Kwek. All Rights Reserved
3.3 2-Bits String Gates 43
We rewrite the truth table for the 2-bits string AND gate in Fig. 3.2. The gate acts
on two input bits that are denoted by A and the auxiliary input bit B; the gate changes
the value of B to the output bit, denoted by Z . Note that the bit A is unchanged and
is called the control bit, since it does not change, and the bit B is called the target
bit—as it is the ‘target’ of the gate. The truth table given in Fig. 3.4 is rewritten for
the AND gate, in the notation of A, B, Z , in Table 3.2 (and later for the NAND gate
in Table 3.3). This notation is used for the truth tables of all (classical) gates.
In Dirac’s bracket notation, the initial state of a circuit starts with the 2-bits string
state |A ⊗ |B = |AB. Due to the action of a classical gate G on two 2-bits string
|AB, to indicate which bit the gate is acting upon, one uses the notation
For the AND gate G = A, the output 1 if both input bits have a 1 and is 0 otherwise.
An AND gate gives a nonzero current only if both the input and target 1-bits have
currents flowing in them. The AND gate A acts on a 2-bits string state and requires
a 4×4 matrix; the classical AND A gate has the truth table given in Table 3.2. The
result can be given in condensed vector notation
|00 → |00
|01 → |00
|10 → |10
|11 → |11
Using the notation of outer product for writing the AND gate as the sum of terms
expressed as |outputinput| and the result given in Eq. 2.45 yields
44 3 Classical Gates and Algorithms
Fig. 3.5 NAND gate as the composition of the AND and NOT gates. Published with permission
of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
Using the representation of the 2-bits string given in Eq. 2.40 it can be verified
that A produces the result given in truth table, Table 3.2. The action of the gate in
Eq. 3.1 in the notation of linear algebra has the following realization given in Eq. 3.3.
For example, using Eq. 3.3
⎡ ⎤ ⎡ ⎤
1 1
⎢0⎥ ⎢0⎥
⎢ ⎥ ⎢
A|00 = A ⎣ ⎦ = ⎣ ⎥ = |00
0 0⎦
0 0
Similarly ⎡ ⎤ ⎡ ⎤
0 1
⎢1⎥ ⎢0⎥
A|01 = A ⎢ ⎥ ⎢ ⎥
⎣ 0 ⎦ = ⎣ 0 ⎦ = |00
0 0
For example, the final state of the AND gate (given in Eq. 3.3), with truth table
given in Table 3.2, does not have enough information in the output state to obtain the
values of the target 1-bits; the output bits Z a with value 0 correspond to three different
target bits and hence cannot be inverted to yield the target bit. This is reflected in the
fact that the AND gate A, considered as a matrix, is not invertible.
The NAND gate is combination of an AND and a NOT gate as shown in Fig. 3.5;
in truth table given in Table 3.3, for the output column denoted by Z n of the NAND
gate has interchanged all the 0’s and 1’s of the AND gate, which is given in Table 3.2.
One can represent the NAND gate by the transformation N given by
⎡ ⎤
0 0 0 0
⎢1 1 0 0⎥
N =⎢
⎣0
⎥ : NAND gate (3.4)
0 0 1⎦
0 0 1 0
One can verify that the NAND is correct by directly applying the expression for the
NAND gate given in Eq. 3.4 on the 2-bits strings and obtain the result given in the
truth table Table 3.3. The transformation N yields the NAND truth table given in
Table 3.3 is given by
Similar to the AND gate, the NAND gate does not have an inverse and hence is
not reversible. The decomposition of the NAND gate given in Fig. 3.5 shows that the
AND and NOT gates—being applied sequentially—yield the NAND gate. In other
words
The order of the gates is reversed compared to the way one thinks of applying the
NOT gate to the output of the AND gate as given in Eq. 3.6 [2]. From Eq. 3.1, one
has for the NAND truth table given in Table 3.3
N |AB = (I ⊗ X )A |AB = (I ⊗ X ) |AZ a = |AZ (3.7)
46 3 Classical Gates and Algorithms
The gate I ⊗ X acts as a NOT gate only on the output bit Z a and is given by
01
X=
10
⎡ ⎤
0 1 0 0
10 01 X 0 ⎢1 0 0 0⎥
X2 ≡ I ⊗ X = ⊗ = =⎢
⎣0
⎥ (3.8)
01 10 0 X 0 0 1⎦
0 0 1 0
N = (I ⊗ X )A = X 2 A (3.9)
The XOR gate, with input A and target B, has the following output Z
• If A or B is 1, but not both, then Z = 1.
• Otherwise, Z = 0.
The definition of the X OR gate yields the following
X OR |AB = |A, Z = A ⊕ B
The X OR gate is reversible and hence has a direct generalization to the quantum gate
denoted by CNOT. The X OR gate and its quantum version are among the most useful
gates since the X OR gate carries out the operation of binary addition. More precisely,
denoting binary addition by ⊕, the truth table of the XOR gate given in Table 3.4, is
reproduced by binary addition since
What is missing in the XOR is the carry of 1 for the addition of 1 ⊕ 1 = 0 plus carry
1. And hence a full binary addition entails using two 1-bits and yields 1 ⊕ 1 = 10.
Hence, XOR is used for the half-Adder that ignores the carry and one has to employ
another NAND gate in conjunction with the XOR gate to obtain the full-Adder,
discussed later in Sect. 3.8.
Similar to Eq. 3.9, the X NOR is defined by applying a NOT gate to the output of
X OR and yields
I 0 X 0
X NOR = (I ⊗ X )X OR = X 2 X OR = X 2 = (3.11)
0X 0 I
48 3 Classical Gates and Algorithms
Fig. 3.7 X NOR gate acting on 2- and 3-bits string. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
The X OR acts on a 2-bits string; as indicated in Fig. 3.7, the action is given by
X OR |AB = |AS
In a more complex circuit, the X OR acts on a 3-bits string; as indicated in Fig. 3.7,
the action is given by
X OR |ABC = |AB S
Note that the X OR does not act on the |B bit; this fact is represented in Fig. 3.7 by
the vertical line crossing the |B bit without any empty or heavy dot.
A general feature of the notation for gates and bits, both classical and quantum,
is the following:
• A vertical line represents the gate and acts on bits represented by horizontal lines.
• Bits that are affected by the gate are marked by a heavy dot or empty circle; in case
of Fig. 3.7, affected bits are the bits A and C, marked by a heavy dot and empty
circle respectively.
• For bits on which the gates don’t act, the vertical line crosses these without any
marking; in Fig. 3.7, bit B is left unchanged.
We need to extend the action of X OR , which requires at least a 2-bits string, to
a circuit with n-bits string—and in particular to a 3-bits string. To extend X OR to a
multibits string, we write X OR in terms of the outer product of the classical bits. The
truth table for X OR given in Table 3.4, using the notation |outputinput| acting on
only two 1-bits (drawing on the left in Fig. 3.7) yields
where X = |01| + |01| is the NOT gate. Equation 3.12 shows that X OR acts as a
NOT gate on the second bit B when the first bit A is equal to |1.
3.5 3-Bits String: Toffoli Gate 49
To evaluate X OR (A, B, C) as shown in Fig. 3.7, the gate X OR has no action of the
second bit |B and acts only on the first and last bit, given by |A and |C, respectively.
The action of gate X OR (A, B, C) on the second bit B is the identity matrix I. Hence,
X OR (A, B, C) acting on a 3-bits string, from Eq. 3.12 is given by
The Toffoli gate, denoted by T , is a universal reversible logic gate, shown in Fig. 3.8,
that acts on three incoming bits: two input bits A, B and one target bit C—and pro-
duces unchanged the two input bits A, B and a third bit Z which is the transformation
of the target bit C. It can be shown that any reversible classical circuit can be con-
structed from Toffoli gates. It is shown in Eq. 3.20 of Sect. 3.6 that the Toffoli gate
is equivalent to the unitary realization of the classical AND acting on a 3-bits string.
The Toffoli gate acts on three bits A, B, C and gives an output also of three bits
A, B, Z . The Toffoli gate action on a 3-bits string and is shown in Fig. 3.8, with
heavy dots indicating the conditioning of the output given by the Z bit.
The action of the Toffoli gate T on the incoming bits yields the following output
Using the notation for the 3-bits as enumerated in Eq. 2.46, from the definition of
the Toffoli gate given in Eq. 3.15, the truth table is given by Table 3.5. The inputs,
target and output bits of the Toffoli gate are given in Table 3.5.
There are a number of special cases of the Toffoli gate that can be read off from
its definition. More precisely,
50 3 Classical Gates and Algorithms
Hence, acting on a bit with C = 0 shows that T is equivalent to an AND gate for
A, B.
• Equivalent to the NOT gate for C
T |11C = |AB, Z = C ⊕ 1
T |A1C = |AB, Z = C ⊕ A
The Toffoli gate for B = 1 is equivalent to the XOR gate acting on A, C. For
A = 1, the Toffoli gate is equivalent to the XOR gate for B, C.
Note that for the first six row entries in Table 3.5, corresponding to the two input
bits A, B not both having 1 as their value, the output Z is and same as the incoming
target bit C and hence unchanged; only the last two output bits are changed by a
NOT gate. Hence, for the eight-dimensional state vectors for the 3-bits strings, one
has the 8 × 8 matrix representation of the Toffoli gate given by
3.5 3-Bits String: Toffoli Gate 51
⎡ ⎤
1 0 0 0 0 0 0 0
⎢0 1 0 0 0 0 0 0⎥
⎢ ⎥
⎢0 0 1 0 0 0 0 0⎥
⎢ ⎥
⎢0 0 0 1 0 0 0 0⎥
T =⎢
⎢0
⎥ ; det T = −1 (3.16)
⎢ 0 0 0 1 0 0 0⎥⎥
⎢0 0 0 0 0 1 0 0⎥
⎢ ⎥
⎣0 0 0 0 0 0 0 1⎦
0 0 0 0 0 0 1 0
It can be seen that the Toffoli matrix given in Eq. 3.16 is invertible, and hence, the
Toffoli gate represents a reversible transformation. It can be shown that all circuits of
a classical computer can be built up from the Toffoli gate, and it is called the universal
gate. The Fredkin gate, which is also a universal classical gate, is equivalent to the
Toffoli gate [2].
The Toffoli gate can be written in the outer product formalism based on the truth
table given in Table 3.5. The action of T gives the following mapping of the input to
output for the classical bits:
input → ouput
|000 → |000
|001 → |001
|010 → |010
|011 → |011
|100 → |100
|101 → |101
|110 → |111
|111 → |110
Anticipating our derivation of the full adder, recall that the bits are written in the
notation |ABC = |A ⊗ |B ⊗ |C, where A, B, C are the first, second and third
bit, respectively. To separate out the third bit, note that the outer product of a ket and
a bra vector yields the following
|ABD E| ≡ |A ⊗ |B D| ⊗ E| = |AD| ⊗ |BE|
⇒ |ABCD E F| = |ABD E| ⊗ |CF|
⇒ |000000| = |0000| ⊗ |00| ; |001001| = |0000| ⊗ |11| ; · · ·
52 3 Classical Gates and Algorithms
Using I = |00| + |11| and X = |01| + |10|, which is the NOT gate, the
derivation above yields the final result
T = |0000| + |0101| + |1010| ⊗ I + |1111| ⊗ X (3.18)
Note Eq. 3.18 is the matrix representation of the fact that the Toffoli gate, acting
on the 3-bits string |ABC a) leaves the |C bit unchanged when the first two bits
|ABAB| have the values |0000| ; |0101| ; |1010| and b) acts on |C as a
NOT gate for the bit |ABAB| = |1111|.
The Toffoli being a universal gate implies that all other gates given in truth table
Fig. 3.4 are special cases. The key feature of the Toffoli gate is that it provides a
reversible realization of all the classical computer gates, including such gates as the
AND and NAND gates that are irreversible. Hence, the Toffoli gate is the basis for
the generalization of all classical gates to the case of quantum gates. The universal
quantum gate is slightly more general than the Toffoli gate. The universal quantum
gate, in addition to T , requires one more qubit—and is discussed later.
To represent the classical gates that are not unitary, like the AND, NAND, OR gates,
one needs to define the gates using three bits and not just two bits. There seems to be
a lot of redundancy in the assignment, but if one demands that the gate be unitary,
there are some additional constraints. As in the case of a Toffoli gate, consider three
incoming bits given by |ABC, with two input bits A, B and a new auxiliary target
bit C; the outgoing bits are denoted by |AB, Z , with Z being the output bit. For any
arbitrary Boolean function f , the action of the gate G that is one-to-one and unitary
is given by
G|ABC = |AB, Z = C ⊕ f (A, B)
which is the result given earlier for the AND gate in Eq. 3.1. Hence, Eq. 3.19 is a
unitary extension of the AND to three bits, with initial value of the target bit being
set to be equal to C = 0 and |AB0 are the incoming bits.
If one re-examines the truth table of the Toffoli gate given in Table 3.5 and looks
at only the rows for which C = 0, one can see it is equal to the truth table for the
AND gate given in Table 3.2. The last line of the truth table, Table 3.5, is non-trivial
and fixed by the requirement that the 3-bit gate be unitary.
The AND gate also appears in the middle of the circuit, where it acts not only on
the incoming target bit but other bits as well. One can extend the definition of the
AND gate for C = 0, 1 to be equal to the Toffoli gate given in Eq. 3.15. Hence,
A3 = T (3.20)
Note that the 3-bits AND gate A3 has the same truth table as the Toffoli gate given
in Table 3.5.
The NAND gate also has an extension to a 8 × 8 matrix, acting on a 3-bit string.
A direct way of obtaining the 3-bits expression for the NAND gate is to generalize
Eq. 3.9. The NAND gate is obtained from the AND gate by acting with a NOT gate
only on the target bit. Hence, we apply the NOT gate to the third output bit, similar to
the case done earlier in Eq. 3.7. Define the NOT gate acting only on the third output
bit, in 2 × 2 block matrix notation with identity I, as follows
⎡ ⎤
X 0 0 0
⎢0 X 0 0⎥
X3 ≡ I ⊗ I ⊗ X = ⎢ ⎥ ; X= 01
⎣0 0 X 0⎦ 10
0 0 0 X
Then one has the following definition for the NAND gate
N3 = (I ⊗ I ⊗ X )A3 = X 3 T (3.21)
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
X 0 0 0 I 0 0 0 X 0 0 0
⎢0 X 0 0⎥ ⎢0 I 0 0⎥ ⎢0 X 0 0⎥
N3 = ⎢
⎣0
⎥·⎢ ⎥=⎢ ⎥ (3.23)
0 X 0 ⎦ ⎣0 0 I 0⎦ ⎣0 0 X 0⎦
0 0 0 X 0 0 0 X 0 0 0 I
One can directly verify using the representation of N3 required for 3-bits is given in
Eq. 3.24; one needs to only look at the result for C = 0 to obtain the truth table for
NAND for the 2−bit case, given in Table 3.3. More precisely, the entire truth table
is given below; only the target bit with C = 0 is relevant for the 2−bits NAND gate,
and indicated by the red color (Table 3.6).
The incoming lines have been grouped in pairs to show how unitarity fixes some
of the elements. Note that the first three values of C = 0 come in pairs to ensure
unitarity. The last 3-bits string 100 is unchanged and hence does not have a pairing.
The last entry 111 does not enter the definition of NAND and has no spare bit to be
mapped into– and hence remains unchanged.
The examples of AND and NAND show that the embedding of the gates acting
on 2-bits has a unique extension to unitary gates acting on 3-bits strings.
3.7 Unitary OR and NOR Gates 55
From the truth table for the OR gate, it can be verified that it has the following matrix
representation ⎡ ⎤
1000
⎢0 1 0 0⎥
O R2 = ⎢ ⎥
⎣ 0 0 0 0 ⎦ : OR gate (3.25)
0011
Similar to the NAND gate, the NOR gate can be obtained from the OR gate by
applying the NOT on the second bit, which is given by X 2 , and yields
N O R2 = X 2 · O R = (I ⊗ X ) · O R
⎡ ⎤⎡ ⎤
0100 1000
⎢1 0 0 0 ⎥ ⎢ 0 1 0 0 ⎥
=⎢ ⎥⎢
⎣0 0 0 1⎦ ⎣ 0 0 0 0 ⎦
⎥
0010 0011
⎡ ⎤
0100
⎢1 0 0 0⎥
=⎢ ⎥
⎣ 0 0 1 1 ⎦ : NOR gate (3.26)
0000
As expected, the O R2 and N O R2 gates, given in Eqs. 3.25 and 3.26, respectively,
are not reversible and since a number of 0’s and 1’s are not equal for the output
bit. Embedding them in the 3-bits string states yields, similar to AND gate, in 2 × 2
block notation, yields the following
⎡ ⎤
I 0 0 0
⎢0 X 0 0⎥
O R3 = ⎢
⎣0
⎥ (3.27)
0 X 0⎦
0 0 0 X
Similar to the NAND gate’s derivation from the AND gate, we have the following
⎡ ⎤
X 0 0 0
⎢0 I 0 0⎥
N O R3 = X 3 · O R3 = ⎢
⎣0
⎥ (3.28)
0 I 0⎦
0 0 0 I
56 3 Classical Gates and Algorithms
Binary numbers form the foundation of all computations carried out by both classical
and quantum computers. Indeed, the bedrock of all arithmetic calculations is the
addition of two binary numbers. Hence, binary addition is an important place to start
the application of the gates and circuits that we have discussed so far.
The derivation in this section is for the half and full adder of the classical computer.
The half adder is done with a logical circuit that is not reversible and hence has no
direct generalization to the half adder for the quantum case. In contrast, the derivation
of the full adder for the classical case is done with a reversible circuit that can in
fact be generalized to the quantum case. The derivations are done to illustrate the
differences in classical and quantum circuits, as well as to foreground the derivation
for the quantum case done in Sect. 7.4.
Binary addition of two string bits is shown in Fig. 3.9. Just like in ordinary addition,
the addition mod 2 is carried out column by column and there is a carry bit. In general,
for a column in the middle of the string, there is an incoming carry bit, denoted by
Cin and an outgoing carry bit, denoted by Cout .
For a non-reversible computation, the initial state |ABCin is transformed by the
full adder F into |ASCout , where S is the binary sum; hence
F|ABCin = |ASCout
The classical circuit for the half and full adder is given in Fig. 3.10a and b. These
circuits are not reversible since as one can see from the figure, information about the
input bits A, B is lost in the output.
3.9 Half-Adder
Instead of using the notation for classical circuit for the half adder given in Fig. 3.10a,
a different notation for the half adder is used for the same circuit and is given in
Fig. 3.11. The notation has three incoming and three outgoing lines and introduces
us to the one used for the reversible circuits, which in turn can be generalized to the
quantum case. In the derivations for the full adder, a reversible classical circuit is
later given in Fig. 3.13 and is used instead of the one given in Fig. 3.10b. Figure 3.13
can be directly generalized to a quantum circuit.
Fig. 3.10 Classical circuits for adding two bits using a half and b full-adder. Published with
permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
To simplify our discussion and demonstrate the main features of binary addition,
we start on the extreme right hand of the binary addition in Fig. 3.9—at the very
beginning of the addition, with the incoming carry Cin = 0. This case is known as
the half adder, since it takes into account only the outgoing carry but does not take
into account an arbitrary incoming carry. Since addition is carried out column by
column, it is sufficient to consider adding two 1-bits, called A and B; adding two
multibit strings will be seen to be reducible to the addition of two 1-bits.
The logic table for the half adder is shown in Table 3.7. An irreversible circuit for
the half adder has inputs A, B and Cin = 0 and outputs A, Sum S and carry Cout , as
is given in Fig. 3.11.
The half-adder gate H is given by
H|AB0 = |ASCout
58 3 Classical Gates and Algorithms
where Cout denotes the carry-out bit. Since the value of the bit B has been lost in the
output, the circuit in Fig. 3.11 is irreversible.
From our earlier discussion on gates, we know that the AND gate for a 3-bits string,
denoted by A3 , has the same truth tables as for a Toffoli gate given in Table 3.5—
and hence is the gate required for the carry-out since it gives a nonzero result for
output Z only if both bits are 1; that is, if A = 1 = B, then the output of the A3 gate
is |ABCout , with Cout = Z = 1. Furthermore, we know that X OR gate does binary
addition (which recall ignores the carry), and hence on the output of the A3 gate
given by |ABCout , we need to apply the X OR gate only on the first two bits A and
B, and the gate for the 3-bits string is X OR ⊗ I, and yields the sum A ⊕ B.
In summary, the logic of the half adder, shown in Fig. 3.11, is the following:
• The gate A3 (A, B, 0) gives an output of 1 only if both A and B are 1. Hence, the
carry out Cout = A3 (A, B, 0) = T (A, B, 0) = AB
• The gate X OR (A, B) = A ⊕ B, which is the binary addition of bits A and B.
The half adder yields both the sum and carry for the bits A and B. Hence, for
S = A ⊕ B, the half-adder is given by
Recall that the explicit matrix representation of the Toffoli gate is given in both
Eqs. 3.16 and 3.22. The explicit representation of X OR ⊗ I is required for verifying
the result obtained for the half-adder.
Using the definition of the tensor product yields the following. In block 2 × 2
notation
I 0 10 01
X OR ⊗ I = ⊗I ; I= ; X=
0X 01 10
The explicit derivation without using the block 2 × 2 notation is given by the fol-
lowing.
⎡ ⎤
1 0 0 0 0 0 0 0
⎢0 1 0 0 0 0 0 0 ⎥
⎡ ⎤ ⎢ ⎥
1 0 00 ⎢ ⎥
⎢0 0 1 0 0 0 0 0 ⎥
⎢0 1 00⎥⎥ 10 ⎢0 0 0 1 0 0 0 0 ⎥
X OR ⊗ I = ⎢
⎣0 ⎦ ⊗ =⎢
⎢0
⎥
⎥ (3.30)
0 01 01 ⎢ 0 0 0 0 0 1 0 ⎥
0 0 10 ⎢0 0 0 0 0 0 0 1 ⎥
⎢ ⎥
⎣0 0 0 0 1 0 0 0 ⎦
0 0 0 0 0 1 0 0
3.9 Half-Adder 59
In block 2 × 2 notation
⎡ ⎤
I 0 0 0
⎢0 I 0 0⎥
X OR ⊗ I = ⎢
⎣0
⎥ (3.31)
0 0 I⎦
0 0 I 0
We can verify that Eq. 3.29 is correct by checking the equation for the special case
of A = B = 1 and Cin = 0; from binary addition given in Fig. 3.11
A ⊕ B = 1 ⊕ 1 = 0 = S ; Cout = 1
and similarly
T
|101 = 0 0 0 0 0 1 0 0
Table 3.8 Logic table for a reversible half adder. The ancillary bit and the carry-in bit have been
set to 0
A B Ancilla Carry-in A B Sum Carry-out
0 0 0 0 0 0 0 0
0 1 0 0 0 1 1 0
1 0 0 0 1 0 1 0
1 1 0 0 1 1 0 1
One can construct a reversible half-adder by adding an ancillary bit, and hence
in the reversible representation, the half-adder has four incoming lines and four
outgoing lines and provides a reversible circuit. Table 3.8 is a logical truth table for
a reversible half-adder. The reversible half-adder circuit is part of the circuit for a
full-adder and is shown in Fig. 3.13.
3.10 Full-Adder
In classical computer, we add two (or three) bits using an exclusive OR gate with the
carry-out bit being an AND gate in a half adder (see Table 3.10). A full adder with
the carry-in as a bit, the picture is slightly more involved. One needs to consider the
extra carry-in bit.
The need for the full adder arises if the incoming bit Cin can be either 0 or 1,
instead of 0 as is the case for the half adder. The full-adder acts on two 1-bits and, in
contrast to the half-adder, keeps track of the incoming and outgoing carry.
It is not difficult to verify that we want a gate that can perform the task given in
the truth table, Table 3.9. The full adder uses the half-adder two times, once to add
the numbers that in principle can generate a carry, and the second time using the
half-adder again to add the incoming carry to the number generated by adding the
two numbers. See Fig. 3.12.
Note that the truth table Table 3.9 yields an irreversible circuit, whereas a quantum
circuit is reversible. Since a quantum gate is unitary, it is necessary to devise a gate
that takes in the same number of inputs as the outputs. Note the important fact that a
classical full adder is the special case of the quantum full adder–the only difference
between the two does not lie in the gates, but in the fact that the classical bit is
replaced by the quantum qubit. Hence, we will analyze the classical full adder using
gates that are valid for both the classical and quantum full adder.
The logic of the full adder is similar to the half adder. We have the following:
• The sum bit: S = (A XOR B) XOR Cin = (A ⊕ B) ⊕ Cin
• The carry-out bit: Cout = A AND B OR Cin (A XOR B) = A · B + Cin (A ⊕ B)
3.10 Full-Adder 61
Fig. 3.12 Full adder equal using two Half adders (HA). Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
Table 3.10 Logic table for a reversible classical and quantum gate for the full adder
Input 1 Input 2 Input 3 Input 4 Output 1 Output 2 Output 3 Output 4
A B Cin S A B Cout S
0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 1
0 1 0 0 0 1 0 1
0 1 1 0 0 1 1 0
1 0 0 0 1 0 0 1
1 0 1 0 1 0 1 0
1 1 0 0 1 1 1 0
1 1 1 0 1 1 1 1
62 3 Classical Gates and Algorithms
Fig. 3.13 Adding two classical bits using unitary gates. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
The logic of the full adder can be implemented by the logic table given in Table 3.10.
We implement Table 3.10 with the quantum circuit in Fig. 3.13.
In Fig. 3.13, there are exactly five gates: Gates 1 to 5 and a Swap gate at the end for
the third and fourth bits. Gate 1 is a AND gate on the first, second and fourth bits. On a
quantum computer, we can do the same arithmetic with the circuit shown in Fig. 3.13.
The circuit has four incoming bits and four outgoing bits given by |ABCin 0 and the
adder yields the following
Note that the classical full adder, given above in Eq. 3.33 has |A, |B as classical
1-bits; the input state is a definite combination of four bits, and the output is also a
combination of four bits.
As mentioned earlier, the full adder gate F is the same for the classical and
quantum case; the crucial difference between adding bits versus qubits lies in the
4-bits string |ABCin 0. For the quantum case, |A, |B are both qubits and the result
of the addition is not a single determinate state, as in Eq. 3.33, but a superposition of
states. The quantum addition of two qubits is discussed in Section 7.4.
In Fig. 3.13, there are exactly five gates: Gate 1 to 5 say and a swap gate at the
end for the third and fourth qubits. Gate 1 is a CCNot gate on the first, second and
fourth qubits.
Using the result from Eqs. 3.13 and 3.18 and that A3 = T , Gate 1 for the full-
adder given in Fig. 3.13 is given by the gate acting as the identity matrix I on the
third bit and hence yielding the following 16 × 16 matrix:
Gate 1 = A3 (A, B, C, 0)
= |0000| + |0101| + |1010| ⊗ I ⊗ I + |1111| ⊗ I ⊗ X
3.10 Full-Adder 63
Note that the bit |C for Gate1 and Gate2 is a placeholder for the third bit required
for these gates. In Fig. 3.13 for Gate 1 this placeholder bit |C = |0 but it has a
nontrivial value for Gate 3 onwards.
Using results from Eq. 3.13 yields the following 16 × 16 matrices for the other
Gates for the full-adder given in Fig. 3.13:
Gate 2 = X OR (A, B) ⊗ I ⊗ I
Gate 3 = A3 (A, B, Cin , S) = I ⊗ T (B, Cin , S)
Gate 4 = I ⊗ X OR (B, Cin ) ⊗ I
Gate 5 = X OR (A, B) ⊗ I ⊗ I
Swap = I ⊗ I ⊗ Swap12(Cin , S)
where
10 01 I 0
I= ; X= ; X OR =
01 10 0X
⎡ ⎤
100 0
⎢0 0 1 0⎥
Swap12 = ⎢
⎣0 1 0
⎥
0⎦
000 1
The explicit 16 × 16 matrices for the Gates and the Swap are given in Sect. 7.4 on
the quantum circuit for the full adder.
The full adder is given by
with the full 16 × 16 matrix given in Sect. 3.11. Collecting all the results, the full-
adder gate F is given by
Example
Consider the binary addition of two bits, with and without Cin and Cout . One
can explicitly verify, as given below, Eq. 3.34 using the following examples of the
addition of two binary bits.
• A = 1; B = 1; Cin = 0 ⇒ 1⊕1 ⊕ Cin = 0 = S and Cout = 1
⇒ F|1100 = |1110
• A = 1; B = 1; Cin = 1 ⇒ 1⊕1 ⊕ Cin = 1 = S and Cout = 1
⇒ F|1110 = |1111
• A = 0; B = 0; Cin = 1 ⇒ 0⊕0 ⊕ Cin = 1 = S and Cout = 0
⇒ F|0010 = |0001
Hence, we have the following summary of our results
64 3 Classical Gates and Algorithms
Fig. 3.14 Ripple effect for an addition of two 4-bit strings. Published with permission of © Belal
E. Baaquie and L. C. Kwek. All Rights Reserved
One verifies, using the matrix representations given in Sect. 3.11, the results obtained
in Eq. 3.35.
To add two binary numbers that are n-bits strings, one can cascade the result of
adding two 1-bits by adding the n-bits strings column by column, passing the carry
from one column to the next. This ‘ripple’ effect in adding two 4-bits strings is shown
in Fig. 3.14.
If one is adding n−bits string to a m−bits string, with n ≤ m, then the full adder
gate F is a matrix of size 16 × 16 that has to be used successively n−times; this
creates a ‘ripple’ effect of the output sum and carries out of the full adder for step
j being the input and carry in for the next addition at step j + 1. Hence, for adding
n−bits string
with the initial Cin = 0. As shown in Fig. 3.14, each box is a full adder, adding two
1-bits Ai , Bi and an incoming carry Ci−1 and an outgoing carry Ci . The result of
sequentially applying the full adder starting from the least significant binary numbers
A0 , B0 and moving to the most significant the most significant binary A3 , B3 yields
the following result
F|A, B, 0, 0 = |AB|Cout S3 S2 S1 S0
3.11 Matrices of Full-Adder Gates 65
Gate 2 = X OR ⊗ I ⊗ I
⎛ ⎞
100000 0 0 0 0 0 0 0000
⎜0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0⎟
=⎜⎜0 0 0 0 0 0
⎟;
⎜ 0 0 0 0 0 0 1 0 0 0⎟
⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0⎠
000000 0 0 0 0 0 1 0000
66 3 Classical Gates and Algorithms
Gate 4 = I ⊗ X OR ⊗ I
⎛ ⎞
100000 0 0 0 0 0 0 0000
⎜0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0⎟
=⎜⎜0 0 0 0 0 0
⎟;
⎜ 0 0 1 0 0 0 0 0 0 0⎟
⎟
⎜0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0⎠
000000 0 0 0 0 0 0 0100
3.11 Matrices of Full-Adder Gates 67
Gate 5 = X OR ⊗ I ⊗ I
⎛ ⎞
100000 0 0 0 0 0 0 0000
⎜0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0⎟
=⎜⎜0 0 0 0 0 0
⎟;
⎜ 0 0 0 0 0 0 1 0 0 0⎟
⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0⎠
000000 0 0 0 0 0 1 0000
The matrix products of the gates that describe the full-adder circuit are given by
Finally, we need to apply the SWAP gate on the last two qubits. Recall the SWAP
gate in computational basis is given by the matrix
⎛ ⎞
1 0 0 0
⎜0 0 1 0⎟
SWAP12 = ⎜
⎝0
⎟
1 0 0⎠
0 0 0 1
68 3 Classical Gates and Algorithms
But since this SWAP gate acts only on the last two qubits, it is described by
F =S ·G (3.36)
= SWAP Gate · Gate 5 · Gate 4 · Gate 3 · Gate 2 · Gate 1 (3.37)
⎛ ⎞
1000000000000000
⎜0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0⎟
=⎜⎜ ⎟ (3.38)
⎟
⎜0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0⎟
⎜0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0⎟
⎜ ⎟
⎜0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0⎠
0000000000000010
To get the adder, one applies the full-adder matrix F to the inputs. The output
does not make sense unless one notes that the fourth qubit is always set to the zero
computational bit. We therefore only need to look at those inputs whose fourth qubit
is |0. We remind the readers that the encoding is
References 69
This process effectively provides us with the mapping of classical bits as:
|0000 → |0000
|0010 → |0001
|0100 → |0101
|0110 → |0110
|1000 → |1001
|1010 → |1010
|1100 → |1110
|1110 → |1111
as described by the full-adder matrix F for the circuit given in Eq. 3.36.
References
The principles and formalism of quantum mechanics are reviewed as these provide
the basis for quantum computers and quantum algorithms. This chapter is based on the
Copenhagen interpretation of quantum mechanics pioneered by Werner Heisenberg,
Niels Bohr and Max Born, with the derivations following the approach of Baaquie
[1]. There are many other interpretations of quantum mechanics, but by and large,
the Copenhagen interpretation is the one that is followed by most practitioners of
quantum computing [2].
This chapter starts with a general discussion on the degree of freedom and its
Hilbert space and Hermitian operators (matrices): these three ingredients play a
central role in the description of quantum systems. The Schroödinger equation is
introduced, but not discussed in any detail since it plays only an indirect role in
quantum algorithms. The measurement procedure and process of a quantum system
are discussed in some detail as the key difference between a classical and quantum
system lies in the significance of quantum measurements. In particular, the cardinal
difference between a classical and quantum algorithm lies in the essential role played
by measurements in quantum mechanics. The mathematical formalism of quantum
mechanics is based on linear vector spaces, and Chap. 2 should be reviewed for the
background material required for this and later chapters.
The description and dynamics of a quantum entity, based on the Copenhagen
interpretation of quantum mechanics [1, 2], can be summarized as follows. Quantum
mechanics is built on five main conceptual pillars that are shown in Fig. 4.1 and
given below [1].
• The quantum degree of freedom space F.
• The quantum state space V, which is a Hilbert space.
• State vector ψ(F), which is an element of Hilbert space. Time evolution of ψ(F)
is given by the Schrödinger equation.
• Hermitian operators Oi (F); i = 1, . . . , I that encode all the observable properties
of the state vector ψ(F).
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 71
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_4
72 4 Principles of Quantum Mechanics
Fig. 4.1 Theoretical schema of quantum mechanics, based on five fundamental ingredients. Pub-
lished with permission of © Belal E. Baaquie. All Rights Reserved
The ‘ground’ on which quantum mechanics stands is the degree of freedom. For
quantum computers, the single 1-bit of the classical computer x = {0, 1} is elevated
in quantum mechanics to the quantum binary degree of freedom. The two values of a
bit x = {0, 1} taken together, as a two element set, yield the binary degree of freedom
F = {0, 1}. For the case of two 1-bits, all possible combinations yield the degree of
F ⊗2 = {0, 1} ⊗ {0, 1} = (x1 , x2 ) consisting of 2 × 2 = 22 number of points; written
out in full detail, the degrees of freedom F ⊗2 is the following four element set
The case for n = 3, all possible combinations yield the discrete set of eight points
for the space of the degrees of freedom F ⊗3
(x1 , x2 , . . . , xn ) : xi = 0, 1; i = 1, 2, . . . , n
Fig. 4.2 Discrete space F ⊗3 = {0, 1}⊗3 for 3-binary degrees of freedom, consisting of 23 = 8
points at the corners of the cube. The coordinates of the corners are the values taken by the binary
degrees of freedom. Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights
Reserved
F ⊗m = {0, 1}⊗n
The degrees of freedom are indeterminate: what this means is that the degrees of
freedom exist as the entire space (set of points) F ⊗m = {0, 1}⊗n , and not as a specific
point of that space [1]. In other words, the degrees of freedom never have a specific
value; for example, in the case of the single binary degree of freedom x = {0, 1},
the degree of freedom always simultaneously has both values of x = 0 and 1. The
specific and determinate values of the degrees of freedom are the points that constitute
the space F ⊗m .
The degree of freedom F can never, in principle, be observed in its totality:
one can only observe the specific and determinate values of the degrees of free-
dom, and that too, one by one: no experiment ever has been able to simultaneously
detect two or more determinate values of the degree of freedom.1 All objects in
spacetime have a determinate and specific value: the degree of freedom F cannot be
directly observed in spacetime, as such, since it is indeterminate. What one observes
in experiments are the specific and determinate values of the degrees of freedom. In
particular, the quantum degrees of freedom given by {0, 1}⊗n always remain inde-
terminate [1]. Any device attempting to measure the degrees of freedom encounters
the state vector of the degrees of freedom. This aspect of the degree of freedom is
discussed later in Sect. 4.2 and shown in see Fig. 4.3.
If the degree of freedom can never be directly observed by any experiment, then
how does one ‘know’ about it? This is best answered by an example. The position of a
particle is the basis of classical physics: at every instant t, the particle has a position
1 One of us (BEB) had an interesting discussion with Nobel Laureate Anthony Leggett. It was
mentioned to him, over dinner, that the quantum mechanical degree of freedom can never, in
principle, be observed: one could only observe the specific values of the degrees of freedom. His
view on this was sought. He stopped having his dinner, put down his knife and fork, and responded
after some thought that: ‘Indeed, this is rather strange, but true’. Later discussions with Leggett
confirmed this aspect of quantum mechanics.
74 4 Principles of Quantum Mechanics
x(t). From the quantum mechanical point of view, all possible ‘positions’ of the
particle are interpreted as specific and determinate values of the degree of freedom.
All the determinate values of the position of the particle, taken together, constitute
the continuous position degree of freedom and yields the degree of freedom space
F = {x : −∞ ≤ x ≤ +∞}. Another example is the case of the binary degree of
freedom, a concept central to quantum algorithms. The 1-bit of a classical computer
is given by 0 and 1; as mentioned earlier, the quantum binary degree of freedom
combines these two values into a single indeterminate entity that simultaneously
consists of 0,1 and constitutes the space F = {0, 1}.
What observes on measuring the position degree of freedom are the specific and
determinate values of the degree of freedom. Experiments can observe only one of
the possible determinate values of the degree of freedom. The outcome of measuring
the degree of freedom is uncertain, discussed in Sect. 4.2, and what one can finally
obtain, after many observations, is the expected (average) value of the position degree
of freedom.
In general, independent classical variables can be generalized to quantum degrees
of freedom by collecting all possible values of the classical variable into a single
space, which is the space F of the degree of freedom that corresponds to the classical
variable. The degree of freedom is a theoretical construct that ‘exists’, for human
beings, as a mathematical form in the human mind; its ontological significance is
discussed in [1].
The degrees of freedom space F is the ‘ground’, the foundation on which the Hilbert
space is built. The degrees of freedom space F exists outside Hilbert space. The term
state space is used interchangeably with Hilbert space throughout this book, and the
terms state vector and wave function are also used interchangeably.
Hilbert space V is a linear vector space of all possible mappings of space (degree
of freedom) F to the complex numbers C that have a norm of unity.
V:F →C
ψ(t, F) : F → C; |ψ|2 = 1
The norm of a state vector |ψ|2 is defined more precisely later on.
4.2 Hilbert Space; State Vectors 75
All information about the degrees of freedom is encoded in the state vector
ψ(t, F): the information has to be extracted by quantum measurements. The only
information that one can extract from the degrees of freedom is what is the likelihood
that the degrees of freedom can be observed taking its various particular values—
while always remaining indeterminate. The degree of freedom, on being observed,
leaves a ‘click’ in the detector: the collection of ‘clicks’ yields the probability of the
indeterminate degrees of freedom taking different values.
The process of quantum measurement, discussed in some detail in Sect. 4.5, is
required for obtaining the results of experiments. The probability of the detector
having a reading corresponding to a determinate value x0 of the degree of freedom
is given by |ψ(x0 )|2 . Note that before the measurement is made, unlike a classical
random variable, the quantum degree of freedom is indeterminate and, unlike a
classical random variable, does not have a definite value; this is the result of the
famous Bell theorem [1].
The degree of freedom is completely ‘veiled’ by the state vector ψ(x): the degree
of freedom is, metaphorically speaking, enclosed and encompassed by its Hilbert
space, as shown in Fig. 4.3: the Hilbert space constitutes an impenetrable barrier and
any experiment that attempts to directly observe the degree of freedom encounters
the state vector enclosing the degree of freedom. This is the reason that the degree
of freedom, as such, cannot be directly observed. The state vector ψ(x) mediates
the process of measurement–interposed between the experiment and the degree of
freedom.
The Hilbert space, in general, is an infinite dimensional function space, with the
additional requirement that the norm of all its state vectors is 1. For discrete degrees
of freedom, as is the case for the binary degree of freedom, a Hilbert space is a finite
dimensional linear vector space consisting of all possible unit norm state vectors.2
Let the degrees of freedom be given by x j , j = 1, 2, . . . , n and let the basis state
vectors be given by
2 To be mathematically rigorous, a Hilbert space is a vector space endowed with an inner product. It
is also a complete metric space with respect to the distance function induced by the inner product.
76 4 Principles of Quantum Mechanics
The Hilbert space V is a linear vector space that has the following properties.
• The basis states are orthonormal
ψi |ψ j = δi− j
• For αi complex numbers, an arbitrary state vector has the following expansion
m
|ψ = αi |ψi : Superposition
i=1
• All the state vectors belonging to Hilbert space V have norm of unity
m
|ψ|2 = ψ|ψ = 1 ⇒ ψ|ψ = 1 = |αi |2
i=1
• One can form the tensor product of the Hilbert space to yield the product Hilbert
space
V P = V ⊗m = V ⊗ V ⊗· · · V ⊗ V
m-times
m
F ⊗k = x ⊗k ; | P = αi j...k |ψi ⊗ |ψ j · · · ⊗ |ψk : Entanglement
i j...k=1
m
x ⊗m | P = P (x) = αi j...k ψi (xi )ψ j (x j ) . . . ψk (xk )
i j...k=1
Superposition and entanglement of state vectors are properties of Hilbert space quite
independent of how the states evolve in time, which is determined by the Schrödinger
equation. A key feature of the Schrödinger equation, discussed later, is that it is
a linear differential equation, and hence, its solutions can be superposed to yield
new solutions. Hence, the fact that Hilbert space allows for the superposition of its
elements turns out to play a key role in quantum mechanics. This feature also plays
a key role in quantum algorithms.
4.2 Hilbert Space; State Vectors 77
Entangled states are not necessarily solutions of the Schrödinger equation. How-
ever, one can prepare initial states that are entangled and these states can be evolved
in time so that they continue to be entangled. These entangled states have a very
special role to play both in quantum algorithms and, quantum cryptography and
quantum communication [3, 4]. Entanglement, similar to superposition of state vec-
tors, is a property of Hilbert space and results in phenomena that are forbidden both
in classical physics and classical algorithms.
ψ(z 1(0) , z 2(0) , . . . , z n(0) ) and eiφ ψ(z 1(0) , z 2(0) , . . . , z n(0) )
lead to the same probabilities and hence are equivalent. For this reason, in many of
the derivations, the overall phase factor is dropped or ignored.
78 4 Principles of Quantum Mechanics
For the probabilistic interpretation, the total probability of observing some deter-
minate value of the degree of freedom must be unity; hence, the functions in Hilbert
space ψ(z 1 , z 2 , . . . , z n ) are normalized functions such that
dz|ψ(z 1 , z 2 , . . . , z n )|2 = 1
R
Recall the discrete binary degree of freedom is the set of two possible values of a
classical bit, namely 0, 1, and hence is represented by the binary set of two points
x = {0, 1}. The single qubit is a state vector of this binary degree of freedom, denoted
by |q = |q(x). The Hilbert space of the qubit is Hq is a function of the binary degree
of freedom {0, 1}, with qubits given by the vectors in Hq .
We will see that the representation of the most general single qubit (given explicitly
in Eq. 6.3) is the superposition of the binary degree of freedom’s basis states |0, |1,
which is called the computational basis states, and can be taken to be two-dimensional
column vectors. The qubit is given by
θ θ
|ψ = |q(θ, φ) = cos |0 + eiφ sin |1; q(θ, φ)|q(θ, φ) = 1(4.3)
2 2
Recall that functions in Hilbert space that differ by a phase (i.e., along a ‘ray’) are
equivalent in quantum mechanics since they do not contribute to the probability. Up
to this ray equivalence, the Hilbert space of a single qubit consists of all possible
values of θ, φ—and which forms the surface of a two-dimensional sphere and hence
Hq ≡ S 2 , as shown in Fig. 6.1.
The n-qubit of a quantum computer are the state vectors of n-binary discrete
degrees of freedom F ⊗n . The degree of freedom space is the n-fold tensor product
F ⊗n = {0, 1} ⊗ · · · ⊗ {0, 1} = {0, 1}⊗n and is a discrete set consisting of 2n points
that are the corners of a 2n -dimensional hypercube. It is the analog of the degree of
freedom space Rn for n-real variables. The state vector of n input and output qubits
are elements of Hilbert space. For n-binary discrete degrees of freedom F ⊗n , the
Hilbert space is a finite dimensional linear vector space and consists of all functions
defined on the set F ⊗n with unit norm. The quantum state vector of n binary degrees
of freedom F = {0, 1}⊗n is given by
2
n
−1 2
n
−1
|ψ = α(x)|x; |α(x)|2 = 1 (4.4)
x=0 x=0
The complex numbers α(x) are the coordinates of the n-qubit state vector in the
2n -dimensional Hilbert space. α(x) is the amplitude of the n-qubit state to be in
quantum state, |x and |α(x)|2 is the probability of the state |x being observed by a
measuring device when |ψ is subjected to repeated measurements.
Another representation of state vector for n-binary discrete degrees of freedom is
given by
2
n
−1
1
|ψ = ψ(x0 , x1 , . . . , xn−1 )|x0 , x1 , . . . , xn−1 (4.5)
i=0 xi =0
2
n
−1
1
|ψ(x0 , x1 , . . . , xn−1 )|2 = 1 (4.6)
i=0 xi =0
Hn ≡ S 2 ⊗ ·
· · ⊗ S2 (4.7)
n-fold tensor product
Every degree of freedom F defines a state space V and operators O that act on that
state space. All operators O are mathematically defined to be linear mappings of the
state space V into itself, shown in Fig. 4.4, and yield
O : |ψ → O|ψ ⇒ O : V → V
O a|ψ1 + b|ψ2 = aO|ψ1 + bO|ψ2 : linear operator
An operator is an element of the space formed by the outer product of V with its
dual V D , that is
∈ V ⊗ VD
O
Note the crucial point that unless i, j have the same range, the equality in Eq. 4.8
cannot hold for all i, j. Hermitian operators on linear vector state space are infi-
nite dimensional generalizations of N × N matrices, with N → ∞ and have new
properties that are absent in finite matrices.
The range over which the finite index i takes values for a finite dimensional matrix
has a generalization for state vectors in an infinite dimensional Hilbert space V. The
domain of the operator O denoted by D(O) ⊂ V is defined by all elements |ψ in
V such that O|ψ ∈ V. Similarly, the vector |χ is in D(O† ), the domain of O† , if
O† |χ ∈ V.
The analog of Hermitian conjugation, being defined only for a square matrix, is
that for operators on Hilbert space, the adjoint (Hermitian conjugate) operator can
be defined for only those operators F for which the domain of the operator and its
adjoint are isomorphic, or in other words, D(O) = D(O† ).
Hermitian conjugation of operators on state space is defined by
4.3 Hermitian and Unitary Operators 81
for any two vectors |ψ, |χ ∈ V. Once the domains of the operator and its conjugate
are isomorphic, the form of the operator has to be invariant under conjugation, that is,
O = O† , for the operator to be self-adjoint.3 More precisely, an operator is Hermitian
if its Hermitian conjugate operator is equal to the operator itself, that is, if
Note that all the diagonal elements of a Hermitian operator O are real since for
any arbitrary state vector |ψ, the diagonal element is as shown below
The trace operation for an operator O similar to matrices is defined as a sum of all
its ‘diagonal elements’. To make this statement more precise, one needs a resolution
of the identity operator on state space V. Consider for concreteness, the continuous
degree of freedom with the completeness equation given by
∞
I= dx|xx|
−∞
∞ ∞
Tr(O) = Tr(OI) = dx Tr O|xx| = dxx|O|x (4.11)
−∞ −∞
3 One of the reasons for studying Hermitian (self-adjoint) operators is because one need not ascertain
the space that an operator acts on, namely whether it acts on V or on its dual VD . For non-Hermitian
operators, and these are the ones that occur in describing classical random systems such as those
that occur in finance [5], the difference is important.
82 4 Principles of Quantum Mechanics
Tr[ ci Oi ] = ci Tr[Oi ]
i i
†
Tr ci Oi = ci∗ Tr∗ [Oi ]
i i
Tr(O1 O2 O3 ) = Tr(O3 O1 O2 ) : cyclic
A unitary operator, the generalization of the exponential function exp iφ, is given
in terms of a Hermitian operator O by the following
U = eiφO ⇒ UU † = I
1 − iaO
V = ⇒ VV† = I
1 + iaO
Every Hermitian operator defines a unitary operator. The most important Hermitian
operator in quantum mechanics is the Hamiltonian. In quantum algorithms, Hermitian
operators rarely occur since all quantum gates are represented by unitary operators.
The Schrödinger equation determines the time evolution of the state function |ψ(t),
where the label t denotes the time parameter. To write down the Schrödinger equation
one first needs to specify the degrees of freedom of the system in question, which
in turn specifies its state space V; one also needs to specify the Hamiltonian H of
the system that describes the range and form of the possible energies the quantum
system can have.
The celebrated Schrödinger equation is given by
∂|ψ(t)
− = H|ψ(t) (4.12)
i ∂t
Consider a quantum particle with mass m moving in one dimension in a potential
V (x); the ‘position’ of a classical particle x is elevated to a continuous degree of
freedom x ∈ R. The Schrödinger equation is given as follows,
∂ ∂ψ(t, x)
− x| |ψ(t) = x|H|ψ(t) ⇒ −
i ∂t i ∂t
∂
= H x, ψ(t, x) (4.13)
∂x
4.4 The Schrödinger Equation 83
The Hamiltonian operator acts on the dual basis states. In the position basis, the state
vector is
x|ψ(t) = ψ(t, x)
The Hamiltonian for the important case of a quantum particle moving in one dimen-
sion is given by
∂2
H=− + V (x) (4.14)
2m ∂ x 2
A variety of techniques have been developed for solving the Schrödinger equation
for a wide class of potentials as well as for multiparticle quantum systems [6].
Let |ψ be the initial value of the state vector at t = 0 with ψ|ψ = 1. Equa-
tion 4.12 can be integrated to yield the following formal solution
The Hamiltonian H is an operator that translates the initial state vector in time, as in
Eq. 4.15. The evolution operator U (t) is defined by
U (t) = e− tH ; U † (t) = e tH
i i
U (t)U † (t) = I
The unitarity of U (t), and by implication the Hermiticity of H, is crucial for the
conservation of probability. The total probability of the quantum system is conserved
over time since unitarity of U (t) ensures that the normalization of the state function
is time-independent; more precisely,
The operator U (t) is the exponential of a Hermitian operator that in many cases, as
given in Eq. 4.14, is a differential operator. The Feynman path integral is a mathe-
matical tool for analyzing U (t) and is discussed in [7].
As mentioned earlier, in quantum algorithms the Hamiltonian H or the other
Hermitian operators seldom appear. The reason is that for quantum algorithms, all
the quantum gates required for transforming the state vector from one state to the
next involve an evolution over a finite time t and hence are all the quantum gates
G are unitary operators and are generically of the form
i
G = U ( t) = exp − tH
84 4 Principles of Quantum Mechanics
The role of the Hamiltonian H is central for constructing a physical device for
executing a quantum algorithm and has been discussed in some detail in [8, 9].
As discussed in Chap. 3, a circuit for a classical computer is a physical circuit built
from conducting materials through which electrical currents flow. All the computa-
tional steps of a classical algorithm take place in the electrical circuits of a classical
computer. Any intermediate step in the classical algorithm can be observed directly.
A quantum circuit is also a physical object with physical process that evolves the
quantum state from its initial state vector to the final output state vector. However, the
computational process of a quantum circuit ‘exists’ in Hilbert space and all the steps
in a quantum computation are transformations of the state vector of n-qubits—given
by |ψ(t)—that take place in Hilbert space. The input qubits state vector |ψ I , given
at initial time t I , is evolved by |ψ(t) = U (t)|ψ I , to the state vector of the output
qubits |ψ F at final time t F and given by
i
|ψ F = exp − (t F − t I )H |ψ I (4.16)
This is further discussed in Sect. 4.9 and shown in Figs. 4.6 and 4.7.
• The state vector |ψ(t) is a complex-valued vector and an element of Hilbert space.
This is the reason that one can entangle state vectors depending on different degrees
of freedom. Note, entanglement is independent of the Hamiltonian as well as of
the Schrödinger equation: it is solely a result of state vectors existing in Hilbert
space. Entanglement of state vectors is an important resource in the efficiency of
quantum algorithms.
• The Schrödinger equation is a first-order differential equation in time, in contrast
to Newton’s equation of motion that is a second-order differential equation in time.
At t = 0, the Schrödinger equation requires that the initial state function for all
values of the degree of freedom be specified, namely |ψ( ), whereas in Newton’s
law, only the position and velocity at the starting point of the particle is required.
• At each instant, Schrödinger’s equation specifies the state function for all values of
the indeterminate degree of freedom. This is the reason that quantum algorithms
are executed in Hilbert space.
• The linearity of the Schrödinger equation is the reason that all the state vectors
|ψ(t) are elements of a linear vector space V. Since Eq. 4.12 is a linear equation;
two solutions |ψ(t) and |χ (t) of the Schrödinger equation can be added to yield
yet another solution given by a|ψ(t) + b|χ (t).
• The linearity of the Schrödinger equation is the reason that state vectors obey the
rule of superposition – a crucial resource in quantum algorithms.
4.5 Quantum Measurement: Born Rule 85
• The Schrödinger equation is the first equation in natural science in which complex
numbers are essential and not just a convenient mathematical tool for representing
real quantities.
The quantum theory of measurement that is discussed in this section, and the one
used in this book is based on the Copenhagen interpretation of quantum mechanics.
In general, in quantum mechanics physical quantities like energy, angular momen-
tum and so on are represented by Hermitian operators. Consider a state vector |ψ
belonging to state space V that describes the degrees of freedom F. The measure-
ment of a physical quantity is mathematically represented by the measuring operator
O; we use the term measuring device and the measuring operator representing the
measuring device interchangeably. Repeated measurements yield the expectation
(average) value of the Hermitian operator O, given by
E V O(F) = ψ|O|ψ
ρ = |ψψ| (4.17)
Measurements on the state vector |ψ using a device represented by the Hermitian
operator O yield the result
E ψ O = Tr(Oρ)
The Born rule states that the process of measurement leads to the quantum state
vector |ψ undergoing a discontinuous change: this discontinuous change leads
to the collapse of the state vector to an eigenstate of the measuring operator. The
measurement is realized by applying measurement gates, which are projection oper-
ators, on the state vector |ψ. The measurement gates are the only irreversible gates
in a quantum circuit. Representing the process of measurement by irreversible gates
is based on the Copenhagen interpretation of quantum mechanics and is explained
below [1, 2].
Unitary transformation can only represent continuous changes in the state vec-
tor. Because the result of a measurement is discontinuous, the transformation of the
initial pre-measurement state to the final post-measurement state cannot be repre-
sented by a unitary transformation. This is the reason that the measurement gates
are non-unitary and irreversible. The process of measurement cannot be represented
by the Schrödinger equation since it requires processes existing outside the smooth
evolution of the state vectors. The mechanism of the collapse of the state vector is
86 4 Principles of Quantum Mechanics
not known even after more than a century of quantum mechanics and remains one
of the outstanding unsolved mysteries of quantum mechanics.
On a more granular level, the process of measurement entangles the eigenstates of
measuring device with the quantum state |ψ (entanglement is discussed in Sect. 5.7).
The measurement results in the measuring device being put into a determinate eigen-
state and which implies with certainty, due to entanglement, that state |ψ is put into
the corresponding determinate eigenstate. The process of measurement, including
entanglement, is discussed rigorously for the spin 1/2 case using the Stern–Gerlach
experiment [1].
The measurement process can use a variety of basis states. Consider a measure-
ment operator O with the following expansion,
N
N
O= λn |ψn ψn |; ψn ψn | = I
n=1 n=1
The eigenvalues λn of O are not needed for our discussion as they refer to the
properties of measuring device [1]. They are given by the operators that project the
state vector to one of the eigenstates |Dn —which correspond to the eigenstates |ψn
of the measuring operator O.
|Dn ⇐⇒ |ψn
N
Mn = |Dn Dn |; |Dn Dn | = I
n=1
where |Dn are eigenstates of the measuring device. The key requirement of the gates
|Dn is that they provide a complete set of basis states. The expansion of state vector
|ψ in terms of the eigenfunctions |ψn of the measurement operator O yields, from
Eq. 4.17, the following density matrix
N
N
|ψ = cn |ψn ⇒ ρ = cn cm∗ |ψn ψm |
n=1 m,n=1
The preparation of the state for the measurement results in entangling the state |ψ
with the device yields
N
|ψ → preparation → cn |ψn |Dn
n=1
N
ρ → preparation → ρout = cn cm∗ |ψn ψm | ⊗ |Dn Dm |
m,n=1
N
ρ → preparation → ρout → Measurement → ρfinal = |cn2 |Dn Dn |
n=1
The irreversibility of the measurement is due to decoherence of ρfinal , since all the
off-diagonal m = n terms of ρout have been eliminated by the process of measure-
ment. Furthermore, due to decoherence, the density matrix ρfinal has no quantum
indeterminacy—and represents a classical random system with random outcomes
for the measuring gates.
The density matrix ρfinal means that observing |ψ results in the state vector
collapsing to a gate |Dn , with the probability of the collapse given by
Tr |Dn ρfinal = Dn |ψ = |cn |2 ; n = 0, 1, . . . , N (4.18)
Summarizing our discussion, applying all the measurement gates on the state vector
|ψ causes the state vector to undergo the following collapse [1, 2].
|z 0 , z 1 , . . . , z n−1
2
n
−1 2
n
−1
|ψ = α(x)|x; |α(x)|2 = 1 (4.20)
x=0 x=0
2
n
−1 2
n
−1
∗
ρψ = α(x)α (x )|xx | = ρ(x, x )|xx |
x,x =0 x,x =0
where
ρ(x, x ) = α(x)α ∗ (x ); x, x = 0, 1, 2, . . . , 2n − 1
M; M = M2
The eigenvalues λ(z) are not required for the measurements. In the computational
basis states, there are 2n projection operators Mz that are given by
The degree of freedom’s state vector in Hilbert space is reduced to the state vector
given in Eq. 4.21 and the measuring also has the same state vector due to entan-
glement. In other words, in the computational basis the result of the measurement
4.5 Quantum Measurement: Born Rule 89
2
n
−1
1
|ψ = ψ(x0 , x1 , . . . , xn−1 )|x0 , x1 , . . . , xn−1 (4.22)
i=0 xi =0
The probability of the quantum state |ψ collapsing to a specific computational basis
state is given by
We review, for greater clarity, Born’s rule on the role of measurements and of the
degrees of freedom in the quantum theory of measurement.
The measurement process results in an unpredictable final state for the degree
of freedom’s state vector as well correspondingly for measuring device—that is
recorded by one of the measurement gates. The indeterminate nature of the quantum
degrees of freedom results in a different final state vector every time a measurement
is performed.
In the quantum mechanical formalism, as discussed earlier, the degrees of freedom
are always indeterminate and unobservable, regardless of whether a quantum mea-
surement is carried out on them or not. The quantum measurement performed on |ψ,
as expressed in Eq. 4.23, results in the post-measurement state |z 0(0) , z 1(0) , . . . , z n−1
(0)
that is a specific quantum state: an eigenfunction of the projection operators. The car-
dinal point to note is that before and after the measurement, the degrees of freedom
remain indeterminate.
All that changes as a result of the measurement is that the input state vector
|ψ—which determines all the information that can be extracted about the degree of
freedom—is altered to another specific state |z 0(0) , z 1(0) , . . . , z n−1
(0)
as a result of the
measurement.
Although the degrees of freedom cannot be directly observed, what one can
observe in the device are the specific and determinate possible values of the degrees
of freedom; for example, the following n-binary string
the pre-measurement state vector |ψ: in particular, |ψ contains the superposition
of many projection operators, as shown in Eq. 4.22. Repeated measurements (of
identically prepared states) result in the counters giving readings of a specific post-
measurement state, |z 0(0) , z 1(0) , . . . , z n−1
(0)
, with the likelihood of occurrence given by
(0) (0) (0)
|ψ(z 0 , z 1 , . . . , z n−1 )| .
2
U |0|ξ → |0|0,
U |1|ξ → |1|1, (4.24)
92 4 Principles of Quantum Mechanics
for some ancillary state |ξ . In standard quantum mechanics, all unitary transforma-
tions are linear. Suppose we have an unknown state
The question is whether we can use the unitary transformation U to change it to two
copies of |ψ, i.e., |ψ ⊗ |ψ. Cloning requires
U |ψ|ξ → |ψ|ψ
= α 2 |0|0 + αβ|0|1 + αβ|1|0 + β 2 |1|1 (4.25)
However
U |ψ|ξ = U (α|0 + β|1) |ξ
= αU |0|ξ + βU |1|ξ by linearity
= α|0|0 + β|1|1 (4.26)
Comparing Eqs. 4.25 and 4.26, one sees that consistency requires that α or β be zero.
This is sometimes known as the no-cloning theorem.
state vector: the object’s collapsed state vector functions as a measuring device,
with the degree of freedom, on being observed, having a determinate value [1].
• Unlike the statements made by some people, there is no need for a conscious
observer in quantum mechanics: once the result of a measurement is recorded in a
device, the process of measurement has been completed. It is of no consequence
whether a human mind reads or does not read the result of a measurement.
• The state vector is in general a non-local entity spread over space. In the collapse
of the state vector, its value becomes zero everywhere except for a particular value,
where the degree of freedom is observed. The question is: does the collapse happen
instantaneously everywhere, or does it take place over a finite time?
Quantum mechanics requires an instantaneous collapse everywhere and an exper-
iment to test this shows that the lower limit for the speed of collapse is 1550 times
the speed of light.4 Hence, the collapse being instantaneous seems to be consistent
with experiment.
• Since the collapse of the state vector seems to be instantaneous, the question arises:
does the infinite speed required for collapsing the state vector simultaneously
everywhere contradict the special theory of relativity? The answer is: No.
• When the state vector is subjected to a measurement, what is the mechanism that
causes the state vector to collapse—so that the degree of freedom is observed
to have a determinate value? The answer to this question is not known. This is
probably what Richard Feynman had in mind when he stated: It is safe to say that
nobody understands quantum mechanics.5
• Note that the state vector ψ(x) : x-indeterminate can never be observed, and what
is observed in an experiment is |ψ(x0 )|2 : x0 -determinate. So the question arises:
do the state vector ψ(x) and Hilbert space ‘exist’, or are they only mathematical
entities that carry information about the degree of freedom x.
One can take many different consistent positions on this question. For Bohr and
Heisenberg the only thing that is ‘real’ are the results obtained by measurements.
They had an agnostic view regarding Hilbert space and the state vector: since one
cannot measure ψ(x), there was no need to discuss the existence or otherwise of
the state vector.
There are other views such as the Many-World interpretation where the state vector
is taken to be real, but the state vector does not collapse when subjected to mea-
surements. Another view, adopted by Baaquie, is that the state vector does, in fact,
undergo a collapse when it is observed—but it also has an ontological existence;
for this view one needs to define precisely what one means by the concept: ‘to
exist’ [1].
The philosophical question—of whether the degree of freedom and Hilbert space
actually ‘exist’ or are simply mathematical constructs for computing experimental
results—does not affect any of the derivations or conclusions regarding quantum
computers and quantum algorithms. The procedure and processes for measurements
and computations are the same for all the interpretations. There have been proposals
4 https://www.nature.com/articles/s41598-019-48387-8.pdf.
5 https://physicscourses.colorado.edu/phys3220/phys3220_fa08/quotes.html.
94 4 Principles of Quantum Mechanics
Fig. 4.5 Degree of freedom F enclosed by the Hilbert space V . Repeated application of Operator
V ) on state vector ψ(V ) ∈ V yields the observed expectation value of the operator given by
O(
V )]. Published with permission of © Belal E. Baaquie 2012. All Rights Reserved
E ψ [ O(
In this section, a summary is given of results that are based on the Copenhagen inter-
pretation of quantum mechanics. Piecing together the various ingredients of quan-
tum mechanics discussed so far yields two different representations of the schema
of quantum mechanics, which reflect the following two different points of view [1]:
1. The relation of the degree of freedom F to the layered superstructure it carries,
shown in Fig. 4.5.
2. The relation of the degree of freedom F with the quantum theory of measurement
and observable, given in Fig. 4.6.
6 https://www.sciencedirect.com/science/article/pii/S135521981530023X.
7 https://www.scientificamerican.com/article/the-many-interpretations-of-quantum-mechanics/.
4.9 Summary of Quantum Mechanics 95
Fig. 4.6 Graphical representation of the schema for the theory of measurements in quantum
mechanics. Published with permission of © Belal E. Baaquie 2012. All Rights Reserved
5. The last outer shell is devices that are designed to represent the operators O(F);
applying the device on the state vector |ψ of the degree of freedom causes
the detector to collapse to a determinate reading in the device, reflecting the
collapse, in Hilbert space, of the state vector |ψ to the observed state vector.
6. Repeatedly applying the measuring device on identically and independently
prepared state vector |ψ results in the observed expectation E ψ [O(F)] =
ψ|O(F)|ψ.
• Copenhagen Theory of Quantum Measurement: Fig. 4.6.
1. From the point of quantum measurements, there are four distinct domains that
result from the structure and superstructure of quantum mechanics as discussed
in the context of Fig. 4.5.
2. The foundation of quantum phenomenon is (the space of) the degree of freedom
F.
3. The quantum states of Hilbert space V(F) provide all the information that can
be obtained about the degree of freedom F.
4. The boundary between the degree of freedom F and Hilbert space V(F) is
impenetrable and not accessible to any form of measurement, as shown in
Fig. 4.6.
5. The degree of freedom F and its Hilbert space F both exist outside of spacetime,
as shown in Fig. 4.6.
6. The Hilbert space F is connected to devices in spacetime by the process of
measurement, as shown in Fig. 4.6.
96 4 Principles of Quantum Mechanics
7. The Hilbert space F and the device in spacetime have a permeable transitional
domain that can be either sharp or fuzzy, depending on the measurement, as
shown in Fig. 4.6 [1].
8. The experimental device prepares the initial state vector of the degree of freedom
I . Once the state vector is prepared and is not subject to any measurements, it
evolves in Hilbert space, as shown in Fig. 4.6.
9. The state vector I evolves according to the equation (t) = U (t) I , until
a measurement is performed at time t∗ > t, when (t∗ ) = F . The observed
state F can be, for example, the completion of a quantum algorithm.
10. The measuring devices are designed to represent the measure the states of the
degrees of freedom using operators O(F). In Fig. 4.6, the measuring device
has been designed to measure a degree of freedom that has N discrete values;
distinct counter-readings x1 , x2 , . . . , x N correspond to the possible values of the
degrees of freedom.
11. To perform the measurement, the state vector is subjected to the experimental
device by applying the operator O(F) on F —and results in the states of the
device becoming entangled with the state vector F [1].
12. The operator O(F) being applied on the final state vector F causes it to collapse
to a definite state of the measuring device and shows a definite counter-reading,
as shown in Fig. 4.6. Entanglement allows us to conclude that the state F in
Hilbert space is the same as the state observed in the device.
13. After repeating the experiment many times on samples prepared identically
and independently, one obtains from the counter-readings of the measuring
device E ψ [O(F)]
= ψ F |O(F)|ψ F , which is the expectation value the oper-
ator O(F).
The two figures given in Figs. 4.5 and 4.6 and their explanations, in short, are
the theoretical foundations of quantum mechanics and the connection of quantum
mechanics to empirically observed results [1].
The Born rule states that a measurement performed on all the degrees of freedom
results in a post-measurement state vector that is an eigenvector of the measurement
operators and yields a determinate reading of the measuring device [1, 2]. This rule
has to be generalized to the case when the system consists of two or more degrees
of freedom: if only a few—not all—of the degrees of freedom are subjected to a
measurement, it leaves the remaining degrees of freedom in a quantum indeterminate
state. To complete the Born rule, the post-measurement state vector of the degrees
of freedom that are not subjected to a measurement needs to be specified. The
generalized Born rule is not discussed in most of the standard books on quantum
mechanics; we follow the derivation given by Mermin [2].
4.10 Generalized Born Rule 97
The generalized Born rule has important applications in quantum algorithms. For
instance, an auxiliary degree of freedom is often introduced in a quantum algorithm,
with a measurement being performed only on the input degrees of freedom—leaving
the remaining auxiliary degrees of freedom untouched. Or sometimes, only one set of
the degrees of freedom are measured, leaving the rest untouched by the measurement.
The result of doing these measurements requires the generalized Born rule for its
interpretation.
Consider a state vector of n-degrees of freedom given by
There are two cases for state vectors depending on two or more degrees of freedom
that are non-entangled or entangled (entanglement is discussed in Sect. 5.7).
• Non-entangled. The state vector can be completely factorized into a product of
state vectors depending on one subset of degrees of freedom.
• Entangled. The state vector is not factorizable into state vectors depending on
separate degrees of freedom.
Consider a device that measures only the x1 degree of freedom. The process of
measurement yields
The value of the observed |x1 is completely arbitrary; the probability of a specific
value of |x1 detected by the observation given by
where
M(x1 ) = |x1 x1 | ⊗ I(x2 )
Since the degrees of freedom x1 , x2 are non-entangled, each degree of freedom makes
no reference to the other.
98 4 Principles of Quantum Mechanics
Consider now the case of an entangled state vector from Eq. 4.4, for a system
with n + m binary degrees of freedom; its state vector can be represented as follows
2
n
−1 2
m
−1
|ψn+m = αx y |xn |ym ; |αx y |2 = 1 (4.27)
x=0 y=0 xy
Suppose one wants to measure only the first n degrees of freedom, leaving the other
degrees of freedom untouched. The projection operators required to carry out the
measurement process act on the first n degrees of freedom, leaving the other m
degrees of freedom unchanged. Hence, the required projection operators are given
by
Mz = |zn n z| ⊗ Im
Recall according to the Born rule, the result of the measurement results in the
state vector for n-degrees of freedom being in an eigenstate of one of the projection
operators. The generalized Born rule states that the remaining m-degrees of freedom
are left undisturbed and in an indeterminate state and described by a state vector that
depends only on the m-degrees of freedom [2]. Hence, the act of measurement yields
the following
The total probability of observing some particular state must be 1 and, using Eq. 4.27,
we have the expected result
∗
p(z) = αzy αzy = |αzy |2 = 1 (4.31)
z z y z y
The key point to note is that a partial measurement collapses the post-measurement
n-degrees of freedom’s state vector into an eigenstate |xn and the remaining m
degrees of freedom continue to be described by the state vector that yields the (con-
ditional) probability given by the probability amplitude |(x)m . The normalization
of |(x)m being equal to one reflects the fact that the state vector |m (x) yields
the (conditional) probability for the outcome of measuring any of the remaining m
degrees of freedom.
The conditional probability amplitude, due to the unit normalization given in
Eq. 4.32, is the following
1
|m (x) = √ αx y |ym ⇒ m (x)|(x)m =1 (4.33)
p(x) y
4.10.1 Example
Consider the case of n + 1 binary degrees of freedom, and only one of the degrees of
freedom is measured, with the rest of the n binary degrees of freedom left untouched.
The general state vector is given by
|ψn+1 = |0 ax |xn + |1 bx |xn = |0 n+1 + |1 n+1
x x
with
n+1 0 |1 n+1 =0
and
n+1 ψx |ψx n+1 =1= |ax |2 + |bx |2 (4.34)
x
where
1 1
|0 n = √ ax |xn ; |1 n = √ bx |xn
p(0) x p(1) x
n i |i n = 1 : i = 0, 1; n 0 |1 n = 0
1
n 0 |1 n =√ a ∗ bx = 0
p(0) p(1) x x
A measurement performed on the first binary degree of freedom has two possible
outcomes and hence yields
More precisely
• The measurement results in the eigenstate |0 with probability p(0). The state
vector undergoes the collapse yielding the following the post-measurement state
vector
|ψn+1 → |0|0 n ; n 0 |0 n = 1
• The measurement results in the eigenstate |1 with probability p(1). The state
vector undergoes the collapse yielding the following the post-measurement state
vector
|ψn+1 → |1|1 n ; n 1 |1 n = 1
Note that, as expected from the generalized Born rule, |0 n , |1 n are the probability
amplitudes for the remaining n degrees of freedom after the measurement of the first
degree of freedom is made.
The underlying reason for the validity of the generalized Born rule discussed in
Sect. 4.10 is because the degrees of freedom are independent of each other: the order
of measuring the degrees of freedom does not matter because of their independence.
Hence, the results obtained for measuring a set of degree of freedom must not depend
on the order in which the measurements are carried out on the degrees of freedom.
4.11 Consistency of Generalized Born Rule 101
To check the consistency of the generalized Born rule, the following two proce-
dures should yield the same result: take a collection of n + m + s degrees of freedom
and proceed in the following manner,
• First measure n + m degrees of freedom directly.
• Alternatively, measure n degrees of freedom, obtain the conditional amplitude for
m + s degrees of freedom and then make a second measurement of the m degrees
of freedom.
We start with the following n + m + s degrees of freedom state vector
2
n
−1 2
m
−1 2
s
−1
|ψn+m+s = αx yz |xn |ym |zs ; |αx yz |2 = 1 (4.36)
x=0 y=0 z=0 x yz
We obtain the post-measurement state vector, using the result given in Eq. 4.33
where
−1
2 s
1
|(x y)s = √ αx yz |zs (4.37)
p(x y) z=0
We now start with the state vector |ψn+m+s given in Eq. 4.36 and measure only the
|xn degrees of freedom; this yields the probability
p(x) = |αx yz |2
yz
The measurement leads to the collapse of the initial state vector to post-measurement
conditional state vector given by
where
1
|(x)m+s = √ αx yz |ym |zs (4.38)
p(x) yz
The second measurement is the result of measuring m degrees of freedom that col-
lapses their state vector to |ym —given that one has already measured the n degrees
of freedom. The second measurement leads to post-measurement state vector that is
102 4 Principles of Quantum Mechanics
given by
(y|x)s
|xn |(x)m+s → |xn |ym |
Hence, we obtain from the conditional amplitude given in Eq. 4.38 the conditional
probability of observing state vector |ym in the second measurement given by
1 p(x y)
p(y|x) = |αx yz |2 = (4.39)
p(x) z p(x)
and hence
p(x y) = p(y|x) p(x) (4.40)
where the last equality above follows from Eq. 4.37. Hence, Eq. 4.41 shows the
consistency of the generalized Born rule [2].
Note that Eq. 4.39 yields
p(x y)
p(y|x) =
p(x)
Equation 4.39 is precisely the equation that one obtains from the theory of probabil-
ity: it expresses the conditional probability p(y|x) in terms of the joint probability
function p(x y) and the probability of the conditioning given by p(x) [11].
The first quantum computer was proposed by Manin in 1980 [12] and Feynman in
1982 [13]. The first quantum code that showed, in principle, that a quantum algorithm
is superior to any classical algorithm is attributed to a 1985 paper by Deutsch [14].
A fundamental question is the relation of computers, both classical and quantum,
to a physical device. Classical computers are based on devices that operate according
to the laws of classical physics, which is an approximation to the laws of quantum
mechanics. Of course, all devices ultimately obey the laws of quantum mechanics,
including the classical computer, so this is not what is meant by a quantum com-
puter. A quantum computer is a physical device that carries out algorithms that are
directly based on the laws of quantum mechanics. Quantum mechanics provides a
new computational paradigm that, surprisingly, had not been contemplated prior to
the 1980s.
4.12 Quantum Mechanics and Quantum Computers 103
The quantum computer demonstrates that the theory of computation can be gen-
eralized to indeterminate qubits based on the physics of quantum mechanics and
provides a ground-breaking paradigm for computer science. It can be shown that
all classical algorithms are special cases of quantum algorithms, and hence classical
computers and information science are a sub-branch of quantum physics. Quantum
information science is yet another arena where the mysterious and ‘counterintuitive
behavior’ of quantum phenomena comes into play.
In physics, the state vector of a physical entity is determined by natural laws,
and theoretical physics attempts to deduce the state vector by studying Nature. In
contrast, quantum computers and algorithms have the following distinctive features
in their use and application of the principles of quantum mechanics.
• For quantum computers, the state vector ψ is not obtained by studying Nature,
but instead, the state vector is designed to carry the information required by the
algorithms of information science. The quantum computer is a physical device
that provides the binary degrees of freedom as well as the various unitary gates
required for quantum algorithms. The physical quantum computer is subjected to
diverse forms of physical interactions so that the state vector evolves in a manner
required for carrying out the various steps of the quantum algorithm.
• The input of the quantum algorithm is a determinate state consisting of a n-binary
bits string; however, although the output of a quantum algorithm is also a n-
binary bits string, its value is random and uncertain: the output takes many
possible values with different probabilities. The Schrödinger equation determines
the probabilities for the different outputs.
• Unlike a classical computer, for which executing the classical algorithm only once
is sufficient to obtain the required output, a quantum algorithm has to be run many
times (in principle infinitely many times), with identical preparation, to ascertain
the probabilities for the various outputs.
• All the intermediate steps of a classical computer can, in principle, be directly
observed. Each updating of a classical algorithm processing n-binary bits strings
produces a determinate state, which is a member of 2n binary strings |x; hence,
each of the binary strings has to be individually updated. This requires, in general,
a memory storage device for all possible configurations of the n-binary bits strings,
which is 2n binary strings. Hence executing a classical algorithm entails having to
store 2n binary strings.
• In contrast, during the process of executing a quantum algorithm, the intermediate
steps of a quantum algorithm cannot, in principle, be directly observed, as dis-
cussed in Sect. 5.2, and is the result of the principle of quantum superposition.
A quantum computer, hence, needs a storage for only the input and output states,
which requires at most two n-binary strings.
• In summary, the quantum algorithm is unlike a classical algorithm, since the quan-
tum algorithm only requires the storage of two n-binary strings. This is unlike a
classical computer that entails having to store 2n -binary strings.
• In updating a classical computer, each step in the algorithm produces a determinate
binary string |x; hence, each binary string has to be individually updated. In
104 4 Principles of Quantum Mechanics
contrast, the state vector evolves as a single entity. The quantum device evolves
the state vector |ψ I from initial time t I to final time t F with state vector |ψ F that
is given, from Eq. 4.16, by
i
|ψ F = exp − (t F − t I )H |ψ I = U |ψ I (4.42)
Equation 4.42 expresses the fact that the entire state vector is evolved in time.
The time evolution of a state vector depending on three computational basis states is
shown in Fig. 4.7.
Mathematically speaking, a vector is independent of its representation in terms of
the basis states. For quantum algorithms, one is interested in specific information that
is contained in the components of the state vector in the computational basis states;
the components a I (x) of |ψ I in the computational basis states yield the following
2
n
−1
|ψ I = a I (x)|x
x=0
The initial value of each coefficient a I (x) is automatically evolved to its final
value a F (x) since it is contained in |ψ F , where
2
n
−1
|ψ F = a F (x)|x
x=0
The solution for the quantum algorithm is usually contained in the coefficients
a F (x). In the evolution of the state vector, all the coefficients a I (x) are simultaneously
updated to a F (x). This is another example of quantum parallelism.
• In summary, a quantum computer (hardware) processing a quantum algorithm
based on n-binary bits strings requires a storage device for only two n-binary strings
and not 2n -binary strings that are required by a classical algorithm. Furthermore,
all the coefficients that express the state vector as a quantum superposition of the
computational basis states are simultaneously updated when the state vector is
References 105
updated. These are two reasons that the quantum computer is far more efficient
and sometimes exponentially faster than a classical computer.
• One can easily imagine a quantum computer with 1000 binary degrees of freedom
being made within a year, and for which no possible physical device can store the
information that the quantum computer is processing—since 21000 is far greater
than all the atoms in the Universe. This aspect of a quantum algorithm is further
discussed in Sect. 19.3.
For computer scientists, the most striking feature of a quantum algorithm is that,
for certain computational tasks of considerable practical interest, a quantum computer
can be vastly more efficient than anything that is possible for a classical algorithm. As
the size of the input is increased, the time it takes the quantum computer to accomplish
such tasks scales up much more slowly compared to any classical computer. In fact, in
some special cases, the quantum algorithm is exponentially faster than any possible
classical algorithm.
References
Two properties of Hilbert space that are pivotal in making quantum algorithms faster
than classical algorithms are superposition and entanglement, discussed in Sects. 5.1
and 5.7. A few special cases, discussed below, concretely illustrate the general prin-
ciples of superposition and entanglement for quantum algorithms.
For a number of algorithms, a quantum computer is much faster than a classical
computer—and in some cases is exponentially faster due to the features of super-
position and entanglement being incorporated into the algorithm. The fact that all
the possible states of many qubits can be updated simultaneously in the process of a
quantum computation is due to the quantum principle of superposition. The property
of quantum entanglement appears in many intermediate steps in the process of a
quantum computation, a property not allowed for classical computers. The princi-
ples of quantum mechanics are required for understanding these counterintuitive and
nontrivial aspects of superposition and entanglement.
To understand both the theory of measurement and entanglement requires the
study of what is called the density matrix. The main properties of density matrices
are reviewed, and the concept of pure, mixed and reduced density matrix are defined.
Separable and entangled states are discussed. The binary degrees of freedom illus-
trate many key features of entanglement, and it is shown later, in Sect. 6.4, that the
Bell states for two binary degrees of freedom are examples of maximally entangled
quantum states.
The discussions in this chapter are based on the results given in Baaquie [1].
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 107
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_5
108 5 Quantum Superposition and Entanglement
The concept of the indeterminacy of quantum paths has been discussed in detail in
Belal [1], and this concept is now analyzed using the two-slit experiment. Similar
to the indeterminate degrees of freedom, quantum superposition—unlike classical
superposition—is a result of indeterminate quantum paths that can never, in principle,
be directly observed.
The two-slit experiment goes back to Young (1799), who showed that light going
through two slits results in interference, and was crucial in demonstrating that light
is a wave: the cardinal property of a wave is that it is spread over space. The two-
slit experiment is one of the deepest and most important experiments in quantum
mechanics and is discussed with the aim of demonstrating the mode of existence of
indeterminate paths, as well as the role of measurement in causing a transition from
the indeterminate form of the quantum entity to its empirical manifestation.
Quantum superposition is one of the bedrocks of quantum mechanics. Quantum
superposition is also a major resource for quantum algorithms, and together with
quantum entanglement, is the reason that, for some cases, quantum algorithms can
perform exponentially faster than the corresponding classical algorithms.
The two-slit experiment provides one of the simplest illustrations of indeterminate
paths and quantum superposition. As explained by Richard Feynman, one of the
leading quantum theorists, the two-slit experiment ‘has been designed to contain
all of the mystery of quantum mechanics, to put you up against the paradoxes and
mysteries and peculiarities of nature one hundred percent’ [2]. Feynman further
explains that all the other paradoxical situations in quantum mechanics can always
be explained by this experiment—which reveals ‘nature in her most elegant and
difficult form’ [2].
The simplest case of indeterminate paths is for the quantum particle to simultane-
ously exist in two distinct paths, as shown in Fig. 5.1 and which can be generalized
to the case of the N -slit, shown in Fig. 5.2. In this section, the two-slit experiment is
analyzed using electrons; it is shown that when a measurement determines the path
of the electron, the path is empirical and determinate and the electron behaves like
a classical particle; however, when the trajectory is not observed, the electron exists
in an indeterminate state and exhibits the phenomenon of quantum interference.
The two-slit experiment is employed for analyzing the following topics.
• The concepts of the empirical and indeterminacy are applied to the time evolution
of a quantum entity. In classical mechanics, the classical entity takes a determinate
path, going through either the slit at position x1 or through the slit at position
x2 . The result of the two-slit experiment can be explained by postulating that
when the quantum entity is not observed, the path taken by the quantum entity is
indeterminate, with the quantum entity simultaneously taking both the paths.
• The superposition of the quantum state vector, which is due to the linearity of the
Schrödinger equation, is also valid for indeterminate paths. For a quantum particle
‘taking’ indeterminate paths, the probability amplitude of going from an initial to a
final position is shown to result from the quantum superposition of the determinate
empirical paths.
5.1 Quantum Superposition 109
Time
xf
tf
t x1 x2
ti
xi
Space
Fig. 5.1 A quantum particle is observed only at initial position xi at time ti and at final position
x f at time t f . The paths taken from initial to final position are indeterminate. Published with
permission of © Belal E. Baaquie 2012. All Rights Reserved
A quantum particle going through two slits, as given in Fig. 5.1, is realized experi-
mentally by the arrangement shown in Fig. 5.3. Unlike Fig. 5.1, the time dependence
of the paths is not shown in Fig. 5.3, where the emphasis is on the measurements
being performed. The information about the paths, in particular whether they are
empirical or indeterminate, is reconstructed from the experimental measurements.
The experiment consists of an electron gun (source) that sends identically prepared
electrons, through a barrier with two slits, to a screen where a screen-detector keeps
track of the point at which the electron hits the screen. Note that the electrons are
sent toward the slits one by one, so that at any given time there is only one electron
traveling from the electron gun to the screen.
The electron leaves the source, shown in Fig. 5.3a, b, with the initial position of
the electron denoted by s; it is then observed at the screen at position denoted by x.
There are two possible paths from source to screen, labeled path 1 going through slit
1 and path 2 going through slit 2, and shown in Fig. 5.3b.
The experiment is performed with detectors 1 and 2, as shown in Fig. 5.3a and
without these two detectors, as shown in Fig. 5.3b. In effect, with detectors 1 and 2
switched on, the path taken by the electron is known, whereas in the case without
the detectors the path information is not known.
110 5 Quantum Superposition and Entanglement
Time
xf
tf
t x1 x2 x3 xN
ti
xi
Space
Fig. 5.2 A quantum particle is observed at first at initial position xi at time ti and a second time at
final position x f at time t f . The quantum particle’s path being indeterminate means that the single
particle simultaneously exists in all the allowed paths. Published with permission of © Belal E.
Baaquie 2012. All Rights Reserved
Fig. 5.3 a Two-slits experiment with determination of the path taken to reach the screen. b Two-slits
experiment without determination of the path taken to reach the screen. Published with permission
of © Belal E. Baaquie 2012. All Rights Reserved
5.1 Quantum Superposition 111
The experiment is shown in Fig. 5.3a; both slits 1 and 2 are open and detectors 1
and 2, at the back of the slits, record which slit the electron passes through. Since
it is known which slit the electron goes through one can plot the following three
distribution curves.
• Distribution curve P1 for electrons that pass through slit 1
• Distribution curve P2 for electrons that pass through slit 2
• Distribution curve PD for electrons that pass through either slit 1 or 2.
The experimental result is the following.
PD = P1 + P2 ; dx PD (x) = 1 (5.1)
The behavior of the electron with detection of which path is taken is exactly the same
as one would obtain for bullets being shot through a metal screen with two openings.
When the trajectory of the electron from source to screen is experimentally observed,
the electron received at the screen-detector came either through slit 1 or through slit
2. The two possible ways of getting to the screen are mutually exclusive, and these
do not interact in any manner and do not generate any interference pattern.
The two-slit experiment has two possible electron paths, namely path 1 and path 2.
The quantum mechanical description of the two-slit experiment is given by assigning
a probability amplitude (a complex number) to each of the two paths. The probability
amplitude is the analog of the state vector for paths and is derived from the quantum
state of the electron’s quantum degree of freedom and is discussed in more detail in
Belal [1].
The following is a notation for the probability amplitude for the different possi-
bilities
The probability of finding the electron at the screen with detection of path taken
is labeled by PD and without detection of path taken is labeled by PI .1
The experimental result for PD is shown in Fig. 5.3a, and the result for PI is shown
in Fig. 5.3b. Note the experimental results obtained for PD and PI are qualitatively
different and need an explanation.
1Recall all measurements in quantum mechanics are of operators representing a physical quantity.
‘Measuring the position’ of the electron is a shorthand for the more precise statement that measure-
ment is mathematically represented by applying the device that contains all the position projection
operators (of the electron) on the electron’s state vector.
112 5 Quantum Superposition and Entanglement
The explanation of quantum mechanics for the experiment with detectors 1 and
2 switched on is the following. The electron leaves the source s with probability
amplitude φ. When the probability amplitude encounters the detectors at the barrier,
a measurement is performed by either detector 1 or 2, depending on which slit
the electron is detected. The probability amplitude φ, similar to the state vector on
being measured, collapses to its empirical manifestation – to either |φ1 |2 or to |φ2 |2 ,
depending on whether it is detected at slit 1 or slit 2, respectively.
The electron arrives at the screen in an empirical state and the probability of being
observed at a point on the screen is given by either |φ1 |2 or |φ2 |2 . The probability of
finding the electron at the screen-detector is the result of the two mutually exclusive
possibilities and hence is given by their sum, namely
Consider now the same experiment as before, but with detectors 1 and 2 at the barrier
removed. The experiment is shown in Fig. 5.3b. The electrons are sent in one by one,
and no measurement is made to determine which slit the electron goes through, and
hence, the path taken by the electron is no longer known. As shown in Fig. 5.3b, the
electron can take two possible paths to reach the point |x at the screen.
The electron leaves the source with probability amplitude φ. On crossing the slits
(barrier), since the electron is not observed, the path taken by the electron is not
known and hence the path of the electron is indeterminate.
One needs to decide as to what is the probability amplitude past the barrier.
Since the propagation of the probability amplitude φ is determined by the linear
Schrödinger equation the probability amplitude obeys the superposition principle.
The probability amplitude for the two possible paths both obeys the Schrödinger
equation, and hence, their linear sum also obeys the Schrödinger equation; the prob-
ability amplitude for arriving at the screen is given by quantum superposition,
namely summing the probability amplitude for the two determinate paths and yields
The probability amplitude for the electron with indeterminate path has nonlocal
information about the likelihood of occurrence everywhere in space. In particular,
for the two-slit experiment, there are nodal points (minimas) of interference pattern,
points for which the probability amplitude is zero, yielding zero likelihood of that the
electron will be detected at those points. Since the electrons are sent in one by one,
each electron, regardless of where on the screen it is detected, has the information
about the entire screen since no electron ever hits the nodal points on the screen.
The interference pattern PI shown in Fig. 5.3b has been verified by many experi-
ments and shows that on repeatedly sending in the electrons—sent in one by one—and
detecting the position of the electrons arriving at the screen, results in building up,
step by step, an interference pattern given by PI . The probability amplitude at the
screen is φ = φ1 + φ2 and shows that, when the path taken by the electron is not
detected, the electron’s path is indeterminate and trans-empirical, showing interfer-
ence.2
The quantum superposition is lost in Fig. 5.3a because one detects the passage of
the electron, by say shining light on the electron as it passes through the slit. The
shining of light is a measurement process that causes a transition by collapsing the
trans-empirical probability amplitude before the barrier, namely φ = φ1 + φ2 to the
empirical probability given by either |φ1 |2 or |φ2 |2 after the barrier—depending on
which slit the electron is observed. The empirical expression |φ1 |2 or |φ2 |2 is said to
be particle-like since it implies that the electron is following a definite trajectory. In
other words, when the electron’s path is measured, the nonlocal probability amplitude
collapses to a (localized) empirically observed determinate state that is particle-like.
2It is important to note, as discussed in the next section, that the electron is interfering with itself —a
completely non-classical and enigmatic phenomenon.
114 5 Quantum Superposition and Entanglement
One of the main takeaways of quantum superposition for quantum algorithms, using
the two-slit experiment as an exemplar, is the following.
• A quantum algorithm starts from an initial state, which is the analog of the electron
starting at the initial point s. The two-slit experiment is the analog of a quantum
algorithm having a single intermediate step before completion, the analog of the
electron reaching the screen.
• The quantum algorithm is subjected to irreversible quantum gates at the screen
and the result that is obtained is analogous to the interference pattern obtained as
the screen at position x and given by PI in Fig. 5.3b.
• One is forbidden to observe the quantum algorithm during any of the intermediate
steps it is taking. A measurement of the quantum algorithm before its completion
(analog of hitting the screen) is analogous to measuring which slit the electron is
going through, as in Fig. 5.3a. This would result in the final result at the screen
being the analog of PD , which is clearly wrong since the actual result is the analog
of PI .
• The analog of the case of the N -slit experiment, shown in Fig. 5.2, is a quantum
algorithm having N intermediates steps before completion. If any of the slits is
observed to determine whether the electron took that slit or not will spoil the
interference. Similarly, if the quantum algorithm is observed at any intermediate
step, the algorithm will become invalid.
• In summary, the rules of quantum superposition, in particular its connection to
measurement, are the reason that unlike a classical algorithm, the intermediate
steps leading to the final answer for a quantum algorithm cannot, in principle, be
observed. Such an observation would destroy the quantum algorithm.
5.3 Partial Trace for Tensor Products 115
In the position basis, for a continuous degree of freedom x, trace is defined in Eq.
4.11 as follows
Tr[O] = dxx|O|x (5.4)
In particular, the trace operation for the outer product of two states is, from Eq. 5.4,
the following
O = |ψχ | ⇒ Tr[O] = dxψ(x)χ ∗ (x)
N
N
Tr[O] = i|O|i = ψ(i)χ ∗ (i)
i=1 i=1
Consider a system with two degrees of freedom with state vectors |ψ1 |ψ2 ; the
outer product is given by
One can now perform a partial trace on O, say over system 2, and yields
Tr2 (O) = |ψ1 ψ1 | ψ2 |ψ2 = c|ψ1 ψ1 | with ψ2 |ψ2 = c
One can further generalize the concept of a partial trace; consider the following linear
sum of the outer product of states
N
O= pi |ψ1i |ψ1i | ⊗ |ψ2i ψ2i |
i=1
where pi are numbers. The partial trace over system 2, using the linearity of trace as
given in Eq. 4.11, is defined as follows
116 5 Quantum Superposition and Entanglement
N
Tr2 (O) = pi |ψ1i ψ1i |ψ2i |ψ2i
i=1
N
= pi ci |ψ1i ψ1i | with ψ2i |ψ2i = ci (5.5)
i=1
The density matrix was introduced in Sect. 4.5 as it plays a defining role in the
theory of quantum measurements. The density matrix is the key to Heisenberg’s
operator formulation [1], with the Schrödinger state vector being replaced by the
density matrix providing a fundamental description of the quantum system. The
density matrix is a special Hermitian operator that has many applications and is
the principal mathematical construction required for describing measurements in
quantum mechanics, as discussed in Sect. 4.5. The density matrix also provides a
quantum mechanical generalization of the concept of conditional probabilities for
quantum mechanical degrees of freedom, as discussed in Sect. 4.10. As mentioned
earlier, the density matrix is required for providing a mathematical criteria for the
entanglement of quantum degrees of freedom.3
The pure density matrix is a Hermitian operator that is equivalent to the state vector
and provides an operator description of the quantum entity.
For a state vector |χ , the pure density matrix is defined by
ρ P = |χ χ | (5.6)
A pure density matrix ρ P is a projection operator and has the following properties
ρ P = |χ χ | ; ρ 2P = ρ P
Tr(ρ 2P ) = Tr(ρ P ) = 1 : Pure state (5.7)
Expressing the state vector in terms of a complete basis state given by |χi yields the
following
3 The density matrix should be termed the density operator since, in general, it is not a finite or
infinite matrix; however, the term density matrix is so widely used that its proper definition is
implicitly understood.
5.4 Density Matrix ρ 117
|χ = ci |χi ; ρ P ≡ |χ χ |
i
⇒ ρP = ci c∗j |χi χ j | = |ci |2 |χi χ j | + ci c∗j |χi χ j | (5.8)
ij i i j; i = j
The off-diagonal terms i = j given in Eq. 5.8 are completely quantum mechanical
in origin and are due to correlations between two different eigenstates |χi and |χ j .
The expectation value of any operator O in a state |ψ can be obtained from the
pure state density matrix and is discussed in Sect. 5.12. The density matrix for a pure
state, namely ρ P , is equivalent to the state vector |ψ and encodes the result of all
observations that can be made on the quantum system.
N
ρM = pi |ψi ψi | (5.9)
i=1
N
N
0 < pi < 1 ; pi = 1 ⇒ Tr(ρ M ) = pi = 1
i=1 i=1
Note the cardinal point that for the mixed density matrix, there are no off-diagonal
terms such as the terms |χi χ j |, i = j given in Eq. 5.8.
The mixed density matrix has the following defining property
ρM
2
= pi2 |ψi ψi | ⇒ Tr(ρ M
2
)= pi2 < 1 (5.10)
i i
Only for a pure state, where only one of the pi is 1, is Tr(ρ 2 ) = 1. Hence, a definition
of a mixed state is
2
Tr(ρ M ) < 1 : Mixed state (5.11)
In Eq. 5.5, it was shown that if one starts with a pure state density matrix and
a partial trace is performed over one of the degrees of freedom, then one obtains
a mixed state density matrix. Performing a partial trace erases information about
the degree of freedom and hence, the density matrix of a mixed state contains less
information than a pure state.
The density matrix for a mixed state is required for mathematically representing
the result of quantum measurements, discussed in Sect. 4.5, and is a precise measure
of how much information is lost in performing an observation on a quantum system.
118 5 Quantum Superposition and Entanglement
The general expression for a ket vector |ψ of a two-state system, parametrized by
the Bloch sphere and discussed later in Sect. 6.3, is given by
θ 1 θ 0
|ψ = cos + eiφ sin
2 0 2 1
1 3
ρ P = |ψψ| = [I + i n̂ i σi ] ; trρ 2P = n̂ 2 = 1 (5.12)
2 i=1
01 0 −i 10
σ1 = ; σ2 = ; σ3 = ; Tr(σi σ j ) = 2δi− j (5.13)
10 i 0 0 −1
The unit vector n̂ is an arbitrary three-dimensional vector that lies on the Bloch
sphere, shown in Fig. 6.1, and is given by
a n̂ ; a ∈ [0, 1]
It can be shown that the most general two-state mixed density matrix is given by
1 3
ρM = [I + ia n̂ i σi ] ; Trρ M
2
= a 2 n̂ 2 = a 2 < 1 (5.14)
2 i=1
For a mixed state, the density matrix is ρ M with 0 ≤ a < 1 and, hence, all the
density matrices for mixed states lie inside the Bloch sphere. For a pure state Trρ 2p = 1
and which yields a = 1. Hence, all the density matrices for pure states are on the
surface of the Bloch sphere.
5.5 Reduced Density Matrix 119
The two-state density matrix has a major application that is the study of quantum
information, in particular on studying the effect of measurements on qubits.
The concept of reduced density matrix can be defined for a system having two or
more degrees of freedom. Consider an experiment in which the projection operators
for only one of the degrees of freedom are measured, with the projection operators
for the other degrees of freedom being completely ignored. Clearly, there is a loss of
information regarding the state of the other degrees of freedom. The reduced density
matrix provides a precise measure on how much information is lost in such a ‘partial’
experiment.
Consider a quantum entity with only two different degrees of freedom; the state
vectors |ψiI and |ψiI I are state vectors for the two distinct degrees of freedom
I and I I , respectively. The general state vector, using the Schmidt decomposition
discussed in Belal [1], for the system of two distinct degrees of freedom is given as
follows
N
| = ci |ψiI |ψiI I ; |ci |2 = 1
i=1 i
N
ρ = | | = ci c∗j |ψiI ψiI | ⊗ |ψiI I ψiI I | (5.15)
i j=1
If measurements are made on only the degree of freedom I with state vectors ψiI , then
the loss of information encoded in state vectors ψiI I is mathematically realized by
performing a partial trace over the I I degrees of freedom, as discussed in Sect. 5.3.
Performing the partial trace in Eq. 5.15 yields the reduced density matrix ρ R , namely
ρ R = Tr I I (ρ) = Tr I I | |
N
= ci∗ c j |ψiI ψ jI | ψ jI I |ψiI I
i j=1
N
⇒ ρR = |ci |2 |ψiI ψiI | (5.16)
i=1
120 5 Quantum Superposition and Entanglement
Hence, Eq. 5.16 shows that the loss of information for a pure density matrix, given
in Eq. 5.15, yields a reduced density matrix that is a mixed density matrix, defined
in Eq. 5.9.
The analysis for the reduced density matrix carried out for discrete degrees of
freedom and given in Eq. 5.16 can also be done for continuous degrees of freedom.
Consider, for concreteness, a quantum system with two degrees of freedom, for
example, two particles with degrees of freedom x1 , x2 (coordinates in one dimen-
sion) respectively, and with state vectors ψ(x1 , x2 ). Consider a non-factorizable state
vector and its density matrix given by
One can sum over one of the degrees of the freedom—in general, by performing
a partial trace of ρ over a degree of freedom as was done in Eq. 5.5—say over the
coordinate x2 and obtain the reduced density matrix ρ R that provides a complete
description for all measurement carried out on only the degree of freedom x1 ; in
symbols (dropping the subscript 1 on x1 )
ρ R = Tr2 ρ = Tr2 (|ψψ|) = dxρ R (x, x )|xx |
ρ R (x, x ) = x|ρ R |x = dx2 ψ(x, x2 )ψ ∗ (x , x2 ) (5.18)
Equation 5.18 shows that the reduced density matrix provides a quantum mechani-
cal generalization of the concept of marginal distribution of the classical theory of
probability [3].
In other words, the reduced density matrix of a separable system is also a pure density
matrix.
Consider two different systems with their own degrees of freedom with density
matrices ρiA and ρiB such that
Tr(ρiA ) = 1 = Tr(ρiB )
One can think of the density matrices as projection operators for the two different
systems. A general representation of a composite system consisting of two separable
subsystems is given by the following bipartite (mixed) density matrix
N
N
ρ AB = pi ρiA ⊗ ρiB ⇒ Tr(ρ AB ) = pi = 1 ; pi ∈ [0, 1] (5.20)
i=1 i=1
N
It is the condition of i=1 pi = 1 that implies that the system is separable, with
a complete description of system A and B being contained solely in ρiA and ρiB ,
respectively. The bipartite density matrix represents a separable quantum system for
which the degrees of freedom for A and B can be considered in isolation from each
other. In other words, one can unambiguously separately measure the degrees of
freedom for A and B and still obtain the correct result for the expectation value of
all observables pertaining to only one of the systems.
The reduced density matrix for the separable system is given by
N
N
ρ A,R = Tr B (ρ AB ) = pi ρiA ; ρ B,R = Tr A (ρ AB ) = pi ρiB (5.21)
i=1 i=1
In classical mechanics, the point particles obeying Newton’s laws are always distinct
entities. In contrast, the distinct ‘identity’ of a particular quantum mechanical degree
of freedom is only meaningful for special cases.
4 A similar result holds for taking a partial trace over the x1 degree of freedom.
122 5 Quantum Superposition and Entanglement
More precisely, if the state vector for two degrees of freedoms can be completely
factorized, namely if the joint state vector is a tensor product of the individual state
vectors of each degree of freedom, then one of the degrees of freedom can be observed
independently of the other. However, if the joint state vectors cannot be factorized,
which are called entangled states, the two degrees of freedom become inseparable,
and one cannot consider either of the degrees of freedom independently of the other.
For example, the degrees of freedom of the state vector in Eq. 5.17 do not factorize,
and hence, the two degrees of freedom cannot be studied in isolation: the expectation
values for degree of freedom x1 depend on the behavior of degree of freedom x2 . This
is an example of an entangled state and indicates that the (two) degrees of freedom
are inseparable, and the state given in Eq. 5.17 is an entangled state.
One needs a quantum system with two or more degrees of freedom to obtain an
entangled state.
An entangled state vector does not have any dynamics, and the property of entan-
glement is purely kinematic; namely it pertains entirely to the structure of the state
vector and not to how it evolves in time (dynamics). The quantum entity represented
by an entangled state does not exist in classical physics and shows the rich structure
of quantum mechanics.
Note that the basis states of state space are only defined up to a unitary trans-
formation [3]. Hence, a state vector that is apparently not separable could, in fact,
be separable if the basis states are transformed to a new basis. To provide a precise
basis independent formulation of entangled states, one needs to express the quantum
system in the language of the density matrix. Just such a general criterion is provided
by the reduced density matrix and is derived below.
In the Schmidt decomposition, an entangled state vector of two degrees of freedom
is given by [1]
| E = ci |ψiI |ψiI I (5.22)
i=n
where, in general, ci can depend on the state vector |ψiI . The pure density matrix
for the state vector | E given in Eq. 5.22 is the following
N
ρE = | E E| = ci c∗j |ψiI ψ jI | ⊗ |ψiI I ψ jI I | ; Tr(ρ 2P ) = 1
i j=1
As was the case for Eq. 5.16, performing a partial trace over the degree of freedom
II yields, from Eqs. 5.5 and 5.22, the reduced density matrix for the entangled state
as follows
5.8 Entanglement for Composite Systems 123
N
ρ E,R = Tr I I | E E | = |ci |2 |ψiI ψiI | (5.23)
i=1
N
2
Tr(ρ E,R )= |ci |4 < 1 (5.24)
i=1
2
Tr(ρ E,R ) < 1 is a basis independent result, since a unitary change of basis leaves
Tr(ρ E,R ) invariant. Tr(ρ E,R
2 2
) < 1 leads to the conclusion that the state | E itself
cannot be written, in any set of basis states, as a product state |ψ I |ψ I I . This is
because a partial trace of the product state would lead to a reduced matrix ρ E R that
would be a pure density matrix – and thus contradict the result that Tr(ρ E2 R ) < 1,
obtained in Eq. 5.24.
In conclusion, for ci = 0 and N > 1, we have
N
| E = ci |ψiI |ψiI I = |χ I |χ I I : Entangled
i=1
N
N
ρ AB = pi ρiA ⊗ ρiB ⇒ Tr (ρ AB )2 = pi2 < 1
i=1 i=1
Although one has Tr((ρ AB )2 ) < 1, this does not necessarily imply that either system
A or B is entangled. Separable systems have been proven to satisfy, using definitions
given in Eq. 5.21, the following two inequalities
I A ⊗ ρ B,R − ρ AB ≥ 0 ; ρ A,R ⊗ I B − ρ AB ≥ 0
124 5 Quantum Superposition and Entanglement
The operator inequality means that all the eigenvalues of the operator are non-
negative. If any one of these two conditions are violated, then ρ AB represents a
composite system that is entangled. This is called the reduction criterion [4].
Consider a pair of binary degrees of freedom (two state systems), which could be
equal to two values of classical bits, with basis states |u 1 , |d1 and |u 2 , |d2 defined
by
1 0 1 0
|u 1 = ; |d1 = : |u 2 = ; |d2 =
0 1 1 1 0 2 1 2
A general expression for a separable product state for the pair of spins is the
following (dropping the subscript on state vector since notation does not need it)
| S = a|u 1 + b|d1 α|u 2 + β|d2 ; |a|2 + |b|2 = 1 = |α|2 + |β|2
In contrast, an example of an entangled state for the two spins, using the rules of
tensor product of vectors given in Sect. 2.6, is given by
The entangled state vector | E has been studied extensively and plays a central
role in the EPR paradox as well as in empirical tests of Bell’s theorem [1].
The proof that Eq. 5.25 is an entangled state requires the evaluation of the reduced
density matrix. The density matrix is given by a tensor (outer) product and, using the
rules given in Sect. 2.6, yields
ρE = | E E|
= |a| |u 1 u 1 | ⊗ |d2 d2 | + |b|2 |d1 d1 |⊗|u 2 u 2 | + off-diagonal
2
(5.26)
⎛ ⎞
0 0 0 0
⎜ 0 |a|2 ab∗ 0 ⎟
=⎜⎝ 0 a ∗ b |b|2 0 ⎠
⎟
0 0 0 0
The reduced density matrix is defined by taking the partial trace over the degree of
freedom of the second spin; under the partial trace, the off-diagonal terms in Eq. 5.26
are all zero. The result is the following
5.10 Quantum Entropy 125
ρ E R = tr2 (ρ E )
= |a|2 |u 1 u 1 | + |b|2 |d1 d1 | (5.27)
|a|2 0
=
0 |b|2
Taking the trace of the reduced matrix over the degree of freedom of the first spin
yields, from Eq. 5.27, the following
Note if either a or b is zero, Eq. 5.28 shows that there is no entanglement, as indeed
is the case since the state vector given in Eq. 5.25 becomes a product state and is
separable.
Hence, we conclude from Eq. 5.28 that, since the reduced density matrix tr (ρ E2 R ) <
1, the state vector given in Eq. 5.25 is entangled, namely
N
S = −Tr(ρ ln ρ) = − pi ln pi (5.29)
i=1
ρ = U diag( p1 , p2 , . . . , p N )U † ; UU † = I
ρ = |ψψ| ⇒ S = −Tr(ρ ln ρ) = 0
A pure state yields zero entropy since, as expected, there is no ignorance in knowing
the state of the system. In contrast to a pure state, if one has no information about a
system, then one expects that entropy should be a maximum.
The entropy of a mixed state, from Eqs. 5.9 and 5.29, is the following
N
S = −Tr(ρ M ln ρ M ) = − pi ln pi
i=1
ρ M = V diag( p1 , p2 , . . . , p N )V † ; V V † = I
126 5 Quantum Superposition and Entanglement
To find the density matrix that yields a maximum value Nof entropy S, we maximize
S with respect to all the pi ’s, with the constraint that i=1 pi = 1; using Lagrange
multiplier λ yields the maximization problem
N
L = S + λ[ pi − 1]
i=1
∂L
0= = −k B (ln p I + 1) + λ ⇒ p I = constant
∂ pI
∂L N
1
0= = pi − 1 ⇒ p I =
∂λ i=1
N
The result above shows that maximum entropy state is one for which all the states
are equally likely. The fact that all states are equally likely is precisely what one
expects for a system about which one is totally ignorant.
The density matrix is proportional to the identity operator I since, due to the
completeness equation, we have
N
|ψi ψi | = I
i=1
1
ρmax = I ⇒ Tr(ρmax ) = 1
N
1
Smax = −Tr(ρ ln ρ) = ln(N )Tr(I)
N
⇒ S = ln(N ) : maximum entropy (5.30)
For a state vector with two degrees of freedom consider the following entangled state
in the Schmidt representation [1]
N
N
| E = ci |ψiI |ψiI I ; |ci |2 = 1
i=1 i=1
that yields, from Eq. 5.23, the reduced density matrix for the entangled state as
follows
5.11 Maximally Entangled States 127
N
ρ E R = Tr2 | E E | = |ci |2 |ψiI ψiI |
i=1
The maximally entangled state has the maximum entropy and hence yields
N
1
ρE R = |ci | 2
|ψiI ψiI | = I (5.31)
Maximal
i=1
N
Maximal
1 1
|ci |2 = ⇒ ci = √ eiφi
N N
1 iφi I
N
| E = √ e |ψi |ψiI I (5.32)
N i=1
1 10
ρN S = I ⊗ I ; Tr(ρ N S ) = 1 ; I =
4 01
The reduced density matrix shows that the pair of spins is entangled since
1 1
ρ N S,R = Tr2 (ρ N S ) = I ; Tr(ρ N2 S,R ) = : Maximally entangled
2 2
An entangled state for two spin degrees of freedom, from Eq. 5.25, is given by
N
5Namely i=1 |ψiI ψiI | = I.
6The maximally entangled state is the same whether the partial trace is performed over quantum
system I or system II.
128 5 Quantum Superposition and Entanglement
ρ E R = Tr2 (ρ E )
= |a|2 |u 1 u 1 | + |b|2 |d1 d1 | (5.34)
|a|2 0
=
0 |b|2
⇒ p1 = |a|2 ; p2 = |b|2
S = −Tr(ρ E R ln ρ E R ) = − p1 ln p1 − p2 ln p2 (5.35)
= −|a| ln(|a| ) − |b| ln(|b| )
2 2 2 2
(5.36)
1
|a| = √ = |b|
2
⇒ S = ln(2) : Maximum entropy (5.37)
1
| E = √ eiφ |u 1 |d2 + |d1 |u 2 (5.38)
2
The density matrix, introduced in Sect. 5.4, is a Hermitian operator closely related
to the state vector; recall from Eq. 5.6 that the pure density matrix for a state vector
|χ is defined by
ρ P = |χ χ | (5.39)
The mixed density matrix ρ M can be used for evaluating the expectation value of any
function of the operator O. However, if one uses ρ M for evaluating the expectation
value of another operator Q that does not commute with O, namely [O, Q] = 0, then
there are unavoidable errors. The magnitude of these errors is set by the Heisenberg
Uncertainty Principle and is discussed in Belal [1].
Consider a quantum mechanical system to be in thermal equilibrium with a heat
bath at temperature T . The system now has a quantum mechanical indeterminacy as
well as classical uncertainty due to thermal randomness. The behavior of the quantum
system is described by the canonical ensemble’s probability distribution of energy
eigenstates—given by the Boltzmann distribution.
Let H be the quantum mechanical Hamiltonian with the following spectral decom-
position in terms of the energy eigenfunctions |ψi and eigenvalues E i
H= E i |ψi ψi |
i
1 −H/k B T 1 −Ei /k B T
ρT = e = e |ψi ψi | ; Z = Tr e−H/k B T (5.41)
Z Z i
1
⇒ ρT = pi |ψi ψi | ; Tr(ρT ) = pi = 1 ; pi = e−Ei /k B T
i i
Z
where k B is the Boltzmann constant. The thermal density matrix ρT for the canonical
ensemble is a mixed state since
Tr(ρT2 ) = pi2 < 1
i
The reason that ρT is a mixed state is that thermal randomness leads to a classical
uncertainty in the state of the system; this in turn entails that all the quantum state
vectors |ψi must be decoherent since there are no quantum correlations between
the different quantum states—unlike the case for a pure density matrix ρ p that has
off-diagonal terms as given in Eq. 5.8.
The expectation value of an operator O, for which [O, H ] = 0, and that is in
equilibrium with a heat bath is given by
130 5 Quantum Superposition and Entanglement
E T [O] = Tr(OρT ) = pi ψi |O|ψi
i
= pi αi ; αi = ψi |O|ψi
i
The thermal density matrix ρT encodes both thermal and quantum uncertainty,
reflected in the probability pi that the quantum system is in eigenstate E i and the
expectation value αi of the operator in this eigenstate.
References
6.1 Introduction
In this chapter, we review the notations used in quantum mechanics and discuss
some fundamental ideas of quantum mechanics within the context of quantum com-
puters. The underlying principles of quantum mechanics and the quantum theory of
measurement have been discussed in Chap. 4. A few highlights of the chapter are
reviewed in the context of qubits.
Consider n-binary degrees of freedom with computational basis states given by
|x0 , x1 , . . . , xn−1 . A quantum algorithm provides an answer to the input qubits and
which is expressed in the final output state. The answer being sought has to be
extracted by measurements performed on the final output state. Measurements are
carried out using an experimental device and represented by projection operators that
represent the physical construction of irreversible measurement gates
The quantum system carrying the qubit |q = |q(x0 , x1 , · · · , xn−1 ) is subjected to
a measurement in which all the measurements gates are applied on the system, and
the outcome of the measurement is that some definite and determinate measurement
gate register a change. This change is a signal that the gate has been triggered by the
measurement; which measurement gates register a signal is completely random.
A list is made of the frequency with which the various measurement gates register
a signal. The state vector
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 131
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_6
132 6 Binary Degrees of Freedom and Qubits
This section is a review of the main results of Chap. 4. The quantum gates, circuits
and qubits, based on the discussion above, are summarized with some repetitions for
greater clarity:
• The classical bit taking values of 0 and 1 is identified as the underlying binary
degree of freedom of the quantum system of a quantum computer.
• Recall, as discussed in Sect. 4.2, that the degree of freedom is intrinsically indeter-
minate, with the binary degree of freedom simultaneously taking both the values
0 and 1.
• The quantum state vector (wave function) of a quantum computer is a complex-
valued function of the degree of freedom that yields the likelihood of observing
the different determinate values of the degree of freedom.
• The quantum state of a single binary degree of freedom is called a qubit and given
in Eq. 4.3. A qubit is a quantum superposition of the 0 and 1 binary degrees of
freedom.
• The qubit encodes the likelihood of observing 0 or 1 if a measurement is performed
on it.
• The single classical bit is replaced by a single qubit.
• All quantum gates are reversible (unitary) transformations.
• In a quantum circuit, a single qubit is represented by a single horizontal line and
gates by various symbols acting on the qubits.
• The quantum circuit is defined by a sequence of unitary gates applied to the input
string state vector of n-binary degrees of freedom to obtain the final output state
vector.
• Once an input string is specified, the computational processes are carried out by
transforming the initial string through a series of gates (more on this later)—using
the laws of quantum mechanics.
• During the computational process, the classical bit is superseded by the qubits,
denoted by |ψ, which consists of a superposition of the basis states of the com-
putational basis.
In principle, for a quantum computer, the input and output string state vector can
be expressed in many ways. But, for simplicity, we work in the computational basis
in which the input and output strings are expressed in terms of the n-binary degrees
of freedom {0, 1}n given in Eq. 2.26. For a quantum computer, the input is a deter-
minate string and the output is also a determinate string. A fundamental difference
between a classical and quantum computer is that the output string of a quantum
computer is random and uncertain—and can only be obtained after performing a
quantum measurement. The output string state is obtained as the average of repeated
measurements of the same algorithm run many times—with identical preparation.
The central role of measurement in quantum mechanics is discussed in Sect. 4.5.
6.3 Single Qubit 133
As given in Eq. 4.4, the state vector |ψ of the n-binary degrees of freedom can be
represented in the computational basis |x, x = 0, 1, 2, . . . , 2n − 1 by the following
expansion
2
n
−1 2
n
−1
|ψ = αx |x ; |αx |2 = 1 (6.1)
x=0 x=0
The state vector |ψ is called the qubits of the n-binary degrees of freedom and is
the superposition of the computational basis states.
The qubits come into play in the following manner. Once the initial state is
provided—and until the output is ready—the transformations inside a quantum com-
puter are all performed on the qubits: the process of quantum computation cannot
be observed as it will destroy the process. Suppose there are many qubits required
for the algorithm; the quantum computer will simultaneously update all the qubits—
sometimes called quantum parallelism. During the entire computational process, all
the qubits are in an indeterminate state that consists of the superposition of the qubit
states.
Once the computation is completed, the output string is in an indeterminate state.
The process of measurement collapses the indeterminate output state—with a certain
probability—to a specific and determinate output string. The quantum mechanical
measurement can, in principle, result in a whole range of possible outcomes, with
the output being in a specific determinate string having only a certain likelihood of
occurrence.
We consider the special cases of n = 1 and n = 2 as they play a key role in quantum
algorithms. For n = 1, the computational basis is given by
|0 ; |1
From Eq. 6.1, the fundamental state vector, corresponding to the classical 1-bit, is
given by
|ψ ≡ |q = α|0 + β|1 ; |α|2 + |β|2 = 1
The special notation |q is used for the state vector of a single binary degree of
freedom and is called the qubit. The crux of the difference between a classical and a
quantum computer is the generalization of the definition of a bit to a qubit. Deutsch’s
1985 paper showed that the fundamental object for quantum algorithms is not the
classical bit, but instead the qubit.
134 6 Binary Degrees of Freedom and Qubits
a b
Fig. 6.1 a Qubits take values on the surface of a two-dimensional sphere. b A qubit that is a
superposition of classical bits. Published with permission of © Belal E. Baaquie and L. C. Kwek.
All Rights Reserved
In general, α = eiχ a, β = eiφ b are in general complex numbers, with a, b real. The
qubit can only be measured up to a global phase, and hence, we can set χ = 0 and
yields
|q = a|0 + eiφ b|1 ; a 2 + b2 = 1
To summarize our earlier discussion on qubits, the qubits are quantum mechanical
state vectors that are a function of the binary degree of freedom 0, 1 that is essentially
indeterminate, having no intrinsic value: the qubit is a quantum state vector that is
the superposition of the single bit states. Metaphorically speaking, the qubit has the
probability of being in the two distinct states given by a 2 , b2 , respectively. The super-
posed state of qubit is forbidden in a classical computer, and it has an interpretation
that requires the quantum theory of measurement.
For the probabilistic interpretation of quantum mechanics, the norm of a qubit is
equal to 1, which implies q|q = 1; hence
θ θ
q|q = 1 ⇒ a + b = 1 ⇒ a = cos
2 2
; b = sin
2 2
6.3 Single Qubit 135
The single qubit is a great enhancement of the 1-bit. The angles θ, φ parametrize a
two-dimensional sphere, called the Bloch sphere, for the qubit and shown in Fig. 6.1.
Every point on the surface of Bloch sphere is a possible (pure) state vector of the
qubit.
ρ = |qq| = 1
2 (I + n · σ ) n · n = 1
Note that σ is a vector of Pauli matrices. With this parametrization, we see that the
vector n can be represented by a point on a unit sphere (Bloch sphere) with azimuthal
angle θ and polar angle φ.
Fully distinguishable and distinct states lie on antipodal points of the sphere. Two
special distinct states of a single 1-bit are simply two points on the Bloch sphere,
which in our parametrization are the North Pole |0 and the South Pole |1. Some
special cases of the qubit q are shown in Fig. 6.1.
• Classical bits:
|q(0, 0) = |0 ; |q(π, 0) = |1
• Superposed states:
1 1
|q(π/2, 0) = √ [|0 + |1] ; |q(π/2, π/2) = √ [|0 + i|1]
2 2
The case of n = 2 consists of two binary degrees of freedom {0, 1} ⊗ {0, 1}. The
computational basis yields the following basis states
A single degree of freedom {0, 1} yields superposed states but has no entangled
states since for entangled quantum states, one needs at least two degrees of freedom.
Hence, for n = 2, we have a set of entangled states, called the Bell states, that in
many cases are more convenient to use as basis states in place of the computational
basis states. The Bell states are given by
1 1
|B1 = √ (|00 + |11) ; |B2 = √ (|00 − |11)
2 2
1 1
|B3 = √ (|01 + |10) ; |B4 = √ (|01 − |10)
2 2
6.5 Bell States: Maximally Entangled 137
1
|x y B = √ (|0y + (−1)x |1 ȳ) ; x, y = 0, 1
2
where ȳ is NOT y.
and
1 0
|02 = |u 2 = ; |12 = |d2 =
0 2 1 2
Case I
Another class of maximally entangled states is given in general by Eq. 5.32
1 iφi I
N
| E =√ e |ψi |ψiI I (6.6)
N i=1
Hence, ignoring an overall phase, from Eq. 6.6 we have the following entangled state
vectors for the two binary degrees of freedom
1
| E = √ (|u 1 u 2 + eiφ |d1 d2 ) (6.7)
2
1 1
|B1 = √ (|00 + |11) ; |B2 = √ (|00 − |11)
2 2
138 6 Binary Degrees of Freedom and Qubits
Case II
Recall from Eq. 5.38 that a maximally entangled state of two binary degrees of
freedom is given by1
1
| E = √ |u 1 |d2 + eiφ |d1 |u 2 (6.8)
2
1 1
|B3 = √ (|01 + |10) ; |B4 = √ (|01 − |10)
2 2
Hence, we see that all the Bell states are maximally entangled.
1 The phase can be moved due to the overall phase being irrelevant.
Chapter 7
Quantum Gates and Circuits
A quantum circuit, like the classical case, represents qubits by lines and gates by
various symbols. At the hardware level, a quantum circuit, like a classical computer,
is a physical object—composed of tiny capacitors with Josephson junctions creating
superconducting qubits that are manipulated using resonators, magnetic and electric
fields and other interactions. The information transmitted along the circuit is no
longer high and low voltages of a classical bit but the quantum mechanical state
(wave) function.
The mathematical structure of the qubits and quantum gates is fundamentally
different from the classical case. For a classical computer, gates are in general irre-
versible, and hence, the classical gates cannot be mapped directly to quantum com-
puters. All quantum gates are unitary transformations, being reversible (unitary)
operations that are applied to one or more qubits; for a reversible computation, the
number of input qubits must equal the number of output qubits.
The general scheme of quantum computation is that the qubit |x is transformed
by some gates and results in taking values |x ⊕ f (x). Since the initial qubit state
is transformed to the final qubit state by reversible operations, the algorithms of a
quantum computer must necessarily be reversible. For a quantum computer, at least
two qubits are required for a reversible computation so that no information is lost
in each step of the algorithm. Hence, to preserve the information contained in the
initial qubit |x, which serves as the initial state for the quantum algorithm , a second
ancillary qubit |y is introduced that carries the result of the computation [1].
Consider a binary function f that is defined by the following mapping (|x ⊗ |y ≡
|x|y)
f : |x|y → |x|y ⊕ f (x)
where recall that y ⊕ f (x) is binary addition. A quantum gate O f implements the
function by the following operation
O f |x|y = |x|y ⊕ f (x)
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 139
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_7
140 7 Quantum Gates and Circuits
Fig. 7.1 A general circuit of a quantum computer. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
The main difference between the classical and quantum circuit diagram is that
(a) all quantum gates are reversible (as are some, but not all, classical gates) and (b)
the input and output n-qubit strings states are, in principle, the superposition of the
binary degrees of freedom.
If the state |x needs n qubits and the function needs ancillary m qubits, then the
computation will need n + m qubits. The dual-register architecture of the input qubit
and the ancillary qubit comes into play in many non-classical algorithms.
A typical circuit of the quantum computer, shown in Fig. 7.1, consists of (a) the ini-
tial and ancillary states, (b) a number of quantum gates, and (c) a special irreversible
quantum gate that terminates the algorithm by performing a measurement.
The quantum circuit shown in Fig. 7.1 has the following components:
1. The horizontal axis denotes time.
2. Each line represents a qubit. The input qubits are indicated by q0 , . . . , q3 .
3. The double line labeled c records the results of measurements.
4. The quantum gates are unitary matrices.
5. Gates denoted by symbols X, H act on only a single qubit.
6. The vertical line with a dot on top and a cross on the bottom are gates that
simultaneously act on the indicated two qubits.
7. In principle, quantum gates can simultaneously act on n-qubit strings.
8. The vertical dashed lines are not part of the circuit and are used to indicate the
difference between gates that act on a single and on two qubits.
9. The measurement gates are irreversible (non-unitary) projection operators, indi-
cated by a counter and pointer in Fig. 7.1.
10. Qubits are terminated with a measurement; in Fig. 7.1, a measurement is per-
formed only on q0 , q1 , q2 but not on q3 .
11. The result of the measurement is recorded in a counter, denoted by double line
labeled by c, with classical binary bits—denoted by 0, 1, 2, 3—reserved for each
qubit in the counter c, as shown in Fig. 7.1.
12. The qubit q3 is not measured so the binary bit 3 is shown on the left of the double
line.
7.1 Quantum Gates 141
There are three Pauli gates: X , Y and Z ; from Eq. 6.4, one changes the notation of
the Pauli matrices to the following
01 0 −i 1 0
X= ,Y = ,Z= . (7.1)
10 i 0 0 −1
The Pauli gates act on a single qubit and can be used for creating superposed qubit
states. The Pauli X gate acts like the classical NOT gate on the basis states; i.e., it
changes the state |0 to |1 and vice versa.
The CNOT gate is the same as the XOR classical gate, and discussed in Sect. 3.4
and given in Fig. 7.2. Two gates in Fig. 7.1 are Pauli X gates, which is the same as
the classical NOT gate.
Unitary rotation matrices, acting on a single qubit, are built from the Pauli gates.
Using the fact that
X2 = Y 2 = Z2 = I
yields
Hence
1 1 1 0 1 1
H =√ ; H =√ (7.3)
0 2 1 1 2 −1
142 7 Quantum Gates and Circuits
The Hadamard gate can be used to change the NOT or Pauli-X gate into a Pauli-Z
gate since
HXH = Z
1 1
H |0 = √ [|0 + |1]; H |1 = √ [|0 − |1] (7.4)
2 2
In Eq. 7.4, the Hadamard gate has created a superposed state for the single qubit,
something forbidden for a classical gate acting on a classical bit. Equation 7.4 can
be rewritten as follows
1
1
H |x = √ (−)x y |y; x = 0, 1 (7.5)
2 y=0
1
1
H |x = √ (−)x y |y; x y = x1 y1 ⊕ x2 y2 · · · ⊕ xn yn ; xi , yi = 0, 1
2n y=0
(7.6)
1
H |0 = √ [|0 + |1] (7.7)
2
Consider the Hadamard gate acting on 2-qubits |q1 q2 ; using the tensor product
notation
To create the computational basis states, the Hadamard gate is often used. Equa-
tion 7.8 can be generalized to n-degrees of freedom. Consider the basis state
1
H ⊗n ⊗⊗n |0 = √ [|0 + |1][|0 + |1] · · · [|0 + |1]
2n
2n −1
1
= √ |x (7.9)
2n x=0
We can construct this state starting from the initial state of |0 in the following
manner. Consider the rotation matrix
Hence, choosing
a = cos θ ; b = sin θ
yields
|q = R y (θ )|0
Fig. 7.3 Preparation of a general single qubit. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
144 7 Quantum Gates and Circuits
The most general two-qubit state vector, from Eq. 6.5, is given by
Choose U so that
1 α 1 γ
U = ⇒ UU † = I
α2 + β 2 β γ 2 + δ2 δ
such that
1 1
U (α|0 + β|1) = (γ |0 + δ|1)
α2 + β2 γ2 + δ2
can be regarded as points on the Bloch sphere and U is simply the unitary (rotation)
matrix that transforms (rotates) the vector |φ1 to |φ2 .
Hence, from Eq. (7.11),
|ψ = U |φ1 ⊗ |φ2 (7.12)
=U α 2 + β 2 |0 + γ 2 + δ 2 |1 ⊗ |φ2
U = |0 0| ⊗ I + |1 1| ⊗ U
One prepares the one-qubit states using the result of Eq. 7.10. Prepare the initial state
|ψi given by
|ψi = (|0 + |1) ⊗ (α|0 + β|1)
|ψ = U|ψi
The quantum circuit for preparing the 2-qubit state is given in Fig. 7.4.
Entangled states are a major resource in quantum algorithms and to express them
in a circuit diagram, one needs to group two or more qubits together. Consider the
entangled state
|ψ E = α|00 + δ|11
X = |0 0| ⊗ I + |1 1| ⊗ X
Applying the CNOT gate to the initial state yields the entangled state
1 1
|B1 = √ (|00 + |11) = √ X (|0 + |1)|0
22 22
1 1
⇒ |B1 = √ X H |0 ⊗ |0 = √ X (H ⊗ I)|00
2 2
1
H |0 = √ (|0 + |1)
2
All the other Bell states can similarly be mapped into the computational basis.
This gate acts on two qubits and if the first qubit is in state |0, it does nothing to the
second qubit, but if the first qubit is in state |1, it applies the X gate to the second
qubit. Another way of thinking of the CNOT gate is
⎛ ⎞
1 0 0 0 0 0 0 0
⎜0 1 0 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 1 0 0 0 0 0⎟
⎜ ⎟
⎜0 0 0 1 0 0 0 0⎟
CCNOT = ⎜
⎜0
⎟ (7.16)
⎜ 0 0 0 1 0 0 0⎟⎟
⎜0 0 0 0 0 1 0 0⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 1⎠
0 0 0 0 0 0 1 0
The logic of adding two numbers on a quantum computer is the same as that for a
classical computer [2, 3]. The quantum adder does not possess any quantum advan-
tage over the classical adder. Nor does it save any resources. We discuss the quantum
full adder here mainly for pedagogical purpose, in particular, to illustrate the fact that
quantum gates are linear operators on the underlying bits as well the interconnection
of the quantum adder with the classical full adder.
The addition of two quantum qubits follows the same logical truth tables and gates
as the classical full adder. In particular, the reversible classical gate F obtained in
Sect. 3.8 and given by the matrix in Eq. 3.36 is also the quantum gate. The main and
significant difference is that quantum adder can also add incoming qubits that are
the superposition of the binary degrees of freedom.
Let the state vector |ψ be the result of the addition of two qubits |A and |B;
then, similar to Eq. 3.33, we have
|ψ = F|ABCin 0 ≡ F |A ⊗ |B ⊗ |Cin ⊗ |0 (7.18)
148 7 Quantum Gates and Circuits
where for the quantum case the incoming qubits are given by
Since F is a linear operator (matrix) acting on a linear vector space, we have from
Eq. 7.18—explicitly writing out the incoming state vectors—the following
|ψ = F (α1 |0 + β1 |1) ⊗ (α2 |0 + β2 |1) ⊗ |Cin ⊗ |0
= α1 α2 F(|00Cin 0) + α1 β2 F(|01Cin 0)
+β1 α2 F(|10Cin 0) + β1 β2 F(|11Cin 0) (7.20)
The qubits and gates discussed in the earlier sections prepare the final quantum
state from the initial input quantum state. The process of computation needs one
more crucial step, which is the process of quantum measurement. In the chapter
on quantum mechanics, in particular, in Sects. 4.5 and 4.10, the Born rule and the
generalized Born rule have been discussed. These rules are studied in the context of
7.5 Quantum Measurements of Qubits 149
Recall from Sect. 4.5 one needs to decide which value of binary degree of freedom is
the device going to study statistically. The final result for a measurement is given by
the arithmetic mean of, in principle, an infinite number of observations. In practice,
a sufficiently large number of observations is sufficient. One needs to keep in mind
the statistical nature of quantum measurements, and that in principle one can never
directly observe the (binary) degree of freedom [4].
The device provides projection operators for the measurement given by
The projection operators are non-Unitary irreversible gates that cause the qubit to
collapse to an eignestates one of the projection operators. The measurement gate is
given in Fig. 7.7.
The measurement requires the density matrix
ρ = |q q|
Fig. 7.7 Irreversible measurement gate. Published with permission of © Belal E. Baaquie and
L. C. Kwek. All Rights Reserved
Fig. 7.8 Measurement of a single qubit; counter C is for recording the result of the measurement.
Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
150 7 Quantum Gates and Circuits
Fig. 7.9 Preparation of a general 2-qubit state using the reversible gate G. C is a counter for
recording the outcome of the measurement. Published with permission of © Belal E. Baaquie and
L. C. Kwek. All Rights Reserved
Fig. 7.10 Simultaneous measurement of both the degree of freedom of a 2-qubit. C indicates a
recording counter that records the result of the measurement. Published with permission of © Belal
E. Baaquie and L. C. Kwek. All Rights Reserved
• The probability of the qubit collapsing to the state |x = |0 is given by the pro-
jection operator M0
Tr(M0 ρ) = |α|2
• The probability of the qubit collapsing to the state |x = |1 is given by the pro-
jection operator M1
Tr(M1 ρ) = |β|2
Figure 7.10 shows the preparation of |ψ using the gate G, and the result of the
measurement of both qubits is indicated by e.
The most general two qubits state vector |ψ can be prepared as shown in Fig. 7.9
using a reversible gate G. From Eq. 6.5, it is given by
Similar to the single qubit case, we have the following projection operators required
for carrying out a quantum measurement on a 2-qubits string.
and
M10 = |1 1| ⊗ |0 0|; M11 = |1 1| ⊗ |1 1|
The simultaneous measurement of both the degree of freedom, shown in Fig. 7.10,
yields the following result
7.5 Quantum Measurements of Qubits 151
and yields the following probability of occurrence of the state |x1 |x2
The generalized Born measurement for the two-qubit case—including the consis-
tency of the generalized measurement discussed in Sect. 4.10—is worked in detail
for pedagogical purpose. A measurement for quantum algorithms that is a partial
Born measurement, discussed in Sect. 4.10, is one in which only a few of the qubits
are measured. To exemplify this measurement, it is sufficient to consider the two-
qubit case with a measurement being carried out on only one of the qubits, followed
by another measurement of the second qubit.
Consider measurement processes shown in Fig. 7.11. To express the result of these
measurements, for clarity we label the first and second qubits and rewrite the state
vector |ψ as follows
|ψ = |01 α|02 + β|02 + |11 γ |02 + δ|02 (7.24)
= p1 (0)|01 | 1 (0) + p1 (1)|11 | 1 (1) (7.25)
where
1
p1 (0) = |α|2 + |β|2 ; | 1 (0) =√ α|02 + β|02 (7.26)
p1 (0)
1
p1 (1) = |γ |2 + |δ|2 ; | 1 (1) = √ γ |02 + δ|02 (7.27)
p1 (1)
with
• Probability of state |0| 1 (0) occurring being given by p1 (0)
• Probability of state |1| 1 (1) occurring being given by p1 (1)
152 7 Quantum Gates and Circuits
Another measurement carried out on state |x1 | 1 (x), as shown in Fig. 7.11,
yields
with
• Probability of state |01 |01 occurring being given by
|α|2
p1 (0) = |α|2 = p(00)
p1 (0)
|β|2
p1 (0) = |β|2 = p(01)
p1 (0)
|γ |2
p1 (1) = |γ |2 = p(10)
p1 (1)
References 153
|δ|2
p1 (1) = |δ|2 = p(11)
p1 (1)
The result above shows that the result of performing successive measurements on
the two qubit yields the same result as the one obtained by simultaneously observing
the two qubits
|ψ → |x1 |x2
Similar to the above derivation, it can be shown that reversing the order of measuring
the qubits yields the same as a single measurement of both the degrees of freedom
in this case.
As mentioned in Sect. 4.11, the degrees of freedom are independent of each other.
Hence, the order of measuring the qubits of the degrees of freedom does not matter.
We have verified that measuring a particular qubit does not depend on measurements
carried out on the other qubit.
However, in a more general case involving measurements of entangled states
the order in which the measurements are made matters. If one uses entangled state
vectors as the basis states, such as the Bell states discussed in Sect. 6.4 for two binary
degrees of freedom, then one needs to keep track of the order of the measurements.
However, in almost all applications measurements are made using the computational
basis, and the quantum circuit is measured for non-entangled states; for these states,
as mentioned above, the order in which the various individual qubits are measured
does not matter.
References
1. Nielsen MA, Chuang IL (2012) Quantum computation and quantum information. Cambridge
University Press, UK
2. Barbosa GA (2006) Quantum half-adder. Phys Rev A 73(5):052321
3. Bomble L, Lauvergnat D, Remacle F, Desouter-Lecomte M (2009) Controlled full adder or
subtractor by vibrational quantum computing. Phys Rev A 80(2):022332
4. Baaquie BE (2013) The theoretical foundations of quantum mechanics. Springer, UK
Chapter 8
Phase Estimation and quantum Fourier
Transform (qFT)
8.1 Introduction
Phase estimation and the quantum Fourier transform (qFT) are the inverse of each
other.1 From a pedagogical point of view, to start the discussion with phase estimation
provides greater clarity. The reason being, as will become clear in the sections below,
that phase estimation requires the removal of phase factors from a qubit, whereas the
qFT requires the addition of phase factors. Removing a phase factor from a qubit has
a transparent representation in terms of the quantum gates, and hence, we start with
phase estimation; the quantum Fourier transform is the inverse of the transformation
for phase estimation [1–4].
Both the unitary operator U and its eigenvector |u are known, and we need to
determine the unknown phase ω. The following procedure is followed. Apply the
operator U on |u2n to yield
2 −1
1
n
1The notation qFT is used for quantum Fourier transform to avoid using QFT, which is the standard
acronym for quantum field theory.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 155
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_8
156 8 Phase Estimation and quantum Fourier Transform (qFT)
where one notes that the labeling for the ket vector |y is taken from Eq. 2.4.
The quantum circuits for U y and |ψ are given in [5], where it is shown how the
action of U y |u is employed to extract the phase exp{2πiωy} to form the state vector
|ψ. The problem of phase estimation is to start with state vector |ψ and determine
the phase ω.
Consider a real number ω with 0 < ω < 1. If one has a system of n qubits, ω can be
expressed approximately as
α1 α2 α3 αn−1 αn
ω + 2 + 3 + · · · + n−1 + · · · + n
2 2 2 2 2
where αi = 0 or 1 for each i. The binomial expression given above is exact only
if ω = x/2n , where x is an integer. As an example, the real number ω . . . can be
expressed approximately (for n = 12) as
1 1 1 1 1
ω + + 6 + 9 + 12 = 0.101001001001
2 23 2 2 2
For an arbitrary value of 0 < ω < 1, the approximate value of ω can be made
arbitrarily accurate by increasing the value of n. The accuracy of the phase estimation
algorithm for ω depends on the number of qubits that are being used to estimate it.
For arbitrary ω, let x/2n be an integer multiple of 1/2n closest to ω. The phase
estimation algorithm returns the value x with probability at least 4/π 2 [1].
In general, for ω close to x/2n , we can write ω as
1 1 1 n
ω x1 + 2 x2 + · · · + n xn = xi 2−i ; xi = 0, 1
2 2 2 i=1
ω = 0.x1 x2 . . . xn (8.2)
Since we have n qubits, the computational basis |x0 x1 . . . xn−1 has 2n basis states
and is labeled by y = 0, 1, 2, . . . , 2n−1 . To estimate ω, consider the state vector given
in Eq. 8.21
2 −1
1
n
Furthermore
n
y= yi 2n−i = 2n−1 y1 + 2n−2 y2 + · · · + 2yn−1 + 20 yn
i=1
n
yω = yi 2n−i × 0.x1 x2 . . . xn (8.4)
i=1
2k x = x1 x2 . . . xk .xk+1 xk+2 . . . xm . . .
= x1 x2 . . . xk + 0.xk+1 xk+2 . . . xm . . . (8.5)
Hence
2n−i × 0.x1 x2 . . . xn = x1 x2 . . . xn−i + 0.xn−i+1 . . . xn
and yields
From Eqs. 8.3 and 8.6, the sum over the qubits factorizes and yields
n −1
2
n
|ψ = exp{2πi yi × 0.xn−i+1 . . . xn }|y
y=0 i=1
1
n 1
= √ exp{2πi yi × 0.xn−i+1 . . . xn }|yi
2n i=1 y =0
i
1
1 1
= √ exp{2πi y1 (0.xn )}|y1 exp{2πi y2 (0.xn−1 xn )}|y2 . . .
n
2 y =0
1 y =0 2
1
× exp{2πi yn (0.x1 x2 . . . xn )}|yn
yn =0
1
= √ |0 + e2πi(0.xn ) |1 |0 + e2πi(0.xn−1 xn ) |1 . . . |0 + e2πi(0.x1 x2 ...xn ) |1 (8.7)
2n 1 2 n
158 8 Phase Estimation and quantum Fourier Transform (qFT)
Fig. 8.1 Three-qubit phase estimation. Gates are placed on the target qubit and the heavy dots
specify the control qubit. Published with permission of © Belal E. Baaquie and L. C. Kwek. All
Rights Reserved
To analyze the general equation given in Eq. 8.7, we start with the case of n = 3 as
this has all the features of the general case.
For n = 3, Eq. 8.7 yields the following
1
|ψ3 = √ |0 + e2πi(0.x3 ) |1 |0 + e2πi(0.x2 x3 ) |1 |0 + e2πi(0.x1 x2 x3 ) |1
23 1 2 3
(8.8)
Note that for n = 3 all unitary gates are 23 × 23 matrices acting on a 23 -dimensional
state space and |ψ3 , which is a 23 -dimensional complex-valued state vector. The
quantum circuit for the n = 3 phase estimation is given in Fig. 8.1.
Note that
x3 |0 + |1 : x3 = 0
|0 + e2πi(0.x3 ) |1 = |0 + exp 2πi |1 =
2 |0 − |1 : x3 = 1
1 1
|0 = √ H |0 + |1 ; |1 = √ H |0 − |1
2 2
and hence
|0 + exp{2πi x/2}|1 |0 : x = 0
H √ = |x = (8.9)
2 |1 : x = 1
Define
Hi = I ⊗ · · · H · · · ⊗ I = Hi† = Hi−1 ; H1 = H ⊗ I ⊗ I
ith position
8.3 Phase Estimation 159
Hence
1
H1 |ψ3 = √ |x3 1 |0 + e2πi(0.x2 x3 ) |1 |0 + e2πi(0.x1 x2 x3 ) |1 (8.10)
22 2 3
The term referring to qubit 2 in Eq. 8.10 cannot be simplified using the Hadamard gate
since the binary number 0.x2 x3 in the exponential needs to simplified. A conditional
gate depending on the first qubit |x3 can be used to transform 0.x2 x3 to 0.x2 as
†
follows. Consider the following (the notation of U12 is used for consistency with the
†
one used in the literature). U12 leaves the third qubit unchanged and hence
†
U12 = |00| ⊗ I ⊗ I + |11| ⊗ R−1 †
⊗ I ≡ U12 ⊗I (8.11)
2
1 0
where R−12 = 0 exp{−2πi/22 } (8.12)
1 †
†
U12 H1 |ψ3 = √ U12 |x3 1 |0 + e2πi(0.x2 x3 ) |1
22 2
× |0 + e2πi(0.x1 x2 x3 ) |1 (8.13)
3
Hence
†
U12 |x3 1 |0 + e2πi(0.x2 x3 ) |1
2
−1
= |00| ⊗ I + |11| ⊗ R2 |x3 1 |0 + e2πi(0.x2 x3 ) |1
2
−1 2πi(0.x2 x3 )
= |01 0|x3 ⊗ I + |11 1|x3 ⊗ R2 |0 + e |1
⎧ 2
⎨ |01 |0 + e2πi(0.x2 ) |1 : x3 = 0
= 2 (8.14)
⎩ |11 R−1 |0 + e2πi(0.x2 1) |1 : x3 = 1
2
2
This yields
160 8 Phase Estimation and quantum Fourier Transform (qFT)
1
†
U12 H1 |ψ3 = √ |x3 1 |0 + e2πi(0.x2 ) |1 |0 + e2πi(0.x1 x2 x3 ) |1 (8.15)
22 2 3
Hence, as shown in Fig. 8.1, applying the Hadamard transformation to the second
qubit yields from above
1
†
H2 U12 H1 |ψ3 = √ |x3 1 |x2 2 |0 + e2πi(0.x1 x2 x3 ) |1 (8.16)
2 3
Reducing 0.x1 x2 x3 to 0.x1 needs two steps, since the gates are conditional on the
values of x2 , x3 . First step is to remove dependence on x3 using R3−1 and the second
step is to remove x2 using R2−1 .
Define unitary gate by U13 that acts on third qubit |0 + e2πi(0.x1 x2 x3 ) |1 condi-
3
tioned on |x3 1 ; it has to leave the qubit |x2 2 unchanged. Hence,
†
U13 = |00| ⊗ I ⊗ I + |11| ⊗ I ⊗ R−1 (8.17)
3
−1 1 0
where R3 = (8.18)
0 exp{−2πi/23 }
In general
1 0
R−1
k = (8.19)
0 exp{−2πi/2k }
1
†
U13 †
H2 U12 H1 |ψ3 = √ |x3 1 |x2 2 |0 + e2πi(0.x1 x2 ) |1 (8.20)
2 3
Applying the Hadamard gate H3 gate to Eq. 8.22 yields the following final result
given in circuit in Fig. 8.1
† † †
H3 U23 U13 H2 U12 H1 |ψ3 = |x3 1 |x2 2 |x1 3 (8.23)
Using the three bit swap gate S3 to reverse the order of the qubits yields
8.3 Phase Estimation 161
S3 |x3 1 |x2 2 |x1 3 = |x1 1 |x2 2 |x3 3 = |x1 x2 x3 = |ω
1 1 1
ω= x1 + 2 x2 + 3 x3
2 2 2
In summary, the phase estimation is given by the following
† † †
S3 H3 U23 U13 H2 U12 H1 |ψ3 ≡ P3 |ψ3 = |x1 x2 x3 = |ω (8.24)
and
1 0
(R−1
k )
†
= Rk = ; Rk R†k = I
0 exp{2πi/2k }
The general case of |ω = |x1 x2 x3 . . . xn follows the same steps and yields an
estimation of
1 1 1 1
ω = x1 + 2 x2 + 3 x3 + · · · + n xn
2 2 2 2
with the generalization of Eq. 8.24 given by
1 2n
−1
|ω = P|ψ = P √ exp{2πiωy}|y (8.27)
2n y=0
The following is a summary of the algorithm for ascertaining the unknown phase
ω.
• The phase ω is expressed as the state vector |ω that is to be determined.
• Start with the right-hand side of Eq. 8.27 that is known and given by
2 −1
1
n
|ψ = √ exp{2πiωy}|y
2n y=0
162 8 Phase Estimation and quantum Fourier Transform (qFT)
1 2n
−1
P √ exp{2πiωy}|y
2n y=0
1 2
n
−1
P √ exp{2πiωy}|y = |ω
2n y=0
The quantum Fourier transform is obtained by the inverting the steps of the algorithm
required for phase estimation.
Consider a binary number x > 1 with the binary expansion given in Eq. 2.2
2n −1
1 2π x y
F |x = √ exp i n |y (8.28)
2n y=0 2
8.4 quantum Fourier Transform 163
Note there is a periodicity of the qFT in the definition given in Eq. 8.28
F |x = F |x + 2n
The periodicity is consistent with the definition of the integer 0 ≤ x ≤ 2n − 1; for
values of x outside this range, since there are in total only n-qubits, the qFT F |x
is defined only for x modulo 2n . All values of x outside the range 0 ≤ x ≤ 2n − 1
are mapped back into the range 0 ≤ x ≤ 2n − 1.
The definitions given for binary numbers yield the following
2n −1 2n −1
1 2π x y 1
F |x = √ exp i n |y = √ exp{2πiωy}|y
2n y=0 2 2n y=0
1
= √ |0 + e2πi(0.xn ) |1 |0 + e2πi(0.xn−1 xn ) |1
2n 1 2
2πi(0.x1 x2 ...xn )
. . . |0 + e |1 (8.29)
n
The expansion of the right-hand side of Eq. 8.29 is given in Eq. 8.7.
The discussion on the quantum Fourier transform is based on the derivation of
phase estimation. Note that P is a unitary gate since it is a product of unitary matrices;
hence its inverse exists and is given by
F = P −1 = P † (8.30)
F · F † = I2n ×2n
2 −1
1
n
P |x1 x2 x3 . . . xn = |ψn = √
†
exp{2πi x y/2n }|y
2n y=0
2 −1
1
n
Similar to the phase estimation algorithm, the quantum Fourier transform algo-
rithm is given by the following. Note that the role of what is known and what is to
be determined is interchanged in going from phase estimation to Fourier transform,
with one being the inverse of the other.
164 8 Phase Estimation and quantum Fourier Transform (qFT)
2 −1
1
n
is to be determined.
• Start with the value of |x.
• Apply the quantum gate F to |x and obtain
F|x
The quantum gate F adds phase factors to the qubits, whereas the quantum gate
for phase estimation P removes the phase factors.
• The final result is given by
2 −1
1
n
To show the close relation between the Fourier transform to phase estimation is
studied for the case of n = 3. The quantum Fourier transform for n = 3, from Eq. 8.8,
is given by
1
F3 |x3 = √ |0 + e2πi(0.x3 ) |1 |0 + e2πi(0.x2 x3 ) |1 |0 + e2πi(0.x1 x2 x3 ) |1
23 1 2 3
(8.31)
An explicit derivation is given of Eq. 8.31 to verify that the quantum Fourier
transform is, in fact, determined by gate F3 given in Eq. 8.32. The quantum Fourier
transform is built from two types of gates, one is the Hadamard gate and the other
is a two-qubit controlled rotation Rk . Consider the Hadamard transform on a single
qubit |x; since H 2 = I, from Eq. 8.9
1 x
H |x = √ |0 + exp 2πi |1 ; x = 0, 1 (8.33)
2 2
8.4 quantum Fourier Transform 165
The subscript on the ket vectors indicates its position in the tensor product.
The unitary gates are given below and are obtained by taking the Hermitian con-
jugation of the earlier results using the identity
(A ⊗ B)† = A† ⊗ B †
where
1 0
Rk =
0 exp{2πi/2k }
The quantum circuit for the n = 3 quantum Fourier transform is given in Fig. 8.2 and
mathematically expressed in Eq. 8.32. The quantum circuit given in Fig. 8.2 is the
inverse of the one for phase estimation given in Fig. 8.1: the order of all the gates
have been reversed and all the gates replaced by their Hermitian conjugation; since
the gates are unitary, Hermitian conjugation results in the gate being replaced by
their inverses.
Comparing the circuits for the phase factor and quantum Fourier transform, given
in Figs. 8.1 and 8.2, respectively, note that the state vectors with and without the
phase factors have been interchanged for the two circuits.
The gate H3 acts on the third qubit |x1 3 gates U13 and U23 act on |x1 3 condi-
tioned by |x3 1 and |x2 2 , respectively. To illustrate the workings of the unitary gates
consider, from Eq. 8.35, the following fragment
166 8 Phase Estimation and quantum Fourier Transform (qFT)
Fig. 8.2 Quantum Fourier transform for three qubits. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
U23 H3 |x3 1 |x2 2 |x1 3
x1
= U23 |x3 1 |x2 2 |0 + exp 2πi |1 3
2
= I ⊗ |00| ⊗ I + I ⊗ |11| ⊗ R2 |x3 1 |x2 2 |0 + exp{2πi(0.x1 )}|1
3
since
|02 δ(x2 ) |0 + exp{2πi(0.x1 )}|1
3
+|12 δ(x2 − 1) |0 + exp{2πi(0.x1 + 0.01)}|1
⎧ 3
⎨ |02 |0 + e 2πi(0.x 1 )
|1 : x2 = 0
= 3
⎩ |12 |0 + e2πi(0.x1 x2 ) |1 : x2 = 1
3
= |x2 2 |0 + e2πi(0.x1 x2 ) |1 (8.40)
3
The other gates in Eq. 8.35 have similar action on the qubits and yield
8.5 Quantum Circuit of qFT 167
F3 |x1 x2 x3 = H1 U12 H2 U13 U23 H3 |x3 1 |x2 2 |x1 3
1 x1
= √ H1 U12 H2 U13 U23 |x3 1 |x2 2 |0 + exp 2πi |1 3
2 2
1
= √ H1 U12 H2 |x3 1 |x2 2 |0 + e2πi(0.x1 x2 x3 ) |1
2 3
1
= √ H1 |x3 1 |0 + e2πi(0.x2 x3 ) |1 |0 + e2πi(0.x1 x2 x3 ) |1
22 2 3
1 1
= √ |0 + e2πi(0.x3 ) |1 · √ |0 + e2πi(0.x2 x3 ) |1
2 1 2 2
1
× √ |0 + e2πi(0.x1 x2 x3 ) |1 (8.41)
2 3
Equation 8.41 is the result given earlier in Eq. 8.31, verifying that the unitary gate
F3 yields the quantum Fourier transform. Note the order of the factors in Eq. 8.41
is correct since the swap gate S3 was used to reorder the qubits before applying the
quantum gates.
For the general case, we need to obtain the n-qubit quantum Fourier transformed
state starting from the input state |x1 x2 . . . xn to output state |y1 y2 . . . yn is given
by the unitary transformation (gate) F and, from Eq. 8.29 yields
2n −1
1 2π x y
F(|x) = F |x = √ exp i n |y
2n y=0 2
The construction of a qFT using a quantum circuit is shown in Fig. 8.3 and dis-
cussed in detail in [1]. As was illustrated for the n = 3 case, the quantum Fourier
transform needs two gates, one is the Hadamard gate and the other is a two-qubit
controlled rotation U jk .
The two-qubit controlled rotation Ui j acts on |xi , |x j , where the first qubit
|xi , i = 1, . . . , n is the target qubit and the second qubit |x j is the control qubit.
Similar to the case of n = 3 (in 2 × 2 block diagonal notation), for the conditioning
qubit |x j and target qubit |xi , we have
Fig. 8.3 Circuit diagram for quantum Fourier transform. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
Fig. 8.4 Gates for the quantum Fourier transform. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
Hence, as shown in the circuit diagram given in Fig. 8.3, the quantum Fourier trans-
form is given by
Note a general feature of quantum circuit diagrams exemplified in Eq. 8.42 is that the
order of the gates (operators) given in the circuit diagrams is reversed when these
operators act on the state vector [3].
A graphical representation of some features of the algorithm that generates the
quantum Fourier transform is shown in Fig. 8.4.
Hence, similar to the derivation for the n = 3 case, applying the gates as shown
in Fig. 8.3 yields
References 169
1 1
F|x1 x2 . . . xn = √ |0 + e2πi(0.x1 ...xn ) |1 · √ |0 + e2πi(0.x2 ...xn ) |1
2 n 2 n
1 1
. . . √ |0 + e2πi(0.xn−1 xn ) |1 · √ |0 + e2πi(0.xn ) |1 (8.45)
2 2 2 1
Comparing Eqs. 8.29 and 8.45, we have obtained the quantum Fourier transform of
the n-qubit |x upto to a cyclical reordering of the n-qubits, which can be realized
by the Swap gate. For the n = 3, the swap was implemented before applying the
quantum gates and hence the final result did not need a reordering.
If the number of qubits is large, the angle of rotation x/2n becomes small for
many of the qubits. An approximate qFT can be defined for which x/2n > L, with
the terms with rotation smaller than L being ignored. This approximation greatly
reduces the number of operations and is useful for many applications.
References
The Deutsch algorithm illustrates, using a very special example, that a quantum
computer, in principle, is more efficient than a classical computer.
Consider a binary function f of a single bit. There are four possible binary valued
functions and are given below.
Table 9.1 shows that the four functions can be grouped as follows: a constant
function, that consists of f 0 , f 1 —a constant function gives the same output as the
input—and a balanced function, consisting of f 3 , f 4 , which gives an equal number
of 0’s and 1’s as output.
The question posed by Deutsch is the following: how many times does the function
f have to be measured in order to determine whether it is a constant or a balanced
function? The answer for a classical computer is that the function f has to be called at
least two times and both f (0), f (1) need to be evaluated. One then has the following
result classical result, requiring two measurements for each case:
• f (0) = f (1), implying the function is a constant since
either f 0 (0) = 0 = f 0 (1) or f 1 (0) = 0 = f 1 (1)
• f (0) = f (1), in which case it is a balanced function.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 173
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_9
174 9 Deutsch Algorithm
The Deutsch algorithm shows that the quantum computer needs to call the func-
tion only once to decide whether is a constant or a balanced function, in contrast to
a classical algorithm that needs to call it at least twice. However, unlike the classi-
cal case where both the values f (0), f (1) are know, the Deutsch algorithm cannot
determine the individual values f (0), f (1), only if it is a constant or balanced. This
is a general feature of quantum algorithms, that a very specific question needs to be
asked to see its quantum advantage over a classical algorithm.
The quantum circuit for the Deutsch algorithm is given in Fig. 9.1. Note at the heart of
the Deutsch algorithm is a gate called the oracle U f that, as shown in Fig. 9.1b, reads
input x and produces output f (x) and carries out the following unitary transformation
where
|x : input state; |y : ancillary state
The oracle is unitary since, using binary addition f (x) ⊕ f (x) = 0 yields
The qubit |x|y ⊕ f (x) obtained by the application of the oracle is an entangled
quantum state and forms a necessary part of the quantum circuit. Entangled states
cannot be factorized into a tensor product of the ingredient states; in the case of
Eq. 9.1, as it stands, the ancillary state |y cannot be factored from the input qubit
|x. However, it will be shown that due to the binary nature of the ancillary state |y,
Uf
9.1 The Deutsch Quantum Circuit 175
1
|ψ(t1 ) = H |0H |1 = |0 + |1 |0 − |1
2
1
= |0 |0 − |1 + |1 |0 − |1 (9.2)
2
The oracle is the gate U f defined in Eq. 9.1 and shown in Fig. 9.1, is given by
U f |x|y = |x|y ⊕ f (x)
|ψ(t2 )
1
= U f |ψ(t1 ) = U f |0 |0 − |1 + |1 |0 − |1
2
1
= |0 |0 ⊕ f (0) − |1 ⊕ f (0) + |1 |1 ⊕ f (1) − |1 ⊕ f (1)
2
(9.3)
1
|ψ(t2 ) = |0 | f − |1 ⊕ f + |1 | f − |1 ⊕ f
2
1
= |0 + |1 | f − |1 ⊕ f (9.4)
2
Note the following important identity, which is used in many of the quantum
algorithms discussed later.
176 9 Deutsch Algorithm
⎧
⎨|0 − |1 : f =0
| f − |1 ⊕ f =
⎩− |0 − |1 : f = 1
⇒ | f − |1 ⊕ f = (−1) f |0 − |1 (9.5)
Equation 9.5 shows that the input qubit has been dis-entangled from the ancillary
qubit due to the binary nature of the qubits and leads to many further simplifications.
Hence, from Eq. 9.5, we have
1
|ψ(t2 ) = (−1) f |0 + |1 |0 − |1 : f (0) = f (1) (9.6)
2
Applying the Hadamard gate to the input qubit yields
|0 − |1
|ψ(t3 ) = (H ⊗ I)|ψ(t2 ) = (−1) f |0 √ : f (0) = f (1)
2
Case (ii): f (0) = f (1). From Eq. 9.3, using the binary identities
yields
1
|ψ(t2 ) = |0 | f (0) − |1 ⊕ f (0) + |1 | f (1) − |1 ⊕ f (1)
2
1
= |0 | f (0) − | f (1) + |1 | f (1) − | f (0)
2
1
= − |0 − |1 | f (1) − |1 ⊕ f (1) (9.7)
2
From Eq. 9.5
1
|ψ(t2 ) = −(−1) f (1) |0 − |1 |0 − |1
2
f (0) 1
= (−1) |0 − |1 |0 − |1 : f (0) = f (1) (9.8)
2
Applying the Hadamard gate to the input qubit yields
|0 − |1
|ψ(t3 ) = (H ⊗ I)|ψ(t2 ) = (−1) f (0) |1 √ : f (0) = f (1)
2
Note the fact the ancillary qubit for both cases is unchanged by the quantum circuit.
This is the feature of the ancillary for many quantum algorithms, and the ancillary
qubit can be thought of as a ‘catalyst’, coming out unchanged in the final state. The
9.1 The Deutsch Quantum Circuit 177
ancillary qubit is not observed in the final state as it carries no information about the
function f .
Summarizing the results, we have
⎧
⎨(−1) f |0 |0−|1
√ : f (0) = f (1) = f
|ψ(t3 ) = 2 (9.9)
⎩(−1) |1 √
f (0) |0−|1
: f (0) = f (1)
2
Note the sign (−1) f = ± on the final state is irrelevant since, as mentioned before,
the quantum state is only measured up to a phase.
Measurement of the single binary degree of freedom is executed by applying the
measurement gates, of which there are two gates for the single qubit, to obtain the
final state of the quantum circuit. The measurement gates are
M0 = |00| ⊗ I; M1 = |11| ⊗ I
1
|ψ(t3 ) → Measurement → |x √ |0 − |1 ; x = 0, 1
2
1 if x = 0 : f (0) = f (1)
Tr Mx |ψ(t3 )ψ(t3 )| =
1 if x = 1 : f (0) = f (1)
Hence, a single measurement for input degree of freedom yields the desired result: if
the result of the measurement for outcome |0 has the probability 1, then the function
is a constant, and if not, then the function is balanced . Note that, as mentioned before,
the result of the measurement does not yield any information of what are the values
of f (0), f (1), but instead only if the functions are constant or balanced.
We rewrite the result of the Deutsch algorithm to make a connection with its
generalization given by Deutsch–Jozsa algorithm. Note that
1
|ψ(t2 ) = (−1) f (0) |0 + (−1) f (0)⊕ f (1) |1 |0 − |1 (9.10)
2
Ignoring the auxiliary qubit and applying the Hadamard transformation on the input
qubit yields
178 9 Deutsch Algorithm
H |0 + (−1) f (0)⊕ f (1) |1 = H |0 + (−1) f (0)⊕ f (1) H |1
1
= √ |0 + |1 + (−1) f (0)⊕ f (1) (|0 − |1)
2
1
= √ {1 + (−1) f (0)⊕ f (1) }|0 + {1 − (−1) f (0)⊕ f (1) |1} (9.11)
2
1
|ψ(t3 ) = (−1) f (0) {1 + (−1) f (0)⊕ f (1) }|0 + {1 − (−1) f (0)⊕ f (1) |1}
2
|0 − |1
× √ (9.12)
2
1
4
|(−1) f (0) + (−1) f (1) |2 : Probability to observe |0
(9.13)
1
4
|(−1) f (0) − (−1) f (1) |2 : Probability to observe |1
The result given in Eq. 9.13 is the special case of the result obtained for the Deutsch–
Jozsa algorithm and given in Eq. 10.5.
Chapter 10
Deutsch–Jozsa Algorithm
x = |x1 x2 . . . xn ; xi = 0, 1 : i = 1, 2, . . . , n
The binary expansion of x in terms of the xi yields the following N values for x
0 ≤ x ≤ N − 1; N = 2n
and
1
N −1
1
⊗n ⊗n
|ψ(t1 ) = H |0 H |1 = √ |x √ |0 − |1 ; N = 2n
N x=0 2
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 179
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_10
180 10 Deutsch–Jozsa Algorithm
Fig. 10.1 The Deutsch–Jozsa algorithm. Published with permission of © Belal E. Baaquie and
L. C. Kwek. All Rights Reserved
Hence
1
N −1
1
|ψ(t2 ) = U f |ψ(t1 ) = √ |x √ |0 ⊕ f (x) − |1 ⊕ f (x)
N x=0 2
1 1
√ [| f − |1 ⊕ f ] = (−1) f √ |0 − |1 = (−1) f H |1
2 2
and hence
N −1
1
|ψ(t2 ) = U f |ψ(t1 ) = √ (−1) f (x) |xH |1 (10.1)
N x=0
All the computational basis states in Eq. 10.1 have the same likelihood of occurrence
so a measurement carried out on |ψ(t2 ) will yield no information. Another Hadamard
transformation H ⊗n needs to done on n-qubit state |ψ(t2 ) so that the algorithm can
leverage on the ‘magic’ of constructive and destructive interference that occurs for
superposed states and yield the sought for result.
The binary function f (x) is a mapping from {0, 1}⊗n → {0, 1}. Hence,
To write the Hadamard transformation for the n-qubit, consider first the action of a
single Hadamard H gate on a single qubit. Recall from Eq. 7.4
10 Deutsch–Jozsa Algorithm 181
1 1
H |0 = √ (|0 + |1); H |1 = √ (|0 − |1)
2 2
1
1
⇒ H |x = √ (−1)x y |y (10.2)
2 y=0
1
1
H ⊗n |x1 , x2 , . . . , xn = √ (−1)x1 y1 ⊕x2 y2 ⊕···⊕xn yn |y1 , y2 , . . . , yn
2n y1 ,y2 ,...,yn =0
1
1
⇒ H ⊗n |x = √ (−1)x y |y; x y = x1 y1 ⊕ x2 y2 ⊕ · · · ⊕ xn yn (10.3)
2n y=0
Equation 10.3 is written in abbreviated vector notation with |x (and |y as well)
stands for the label of n qubits
1
N −1
|ψ(t3 ) = H ⊗n ⊗ I |ψ(t2 ) = (−1)x y⊕ f (x) |yH |1 (10.4)
N y x=0
Performing a generalized Born measurement of only the input qubits (and not of the
auxiliary qubit) yields, using the results of Sect. 4.10, the following
The measurement of all the qubits results in |y, which is one of the possible deter-
minate value of the qubits. The probability P(y) for obtaining the determinate value
|y as the final state is given by
1 2
N −1
P(y) = 2 (−1)x y⊕ f (x)
N x=0
Similar to the Deutsch algorithm, to check whether the binary function is balanced
or a constant, we need to find the probability that the final state of the input qubits is
given by
|y = |000 . . . 000
In other words, what is probability P(0) that the state |ψ(t3 ) collapses to the state
|0⊗n ?
182 10 Deutsch–Jozsa Algorithm
Let M0 = |0⊗n ⊗n
0| ⊗ I; then
1
N −1 2
P(0) = Tr M0 |ψ(t3 ) ψ(t3 )| = 2 (−1)x y⊕ f (x)
N x=0 y=0
1 2
N −1
f (x)
= (−1) (10.5)
N 2 x=0
1 : f (x) : constant
=
0 : f (x) : balanced
Recall the sum over x is over all basis states. The Deutsch–Jozsa algorithm states
that the quantum computation yields a final state which, with one observation, can
unambiguously decide whether the function is constant or balanced. As noted earlier,
Eq. 9.13 is the special case of Eq. 10.5 for x = 0, 1.
If the function f (x) is a constant, then every term in the sum in Eq. 10.5 is either
+1 (for f (0) = 0) or −1 (for f (0) = 1); hence, there is constructive interference of
all the terms and yields
N −1 2
1 2
(±1) 1 = 1 : constant function
N 2
x=0
leading to probability 1 (certainty) that the input state |0⊗n will be observed when
the degrees of freedom for the output state are measured.
If the function is balanced, then there are equal number of +1 and −1 terms in
Eq. 10.5 and yields
N −1
1
| (−1) f (x) |2 = 0 : balanced function
N 2 x=0
since all the terms exactly cancel to zero. In other words, there is destructive inter-
ference, with the probability of the output qubit being in the state |0⊗n is zero.
To know precisely what are the values f (x) for the balanced case needs more
information, including the complete definition of the function f (x). For the purpose
of the Deutsch–Jozsa algorithm, the detailed knowledge of f (x) is not necessary.
To determine whether the function f (x) is constant or balanced, a classical com-
puter would have to call the function 2n−1 + 1 times, whereas the quantum computer
can obtain the result with only one measurement. This is an enormous and exponen-
tial improvement. However, this example is not very useful as it does not have much
utility in practice.
If a classical randomized algorithm is used, the number of times the function
needs to be called is much less than 2n ; but if one wants to be certain about the result,
2n−1 + 1 calls of the function are needed for the classical case.
10 Deutsch–Jozsa Algorithm 183
Grover’s algorithm and Shor’s algorithm for factorizing (large) primes are the two
masterpieces of quantum computing. Although Grover’s algorithm is usually consid-
ered in the context of an efficient search for entries in a large database , its potential
uses are pervasive, apparently occurring even in the biological process of protein
synthesis and, in material science, where electrons perform a Grover search in the
search for defects in two-dimensional lattices.1
Consider the following problem. Suppose one has a database of one million
entries. Each entry is, and to a number (the register) and a corresponding object.
Suppose one would like to find the register of a particular object. How many steps
will the computer need to find the number (register) associated with the object?
The classical computer will need to compare each number with the object asso-
ciated with it. For a database with size N , this will take N /2 steps on the average,
since sometimes the correspondence may be found after a few steps, and sometimes √
it may need N steps. The Grover algorithm is far more efficient, requiring only N
steps. It can be shown that no classical computer can be as efficient as the Grover
algorithm. For a database with one million entries, the Grover algorithm requires
only 1000 searches. This is a big saving, in terms of time and resources.
A natural question arises in the Grover search algorithm, which is, if we know
that a particular qubit satisfies the criterion of the sought for result, then are not
we assuming that we know the answer? The answer is ‘No’, since there is a vast
difference between knowing the solution and being able to recognize the solution [1].
To illustrate the difference between knowing and recognizing a solution, consider
a telephone book with the names arranged alphabetically. Suppose now one is given
the phone number and one needs to find the name for that number. Since one does
not have the answer, one needs to check the number with, in principle, every name
in the phone book. Once one finds the name that matches the number, recognizing
1https://www.technologynetworks.com/informatics/news/important-quantum-algorithm-may-
be-a-property-of-nature-324062.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 185
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_11
186 11 Grover’s Algorithm
the name is automatic. Hence, recognizing the solution is different from knowing
the solution. For a telephone book with a million names, doing the search using a
classical computer will take roughly a million steps whereas the Grover algorithm
can complete the search in a thousand steps.
Another example of the difference between knowing and recognizing a solution
is the factorization of primes. Consider a search algorithm for finding the primes of
a large integer m = pq, where p, q are primes: One needs an algorithm to find p, q.
If the solution to the factorization is known, then one knows the values of p, q.
If one does not have the solution, then one needs to find p, q, q < p. For a√classical
algorithm, one starts by generating √ numbers, with x ranging from 1, . . . , m since
the smaller prime q is less than m. For each number x, the code carries out the
relatively easy operation m/x; if x divides m, it is the number q that we are looking
for. The larger prime is then determined by p = m/x.
Hence, recognizing the solution means determining whether x can divide m.
Dividing m by x is far easier that directly factoring m into the prime numbers p, q.
The process of checking, for each x, whether x divides m allows the search algorithm
to ‘mark’ the solution being sought. The advantage of the Grover algorithm over the
classical case is discussed later in Sect. 11.8.
The main steps in the Grover algorithm are outlined with a simple example using
intuitive reasoning to illustrate the more complex operations for the general case. The
essential idea is encapsulated in the phase inversion and the amplitude amplification.
The steps of the Grover algorithm are illustrated in Fig. 11.1. Let |x be the basis
state for n = 2 qubits. The Grover algorithm’s objective is to identify a specific
(marked) basis state that is given to be |ξ = |10. It has the following four steps:
1. Create an initial state in which all the basis states are equally superposed and,
for n = 2, is given by
1
2 −1
1
n
At this stage all the basis states |xi have the same amplitude and shown in
Fig. 11.1a.
2. Construct the oracle gate to identify and mark the state being sought by flipping
the basis state |ξ , which is done by inverting the phase of the marked state from
1 to −1, shown in Fig. 11.1b, and given by
1
|ψ(t1 ) → |ψ(t2 ) = |00 + |01 − |10 + |11
2
11.2 Grover’s Quantum Circuit 187
Fig. 11.1 Phase inversion and amplification in Grover’s algorithm. Published with permission of
© Belal E. Baaquie and L. C. Kwek. All Rights Reserved
3. The flipped basis state |ξ is then amplified using what is called the Grover
diffusion gate, which is not required in this example.
4. The mean of all the amplitudes after flipping the marked state |ξ is +1/2. All the
basis states are reflected about their mean, which in effect, reduces the ampli-
tude of all the basis states except |ξ , which is further amplified, and shown in
Fig. 11.1c and given by
5. The Grover algorithm stops after these three steps since the output is equal to
the marked state with probability one (certainty).
6. For the general case, the process is continued until sufficient accuracy is attained
so that a measurement, with high likelihood, only detects the marked state |ξ .
One can see from the steps enumerated above that the Grover algorithm first
performs a phase inversion to identify the qubit being sought. In general, the algorithm
amplifies the amplitude for the marked basis state and then does another inversion
to attenuate the amplitude of all the basis states, except the marked state.
We now discuss the general case for n-qubits. Let |x signify the basis states that are
being scanned, and for each |x the oracle U f looks up the name associated with the
number. Let ξ correspond to the number that is associated with the name that one is
looking for. The search function f is defined as follows
188 11 Grover’s Algorithm
Fig. 11.2 Quantum circuit for the Grover algorithm. M in the figure stands for measurement.
Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
0 : x = ξ
f (x) = (11.1)
1 :x =ξ
The oracle , similar to the Deutsch algorithm, carries out the following transfor-
mation
The oracle U f looks up for every string of |x, say from the phone book that is
supplied to it, whether the string corresponds to the name one is looking for. If it
finds that one of the string ξ exactly matches the name, it gives an output of 1,
otherwise the output is 0. The algorithm provides no information of what is the value
of the string ξ until a measurement is performed. √
The transformation is applied, in Grover’s case, N times, we see that at every
time step, all the possible values of the string are updated, with only the amplitude of
x = ξ qubit increasing. It is only at the end of the computation, when a measurement
is performed, that the result for ξ emerges. The Grover algorithm is an inverse
function algorithm: given f (x), the algorithm finds ξ .
In summary, the output of the process of quantum computation for the Grover
algorithm produces, with a high likelihood, the qubit |ξ .
The Grover quantum circuit, shown in Fig. 11.2, has the following states and gates.
11.2 Grover’s Quantum Circuit 189
• The input state is the n-fold tensor product of the qubit |0 time the ancillary qubit,
and given by
The oracle operator U f has enough information to ‘mark’ the string state |ξ ; once
this state has been identified by a phase inversion, the diffusion operator W is applied
√
to enhance the probability of this state being observed. The process is repeated N
times so that one is almost certain to observe the state |ξ when the measurement is
performed.
190 11 Grover’s Algorithm
1 1
ψ(t1 ) = H ⊗2 |0⊗2 H |1 = |00 + |01 + |10 + |11 √ |0 − |1 (11.3)
2 2
Let the sought after qubit be |ξ = |10 and hence f (ξ ) = 1;let U f be the oracle
gate. Equations 9.5, 11.1 and 11.2 yield
Hence
U f |10 |0 − |1 = |10|0 ⊕ 1 − |10|1 ⊕ 1 = −|10 |0 − |1
with the rest of the qubits remaining unchanged; note the ancillary qubit |0 − |1
has been restored to its initial value, leaving a net negative sign to the input state
|ξ = |10. Hence, the action of the oracle U f yields
1 1
|ψ(t2 ) = U f |ψ(t1 ) = |00 + |01 − |10 + |11 √ |0 − |1
2 2
√
The ancillary qubit |0 − |1 / 2 does not play any further role and is dropped.
The state vector having no reference to the ancillary qubit is given by the following
1
|ψ(t2 ) → |00 + |01 − |10 + |11 (11.4)
2
At this stage, if a measurement is carried out on |ψ(t2 ), from Eq. 4.18, all the
components of |ψ(t2 ) would have equal likelihood of occurrence and one would
not be able to detect the sought for qubit |10.
There is a unitary transformation (reversible gate), denoted by W , that amplifies the
amplitude for |10 and is the key to the Grover algorithm. The Grover amplification
works by reflecting a sequence of numbers about their mean. If a number is above
the mean, it is reflected to a value below the mean. And if it is less, it is reflected to
a value above the mean.
For the state vector given in Eq. 11.4, its coefficients are 1, 1, −1, 1, with their
average being 1/2. The coefficients with +1 are 1/2 above the average and hence are
reflected to 0; the coefficient −1 is reflected to 2 since it is below the average and is
reflected to the value of 1/2 + 3/2 = 2. Hence, after the reflection we have, as shown
in Fig. 11.3
11.3 Grover Algorithm: Two-Qubit 191
The reversible gate W makes the Grover reflection and yields the result
For the two-qubit case, the Grover search algorithm yields the result with one
updating. The gate W for the two qubits is given by Chris [2]
⎡ ⎤ ⎡ ⎤
−1 1 1 1 0
1⎢ 1 −1 1 1 ⎥ 0 1 ⎢0⎥
W = ⎢⎣
⎥ ; |10 = ⊗ =⎢ ⎥
2 1 1 −1 1 ⎦ 1 0 ⎣1⎦
1 1 1 −1 0
It can be verified that W is reversible since W T W = I. The matrices and input qubits
above yield Eq. 11.6, as expected
⎡ ⎤⎡ ⎤ ⎡ ⎤
−1 1 1 1 1 0
1⎢ 1 −1 1 1 ⎥ ⎢1 ⎥ ⎢0⎥
W |ψ(t2 ) = ⎢ ⎥⎢ ⎥ = ⎢ ⎥ = |10 = |ξ
4⎣ 1 1 −1 1 ⎦ ⎣ −1 ⎦ ⎣ 1 ⎦
1 1 1 −1 1 0
192 11 Grover’s Algorithm
1
N −1
1
|ψ(t1 ) = H ⊗n |0⊗n H |1 = √ |x √ |0 − |1 ; N = 2n
N x=0 2
Hence
1
N −1
1
|ψ(t2 ) = U f |ψ(t1 ) = √ |x √ |0 ⊕ f (x) − |1 ⊕ f (x)
N x=0 2
1 1
√ [| f − |1 ⊕ f ] = (−1) f √ [|0 − |1 = (−1) f H |1
2 2
and hence
N −1
1
|ψ(t2 ) = U f |ψ(t1 ) = √ (−1) f (x) |xH |1 (11.7)
N x=0
N −1
1
|ψ(t2 ) = O √ |x H |1 (11.8)
N x=0
N −1
1 1
N
1 1
|φ = √ |x = √ |x + √ |ξ ; φ|ξ = √ (11.9)
N x=0 N x=ξ N N
N −1
N −1
1 1
O|φ ≡ O √ |x = √ (−1) f (x) |x (11.10)
N x=0 N x=0
11.5 Grover Diffusion Gate W 193
Equations 11.7 and 11.8 show that the oracle U f can be completely replaced by
the operator O acting only on the input qubits. For this reason, the Grover algorithm
does not depend on the ancillary qubit H |1 and henceforth it will be dropped.
Note from Eq. 11.9 that the sought for qubit |ξ has almost no overlap with the
input qubit |φ; hence on observing the input degrees of freedom, the likelihood
of observing |ξ is negligible. To increase the amplitude of the |ξ qubit being the
outcome of the measurement, the reflection process used for two qubits needs to be
generalized for n- qubits.
Note from Eq. 11.10 that
N −1
N −1
N −1
O |x = (−1) f (x) |x = −|ξ + |x
x=0 x=0 x=ξ
O = I − 2|ξ ξ | (11.11)
N −1
N −1
N −1
O |x = I − 2|ξ ξ | |x = |x − 2|ξ
x=0 x=0 x=0
Hence
N −1
1 2
√ O| |x = |φ − √ |ξ ; O|ξ = −|ξ
N x=0
N
The oracle U f has marked the qubit that we are looking for. As in the two-qubit
case, the marked qubit |ξ in the state function |ψ(t2 ) has to be amplified so that on
measurement of the state function we observe qubit |ξ with high likelihood [3].
The amplification is carried out by what is known as the diffusion operator W ,
which is the generalization of the reflection operator used for the two-qubit case. The
diffusion gate W is defined by
W = 2|φ φ| − I
2
⇒ W |φ = |φ ; W |ξ = √ |φ − |ξ
N
In terms of the diffusion gate, the equation for the Grover algorithm is given by
the following
194 11 Grover’s Algorithm
From Eq. 11.12, we see that the recursion equation that needs to be studied is
G|φ. After k-recursions, the final state function for Grover’s algorithm is
|ψk = G k |φ
The solution sought√for by the algorithm, as shown below, is achieved after applying
operator G K = π N /4 times and yields
π√
|ψ(t3 ) → G K |φH |1 ; K = N
4
The scheme of computation is given in Fig. 11.4. Every recursion of G k |φ rotates
the state |φ toward |ξ .
Consider the following decomposition
N −1 N −1
1 N −1 1 1
|φ = √ |x = √ |x + √ |ξ
N x=0 N N − 1 x=ξ
N
N −1
N −1 1 1
⇒ |φ = |η + √ |ξ ; |η = √ |x (11.14)
N N N − 1 x=ξ
11.5 Grover Diffusion Gate W 195
Define
θ N −1 θ 1
cos = ⇒ sin =√ (11.15)
2 N 2 N
Equation 11.20 shows that the action of G, on the two-dimensional space spanned
by |η, |ξ , is to rotate the vectors |φ toward |ξ , as shown in Fig. 11.4.
196 11 Grover’s Algorithm
The Grover algorithm consists of doing a sequential application of the oracle and
diffusion operators to make the initial state function parallel to the qubit |ξ . Each
application of O marks the sought for state and yields O|φ; W then makes a reflection
of the state O|φ about |φ and yields W O|φ = G|φ, thus bringing the resultant
state closer and closer to the qubit |ξ . See Fig. 11.4.
Suppose after k recursions, we obtain [4]
θ θ
|ψk = G k |φ = ak |ξ + bk |η : a0 = sin ; b0 = cos (11.21)
2 2
Note that
Hence, from Eq. 11.21, after k-recursions the n-qubit is the following
θ θ
|ψk = G k |φ = sin + kθ |ξ + cos + kθ |η (11.27)
2 2
2
θ √
N
and
1 2k 1 2k
|ψk sin √ + √ |ξ + cos √ + √ |η (11.28)
N N N N
To take the input qubit close to |ξ , one needs to continue the recursion N times
until
π√
k→K = N ; N = 2n (11.29)
4
and shown in Fig. 11.5.
Equation 11.28 yields
1 π 1 π
|ψ K = sin √ + |ξ + cos √ + |η |ξ (11.30)
N 2 N 2
On measuring all the n-output qubits with measurement gates M = |x x|, shown
in Fig. 11.5, leads to the result
Fig. 11.5 Graphical representation of the Grover algorithm, with G = W O. Published with per-
mission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
π
sin2 =1 :x =ξ
Tr |x x|ψ K ψ K | = | x|ψ K | 2 2 (11.32)
0 : x = ξ
Hence, on measuring the degrees of freedom for the output state, one obtains the
result of |ξ —with probability almost equal to 1.
In summary, starting from an input n-qubit state in which all the√ computational
basis states are equally likely, after applying the Grover rotation π 2n /4 times, on
measuring the n-degrees of freedom, the output has probability close to 1 for the
sought for state |ξ .
Grover’s algorithm can be generalized to seeking a linear combination of M output
states as the required outcome. One generalizes the decomposition given in Eq. 11.14
to the following
N −1 −M
1
N
M 1
M
N−M 1
|φ = √ |x = √ |x + √ |x
N x=0 N N − M x=M+1 N M x=1
N−M M
⇒ |φ = |η + |ξ (11.33)
N N
where
−M
N
1
M
1
|η = √ |x ; |ξ = √ |x
N − M x=M+1 M x=1
θm M M
sin = ⇒ θm 2
2 N N
Hence, the number of times that the oracle needs to be called, similar to Eq. 11.29,
is given by
π N
k → Km = ; N = 2n (11.35)
4 M
To understand the workings of the Grover algorithm, the earlier result for two qubits
obtained by the process of reflection is analyzed using the general result obtained
for the n-qubit case.
Note for a single recursion (k=1), the output qubit from Eq. 11.27 is given by
3θ 3θ
|ψ1 = G|φ = sin |ξ + cos |η (11.36)
2 2
As before, we can ignore the ancillary qubit and focus on the input qubit. Suppose
the qubit we are looking for is |ξ = |01. As before, the two-qubit input is separated
into |ξ , |η as follows
√
1 1 3 1
|φ = |00 + |01 + |10 + |11 = |01 + √ |00 + |10 + |11
2 2 2 3
√
1 3 1
⇒ |φ = |ξ + |η : ξ |φ = : ξ |η = 0 ; η|η = 1(11.37)
2 2 2
Hence, for the two qubits, we have the decomposition shown in Fig. 11.6 and
yields
θ θ θ 1 π
|φ = sin |ξ + cos |η : sin = ⇒ θ= (11.38)
2 2 2 2 3
200 11 Grover’s Algorithm
Recall
G = 2|φ φ| − I I − 2|ξ ξ |
Applying operator G to the two-quit bit state given in Eq. 11.38 yields
and we have recovered the result obtained earlier in Eq. 11.6 for the two qubits using
reflections. The general result, from Eq. 11.36 and for θ = π/3, yields
3θ 3θ π π
G|φ = sin |ξ + cos |η = sin |ξ + cos |η
2 2 2 2
⇒ G|φ = |ξ = |01 (11.40)
Equation 11.40 confirms the result obtained in Eq. 11.39 that for a two-qubit,
Grover’s algorithm needs to be run only once to arrive with certainty at the sought
for qubit |01. In contrast, a classical computer—or classical circuit—for a search in
N = 22 = 4 numbers would need to the call the oracle, on the average, 2.25 times
[1].
11.8 Discussion
2 Shor’s algorithm is more efficient for factorizing primes, but for pedagogical purposes, the fac-
torization of primes is a good example for explaining Grover’s algorithm.
11.8 Discussion 201
algorithm,
√ the total number of degrees of freedom required for the prime factorization
is N = m, with x ranging from 1, . . . , N .
For each number x, the oracle carries out the relatively easy integer division given
by N /x; if x divides N , it is the marked state ξ that we are looking for. Hence, the
oracle for factorizing an integer made out of two primes defines the marked basis
state ξ by the following
ξ : if N /x = integer
x=
x : if N /x = integer
The oracle (search function) f (x) given in Eq. 11.1 is defined as follows
0 : x = ξ
f (x) = (11.41)
1 :x =ξ
N −1
1
|ψ(t2 ) = U f |ψ(t1 ) = √ (−1) f (x) |xH |1
N x=0
In contrast, a classical algorithm cannot update the different allowed state simulta-
neously since the classical updating needs to do be done one by one.
202 11 Grover’s Algorithm
References
1. Nielsen MA, Chuang IL (2012) Quantum computation and quantum information. Cambridge
University Press, UK
2. Chris B (2019) Quantum computing for everyone. MIT Press, USA
3. Bernard Z (2018) A first introduction to quantum computing and information. Springer, UK
4. Rieffel Eleanor G, Polak Wolfgang H (2011) Quantum computing: a gentle introduction. MIT
Press, USA
Chapter 12
Simon’s Algorithm
At the outset of quantum algorithms in the early nineties, there were not many prac-
tical algorithms that show significant advantage of a quantum computer to a classical
computer. In 1994, Daniel Simon came up with one of the earliest examples [1].
In Simon’s problem, we are given an unknown function f implemented with a
black box or oracle such that f : {0, 1}n → {0, 1}n satisfies the property that for all
x, y ∈ {0, 1}n , there exists a nonzero element a ∈ {0, 1}n
x ⊕ y =a ⇒ y = x ⊕a
In the quantum algorithm, we start with the initial state with two registers
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 203
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_12
204 12 Simon’s Algorithm
1
|ψ2 = √ |i|0⊗n (12.2)
2n i∈{0,1}n
1
U|ψ2 = |ψ3 = √ |i| f (i)
2n i∈{0,1}n
1
= √ |i| f (i) + |i ⊕ a| f (i ⊕ a)
2n+1 i∈{0,1}n /2
1
= √ |i + |i ⊕ a | f (i) (12.3)
2n+1 i∈{0,1}n /2
since f (i ⊕ a) = f (i).
By measuring all the qubits i, we observe one of the qubits, say i = i 0 , with some
probability. The Born rule, discussed in Sect. 4.5, yields a single term from the sum
given in Eq. 12.3, corresponding to some i = i 0 , given by
The state vector of the first register, as a result of the measurement, is left in the
state
1
|ψ4 (i 0 ) = √ |i 0 + |i 0 ⊕ a
2
Note that from Eq. 7.4, the Hadamard transformation for n qubits can be written as
1
H ⊗n |x = √ (−1)x y |y
2n y∈{0,1}n
|ψ5 = H ⊗n |ψ4 (i 0 )
1
= √ (−1)i0 · j + (−1)i0 · j | j ; i 1 ≡ i 0 ⊕ a (12.4)
2n+1 j ∈{0,1}n
The Hadamard transformation introduces n-qubits labeled by j . Let all the qubits
denoted by j be measured, and let the outcome of the measurement be given by j.
The probability of obtaining this result is given by
12.2 An Illustrative Example 205
1 2
P(i 0 , j) = Tr M( j)|ψ5 ψ5 | = (−1)i0 · j + (−1)i1 · j (12.5)
2n+1
If the output is zero, the result is discarded. The output will be nonzero if
(−1)i0 · j = (−1)i1 · j
⇒ i0 · j = i1 · j
⇒ i 0 · j = (i 0 ⊕ a) · j
⇒ i0 · j = i0 · j ⊕ a · j
⇒ a · j ≡ 0 (mod2). (12.6)
The string j = j1 is recorded and the inner product with a is zero mod 2.
Repeating the algorithm roughly n times, we get n different values of ji (i =
1, . . . , n) satisfying
a · j1 = 0
a · j2 = 0
a · j3 = 0
..
.
a · jn = 0. (12.7)
From Eq. (12.7) a can be determined easily with classical methods (say Gaussian
elimination).
This algorithm is a precursor to Fourier transform corresponding to a period of two.
For the general case of the function having the periodic property of f (x) = f (x + a)
with addition not being binary but of two numbers, one needs the quantum Fourier
transform for solving it and forms the core idea of the Shor algorithm.
Let us now consider a particular example involving a function f : {0, 1}3 → {0, 1}3 .
Let us also suppose that a = 101.
We first initialize two three-qubit registers to |0001 ⊗ |0002 .
Since a = |101, we have
Fig. 12.1 Simon’s algorithm for a function acting on three qubits. Published with permission of
© Belal E. Baaquie and L. C. Kwek. All Rights Reserved
1 H ⊗H ⊗H 1
√ (|010 + |111) −→ (|000 − |010 + |101 − |111) (12.8)
2 2
and a measurement of the first register yields any of the four states
with equal probability (in this case 1/4). Therefore, after many measurements, we
get
a · 000 ≡ 0 mod 2
a · 010 ≡ 0 mod 2
a · 101 ≡ 0 mod 2
a · 111 ≡ 0 mod 2.
This is a set of simultaneous equation. Assuming that a = (x, y, z), then we see that
except for the first equation above, the rest of the equations translate into:
y ≡ 0 mod 2
x + z ≡ 0 mod 2
x + y + z ≡ 0 mod 2,
Reference 207
from which it is not difficult to deduce that the solution is a = 101. Note that the
first equation is not very useful. There is typically a minimum number of equations
needed, but it is still better than existing methods with classical computers.
Reference
13.1 Introduction
The Shor algorithm is widely regarded as the first non-trivial quantum algorithm that
shows a potential of an ‘exponential’ speeding-up over its equivalent classical algo-
rithms. Proposed by Peter Shor in 1994, the algorithm seriously challenges existing
classical algorithms for integer factorization [1].
Why is Shor’s algorithm so important?
For many years, the security of the many Internet transactions and the secure
transfer of secret and confidential documents has relied on the fact that one could
encrypt information using a publicly available key, but the reverse process of decod-
ing the encrypted message relies on the difficulty of factoring a large (seriously
large) integer. Such a scheme was first devised by a trio of computer scientists and
mathematicians, Ron Rivest, Adi Shamir and Leonard Adleman in the seventies [2].
The scheme now known as the RSA public-key cryptosystem relies precisely on
this difficulty of factoring a big number formed from the product of two large prime
numbers. In short, although multiplying two large prime numbers is easy, factoring
is difficult. The easy computation (multiplication) is used for encryption, and the
difficult computation (factoring) is needed for decoding or decryption.
Peter Shor showed, in 1994, that if we have a workable quantum computing
machine, then we should be able to factorize any product of two large primes more
easily and faster than any classical algorithm. To factorize a number N into its prime
factors, one needs to find cycle (period) r of a periodic function (defined below) that
takes a classical computer about exp(N 1/3 ) steps; in contrast, using Shor’s algorithm,
the algorithm takes only N 3 number of steps [3]. This exponential acceleration means
that many encrypted codes based on factoring a large number N into its primes can
be decoded by Shor’s algorithm.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 209
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_13
210 13 Shor’s Algorithm
To understand the Shor algorithm, it is instructive to know how the classical algorithm
works. Let us start with a simple example. Suppose we wish to find the prime factors
of the number 15. The classical algorithm to factorize 15 goes as follows:
1. Choose any number that has no common divisor to 15, a say 2.
2. Consider the sequence of numbers {a i } for i = 0, 1, 2, · · · :
We see that there is a repetition of the outcomes in the sequence; after every four
numbers, the sequence returns to the number 1. We say that the sequence has a
cycle length r of 4.
3. Determine GCD(a r/2 ± 1, 15)= GCD(22 ± 1, 15) which obviously yield 3 or
5, where GCD is the greatest common divisor.
The difficult thing about this algorithm is getting the cycle length r . For the number
15, it was straightforward, in fact trivial. However, for a large prime number, this is
not so. For instance, the 100th prime1 is 541, and the 101st prime is 547. The product
of these two primes is N = 295827. If we choose a = 3 and consider the sequence of
numbers 3r Mod (N ), on a modestly fast laptop it takes at least 10 s before it yields
the correct cycle length, which is r = 1890.
The classical algorithm relies on the determination of the cycle length. Let us now
present Shor’s elegant algorithm for finding this cycle length. The description follows
closely the treatment in [4, 5]. The principal idea in the algorithm is the creation a
state with periodicity r , and then apply Fourier transform over Z Q , (the additive group
of integers modulo Q), to reveal this periodicity. The quantum Fourier transform over
the group Z Q is defined as follows
1 2πiab/Q
Q−1
|a −→ √ e |b = | Q,a (13.1)
Q b=0
1 One can try to use the 2020th and 2021th prime. Their product is 308 915 767. However, a laptop,
after five hours, fails to find the cycle length.
13.3 Quantum Algorithm 211
f (x) = a x Mod N
Note that
In accordance with Euler’s theorem, the function has the crucial property that it is a
periodic function of x with some period r . Hence, for integer p
f (x + s) = f (x) ; s = pr
Note that due to the fact that f (x) = a x Mod N , the function f (x) never takes the
same value within one period.
1
Q−1
|ψ1 = H ⊗n |0⊗n ⊗ |0⊗n = √ |x ⊗ |0⊗n (13.2)
Q x=0
Note the quantum algorithm is based on the input state |ψ1 that can be created
by the hardware.
2. Use unitary transformation U f to create the state
1
Q−1
|ψ f = U f |ψ1 = √ |x ⊗ | f (x) (13.3)
Q x=0
3. Let the total number of qubit states be divided into periods of length r . The number
of states in each cycle is given by A where
Q Q
A=[ ] or A = [ ] + 1 ; Q = 2n
r r
4. Using f (x + kr ) = f (x), Eq. 13.3 yields
r −1 A−1
1
|ψ f = U f |ψ1 = √ |xi + kr ⊗ | f (xi + kr )
Q i=0 k=0
r −1 A−1
1
=√ |xi + kr ⊗ | f (xi ) (13.4)
Q i=0 k=0
Note the important fact that the quantum algorithm is based on the explicit repre-
sentation of the input state given in Eq. 13.2, for which we do not need to know the
numerical value of r . To rewrite the summation as in Eq. 13.4 is a mathematical
transformation of the input state, and for doing so all that we need to know is that
Q > A > N , which is guaranteed since Q N 2 .
5. The auxiliary state vector | f (xi ) is available to the device, although the pre-
factor that contains a sum over r is not known. A measurement is carried out
on the |x qubit states; the measurement yields, with some likelihood, the state
vector to which |ψ f has collapsed to and yields a particular value of the state
vector which is denoted by |xi → |x0 . Note the important fact that to perform
this measurement, no knowledge of r is required.
The state vector given in Eq. 13.4 is entangled: the state vector’s dependence on
the degrees of freedom xi and k is not factorizable into product state vectors. The
generalized Born rule for measurement, discussed in Sect. 4.10, states that if the
measurement yields the state vector to be, with some likelihood, in the state |x0 ,
then the resultant post-measurement state vector is given by
13.3 Quantum Algorithm 213
|ψ f (x) → |ψ3 (x0 )| f (x0 ) ; ψ3 (x0 )|ψ3 (x0 ) = 1 (13.5)
where
1
A−1
|ψ3 ≡ |ψ3 (x0 ) = √ |x0 + kr (13.6)
A k=0
The post-measurement state given in Eq. 13.5, for different values of x0 occurs
with different likelihoods, as discussed in Sect. 4.10. Since the analysis of the
state |ψ3 is valid for all values of x0 , we do not need to know the likelihood of
the various post-measurement states for the different values of x0 .
The generalized Born rule does the magic of picking out the state vector |ψ3 ,
which contains the number A that has information about r . The auxiliary state
has factored out and will be ignored henceforth. It is now a matter of another
measurement that allows us to isolate r and hence factorize N into a product of
two primes.
6. Apply the quantum Fourier Transform on the first register
⎛ ⎞
1 ⎝ 1 2πi( jr +x0 )k/Q ⎠
Q−1 A−1
|ψ3 = √ √ e |k
Q k=0 A j=0
7. Measure only the first register. Let |k1 be the outcome of the measurement; the
probability is given by
Tr M(k1 )|ψ3 ψ3 |
⎛ ⎞ 2
1
A−1
= ⎝√ exp [2πi( jr + x0 )k1 /Q]⎠
Q A j=0
2
x 0 k1
A−1
1 jr k1
= √ exp(2πi ) exp(2πi )
QA Q j=0 Q
2
1
2 A−1
x 0 k1 jr k1
= exp(2πi ) √ exp(2πi )
Q Q A j=0 Q
2
1 A 1
= √ A = , (13.7)
QA Q r
r k1
is some integer m 1
Q
214 13 Shor’s Algorithm
k1 m1
⇐⇒ r k1 ≡ 0 Mod Q
Q r
This gives possible r s as r1 , r2 which we can check to see if it is the correct r (see
analysis with continued fractions later).
It is interesting to note that in the second step of the algorithm, all numbers between
0 and Q − 1 are present in the superposition, with equal weights. Subjecting this
linearly superposed state to a unitary transformation associated with the function,
generating the sequences of numbers, {a 0 , a 1 , . . . a r −1 } is analogous to a parallel
processing of all numbers from 0 to Q − 1. The third step of the algorithm groups
the numbers in the sequence into sets, each with periodicity r . This is done as follows:
there are r possible values written on the second register: a ∈ {a 0 , a 1 , . . . a r −1 }. The
state in the third step can thus be written as:
⎛⎛ ⎞ ⎛ ⎞
1 ⎝⎝
Q−1 Q−1
√ |l ⊗ |a⎠ + ⎝ |l ⊗ |a 2 ⎠ + · · ·
Q
x=0|a l =a x=0|a l =a 2
⎛ ⎞⎞
Q−1
+⎝ |l ⊗ |a r ⎠⎠ = 1 (13.8)
x=0|a l =a r
Note that the values l that give a l = a have periodicity r : If the smallest such l is x0 ,
then x = x0 + r, l0 + 2r, . . . will also give a x = a. Hence, each term in the brackets
has periodicity r . Each set of x’s, with periodicity r , is attached to a different state
of the second register. Before the computation of a x , all x’s appeared equally in the
superposition.
Writing down the a x on the second register can be thought of as giving a different
‘color’ to each periodic set in [0, Q − 1].
The measurement of the second register picks randomly one of these sets. The
state then collapses to a superposition of l’s with periodicity r and an arbitrary shift
l0 . To determine the the periodicity, we apply Fourier transform.
We then measure the first register, to obtain k. To find the probability to measure
each k, we need to sum up the weights coming from all the j’s in the periodic set.
13.3 Quantum Algorithm 215
2
1 2πik( jr +x0 )/Q
A−1
Prob(k) = √ e (13.9)
Q A j=0
2
1 2πikr/Q j
A−1
= √ (e ) (13.10)
Q A j=0
In the case of imperfect periodicity, r does not divide Q, it turns out that with
high probability, we will measure only k’s which satisfy an approximate criterion
kr ≈ 0 mod Q. In particular, consider k’s which satisfy:
There are exactly r values of k satisfying this requirement, because k runs from
0 to Q − 1, therefore kr runs from 0 to (Q − 1)r , and this set of integers contains
exactly r multiples of Q. Now the probability to measure such a k is bounded below,
by choosing the largest exponent possible. It is interesting to note that a slightly
different way of arriving at the same conclusion is:
1 2πikr/Q j 2
A−1
Prob(k) = | √ (e ) |
Q A j=0
1 1 − ei2kπr A/Q 2
= | |
Q A 1 − ei2kπr/Q
1 eikπr A/Q (e−ikπr A/Q − eikπr A/Q ) 2
=
Q A eikπr/Q (e−ikπr/Q − eikπr/Q )
1 sin( Q ) 2
kπr A
=
Q A sin( kπr
Q
)
1 sin(kπ ) 2 Q
≈ | kπr | where we have assumed A ≈ and Q r
QA Q
r
1 1 2 sin(kπ )
≈ | | choosing k so that ≈1
Q A Qr kπ
1 Q2
=
Q A r2
1 Q
≈ using r ≈
r A
The approximation arises due to the fact that Q is chosen to be much larger than N >
r , in which case the sine term in the numerator is close to 1 with negligible correction
of the order of r/Q. In the denominator, we use the approximation: sin(x) ≈ x for
small x, and the correction is again of the order of r/Q. The probability to measure
any k which satisfies 13.11 is approximately 1/r .
At this juncture, let us consider an example of a specific case where Q = 200
and r = 13. Let A = [Q/r ] = 15. We can now plot the probabilities Prob(k) for
1 ≤ k ≤ 199. From Fig. 13.2, we see that there are some k values that give higher
probabilities than others. Here k = 15, 31, 46, 77 and 92 gives Prob(k) > 0.04. Sup-
pose a measurement of the probabilities yield k = 77. In this case, a good approxi-
k 77
mation is to consider the continued fraction of = = {0, 2, 1, 1, 2, 15} which
Q 200
13.3 Quantum Algorithm 217
occurs with a probability approximately 1/13 ≈ 0.07. From the continued fraction,
77
{0, 2, 1, 1, 2, 15}, we see that the fractions below all approximate :
200
1
0 + 1/2 =,
2
1
0 + 1/(2 + 1/1) = ,
3
2
0 + 1/(2 + 1/(1 + 1/1)) = ,
5
5
0 + 1/(2 + 1/(1 + 1/(1 + 1/2))) =
13
We clearly see that r = 13 is one of the possibilities. It is then possible to figure out
the correct r from several measurements.
Why are such k’s ‘good’? Given an integer k which satisfies the criterion 13.11,
we can find r with reasonably high probability. Note that for ‘good’ k’s, there exists
an integer m such that:
k m 1
| − |≤ .
Q r 2Q
There is only one fraction with such a small denominator that approximates a
fraction so well with such large denominator. Given k/Q, the approximating fraction,
m
r
, can be found efficiently, using the method of continued fractions:
1
a = a0 + ,
a1 + a21+·
where ai are all integers. Finding this fraction, the denominator will be r ! There is
high probability that m is coprime to r . The probability is greater than 1/ log(r ). If
not, we repeat the iteration.
This concludes Shor’s algorithm.
References
1. Shor PW (1994) Algorithms for quantum computation: discrete logarithms and factoring. In:
Proceedings 35th annual symposium on foundations of computer science. IEEE, pp 124–134
2. Calderbank M (2007) The rsa cryptosystem: history, algorithm, primes. Chicago: Math.
Uchicago. Edu
3. Mermin ND (2007) Quantum computer science. Cambridge University Press, UK
4. Michel LB (2006) A short introduction to quantum information and computation. Cambridge
University Press, UK
5. Artur E, Richard J (1996) Quantum computation and shor’s factoring algorithm. Rev Mod Phys
68(3):733
Part III
Applications
Chapter 14
Quantum Algorithm for Option Pricing
One of the main areas for the application of quantum algorithms is in the pricing
of options. An introductory text cannot do justice to this fast-evolving subject, and
hence the discussion will focus on only the pricing of a European call or a put option.
Other more complex financial instruments are left for further reading.
The approach of this chapter is the one taken in [1–3]. The principles of finance
are taken from the existing theories of finance, and financial instruments are not
assumed to have any quantum indeterminacy—but rather, the uncertainty in the
future values of financial instruments is determined by classical probability theory.
Quantum algorithms are focused on more efficient procedures for evaluating option
prices.
The price of all options is the discounted value of the expectation value of a payoff
function in the future, with the future uncertain price of financial instruments, like
stocks or bonds, being represented by classical random variables. Most numerical
studies of option pricing are based either on solving the relevant partial differential
equations or on Monte Carlo simulations of the stochastic equations [4].
Consider the price of a path independent option C(x, t, T ) at present time t, and
which matures at a future time T . The payoff function of the option ν(x) is defined
to be the price of the option when it matures at a future time T and is given by
The evolution of the stock price S = e x(t) is given by a stochastic differential equation.
The payoff function of a call option is given by
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 221
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_14
222 14 Quantum Algorithm for Option Pricing
ν(x) = [e x − K ]+
Let the initial stock price be S = e x0 , with spot interest rate given by r and remain-
ing time for maturity of option given by τ = T − t; let the price of the option for
remaining time be given by C(x, τ ). Let P(x0 , x; τ ) be the conditional probability
that given the stock price is S = e x0 today, it has a value of e x after time τ ; the
discounted price of the payoff yields the option price is given by
C(x0 , τ ) = e−r τ dx P(x0 , x; τ )ν(x) = e−r τ dx p(x)ν(x)
where
Ignoring for the rest of the discussion the discounting by the spot interest rate. The
price of the call option is given by evaluating the expectation value E[ν]. Equa-
tion 14.1 yields the following expectation value
E[ν] = dx p(x)ν(x) (14.3)
Note that an European and American call option’s price is always less than the
security S = e x0 [4]; hence by dividing out by S = e x0 , one can always redefine the
payoff function so that
For ease of notation, we use ν and e−x0 ν interchangeably, and the difference will be
known from the context of the equation.
If one does a Monte Carlo simulation for the evolution of the stock price using
its stochastic differential equation, then after N trials of evolving the initial value of
the log of stock x0 to its final random values x (i) , the Monte Carlo estimate of the
expectation value, from Eq. 14.3, is given by
1
N
σν
E MC [ν] = ν(x (i) ) ± √ with 66% likelihood
N i=1 N
N −1
σν
E[ν] = p(x (i) )ν(x (i) ) ± with 66% likelihood
i=0
N
14.2 Quantum Algorithm 223
N −1
σν
E[ν] = p(x)ν(x) ± with 66% likelihood (14.5)
x=0
N
The basic strategy for applying quantum algorithms to option pricing is to map the
computation required for evaluating the option’s price to an equivalent quantum
algorithm. One is then free to use the resources of both quantum entanglement and
superposition in improving the efficiency of the quantum algorithm, which for option
pricing achieves a quadratic improvement when compared to the classical Monte
Carlo simulation. It is worth noting that one is evaluating a classical quantity using
the computational tools of a quantum algorithm.
A quantum algorithm for pricing options has the following distinct steps.
1. The classical random variable x with the probability distribution function p(x)
given by Eq. 14.2 is discretized and replaced by n binary quantum degrees of
freedom, which yields the basis states |x with x = 0, 1, . . . , 2n − 1, with N = 2n .
2. The basis states are combined into a superposed state to encode the option’s √ data.
3. The probability distribution function p(x) defines the function α(x) = p(x),
and the initial data of the option is encoded into the state vector |ψ.
4. The superposed basis states |x yield the n qubits state vector
2
n
−1 2
n
−1
|ψ = a(x)|x ; |a(x)|2 = 1
x=0 x=0
5. A state that entangles the state vector |ψ with the payoff function ν is created
using an auxiliary qubit and is given by
2
n
−1
|ψ → |η = a(x)|x 1 − ν(x)|0 + ν(x)|1
x=0
6. In Sect. 14.4 onwards, amplitude amplification is applied to the quantum state |η.
A quantum gate (oracle) is applied simultaneously to all the basis states and the
auxiliary qubit. At the end of the application of the gate, one of the states that
hold the correct answer is marked, as in the case of Grover’s algorithm.
224 14 Quantum Algorithm for Option Pricing
7. The probability of measuring the marked state is amplified using quantum gates
that achieve amplification using quantum interference.
8. A generalized Born measurement is carried out on the final qubits.
We discuss a quantum algorithm that is valid for any expectation value. The algorithm
for amplitude amplification is later built on this algorithm.
The required quantum algorithm yields the following expectation value
2
n
−1
E[ν] = |a(x)|2 ν(x)
x=0
The algorithm is defined by the following [5]. Consider an ancillary qubit state
|0 and a conditional gate R such that
R |x|0 = |x 1 − ν(x)|0 + ν(x)|1
2
n
−1
⊗n
A|0 = a(x)|x (14.6)
x=0
Hence
2
n
−1
|η = R A|0⊗n |0 = R a(x)|x|0 ; η|η = 1
x=0
2
n
−1
⇒ |η = a(x)|x 1 − ν(x)|0 + ν(x)|1 (14.7)
x=0
The state vector |η is a rotation of state vector |ψ through an angle γ and shown
in Fig. 14.1. The unitary transformation F is given by
F = R(A ⊗ I2 ) : F |0⊗n |0 = R(A ⊗ I2 ) |0⊗n |0 = |η (14.8)
where
2 −1 2 −1
1 1
n n
| 0 = √ a(x)|x 1 − ν(x) ; | 1 = √ a(x)|x ν(x)
p(0) x=0 p(1) x=0
and
2
n
−1 2
n
−1
p(0) = |a(x)| (1 − ν(x)) ; p(1) =
2
|a(x)|2 ν(x)
x=0 x=0
The probability of observing the ancillary qubit |1 is given by the following expec-
tation value
−1
2 n
μ = p(1) = η| In ⊗ |11| |η = η|11|η = |a(x)|2 ν(x)
x=0
⇒ μ = E[ν] ≈ dx p(x)ν(x) (14.9)
Hence, we see from Eq. 14.9 that any expectation value can be re-expressed as a
quantum algorithm. The only constraint in finding the expectation value is that,
since 0 ≤ μ ≤ 1, we must have that ν(x) ≤ 1 for all x.
Equation 14.9 is based on sampling a random outcome many times and hence
reproduces the classical Monte Carlo result. In observing the ancillary qubit, we
have two outcomes: |1 with probability μ and |0 with probability 1 − μ; this is
a Bernoulli random variable with σμ2 = μ(1 − μ). From the central limit theorem,
performing the measurement N , the accuracy of the estimate is given by
σμ
μ̃ = μ ± √ with 66% likelihood
N
The accuracy and speed are the same as the classical Monte Carlo calculation.
Fig. 14.1 Rotations of the initial qubit state |ψ to the final state Q|ψ. Published with permission
of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
The state vector V |η is a reflection of |η about the axis defined by the state vector
|ψ, and is shown in Fig. 14.1.
The angle between the state |η, defined in Eq. 14.7, and V |η yields the angle θ ,
as shown in Fig. 14.1, and given by the following
2π θ
cos ≡ η| V |η = η|V |η
2
= η|η − 2η|11|η = 1 − 2η|11|η
2
n
−1
= 1−2 |a(x)|2 ν(x) = 1 − 2μ
x=0
1
⇒ μ = (1 − cos(π θ )) (14.10)
2
Once θ is evaluated, the price of the option μ can be obtained from it.
14.4 Algorithm for Quadratic Improvement 227
The rotation operator Q needs to be defined that will act on the input qubit |ψ and
rotate it in the plane spanned by |η and V |η through an angle 2θ to yield state vector
Q|ψ. Following the derivation given in Patrick et al. [5], define another operator
U = I2n+1 − 2|ηη|
Note that
U |η = −|η ; U |η⊥ = |η⊥ : η|η⊥ = 0
and hence −U reflects about the axis defined by |η, leaving the state vector |η
unchanged. Define the operator
U = FZF †
since
Define the diffusion operator Q, similar to the case of Grover’s rotation operator,
that rotates the initial state vector |ψ and is given by Patrick et al. [5]
Q = U (V U V ) ≡ U S
= I2n+1 − 2|ηη| V I2n+1 − 2|ηη| V
= I2n+1 − 2|ηη| I2n+1 − 2V |ηη|V (14.12)
since V 2 = I2n+1 .
The action of Q = U S, with S = V U V and U = F Z F † , on an arbitrary state
|ψ in the span of |η and V |η is shown in Fig. 14.1. First, the action of −S on |ψ is
to reflect along V |η, resulting in the intermediate −S|ψ. Then, −U acts on −S|ψ
by reflecting along |η. The resultant state Q|ψ has been rotated anticlockwise by
an angle 2θ in the hyperplane of |η and V |η.
From the expression above, it can be seen that the operator Q rotates vectors in the
two-dimensional plane defined by the vectors |η and V |η, as shown in Fig. 14.1.
Note that
Q = U V U V = FZF † · V · FZF † · V
Fig. 14.2 Gates for operator Q. Published with permission of © Belal E. Baaquie and L. C. Kwek.
All Rights Reserved
yields
V |η = cos(π θ )|η + eiχ (sin(π θ ))|η⊥
From above equation it follows that, even though |η and V |η are not orthogonal,
they are linearly independent.
Consider an arbitrary state vector |ψ in the span of state vectors |η and V |η;
since these two vectors are linearly independent we have
Hence
Q|η = − 1 + 4 cos2 (π θ ) |η − 2 cos(π θ )V |η
QV |η = 2 cos(π θ )|η − V |η (14.15)
The action of the diffusion operator Q on the space spanned by |η and V |η is closed
and yields
On the subspace spanned by |η and V |η, Q is equal to the matrix M and yields the
following linear transformation on the coefficients a, b
ã a
=M (14.18)
b̃ b
and yields
(1 + λ)2 − (1 + λ) cos2 (π θ ) + cos2 (π θ ) = 0
1 2
λ± = cos (π θ ) − 2 ± i cos(π θ ) 4 − cos2 (π θ ) (14.21)
2
Note that
cos2 (π θ ) − 2 = 2 cos(2π θ ) ; cos(π θ ) 4 − cos2 (π θ ) = 2 sin(2π θ )
230 14 Quantum Algorithm for Option Pricing
For completeness, note that the matrix Q in the {|η, |η⊥ } basis is given by
cos(2π θ ) eiχ sin(2π θ )
Q= −iχ
−e sin(2π θ ) cos(2π θ )
The eigenvectors of Q are |ψ± with eigenvalues exp{±i2π θ }. The explicit rep-
resentation of the eigenvectors is not required, but they are given for completeness.
The eigenvectors of Q are given by
with
a± 4α 2 − 1 2α a± a
M = = e±i2πθ ± (14.23)
b± −2α −1 b± b±
1 1
|ψ+ = √ |η − e−iπθ V |η ; |ψ− = √ eiπθ |η + V |η (14.24)
2 2
Note |ψ± are not normal or orthogonal since |η and V |η are not orthogonal. The
amplitude amplification does not require that the eigenfunctions |ψ± be orthogonal,
and hence, the state vector |ψ needs not be expressed in an orthogonal basis.
Consider a m-qubit state |y and the n + 1-qubit |η; the input tensor m-qubit ⊗
n + 1-qubit state is given by
|y|η
2
n
−1
|η = a(x)|x 1 − ν(x)|0 + ν(x)|1 : η|η = 1
x=0
where
Q y ≡ (Q) y
The phase angle θ is evaluated in the following manner. Take a copy of input
|0⊗(n+1) and applying F yields
F|0⊗(n+1) = |η
232 14 Quantum Algorithm for Option Pricing
The m-qubit register is prepared in the uniform superposition state using the
Hadamard gate and yields
2 −1
1
m
⊗m
H |0 |η = √ |y|η
2m y=0
Applying the controlled Qc to the input state yields the following entangled state
⎡ ⎤
2 −1 2m −1
1
m
⎣ 1 ⎦
| = Qc √ |y|η = √ |yQ y |η
2m y=0 2m y=0
1
2m −1
=√ |yQ y β+ |ψ+ + β− |ψ−
2m y=0
1
2m −1
⇒ | = √ |y e2πi yθ β+ |ψ+ + e−2πi yθ β− |ψ− (14.25)
2m y=0
2 −1
1 −2πi x y/2m
m
|y = √ e |x
2m x=0
The full quantum circuit for the phase estimation is shown in Fig. 14.3
Fig. 14.3 Quantum circuit for estimation of the phase θ. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
14.6 Amplitude Amplification 233
|
2m −1
1 1
2m −1
|x e−2πi(x/2 −θ)y β+ |ψ+ + e−2πi(x/2 +θ)y β− |ψ−
m m
=√ √
2m y=0 2m x=0
2
m
−1
⇒ | = |x β+ (x)|ψ+ + β− (x)|ψ− (14.26)
x=0
where
2 −1
1
m
Recall from Eq. 14.10 that the angle θ ∈ [0, 1] is defined by the payoff function
and is not an integer. Consider θ = θm + δ, where θm is a binary decimal closest to
θ . Then, for example
2 −1
1
m
Note
2 −1
1
m
For x = 2m θm , we have
2 −1
1
m m
1 1 − e2πiδ2
β+ (2m θm ) = exp{2πiδy}β+ = β+ β+ + O(δ/2m )
2m y=0 2m 1 − e2πiδ
2
m
−1
1
| = β(x)|x · β+ (x)|ψ+ + β− (x)|ψ−
x=0
β(x)
2
m
−1
⇒ | ≡ β(x)|x| (x) ; β(x) = β+2 (x) + β−2 (x) (14.27)
x=0
234 14 Quantum Algorithm for Option Pricing
The probability β 2 (x) to find the system in qubit basis state |x is given by
|β(x)|2 = Tr |xx| ⊗ I2n || = |β+ (x)|2 + |β− (x)|2
The maximum likelihood of occurrence for a qubit x, as shown in Fig. 14.4, is given
by
x± /2m = ±θm
Since the option price is the function cos(±2π θm ), the value of either of the qubits
x± that occur with maximum likelihood gives the option price.
It is shown in Patrick et al. [5] that the estimate of the option price has the expected
quadratic speeding up given in Eq. 14.5. An intuitive discussion of this result is given
in Sect. 14.8.
+∞
e−r τ
dxe− 2τ σ 2 (x−x0 −τ (r − 2 σ )) [e x − K ]+
1 1 2 2
C(x0 , τ ) = √
2π τ σ 2
−∞
+∞
e− 2 x √τ σ x+x0 +τ (r − 1 σ 2 )
1 2
= e−r τ dx √ e 2 −K
2π +
−∞
max
+x
e− 2 x √τ σ x+x0 +τ (r − 1 σ 2 )
1 2
−r τ
e dx √ e 2 −K (14.28)
2π +
−xmax
14.7 Call Option 235
0.4
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
x
Fig. 14.5 Discretized Gaussian probability distribution function. Published with permission of
© Belal E. Baaquie and L. C. Kwek. All Rights Reserved
In the approximation given in Eq. 14.28, one replaces [−∞, +∞] by [−xmax , +xmax ];
it is sufficient to take xmax to be 1. The probability density for the Gaussian random
variable is given by
1
p(x) = √ e− 2 x
1 2
2π
2−1 n
1
p(x) → p j = p(x j ) ; c = p(x j )
c j=0
is discretized to
ν j = ν(x j )
A binary approximation ν̃ j is made of the discretized payoff function such that the
error is given by
1
|ν j − ν̃ j | < n
2
236 14 Quantum Algorithm for Option Pricing
Hence, from Eq. 14.28, the approximate call option price is given by
2
n
−1
−r τ
C(x0 , τ ) e p j ν̃ j (14.29)
j=0
2
n
−1
√
A|0⊗n = p j | j (14.30)
j=0
2
n
−1
√
|η = p j | j 1 − ν̃ j |0 + ν̃ j |1 : η|η = 1 (14.31)
j=0
2
n
−1
μ = η| I2n ⊗ |11| |η = ν̃ j p j
j=0
and we have recovered the approximate call option price given in Eq. 14.29. The
quadratic improvement discussed in Sect. 14.4 can be applied for pricing the call
option.
14.8 Discussion
The Grover and option price algorithms are both based on amplitude amplification.
There is however an interesting difference between the two. For Grover’s case, one
is seeking a marked state vector, |ξ , as in Eq. 11.32. Hence, there is no need for
a Fourier transform for isolating the marked state vector, since doing the recursion
enough times makes the coefficient of |ξ in the superposed state vector almost equal
to 1.
In contrast, the algorithm for finding the option price reduces the problem to
finding an unknown angle θ . The Grover approach does not work, since for Grover’s
algorithm, the angle θ is known: it is determined by the number of qubits being used
for the algorithm. The number of recursions required to find the marked state |ξ is
determined by θ .
For finding the option price, the Fourier transform is required to pick out the most
likely state, which after sufficient iterations of the diffusion operator Q, is seen to
yield the sought for angle.
References 237
References
1. Baaquie BE (2004) Quantum finance: path integrals and Hamiltonians for options and interest
rates. Cambridge University Press, UK
2. Baaquie BE (2010) Interest rates and coupon bonds in quantum finance, 1st edn. Cambridge
University Press, UK
3. Baaquie BE (2018) Quantum field theory for economics and finance. Cambridge University
Press, UK
4. Hull JC (2000) Options, futures, and other derivatives, 4th edn. Prentice Hall, New Jersey
5. Rebentrost P, Gupt B, Bromley TR (2018) Quantum computational finance: Monte carlo pricing
of financial derivatives. Phys Rev A 98:022321
6. Orús SMR, Lizaso E (2019) Quantum computing for finance: overview and prospects. Rev
Phys (4):100028
7. Brassard MMG, Høyer P, Tapp A (2000) Quantum amplitude amplification and estimation.
arXiv:quant-ph/0005055v1
8. Kaneko NTK, Miyamoto K, Yoshinox K (2020) Quantum computing for finance: overview
and prospects. arXiv:1905.02666v4
9. Baaquie BE (2020) Mathematical methods and quantum mathematics for economics and
finance. Springer, Singapore
Chapter 15
Solving Linear Equations
15.1 Introduction
Historically, some of the most ancient mathematical problems are directly related to
the solutions of linear equations. As a matter of fact, a long time ago, the Chinese
mentioned their techniques for solving linear equations with remarkable resemblance
to our modern Gaussian elimination method [1]. Published nearly two thousand years
ago, the method was described in a book entitled ‘The Nine Chapters on the Mathe-
matical Art’ (Jiuzhang Suanshu) [1].1 Like many ancient publication, nobody really
knows the true authors of the book. Yet, it constitutes an important mathematical trea-
tise that well precedes the magnificent works of Carl Friedrich Gauss (1777–1855). It
is also interesting to note that one of the first digital computers, the Atanasoff–Berry
Computer (ABC), is designed specifically for solving linear equations.
Nowadays, the solution of linear equations features prominently in many science,
engineering or even finance problems. A system of linear equations is typically cast
into matrix form:
Ax = b, (15.1)
1 Jiuzhang is also the name given to one of the latest quantum computers in China.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 239
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_15
240 15 Solving Linear Equations
In 2009, Aram Harrow, Avinatan Hassidim and Seth Lloyd proposed a quan-
tum algorithm for solving a linear set of equations [2]. This algorithm is nowadays
widely known by its acronym, HHL. The classical computer takes polynomial time
to solve a system of n equations. For a set of linear equations of size n with condition
number κ, sparsity s and desired precision , the time complexity is known to be
O(log(n)s 2 κ 2 /). This is not exponential speedup in the computational time over the
classical algorithms, for instance, for the Gaussian elimination, the time complexity
is roughly O(n 3 ), and if it is sparse, that complexity reduces to O(κsn log n/ log )
by gradient descent. Yet like Grover’s algorithm, it can still provide an advantage
over classical algorithm if used appropriately.
or |x = A−1 |b. So if A is Hermitian so that A = A† , then we are looking for the
solution of e−i At |b. Even if A is not Hermitian (or even a square matrix), we can
modify the problem into
0 A 0 |b
= . (15.3)
A† 0 |x 0
ei At⊗ p̂ |u i ⊗ |0r
gives |u i ⊗ |λi r where the little subscript r denotes the register and p̂ is some
momentum operator.
15.2 Harrow–Hassidim–Lloyd Algorithm 241
We are now in a position to describe the entire process involved in HHL. We start
⊗p
with the state |0a |0r |bm , where the subscript m denotes the state stored in the
memory, r denotes the register of p qubits (for storing the binary fraction form of the
phase associated with the eigenvalue of A, and a denotes the ancillary qubit needed
⊗p
for the operation, i.e., |0a |0r |bm .
We then perform the quantum phase estimation using the unitary transformation
ei A :
n
|0a |0r⊗ p |bb →e i2π A
|0a |0r⊗ p |bm = β j e2πi λ̃ j |0a |λ̃ j r |u j m (15.4)
j=1
for some coefficients β j . Since A is a known Hermitian matrix, the matrix ei2π A ≡ U
is unitary so the eigenvalues |ei2π λ̃ j | = 1 where λ̃ j is the j-th eigenvalue of A with
eigenvector |u j . Note that any unitary transformation U can be easily realized in the
circuit model since any unitary matrix can be decomposed into three Pauli rotation
operators,
{exp(iθk σk /2), k = (x, y, z)}
n
β j |0a |λ̃ j r |u j m
j=1
n n
C2 C
β j |0a |λ̃ j r |u j m → βj 1− |0a + |1a |λ̃ j r |u j m (15.5)
j=1 j=1
λ̃2j λ̃ j
n
C2 C
βj 1− |0a + |1a |0r⊗ p |u j m . (15.6)
λ˜j
2
j=1
λ̃ j
In terms of gates, the reverse of the quantum phase transformation is just the symmet-
rical reversal of all the gates in the quantum phase estimation and quantum Fourier
transform stages.
Measuring the ancillary qubit in the computational basis, i.e., {|0, |1}, yields
n
βj
C |u j m ≈ A−1 |bm ∼ |xa (15.7)
˜
λj
j=1
It is not necessary in the HHL algorithm to compute the eigenvectors and eigen-
values of the matrix A, but for the purpose of illustrating the algorithm, we will
do it: Matrix
A has eigenvalues λ̃1 = 1/2 and λ̃2 =1/4 with eigenvectors |u 1 =
1 1 √ 1 1 √
√ = 1/ 2(|0 + |1) and |u 2 = √ = 1/ 2(|0 − |1), respec-
2 1 2 −1
tively. In the new basis {|u i } (i = 1, 2),
√
|b = |1 = 1/ 2(|u 1 − |u 2 ). (15.9)
Note that in binary notation, the eigenvalues λ1 ≡ 0.1 (or in state notation, |10) and
λ2 ≡ 0.01 (or in state notation, |01).
We then apply the quantum phase estimation algorithm using the unitary evolution
matrix
2
U = exp(i2π A) = exp(2πi λ̃ j )|u j u j |. (15.10)
j=1
Note that like quantum phase estimation where we wish to estimate the unknown
phase of a unitary matrix, we do not really need to know these eigenvalues and
eigenvectors (see Sect. 15.4). It is useful to decompose the vector |b in terms of
the eigenvectors of A since the circuit in Fig. 15.1 acts only on |b and not on the
eigenvectors |u 1 or |u 2 .
15.3 Specific Example 243
Fig. 15.1 Circuit diagram for the first part of HHL algorithm. Published with permission of © Belal
E. Baaquie and L. C. Kwek. All Rights Reserved
If we now perform an inverse Fourier transform on the first two qubits, we get
3 2 3 3
1 1 2 2πik
|state at (B) = √ exp(i2π λ̃ j k) √ exp − | |u j
2
j=1 k=0
2 =0
4
2 3
1 3 1 2 2πik
= √ √ exp i2π λ̃ j k − | |u j ,
2 2 j=1 k, =0
4
2 3
1 5 2π
= √ exp i (4λ̃ j − )k | |u j (15.12)
2 j=1 k, =0
4
Noting that λ̃1 = 1/2 and λ̃2 = 1/4, we see that whenever
1 = 4λ̃1 = 2,
2 = 4λ̃2 = 1,
244 15 Solving Linear Equations
the expression in Eq. (15.12) peaks. To see this, we tabulate the coefficients in the
expression in Eq. (15.12) for each j:
k
|00 |01 |10 |11
0 1 1 1 1
1 exp i 2π
4 (4λ̃ j ) exp i 2π
4 (4λ̃ j − 1) exp i 2π
4 (4λ̃ j − 2) exp i 2π
4 (4λ̃ j − 3)
2 exp i 2π(2)
4 (4λ̃ j ) exp i 2π(2)
4 (4λ̃ j − 1) exp i 2π(2)
4 (4λ̃ j − 2) exp i 2π(2)
4 (4λ̃ j − 3)
3 exp i 2π(3)
4 (4λ̃ j ) exp i 2π(3)
4 (4λ̃ j − 1) exp i 2π(3)
4 (4λ̃ j − 2) exp i 2π(3)
4 (4λ̃ j − 3)
k
|00 |01 |10 |11
0 1 1 1 1
1 exp(iπ ) exp(i π2 ) 1 exp(−i π2 )
2 exp(2iπ ) exp(iπ ) 1 exp(−iπ )
3 exp(i3π ) exp(i 3π4 ) 1 exp(−i 3π2 )
Sum 0 0 4 0
Note that the state |10 and |01 are precisely the binary fractions 1/2 and 1/4,
respectively. In this case, p = 2 suffices to nail the precision needed in the binary
fractions.
We are now ready for one last step. We attached another ancillary qubit and
apply a rotation to the ancillary qubit conditioned on the first two qubits above.
Essentially we apply a rotation exp(iθi /2σ y ) on the ancillary qubit where the angle
θi = 2 sin−1 (C/λi ) for some suitably chosen parameter C (Fig. 15.2).
So our final state is
|state at (B)|0
→ |final state
1 C2 C
= √ |10|u 1 ( 1 − |0 + |1)
2 λ̃1 λ̃1
C2 C
−|01|u 2 ( 1 − |0 + |1) (15.13)
λ̃2 λ̃2
15.4 Why Do We Not Need the Eigenvalues? 245
Fig. 15.2 Conditional rotation depending on the eigenvalues. Published with permission of © Belal
E. Baaquie and L. C. Kwek. All Rights Reserved
Fig. 15.3 Circuit diagram for the full HHL algorithm. Published with permission of © Belal E.
Baaquie and L. C. Kwek. All Rights Reserved
We then reset the qubits used for the phase estimation |01 and |10 to |00 (using
a circuit that is exactly the mirror image of the one used earlier to generate the
eigenvalues, see Fig. 15.3) so that a measurement on the top ancillary qubit yielding
the state |1 (success) gives the final result as
1 1 1
|x ∝ √ |u 1 − |u 2 . (15.14)
2 λ̃1 λ̃2
Fig. 15.4 Schematic perspective of the HHL algorithm acting on an eigenstate of A. Published
with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
We see that after the quantum phase estimator is completed, the state of the
system is |0a |λ|u, where λ is the corresponding eigenvalue of A with eigenvector
|u. Note that the qubits in the register are a binary representation of the eigenvalue
λ, i.e., the first bit is 1/2, the second bit is 1/4, the third bit is 1/8 and so forth. The
conditional rotation uses the same state λ but this time it labels the qubits in the
register differently as 2, 22 , 23 , etc., effectively rotating the ancillary qubit set initially
at |0 to cos θ |0 + sin θ |1 where sin θ ∝ λ−1 . This is equivalent to extracting the
eigenvalue of A and multiplying the input state |u by λ−1 .
For an arbitrary state |b, we can regard this state as a superposition of {|u i }; i.e.,
we can say that such a state is in state |u i with probability | u i |b|2 since2
|b = |u i u i |b.
i
In this way, the output state takes on λi−1 |u i with the same probability | u i |b|2 .
Thus, we never need to know which eigenstate of A is being operated, but our final
output state simply yields
λi−1 |u i u i |b,
i
2 Note that |u i u i | is just the identity matrix due to the completeness relation of the orthonormal
i
eigenstates of exp(i A).
References 247
The HHL algorithm is sufficiently flexible for other applications. In particular, it can
be exploited for applications in machine learning [3] where the algorithm is used as
a subroutine. Examples of such applications are:
• quantum support vector machine (SVM) [4]—are supervised learning models with
associated learning algorithms that analyze data for classification and regression
analysis;
• quantum linear regression [5]—somewhat similar to SVM, linear regression seeks
to predict the relationship between the input variables and the target variables;
• quantum recommendation systems—primarily used in commercial applications
to predict products or items that the users have shown inherent interests [6, 7];
• quantum singular value thresholding [8]—an algorithm often used in solving the
image classification problem in machine learning.
References
1. Dauben JW (1998) Ancient Chinese mathematics: the (jiu zhang suan shu) vs euclid’s elements.
Aspects of proof and the linguistic limits of knowledge. Int J Eng Sci 36(12–14):1339–1359
2. Harrow AW, Hassidim A, Lloyd S (2009) Quantum algorithm for linear systems of equations.
Phys Rev Lett 103(15):150502 (2009)
3. Duan B, Yuan J, Yu C-H, Huang J, Hsieh C-Y (2020) A survey on HHL algorithm: from theory
to application in quantum machine learning. Phys Lett A 126595
4. Rebentrost P, Mohseni M, Lloyd S (2014) Quantum support vector machine for big data classi-
fication. Phys Rev Lett 113(13):130503
5. Wiebe N, Braun D, Lloyd S (2012) Quantum algorithm for data fitting. Phys Rev Lett
109(5):050505
6. Preskill J (2018) Quantum computing in the NISQ era and beyond. Quantum 2:79
7. Tang E (2019) A quantum-inspired classical algorithm for recommendation systems. In: Pro-
ceedings of the 51st annual ACM SIGACT symposium on theory of computing, pp 217–228
8. Duan B, Yuan J, Liu Y, Li D (2018) Efficient quantum circuit for singular-value thresholding.
Phys Rev A 98(1):012308
Chapter 16
Quantum-Classical Hybrid Algorithms
At the moment, quantum computers are extremely noisy . Yet, one would still like to
harness the advantage of existing quantum computational device if possible. The con-
viction comes from our understanding of quantum mechanics. In theory, we should
be able to get quantum advantage with quantum theory. John [1] has coined the word
‘Noisy Intermediate-Scale Quantum’ (NISQ) computers to describe all computa-
tional devices with limited number of qubits in which we have no good control over
the qubits. In the NISQ era, it is likely that some form of hybrid algorithms could be
useful [2] (Fig. 16.1).
Hybrid quantum algorithms use both classical and quantum resources to solve
potentially difficult problems [3, 4]. The underlying idea is that one should assign
appropriate tasks to appropriate devices. If quantum computers can solve certain
task like finding the overlap of wave functions more efficiently, then we should
let a quantum computer performs that task. Also with the current noisy quantum
computers, it is unlikely that they can perform optimization efficiently. However,
classical computers have a proven record of solving these problems. So, certain
optimization should be carried out with a classical computer.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 249
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_16
250 16 Quantum-Classical Hybrid Algorithms
Fig. 16.1 Using the conventional (classical) computer to perform computations best suited for a
classical computer and feeding the output to a quantum computer that works on the part best suited
for a quantum computer. Published with permission of © Belal E. Baaquie and L. C. Kwek. All
Rights Reserved
It is known that if the Hamiltonian acts at most on k qubits, then the problem is
known to be QMA-complete for k ≥ 2.
To understand a little about the last statement, we first digress a little to explain
quantum complexity theory. The Quantum Merlin–Arthur (QMA) class is an exten-
sion of the classical class non-deterministic polynomial (NP) in computational com-
plexity theory . The class NP concerns problems that are hard to solve yet it is easy
to verify that the solution is correct. One such problem is the prime number factor-
ization, that we have seen earlier. It is hard to factorize a large number that is made
up of two large prime numbers, but it is easy to verify the answers are right or wrong
once we are given the factors. The probabilistic extension of NP problems is the
class Merlin–Arthur (MA). In NP, the verification or proof can be done with absolute
certainty. In MA, the verification is accepted with a certain probability, say greater
than 2/3 (or one standard deviation as in a normal distribution test). MA is the class
16.2 Variational Quantum Eigensolvers 251
Fig. 16.2 Schematic diagram of the variational quantum eigensolver (VQE) in which part of the
computations is done in a quantum computer and optimization is done in a classical computer.
Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
where h α are coefficients and Pα are called Pauli strings. Pauli strings are tensor
products of Pauli matrices including the identity matrix.
To perform VQE, one proceeds with the following steps [6]:
1. Map the problem for finding the ground state of a Hamiltonian to the form in
Eq. 16.2.
2. Prepare a trial state |({θi }) that depends on some set of parameters {θi }.
3. We use a quantum computer to evaluate the expectation values
.
4. We feed
the measured valuesj from the quantum computer to find the energy
E = α h α ({θi })| ⊗ Nj=1 σα j |({θi }) ≥ E exact and adjust the parameters θ
in a classical computer. This is the optimization process.
5. We update the set of parameters {θi } and proceed with the iteration (Fig. 16.2).
252 16 Quantum-Classical Hybrid Algorithms
n
HP ≡ C(ei )|ei , (16.3)
i=1
n
HM ≡ σ̂xi , (16.4)
i=1
The final quantum state is given by applying H P and HM alternately on the initial
state p-times:
where C(z) enumerates the number of edges cut and αs are the labels for the edges.
The term Cα (z) = 1 if z places one vertex from the αth edge in set A and the other
vertex in set B. If this is not possible, Cα (z) = 0. It turns out that finding the cut that
yields the maximum possible value of C is a hard problem (actually NP-complete in
complexity theory).
We assign the vertices to set A and set B with a bit string z. In the example in
Fig. 16.3a, z = z 1 z 2 z 3 z 4 since there are four vertices. If we assign the ith vertex to
set A, then z i = 0, otherwise, if the ith vertex is assign to set B, we write z i = 1. In
Fig. 16.3b, z = 0101 since the vertices 1 and 3 are in set A and vertices 2 and 4 are
in set B.
To implement QAOA, we consider the objective (or cost) function
1
Cα = (1 − σiz σ jz ) (16.9)
2
where the αth edge is between the vertices (i, j). Clearly, Cα has eigenvalue 1 if and
only if ith and jth qubits yield different z-axis measurements corresponding to the
different partitions.
The algorithm QAOA begins with a uniform superposition of all possible n-bit
strings. In the case here, the number of vertices n = 4.
1
|+4 = √ |z (16.10)
2n z∈{0,1}n
Our aim is to explore the bit strings z for a superposition that yields the largest value
for the C operator. Using 2 p angle parameters,
where
n
e−iβk σ j ,
z
U Bk =
j=1
e−iγk (1−σm σn )/2 ,
z z
UC k =
all edges(m,n)
where the matrices σiα (α = x, y, z) are Pauli matrices and the label i refers to the
ith qubit.
These operators e−iγk (1−σm σn )/2 (in U Bk ) and e−iβk σ j (in UCk ) can be implemented
z z z
straightforward. It is just a rotation matrix along the Pauli-x axis. For the two-qubit
gate, we see that
To see how Eq. (16.11) is obtained, we need to note that the CNOT gate can be cast
into the form
CNOTmn = |0m m 0| ⊗ In + |1m m 1| ⊗ σnx .
Thus,
z z
Fig. 16.4 a Quantum circuit for the entangling gates e−iγk (1−σ j σk )/2 . b Circuit for the single-qubit
z
operation: e−iβk σ j . Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights
Reserved
16.4 MaxCut Problem 255
= |0m m 0| ⊗ In + |1m m 1| ⊗ σnx · e+iγk σn /2 ·
z
|0m m 0| ⊗ In + |1m m 1| ⊗ σnx
= |0m m 0| ⊗ e+iγk σn /2 + |1 j j 1| ⊗ σnx e+iγk σn /2 σnx
z z
1 1
so we can replace |0m m 0| by (I + σmz ) and |1m m 1| by (I − σmz ). Substituting
2 2
back into Eq. (16.12) gives
1 1
= (Im + σmz ) ⊗ e+iγk σn /2 + (I j − σmz ) ⊗ e−iγk σn /2
z z
2 2
1 +iγk σ z /2 −iγ σ n /2
z
= Im ⊗ e n +e k
2
1
+ σmz ⊗ e+iγk σn /2 + e−iγk σn /2
z z
2
1 1 z
= (Im ⊗ (2 cos(γk /2))) + σm ⊗ 2i sin(γk /2)σnz
2 2
= (Im ⊗ (cos(γk /2))) + σmz ⊗ i sin(γk /2)σnz
= Im ⊗ In cos(γk /2) + i sin(γk /2)σmz ⊗ σnz
= eiγk σm ⊗σn /2
z z
which is the required gate up to a global phase. These quantum gates allow us to
estimate the expectation value γ , β|C|γ , β.
We perform classical optimization over the circuit parameters (γ , β) to obtain the
best state |γ , β that is most likely to yield an approximate partition |z on performing
a measurement in the computational basis. In the case of the graph in Fig. 16.3b,
we see that the optimal partitions correspond to the strings |0101 or |1010. The
optimization process essentially corresponds to an evolution of the initial state to the
plane spanned by the basis states {|0101, |1010} (Fig. 16.5).
256 16 Quantum-Classical Hybrid Algorithms
References
1. John P (2018) Quantum computing in the NISQ era and beyond. Quantum 2:79
2. Bharti K, Cervera-Lierta A, Kyaw TH, Haug T, Alperin-Lea S, Anand A, Degroote M, Hei-
monen H, Kottmann JS, Menke T, Mok W-K, Sim S, Kwek L-C, Aspuru-Guzik A (2022)
Noisy intermediate-scale quantum algorithms. Rev Mod Phys 94:015004
3. McClean JR, Romero J, Babbush R, Aspuru-Guzik A (2016) The theory of variational hybrid
quantum-classical algorithms. New J Phys 18(2):023023
4. Zhu D, Linke NM, Benedetti M, Landsman KA, Nguyen NH, Alderete CH, Perdomo-Ortiz
A, Korda N, Garfoot A, Brecque C et al (2019) Training of quantum circuits on a hybrid
quantum computer. Sci Adv 5(10):eaaw9918
5. Peruzzo A, McClean J, Shadbolt P, Yung M-H, Zhou X-Q, Love PJ, Aspuru-Guzik A, O’brien
JL (2014) A variational eigenvalue solver on a photonic quantum processor. Nat Commun
5:4213
6. Moll N, Barkoutsos P, Bishop LS, Chow JM, Cross A, Egger DJ, Filipp S, Fuhrer A, Gambetta
JM, Ganzhorn M et al (2018) Quantum optimization using variational algorithms on near-term
quantum devices. Quantum Sci Technol 3(3):030503
7. Farhi E, Goldstone J, Gutmann S (2014) A quantum approximate optimization algorithm.
arXiv preprint arXiv:1411.4028
8. Farhi E, Goldstone J, Gutmann S, Sipser M (2000) Quantum computation by adiabatic evo-
lution. arXiv preprint quant-ph/0001106
9. Bengtsson A, Vikstål P, Warren C, Svensson M, Gu X, Kockum AF, Krantz P, Križan C, Shiri
D, Svensson I-M et al (2020) Improved success probability with greater circuit depth for the
quantum approximate optimization algorithm. Phys Rev Appl 14(3):03401
Chapter 17
Quantum Error Correction
17.1 Introduction
Classical computation works on two binary bits, 0 or 1. Errors can occur in the
transmission of data from one point to another via bit-flip errors. Typically, such
errors arise from stray electromagnetic fields in the transmission lines or from faulty
computer chips causing the bit to change from 0 to 1 or vice verse. The analogous
type of error in a quantum computer is one that affects the basis states |0 and |1:
|0 → |1, or |1 → |0. Such error is described with the X (or σx ) operator:
01
X= . (17.1)
10
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 257
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_17
258 17 Quantum Error Correction
In quantum systems, aside from bit-flip errors, we expect another type of errors,
namely phase-flip errors. A phase-flip error does not change the computational basis
states. It simply adds a phase to one of the basis state, i.e., |1 → −|1. A phase-flip
error is one that transforms the basis states as follows1 :
|0 → |0
|1 → eiπ |1 = −|1. (17.3)
Having described the actions of X and Z , one question that is often asked is
what about the Y operator? The operator Y is really a combination of X and Z in
concatenation since Y = −i Z X .
1 More generally, in a phase-flip error, the phase needs not be π , it could be an arbitrary angle:
|1 → eiπ |1.
17.4 Nine-qubit Code 259
For simplicity, we assume that the states associated with the environment {|ξi } are
distinguishable from each other, so that ξi |ξ j = δi j . Note that there is a probability
1 − p1 − p2 − p3 that the state remains untouched (identity operation).
If we traced out the environmental degree of freedom, then we see that the state
|ψψ| = ρ becomes
√ √
where the K i = pi σi (i = 1, 2, 3) and K 4 = 1 − p1 − p2 − p3 I . Here, σ1 = X ,
σ2 = Y and σ3 = Z as in the usual notations. The operators K i are called Kraus
operators and they satisfy
4
K i† K i = I (17.8)
i=1
In classical error correction codes, repetition code is one way to overcome errors.
Typically instead of sending a single classical bit b over a channel, one repeats the bit
a number of times, typically three times, and decides the results based on majority
votes.
Unlike classical repetition codes, quantum codes need to safeguard against
not just√bit-flip errors, i.e., 0 → 1 and
√ vice
verse, but also √phase-flip errors. The
state 1/ 2 (|0 + |1) can become 1/ 2 |0 + eiπ |1 = 1/ 2 (|0 − |1), a com-
pletely orthogonal state.
One of the easiest ways to overcome both bit-flip and phase-flip error is to encode
|0 and |1 as
1
|0̄ = √ (|000 + |111)(|000 + |111)(|000 + |111) (17.9)
2 2
1
|1̄ = √ (|000 − |111)(|000 − |111)(|000 − |111) (17.10)
2 2
These codes do not violate the no-cloning theorem. An arbitrary code word is a linear
superposition of these two states:
The two logical states |0̄ and |1̄ can be regarded as two layers of onion peels. The
inner layer, i.e., |000 ± |111 corrects bit-flip errors and any correction is done with
majority votes. For example, if there is a bit flip in the second qubit,
The outer layer corrects for phase flips. In this case, we take the majority of the three
signs.
|+|−|+ → |+|+|+ (17.13)
√
where we have used |± = 1/ 2 (|000 ± |111). Naturally, one can check that the
code works even if there is both a bit-flip and a phase-flip error.
Now that we know the code, we still need to know how to correct for errors.
First, we need to determine if the first three qubits are the same, and if not which is
different. To do this, we perform the following operations on the first three qubits:
Z ⊗ Z ⊗ I and I ⊗ Z ⊗ Z . (17.14)
since i ⊕ j = i + j, Mod 2 and effectively detects the parity of (i, j). Thus, measur-
ing the ancilla tells us the eigenvalue of Z ⊗ Z ⊗ I and nothing about the encoded
data.
Next, we need to correct for phase error. To do this, we perform the following
measurements:
X⊗X⊗X⊗X⊗X⊗X⊗I⊗I⊗I
and I ⊗ I ⊗ I ⊗ X ⊗ X ⊗ X ⊗ X ⊗ X ⊗ X. (17.15)
17.5 General Properties of Quantum Error-Correcting Codes 261
These two measurements detect phase errors on the first six and last six qubits. As
for bit-flip error, the error detected anti-commutes with the operator measured. The
nine-qubit error correction codes is also known as the Shor code.
In this section, we follow closely Sect. 17.2 of the excellent review by Daniel Gottes-
man [1]. There are many other useful references as well, see for example [6–8].
An important feature of quantum error correction is linearity of quantum mechan-
ics. Because of this feature, we only need to correct a subset of errors, for instance in
the one-qubit case, {I, X, Y, Z } where X, Y, Z are the Pauli operators. If a quantum
code corrects errors A and B, it also connects a linear combination of A and B.
In the presence of noise, any two orthogonal logical states, |0̄ and |1̄ remain
orthogonal with errors, i.e., E 1 |0̄ and E 2 |1̄ are orthogonal:
As noted in Ref. [3], if the condition in Eq. (17.16) was not satisfied, then the errors
would destroy the perfect distinguishability of orthogonal codewords and the encoded
quantum information would be damaged. Therefore, it is sufficient to distinguish
error E 1 from error E 2 when they act on |0̄ and |1̄ for E 1 = E 2 :
When we cannot distinguish between the two errors, it is still sometimes perfectly
all right if one constructs new operators F1 = (E 1 + E 2 )/2 and F2 = (E 1 − E 2 )/2,
assuming 0̄|E 1† E 2 |0̄ is real so that
Moreover, all errors acting on the Hilbert space form a linear subspace, E. Let
{E i } be a basis of E. Let C be a subspace of the Hilbert space that constitutes the
space of error-correcting codes and {ψi } be a basis for C. Consider logical qubits
|0 L and |1 L on a two-qubit subspace subject to the following interaction operators
[9]:
262 17 Quantum Error Correction
⎛√ ⎞
1 − 2q 0 0 0
⎜ 0 10 0 ⎟
E0 = ⎜
⎝
⎟;
⎠
0 01√ 0
0 0 0 1 − 2q
⎛√ ⎞
q/2 0 0 √ 0
⎜ 0 0 0 q/2 ⎟
E1 = ⎜ √
⎝ q/2 0 0 0 ⎠ ;
⎟
√
0 0 0 q/2
⎛ √ ⎞
q/2 0 0 √ 0
⎜ 0 00 q/2 ⎟
E2 = ⎜ √
⎝ − q/2 0 0
⎟.
⎠ (17.20)
√0
0 0 0 − q/2
You can easily check that i E i† E i = 1. Also, it is not hard to verify that
i L |E i† E j |i L = jL |E i† E j | jL (17.21)
i L |E i† E j | jL =0 (17.22)
Classical error correction has been developed over many years. A linear code is
an error-correcting code in which any linear combination of codewords is also a
codeword. The repetition code in which we repeat a classical bit a number of times
and correct through majority vote is an example of a linear code. Nonlinear codes
outperform linear codes in terms of error detection and correction. However, these
codes are more complicating. The human visual system uses codes as well. However,
human vision does not operate linearly, and the code used in vision is typically
nonlinear.
One of the key notions in the theory of linear codes is Hamming distance. Suppose
two codewords x = x1 x2 x3 . . . xn and y = y1 y2 y3 . . . yn , we define for every i, the
distance
1, xi = yi
d(xi , yi ) = , (17.23)
0 xi = yi
n
then the Hamming distance between the two codewords is d(x, y) = d(xi , yi ).
i=1
For instance, the Hamming distance between the code word 0101 and 1001 is 3. It
is easily verified that d(x, y) is a metric in the strict sense:
17.6 Classical Linear Codes 263
d(x, y) = 0 ⇔ x = y (17.24)
d(x, y) = d(y, x) symmetry (17.25)
d(x, y) ≤ d(x, z) + d(z, y) triangle inequality. (17.26)
Let C be a code of length n over a set of alphabets A. In the case of binary bits,
the alphabets are {0, 1} and the set of codes of length 2 are |A|2 ≡ {00, 01, 10, 11}
where |A| denotes the size of the set of the alphabets. The nearest neighbor decoding
rule explicitly says that every x ∈ An is decoded to the codeword cx ∈ C closest to
x such that d(x, cx ) = minc∈C (d(x, c)). For any code C, the distance of the code is
defined as d(C) = min{d(c1 , c2 )|c1 , c2 ∈ C, c1 = c2 }.
With these definitions, we can now embark on some descriptions of linear codes.
A linear code of length n and dimension k with Hamming distance d is denoted as
an [n, k, d] code. Another way of looking at an [n, k, d] code is: with a binary string
of length n, we have a space of 2n strings. We designate a subset of k-bit string as the
codewords such that the Hamming distance between any two codewords is at least d.
The space C of the code is spanned by a basis of k vectors v1 , v2 , . . . vk so that
an arbitrary codeword is expressed as a linear combination of these basis vectors:
v(α1 , α2 , . . . , αk ) = αi vi , (17.27)
i
The matrix G is called the generator matrix of the code. Equation (17.27) can then
be written succinctly as:
v(α) = αG (17.29)
We can also define the parity check matrix H of size (n − k) × n whose rows are (n −
k) linearly independent vectors that are orthogonal to the code space. Orthogonality
is defined with respect to the bit-wise inner product modulo 2. Clearly we have:
H GT = 0 (17.30)
Fig. 17.1 Figure showing the minimum distance and error correction capability of a linear code.
Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
H (v + e) = hv + H e = H e, (17.32)
and H e is called the syndrome of the error e.If we denote the set of all possible
errors {ei } as E, error recovery is possible if and only if all errors possess distinct
syndromes. We can unambiguously diagnose the error for a given syndrome H e by
flipping the bits specified by e as:
v + e → (v + e) + e = v (17.33)
v + e1 → v + (e2 + e2 ) = v (17.34)
The distance of a code C, d, is the minimum weight of any vector in the code,
where the weight is the number of 1’s in the string v. Classical coding theory says
that a linear code with distance d = 2t + 1 can correct t errors,see Fig. 17.1.
For
dmin − 1
codes with n = 7, k = 4 and a minimum distance dmin = 7, t = = 1.
2
In short, a linear code with a distance d = 2t + 1 can correct t errors and the code
assigns a distinct syndrome to each e ∈ E, where E contains all the vectors of weight
t or less. If H e1 = H e2 , then
0 = H e1 + H e2 = H (e1 + e2 )
and then e1 + e2 ∈ C. But if e2 and e2 and each codeword has weight no larger than
t, then the weight of e1 + e2 should not be greater than zero and no larger than 2t.
Since d = 2t + 1, no such vector exists and hence H e1 = H e2 .
17.7 An Example of a Linear Code: Hamming Code 265
For any code C, one can also construct a dual code. For a k × n generator matrix
G, and the (n − k) × n parity check matrix H of a code C, we see that H G T = 0.
By taking the transpose, it follows that G H T = 0, and we may now regard H T as a
generator and G as the parity check of an (n − k)-dimensional code, denoted by C ⊥
and known as the dual of the code C.
For any code C and its dual code C ⊥ , it can be shown that
k
v.u 2 , u ∈ C⊥
(−1) = (17.35)
/ C⊥
0, u ∈
v∈C
x1 x2 x3 x4 p1 p2 p3
0 0 0 0 0 0 0
0 0 0 1 0 1 1
0 0 1 0 1 1 0
0 0 1 1 1 0 1
0 1 0 0 1 1 1
0 1 0 1 1 0 0
0 1 1 0 0 0 1
0 1 1 1 0 1 0
1 0 0 0 1 0 1
1 0 0 1 1 1 0
1 0 1 0 0 1 1
1 0 1 1 0 0 0
1 1 0 0 0 1 0
1 1 0 1 0 0 1
1 1 1 0 1 0 0
1 1 1 1 1 1 1
p1 = x 1 ⊕ x 2 ⊕ x 3 , (17.36)
p2 = x 2 ⊕ x 3 ⊕ x 4 , (17.37)
p3 = x 1 ⊕ x 2 ⊕ x 4 . (17.38)
It is not difficult to check that the Hamming distance between these code words is at
least 3. Thus these codes are called [7, 4, 3] codes, meaning that it is a seven-bit text
that encodes a four-bit text, whose Hamming distance is at least 3. Moreover, we see
from previous section that we can correct at least one error.
266 17 Quantum Error Correction
Now suppose the message sent is (0, 0, 1, 0, 1, 1, 0). Suppose also that after going
through a noisy channel, the received message is (0, 0, 1, 0, 0, 1, 0). Clearly in this
case, we can compute (s1 , s2 , s3 ) = (1, 0, 0), telling us that an error (see table below)
has occurred in the parity bit p1 . This three-bit vector (s1 , s2 , s3 ) is called a syndrome.
Depending on the value of the syndrome, we can correctly identify the error and
correct it. More generally, we can compare the result of the syndrome with the
following table:
Syndrome Error
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1
0 1 0 0 0 0 0 0 1 0
0 1 1 0 0 0 1 0 0 0
1 0 0 0 0 0 0 1 0 0
1 0 1 1 0 0 0 0 0 0
1 1 0 0 0 1 0 0 0 0
1 1 1 0 1 0 0 0 0 0
It can check easily that the Hamming distance of the code is d = 3. The generator
matrix G of the code is ⎛ ⎞
1010101
⎜0 1 1 0 0 1 1⎟
G=⎜⎝0 0 0 1 1 1 1⎠.
⎟ (17.45)
1110000
The dual of the Hamming code is the [7, 3, 4] code generated by H . For the CSS
code, we choose C1 to be the Hamming code and C2 as the the dual code. Note that
C2 is an even subcode of C1 .
We define two bases: the F and P bases. In the F basis, the two orthogonal
codewords are:
1
|0 F = √ |v
8 evenv∈Hamming
1
|1 F = √ |v. (17.46)
8 oddv∈Hamming
Since both |0 F and |1 F are superpositions of Hamming codewords, bit flips can be
diagnosed within the basis by performing the parity check with the H matrix. In the
Hadamard rotated basis, these codes words become the P basis:
268 17 Quantum Error Correction
1 1
|0 F → |0 P ≡ |v = √ (|0 F + |1 F ), (17.47)
4 v∈Hamming 2
1 1
|1 F → |1 P ≡ (−1)W t(v) |v = √ (|0 F − |1 F ). (17.48)
4 v∈Hamming 2
In this basis the states are still superposition of (hamming) codewords and so bit flips
in the P basis are phase flips in the original basis and can still be corrected with the
H parity check.
References
1. Daniel G (2010) An introduction to quantum error correction and fault-tolerant quantum com-
putation. In: Quantum information science and its contributions to mathematics, Proceedings of
symposia in applied mathematics, vol 68, pp 13–58
2. McMahon D (2007) Quantum computing explained. Wiley
3. Preskill J (1998) Lecture notes for physics 229: quantum information and computation. Califor-
nia Institute of Technology, vol 16
4. Nielsen MA, Chuang I (2002) Quantum computation and quantum information
5. Wooters WK, Zurek WK (1982) Quantum no-cloning theorem. Nature 299:802
6. Steane AM (1998) Introduction to quantum error correction. Philosophical transactions of the
royal society of London. Series A: Math Phys Eng Sci 356(1743):1739–1758
7. Devitt SJ, Munro WJ, Nemoto K (2013) Quantum error correction for beginners. Rep Progress
Phys 76(7):076001
8. Lidar DA, Brun TA (2013) Quantum error correction. Cambridge University Press
9. Emanuel K, Raymond L, Lorenza V (2000) Theory of quantum error correction for general
noise. Phys Rev Lett 84(11):2525
10. Blahut RE (2003) Algebraic codes for data transmission. Cambridge University Press
11. Steane AM (1996) Error correcting codes in quantum theory. Phys Rev Lett 77(5):793
12. Calderbank AR, Shor PW (54) Good quantum error-correcting codes exist. Phys Rev A
54(2):1098
Chapter 18
One-Way Quantum Computer
So far, we have described a quantum computer technology that relies on gates and
connecting wires to implement any algorithm. Such a paradigm is sometimes called
the quantum circuit model. In this model, every quantum algorithm is implemented
through a quantum circuit, and the basic building blocks of quantum circuits are
quantum gates. Each quantum gate operates on one or two qubits, which are called
single-qubit gates and two-qubit (possibly entangling) gates respectively. An example
of entangling two-qubit gates is the controlled-NOT gate (or controlled-Z ), which is
given in the computational basis by the matrix
⎛ ⎞
1 0 0 0
⎜0 1 0 0⎟
⎜ ⎟. (18.1)
⎝0 0 0 1⎠
0 0 1 0
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 269
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_18
270 18 One-Way Quantum Computer
Fig. 18.1 A quantum circuit. Published with permission of © Belal E. Baaquie and L. C. Kwek.
All Rights Reserved
Fig. 18.2 a A single-qubit gate U ; b A controlled-NOT gate with the top qubit as the control qubit
and the bottom qubit as the target qubit; c A controlled-Z gate; d A single-qubit measurement in
the basis {U |0 , U |1}, and the measurement result m 1 is obtained which will give an output state
U |m 1 . Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
In this section, we briefly describe how MBQC works. Figure 18.3 provides a
schematic illustration of MBQC. In this figure, each circle represents a qubit in
a two-dimensional square lattice. Qubits that are connected with a solid line are
neighbors. A system of qubits is first prepared as a cluster state |C . Each qubit
is then measured sequentially, from the left columns to the right columns, so the
information flows from left to right. The arrow in each circle illustrates the direction
of the spin that is measured, and the choice of directions depends on the results of
earlier measurements. At the end of the procedure, all the spins are measured, and
the measurement results together give the result of the computation. As mentioned
before, since measurement constitutes an irreversible process, MBQC is also known
in the literature, as the ‘one-way quantum computing’.
In Sect. 18.2, we take a closer look at the cluster state and in Sect. 18.3, we show
how MBQC can simulate any quantum circuit efficiently, hence universal quantum
computing can also be implemented by MBQC.
272 18 One-Way Quantum Computer
The cluster state was first introduced by Briegel and Raussendorf shortly before they
introduced the model of MBQC [16]. The term ‘cluster state’ actually refers to a
family of highly entangled quantum states. These states are quantum states of qubits
associated with certain lattices (or just simply arbitrary graphs). For any arbitrary
graph of n vertices, one can always define a cluster state. For example, the graph can
be a 2D square lattice discussed in Fig. 18.3, or the 2D honeycomb lattice given in
Fig. 18.4, or a simple graph of three vertices given in Fig. 18.5a.
The creation of the cluster state associated with a given graph is described in three
easy steps.
• Initialize every qubit to the state |0.
• Apply
√ a Hadamard gate on each of the qubits so that each node becomes
1/ 2(|0 + |1).
• Apply a controlled-Z gate to each pair of qubits whose corresponding graph ver-
tices are connected by a solid line.
As an example, the cluster state associated with the graph of three vertices given in
Fig. 18.5a can be realized in the circuit model with the circuit given in Fig. 18.5(b).
18.2 The Cluster State 273
Fig. 18.5 a A three-qubit graph; b A circuit that creates the cluster state associated with the
three-qubit graph. Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights
Reserved
1 1 1
ψ2 = √ (|0 + |1) ⊗ √ (|0 + |1) ⊗ √ (|0 + |1)
2 2 2
1
= √ (|0 + |1) ⊗ (|0 + |1) ⊗ (|0 + |1)
2 2
1
= √ (|000 + |001 + |010 + |011 + |100 + |101
2 2
+ |110 + |111)
• Apply CZ gate between qubit 1 and 2 and then between qubit 2 and 3. The order
is immaterial.
C Z 12 1
ψ3 −→ √ (|000 + |001 + |010 + |011 + |100 + |101
2 2
− |110 − |111)
C Z 23 1
−→ √ (|000 + |001 + |010 − |011 + |100 + |101
2 2
− |110 + |111)
1
(|0 + 0 + |0 − 1 + |1 − 0 + |1 + 1)
2
1
where ψi are the intermediate states and |+ = √ (|0 + |1) and |− =
2
1
√ (|0 − |1). Of course, the final graph state, that is generated, is given by ψ3 .
2
Consider ψ3 . Suppose we now apply the Pauli-X operator ( i.e., σx ) to the first
site, which we denote as X 1 , and the Paul-Z operator to the second site, which we
denote as Z 2 . What happens?
Recall that
274 18 One-Way Quantum Computer
We see that
1
X 1 Z 2 |ψ3 = √ (|100 + |101 + (−1) |110 − (−1) |111
2 2
+ |000 + |001 − (−1) |010 + (−1) |011)
= |ψ3 .
Similarly, one checks also that Z 1 X 2 Z 3 acting on |ψ3 does not change the state;
i.e., the state is invariant under the operator Z 1 X 2 Z 3 . Moreover, the state is also
invariant under Z 2 X 3 .
Thus, we see that the state is unchanged by the operators
{X 1 Z 2 , Z 1 X 2 Z 3 , Z 2 X 3 }.
How do we get these operators that allow the state ψ3 to stay unchanged? For each
node (or vertex) i in Fig. 18.5a, we apply an X i operator and, at the same time, we
apply a Z j operator to any other nodes j that are connected to the node i by an edge.
These operators that leave the graph state unchanged are called stabilizers. Thus, for
the graph with five nodes shown in Fig. 18.6, the stabilizers are
{X 1 Z 2 , Z 1 X 2 Z 3 Z 5 , Z 2 X 3 Z 5 , X 4 Z 5 , Z 2 Z 3 Z 4 X 5 }
More generally, for each vertex j in a given graph, we denote the neighboring
qubits of j by nb( j). It is easily shown that the graph or cluster state |C associated
with the graph is an eigenstate of the operator X j k∈nb( j) Z k with eigenvalue 1,
where X j (Z k ) is the Pauli X (Z ) operator acting on the jth (kth) qubit. That is,
We can glean the same insight from a slightly different angle. We again take the
simple example given in Fig. 18.5. We denote the qubits from left to right as 1, 2, 3,
and the controlled-Z gate acting on the jth and kth qubits by S jk . Then the cluster
state associated with the graph is given by (according to the circuit given by 18.5b)
where H j is the Hadamard operator acting on the j-th qubit. Now we show that
Eq. (18.2) holds. That is,
X 1 Z 2 |C = |C ,
Z 1 X 2 Z 3 |C = |C ,
Z 2 X 3 |C = |C . (18.4)
Z j S jk = S jk Z j and X j S jk = S jk X j Z k ,
Z j H j = H j X j and X j H j = H j Z j . (18.5)
Substituting Eq. (18.3) into Eq. (18.5) immediately result in Eq. (18.4). In general, it
is straightforward to show that Eq. (18.2) holds for any cluster state associated with
any graph based on a similar argument.
One sees that the operator X j k∈nb( j) Z k has eigenvalues +1, and the operators
corresponding to different vertices commute. For instance, X 1 Z 2 and Z 1 X 2 Z 3 and
Z 2 X 3 commute with each other. Therefore, if we choose a Hamiltonian HC as
HC = − Xj Zk , (18.6)
j k∈nb( j)
where the summation is running over all vertices of the graph, then |C is obviously
the unique ground state of the Hamiltonian HC . Moreover, this Hamiltonian is obvi-
ously gapped; i.e., there is a gap between the ground state and the next excited state,
and frustration-free (as |C is the ground state of each term in the summation).
So it would be great if we could find such Hamiltonian in Nature. But alas, such a
Hamiltonian is in general not a two-body nearest-neighbor Hamiltonian and most
Hamiltonians in Nature, relying on say electromagnetic (Coulomb for instance) or
gravitational forces, are just two-body terms.
In this subsection, we show that MBQC based on certain cluster states can be used to
perform universal computation. As discussed before, in order to implement univer-
276 18 One-Way Quantum Computer
Fig. 18.7 (This figure is redrawn from Eqs. (18.11) and (18.12) in [23]). a A circuit for one-bit
teleportation; b Generalized one-bit teleportation. Published with permission of © Belal E. Baaquie
and L. C. Kwek. All Rights Reserved
sal quantum computation, one needs to realize any arbitrary single-qubit gate and a
suitable entangling gate, for instance, the controlled-NOT gate. Apart from the orig-
inal discussion on how MBQC simulates these gates [13], there are other alternative
discussions [17–23]. Here we follow the explanation given by Nielsen in [23], based
on the primitive circuit given in Fig. 18.7a that is proposed in [24].
The circuit in Fig. 18.7a is sometimes known as one-bit teleportation scheme,
where |+ = √12 (|0 + |1). To show how it works, let |ψ = α |0 + β |1. Then
note
1
H1 S12 (α |0 + β |1) ⊗ √ (|0 + |1)
2
1
= √ (|0 ⊗ H |ψ + |1 ⊗ X H |ψ), (18.7)
2
where S12 is the controlled phase gate acting on the two qubits. Measuring the first
qubit in the {0, 1} basis (or Z measurement) gives the desired result. This circuit is
then directly generalized to the one given in Fig. 18.7b, since Z θ commutes with S12 .
We then measure the first qubit and depending on the outcome of measurement, we
get H |ψ if the outcome is |0 (i.e., m = 0) or X H |ψ if the outcome is |1 (i.e.,
m = 1). In short, we have X m H |ψ.
θ
In Fig. 18.7b, we added a Z θ gate where Z θ = ei 2 Z , with Z as the Pauli-Z operator.
Note that H Z θ acting on the control-phase operator means that Z θ acts on S12 first
and then followed by the Hadamard operator, H . However, Z θ commutes with S12 ,
so in accordance with Eq. (18.7), the result is just
1
√ (|0 ⊗ H Z θ |ψ + |1 ⊗ X H Z θ |ψ).
2
Fig. 18.8 Concatenation of the ‘generalized’ teleportation circuit to form the arbitrary single-qubit
gate. Published with permission of © Belal E. Baaquie and L. C. Kwek. All Rights Reserved
where we note that in the last equality, we have used H 2 as the identity matrix.
Depending on the outcomes of the measurement, we see that we have performed the
following transformation
ζ η θ
U (ζ, η, θ ) = X ζ Z η X θ = ei 2 X ei 2 Z ei 2 X (18.10)
on the input state |ψ. Since, up to a global phase, U (ζ, η, θ ) is just the most general
form for an arbitrary single-qubit rotation, we have shown that we can perform
arbitrary unitary operation on a single qubit.
For universal quantum computation, we need to demonstrate that we can also
achieve a two-qubit entangling gate. It can be shown that no one-dimensional cluster
state array can simulate a two-qubit entangling gate. One needs to have a two-
dimensional array. To see how we can do this, let us consider the two-dimensional
cluster state in Fig. 18.9. This cluster state is a four-qubit state. Qubits 1 and 4 are
the input states, and we assume that they are separable with the states α|0 + β|1
and α |0 + β |1, respectively.
It is not hard to show that the resulting state after applying the control-phase gates
is
278 18 One-Way Quantum Computer
Fig. 18.9 A four-qubit cluster or graph state can be used to simulate a Controlled-NOT gate. The
1
state |+ is √ (|0 + |−). Published with permission of © Belal E. Baaquie and L. C. Kwek. All
2
Rights Reserved
1
|2D state = (|00(αα |+|0 + αβ |+|1)
2
|01(αα |−|0 − αβ |−|1)
|10(βα |+|0 + ββ |+|1)
−|11(βα |−|0 − ββ |−|1)). (18.11)
on qubit 3 and 4 with qubit 4 as the control bit which we denote as CNOT43 . We see
that in Eq. (18.12), a controlled NOT operation is applied to the state (α|0 + β|1)3
whenever the state of the second qubit is |14 .
What happens if the outcome is not | + +12 ? Suppose the measurement outcomes
of qubit 1 and 2 is | + −12 . In this case, we see that the state of qubit 3 and 4 becomes
It is shown in Sect. 18.3 that arbitrary single-qubit gates and the controlled NOT gate
can be simulated by MBQC with the appropriate cluster states or graph state. Uni-
versal quantum computing can then be implemented by concatenating these graphs
together. It should be noted that not all graph states are appropriate as resource states
for universal MBQC, for instance graph states associated with the tree graphs (i.e.,
graph without cycles) are not necessary resource states for MBQC [25–28]. Yet,
many of these graphs, for instance, the cluster states associated with a square lattice
or the honeycomb lattice [29], are demonstrated to be useful.
The advantage of MBQC for the implementation of quantum computing in the real
world is that once the highly entangled resource state is prepared, only single-qubit
measurements are needed throughout the entire process of computation, and quantum
entangling gates are unnecessary. The challenge in implementing quantum entangling
gates in a circuit model is the high noise and low fidelity. In MBQC, one avoids
entangling gates but the computation requires the preparation of a highly entangled
resource. Such a resource, e.g., cluster state, typically uses a three-step procedure
outlined in Sect. 18.2. The third step requires the application of a controlled-Z gates
on pairs of qubits connected by edges in the graph. So, a blind adherence to this
approach provides no advantage over the quantum circuit model.
An appealing idea that overcomes the need for entangling operations completely
is to seek for a physical system in which one could obtain the required entangled
resource states as the unique ground state. By cooling some quantum many-body,
hopefully just two-body, systems, one hopes to generate such entangled resource.
Yet, interactions in Nature are described solely by two-body process. So we hope
to achieve these ground states with systems whose Hamiltonians are equipped only
with two-body terms. We already know that the cluster state is a unique ground state
of the Hamiltonian HC given in Eq. (18.6), and that HC is gapped and frustration-
free. However, HC involves many-body interactions, not just two-body interactions
and such Hamiltonians are generally difficult to find in nature. For instances, the
HC associated with a 2D square lattice involves five-body interactions and the HC
associated with the 2D honeycomb lattice involves four-body interactions. Even the
HC associated with a 1D chain involves at least three-body interactions.
280 18 One-Way Quantum Computer
One therefore hopes that there exists a Hamiltonian with just two-body interactions
that gives a particular useful cluster state as the unique ground state. Unfortunately,
this turns out to be impossible as observed by Nielsen [23]. The idea behind the
proof is the following: if the Hamiltonian involves at most two-body interactions,
then its ground state energy is totally determined by the two-particle reduced density
matrices of the states. So, given any cluster state, |C , which acts as a resource
state for MBQC, some of the eigenstates of HC have the same two-particle reduced
density matrices as |C . Therefore, if the cluster state |C is the ground state, then
some other eigenstates of HC are also ground states, meaning the cluster state cannot
be the unique ground state of any two-body Hamiltonian. Given this no-go theorem,
what can do next?
In the original proposal by Raussendorf and Briegel [30], cluster states are cre-
ated by unitary evolution of Ising-type spin–spin interactions. There has been a pro-
posal to generate macroscopic cluster state in 3D lattice arrays of ultracold bosonic
and fermionic atoms [31–34]. Experimental efforts in this direction for sufficiently
large-scale cluster states are still rather challenging. Moreover, we have seen that an
alternative method of generating the resource state as the unique ground state of a
short-ranged interacting Hamiltonian with a finite spectral gap by cooling the system
to low-enough temperature is not feasible.
If we relax the condition for generating exact ground states, one can generate
an approximate cluster state as ground state of a two-body interacting Hamiltonian
through perturbation [35]. An alternative idea toward this goal is to exploit higher
dimensional states called tri-cluster state [36]. The tri-cluster state is a universal
resource state with a nearest-neighbor interacting parent Hamiltonian equipped with
a nonzero spectral gap on a hexagonal lattice. This quantum state has a local Hilbert
space of dimension six and contains the cluster state in three different bases, hence
the name tri-cluster state. Due to the extra dimensions, the tri-cluster state can be
further converted to a cluster state of qubit local Hilbert space (i.e., of two levels)
by the so-called quantum state reduction [28]. The technique has been extended to
three-dimensional graph states [37] and finite temperature states [26].
In recent years, continuous variable large-scale photonic cluster states have
been constructed [38, 39]. To demonstrate that these resources can be used for
measurement-based quantum computation, these states however need the prepa-
ration of highly squeezed states [40], which are experimentally challenging. For
discrete variable quantum computation, i.e., using 0s and 1s, experimental progress
is more difficult [41]. Yet overall, this paradigm in which quantum entanglement
is established right at the start provides a viable and interesting alternative to the
unitary circuit approach where quantum entanglement is created on demand through
entangling gates throughout the algorithm.
References 281
References
1. Vidal G (2003) Efficient classical simulation of slightly entangled quantum computations. Phys
Rev Lett 91(14):147902
2. Noah Linden, Sandu Popescu (2001) Good dynamics versus bad kinematics: is entanglement
needed for quantum computation? Phys Rev Lett 87(4):047901
3. Cory D, Heinrichs T (2004) Nuclear magnetic resonance approaches to quantum information
processing and quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.
gov
4. Wineland D, Heinrichs T (2004) Ion trap approaches to quantum information processing and
quantum computing. Quantum Inf Sci Technol Road v2.0. http://quist.lanl.gov
5. Caves C, Heinrichs T (2004) Neutral atom approaches to quantum information processing and
quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.gov
6. Chapman M, Heinrichs T (2004) Cavity qed approaches to quantum information processing
and quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.gov
7. Kwiat P, Milburn G, Heinrichs T (2004) Optical approaches to quantum information processing
and quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.gov
8. Clark R, Awschalom D, DiVincenzo D, Hammel PC, Steel D, Birgitta Whaley K, Heinrichs
T (2004) Solid state approaches to quantum information processing and quantum computing.
Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.gov
9. Orlando T, Heinrichs T (2004) Superconducting approaches to quantum information processing
and quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.gov
10. Lloyd S, Hammel PC, Heinrichs T (2004) “unique” qubit approaches to quantum information
processing and quantum computing. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.
gov
11. Divincenzo DP (2000) The physical implementation of quantum computation. Fortschritte der
Physik 48:771–783
12. Alamos L (2004) National security. Quantum Inf Sci Technol Roadmap v2.0. http://quist.lanl.
gov
13. Robert R, Briegel Hans J (2001) A one-way quantum computer. Phys Rev Lett 86(22):5188–
5191
14. Kitaev A, Laumann C (2009) Topological phases and quantum computation. arXiv:0904.2771
15. Farhi E, Goldstone J, Gutmann S, Sipser M (2000) Quantum computation by adiabatic evolu-
tion. arXiv:quant-ph/0001106
16. Briegel HJ, Raussendorf R (2001) Persistent entanglement in arrays of interacting particles.
Phys Rev Lett 86:910–913
17. Nielsen MA (2003) Quantum computation by measurement and quantum memory. Phys Lett
A 308:96–100
18. Leung DW (2001) Two-qubit projective measurements are universal for quantum computation.
arXiv:quant-ph/0111122
19. Leung DW (2003) Quantum computation by measurements. arXiv:quant-ph/0310189
20. Aliferis P, Leung DW (2004) Computation by measurements: a unifying picture. Phys Rev A
70(6):062314
21. Childs AM, Leung DW, Nielsen MA (2005) Unified derivations of measurement-based schemes
for quantum computation. Phys Rev A 71(3):032318
22. Jorrand P, Perdrix S (2005) Unifying quantum computation with projective measurements only
and one-way quantum computation. In: Ozhigov YI (ed) Society of photo-optical instrumen-
tation engineers (SPIE) conference series, volume 5833 of society of photo-optical instrumen-
tation engineers (SPIE) conference series, pp 44–51
23. Nielsen Michael A (2006) Cluster-state quantum computation. Rep Math Phys 57(1):147–161
24. Zhou X, Leung DW, Chuang IL (2000) Methodology for quantum logic gate construction. Phys
Rev A 62(5):052316
25. Shi Y-Y, Duan L-M, Vidal G (2006) Classical simulation of quantum many-body systems with
a tree tensor network. Phys Rev A 74(2):022320
282 18 One-Way Quantum Computer
26. Li Y, Browne DE, Kwek LC, Raussendorf R, Wei T-C (2011) Thermal states as universal
resources for quantum computation with always-on interactions. Phys Rev Lett 107(6):060501
27. Kyaw TH, Li Y, Kwek L-C (2014) Measurement-based quantum computation on two-body
interacting qubits with adiabatic evolution. Phys Rev Lett 113(18):180501
28. Kwek LC, Wei Z, Zeng B (2012) Measurement-based quantum computing with valence-bond-
solids. Int J Mod Phys B 26(02):1230002
29. van den Nest M, Miyake A, Dür W, Briegel HJ (2006) Universal resources for measurement-
based quantum computation. Phys Rev Lett 97(15):150504
30. Raussendorf R, Briegel HJ (2001) A one-way quantum computer. Phys Rev Lett 86(22):5188
31. Mandel O, Greiner M, Widera A, Rom T, Hänsch TW, Bloch I (2003) Controlled collisions
for multi-particle entanglement of optically trapped atoms. Nature 425(6961):937–940
32. Gao X, Wang S-T, Duan L-M (2017) Quantum supremacy for simulating a translation-invariant
Ising spin model. Phys Rev Lett 118(4):040502
33. Mamaev M, Blatt R, Ye J, Rey AM (2019) Cluster state generation with spin-orbit coupled
fermionic atoms in optical lattices. Phys Rev Lett 122(16):160402
34. Amico L, Boshier M, Birkl G, Minguzzi A, Miniatura C, Kwek L-C, Aghamalyan D, Ahufinger
V, Anderson D, Andrei N (2021) Roadmap on atomtronics: state of the art and perspective.
AVS Quantum Sci 3(3):039201
35. Bartlett SD, Rudolph T (2006) Simple nearest-neighbor two-body hamiltonian system for
which the ground state is a universal resource for quantum computation. Phys Rev A
74(4):040302
36. Chen X, Zeng B, Gu Z-C, Yoshida B, Chuang IL (2009) Gapped two-body hamiltonian
whose unique ground state is universal for one-way quantum computation. Phys Rev Lett
102(22):220501
37. Wei T-C, Li Y, Kwek LC (2014) Transitions in the quantum computational power. Phys Rev
A 89(5):052315
38. Asavanant W, Shiozawa Y, Yokoyama S, Charoensombutamon B, Emura H, Alexander RN,
Takeda S, Yoshikawa J, Menicucci NC, Yonezawa H et al (2019) Generation of time-domain-
multiplexed two-dimensional cluster state. Science 366(6463):373–376
39. Yokoyama S, Ukai R, Armstrong SC, Sornphiphatphong C, Kaji T, Suzuki S, Yoshikawa J,
Yonezawa H, Menicucci NC, Furusawa A (2013) Ultra-large-scale continuous-variable cluster
states multiplexed in the time domain. Nat Photon 7(12):982–986
40. Menicucci NC, Van Loock P, Gu M, Weedbrook C, Ralph TC, Nielsen MA (2006) Universal
quantum computation with continuous-variable cluster states. Phys Rev Lett 97(11):110501
41. Larsen MV, Guo X, Breum CR, Neergaard-Nielsen JS, Andersen UL (2019) Deterministic
generation of a two-dimensional cluster state. Science 366(6463):369–372
Part IV
Summary
Chapter 19
Efficiency of a Quantum Computer
Some of the quantum algorithms discussed are reviewed to see what general lessons
can be drawn from them. Two cardinal points should be kept in mind: (a) quantum
superposition, called quantum parallelism in the popular literature, and quantum
entanglement play a crucial role in the advantage of a quantum over a classical algo-
rithm, and (b) quantum measurement theory plays an essential and counterintuitive
role in obtaining results that are impossible for a classical computer. In particular,
unlike a classical computer each step in the execution of a quantum computation
cannot, in principle, be observed: one can only observe the initial and final quantum
states of a quantum algorithm. A key to the superiority of the quantum computer
over a classical one arises from the use of the qubit as a basic unit of computation.
The qubit allows for the superposition of two classical bits, and which leads to many
advantages over a classical algorithm.
• Deutsch algorithm. The qubit in the Deutsch allows for transformations of the
quantum algorithm, based on superposition, that gives a result no classical algo-
rithm can provide.
• Deutsch–Jozsa algorithm. This algorithm demonstrates the power of quantum
computing arising from superposition. Note that, from Eq. 10.5, the final amplitude
for the output qubit state of Deutsch–Jozsa algorithm is given by
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 285
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2_19
286 19 Efficiency of a Quantum Computer
1 2
(−1) f (x) (19.1)
N x
The fact that the f (x) is simultaneously evaluated for all x is directly employed
in obtaining the result above. In contrast, a classical algorithm can only evaluate
f (x) for x one at a a time; or it requires parallel capabilities for evaluating f
for all x, which soon becomes impractical when the number of configurations
exponentially increase. As n gets larger, the resources required to evaluate f (x)
by classical computer scale as a power of n.
Constructive and destructive interference that takes place in the summation given
in Eq. 19.1 is a direct result of quantum parallelism, which is impossible in a
classical computer.
• Grover algorithm. The Hadamard gate H ⊗n is applied to the input n-qubit state
|0⊗n and maps the input qubit into a linear combination, with equal amplitude,
of all the computational basis states. Recall from Eq. 11.10
1
N
|0 → √ |x
N x=1
The ability of Hadamard gates to map the input qubit into this linear combination
is due to the superposition principle of quantum mechanics.
The n-qubits evolve in the Hilbert state space of the qubits. The advantage of the
Grover algorithm over the classical case lies in the fact that it is the state vector
|ψ that evolves in Hilbert space; due to the superposition principle, one has the
simultaneous updating of all the basis states, as given in Eq. 11.7
N −1
1
|ψ = √ (−1) f (x) |xH |1 (19.2)
N x=0
What Eq. 19.2 tells us is that the state vector |ψ is being evolved; the right hand
side of Eq. 19.2 are the components of the state vector in the computational basis
states, and these components are all evolved simultaneously. See Sect. 4.12 and
Eq. 4.42 for a more detailed discussion. It should be noted that using all the values
of f (x) in Eq. 19.2 does not mean that we know the value of the function f (x):
for this one would need to make separate measurements that would evaluate the
value of f for each x.
For n > 100, simultaneously evaluating f (x) for 2n values x of the argument is
impossible for a classical computer: it would need to evaluate, separately, the value
of f for each of the 2n values of x.1
The key to the Grover algorithm is that the amplification (rotation) gate G acts on
all the n-qubits at the same time and yields
We can extract the quantity A from Eq. 19.3 using the fact the right hand side is
an entangled state of qubits of the first and second registers. A measurement on
the qubits of the second register, namely | f (xi ), which does not need knowledge
of the quantity A, yields the value of A on performing the measurement.
The generalized Born rule shows that, as given in Eq. 13.4, the process of measure-
ment of the qubits of the second register, due to the collapse of the state vector,
picks out a single state vector from Eq. 19.3, say | f (x0 ), from the summation
r −1
i=0 and yields
The state vector |ψ3 (x0 ) is picked out by the generalized Born measurement since
it is entangled with the state vector | f (x0 ). The value of x0 is arbitrary and | f (x0 )
has some likelihood of being detected. This likelihood does not concern us since
the analysis for obtaining A is valid for all x0 and | f (x0 ) is ignored henceforth.
The post-measurement state vector for the k degree of freedom is given by
1
A−1
|ψ3 (x0 ) = √ |x0 + kr ; ψ3 (x0 )|ψ3 (x0 ) = 1 (19.5)
A k=0
√
Note the important fact that the pre-factor of 1/ A is a result of the generalized
Born measurement that requires the state |ψ3 (x0 ) to be normalized. Since Q is
known and A can be extracted from Eq. 19.5, the equation Q = r A allows one
to obtain the value of r , and which in turn leads to the factorization of N into
its primes. The Shor algorithm shows that a quantum algorithm, due to the non-
classical process of a quantum measurement, superposition and entanglement,
yields a result that is not possible for a classical algorithm.
288 19 Efficiency of a Quantum Computer
2Fugaku has been superseded as the fastest supercomputer in the world by Hewlett Packard Enter-
prise Frontier, or OLCF-5, in May 2022.
19.2 Memory and Speed of Quantum Computations 289
Every time the algorithm is run, the same output register can be used for recording
the new outcome, which is uncertain. The remaining 2n configurations required
for the algorithm are employed in Hilbert space, which is not observable.
290 19 Efficiency of a Quantum Computer
4. The speed of the quantum computer is determined by the speed of the updating,
as well as the fact that there is parallel updating of all the components of the
state vector. As mentioned above, and given in Eq. 4.42, the updating of the
quantum system evolves the entire state vector: hence the simultaneous evolution
of all the components of state vector in terms of the computational basis states—
which can run into millions for an algorithm like the Shor algorithm—results in
an exponential speeding up compared to a classical computer. For example, as
mentioned in Chap. 1, quantum computing system of ‘Jiuzhang’ is 100 trillion
times faster than the world’s fastest existing supercomputer.
5. The upper limit on the speed of quantum computations is imposed by how fast
the quantum state can be updated. One line of reasoning is that the time-energy
uncertainty principle limits the speed with which one can evolve a quantum state to
another orthogonal state. Let the minimum time be TM ; similar to the uncertainty
principle, TM is given by the following Margolus–Levitin theorem
h
TM ≥
4E
where E is the average energy of the quantum state being evolved. However,
it has been shown that the speed of computation is not limited by the Margolus–
Levitin theorem but by other considerations such as information density and
information transmission speed, which is less than the speed of light [1].
The question and answer below is a continuation of the interview in Sect. 1.1. Many
of the points covered in earlier discussions are revisited for greater clarity, and we
review the earlier discussion in Sects. 4.12 and 19.1. The answer below is based on
the Copenhagen interpretation of quantum mechanics: open questions regarding this
interpretation are discussed in Sect. 4.8.
Hobson: What are quantum computers teaching us about our quantum mechanical
universe?
Baaquie: Quantum computers bring to the forefront the paradoxes, enigmas and
conundrums of quantum mechanics that have been, and continue to be, encased in a
thick shell of formalism [2].
To illustrate these paradoxes, consider how information is stored for a classical
computation, which we can then compare with a quantum computation. To make
things explicit and clear, consider a computation involving three binary bits. The
23 -eight configurations, as enumerated in Sect. 4.1, are
The input and output for both the classical and quantum computation is a determinate
3-bits string, which could, for example, be
The classical computer’s algorithm, in principle, needs to store all the eight con-
figurations given above, since any of the eight configurations may be generated as
the algorithm is executed, and each intermediate step of the classical computation is
a configuration of the classical computer that can be directly observed. In contrast,
none of the intermediates steps of a quantum algorithm can, in principle, be observed:
only the input and output states of the quantum algorithm can be observed—this is
discussed in Sect. 5.2. Hence, the quantum computer only needs the input and output
basis states, which are two 3-bits strings.
In summary, as discussed in Sect. 4.12, for a computation requiring say 300 bits,
a classical computer needs to have a storage device that can store 2300 -binary string
configurations, and which requires a physical device that would have more atoms
than the entire Universe. In contrast, this very same computation can be carried out
by a quantum computer with just 300 qubits.
So the question arises: where is the information of the quantum computer being
stored and where does the process of quantum computation take place? To answer
this, one needs to start with the nature of a quantum degree of freedom. Recall
from Sect. 4.1 that the quantum degree of freedom is an indeterminate entity that
cannot, as such, be observed in physical spacetime: what can be observed are only the
particular and determinate values of the degree of freedom. Every time its state vector
is observed, the underlying quantum degree of freedom—with some likelihood—is
always observed to be in a determinate state.
The Copenhagen interpretation of quantum mechanics and the one used in quan-
tum computers, which was pioneered by Niels Bohr, Max Born and Werner Heisen-
berg, provides the following explanation: the indeterminate quantum degrees free-
dom of a quantum computer is described by qubits (state vector) that ‘exists’ in
Hilbert space—a mathematical space that is a superstructure of quantum mechanics.
Both the non-trivial phenomena of quantum superposition and quantum entangle-
ment are properties of elements (vectors) of Hilbert space.
It is a remarkable fact that, as discussed by Baaquie [2], the Copenhagen inter-
pretation of quantum mechanics implies that Hilbert space exists outside of space
and time.
The hardware (quantum device) subjects the state vector of the degree of freedom
to various process using electric and magnetic fields, photons and so on, so as to
evolve the quantum state vector in Hilbert space, as shown in Fig. 4.6. In particular,
the hardware evolves the state vector coherently in Hilbert space—as dictated by the
quantum algorithm—and in doing so executes the quantum algorithm, as shown in
Fig. 4.6.
As discussed in Sect. 5.2, before the completion of the quantum algorithm no
measurement should be performed on the degree of freedom—since doing so will
pre-maturely terminate the algorithm. On the completion of the computation, a mea-
292 19 Efficiency of a Quantum Computer
surement is performed on the quantum device that causes the qubit (state vector) in
Hilbert space to ‘collapse’—with different likelihoods—to one of the possible deter-
minate output states determined by the measuring device. For a quantum computer, as
mentioned earlier, the possible output states can be the computational basis states—
which are the particular and determinate values of the degrees of freedom.3 The
process of measurement projects the degree of freedom—with different likelihood—
from Hilbert space to one of the possible computational basis states, which is observed
output state; see Fig. 4.6.
In sum, the process of quantum computation takes place in Hilbert space
that exists outside spacetime and the results are observed by measuring devices
that are in spacetime.
The degrees of freedom and its corresponding Hilbert space are fundamental
ingredients of quantum mechanics, and quantum computers bring out this aspect of
quantum mechanics with full force. It is as if, while the different steps of the quantum
algorithm are being carried out by the evolution of the quantum device in physical
spacetime, we are ‘looking’ at Hilbert space—and the indeterminate quantum degree
of freedom that generates it.
19.4 Conclusions
3Recall the degree of freedom can have many determinate representations depending on the mea-
suring device.
References 293
High-level languages do not refer to the hardware required for carrying out logical
operations, and such a high-level programming language has yet to be developed for
quantum computers.
Building hardware for quantum computers poses formidable—but apparently not
insurmountable—technological challenges. For any realistic problem, one would
require about 100 ◦ C of freedom. In 2019, Google had the most powerful quantum
computer with 72 qubits.4 IonQ claims to have the most powerful quantum computer
in 2022, based on application-oriented industry benchmarks.5
Quantum mechanics started with Schördingers equation in 1926 and it has taken
almost a century to understand its implications for information and computer science.
What is remarkable is that the hardware of a quantum computer is a macroscopic
physical object that obeys the laws of quantum mechanics, bringing forth the para-
doxes and enigmas of quantum theory—which explains the microscopic behavior of
nature—to a new and currently unexplored regime.
Quantum computers have the potential for an epoch-making transformation in
the science of information processing. Quantum algorithms hold the promise of
solving problems that have so far been considered insoluble. It is hoped that quantum
computers will usher in a new wave of high technology and open up new vistas for
the fundamental sciences as well.
References
1. Jordan SP (2017) Fast quantum computation at arbitrarily low energy. Phys Rev A 95:032305
2. Baaquie BE (2013) The theoretical foundations of quantum mechanics. Springer, UK
4 https://www.technologyreview.com/2019/09/18/132956/ibms-new-53-qubit-quantum-
computer-is-the-most-powerful-machine-you-can-use/.
5 https://www.hpcwire.com/off-the-wire/ion-qs-aria-quantum-computer-achieves-20-
algorithmic-qubits/.
Index
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer 295
Nature Singapore Pte Ltd. 2023
B. E. Baaquie and L.-C. Kwek, Quantum Computers,
https://doi.org/10.1007/978-981-19-7517-2
296 Index