0% found this document useful (0 votes)
142 views297 pages

Quantum Computers - Theory and Algorithms by Belal Ehsan Baaquie Leong-Chuan Kwek (Springer 2023)

Quantum computing

Uploaded by

siradjbenam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views297 pages

Quantum Computers - Theory and Algorithms by Belal Ehsan Baaquie Leong-Chuan Kwek (Springer 2023)

Quantum computing

Uploaded by

siradjbenam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 297

Belal Ehsan Baaquie

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

ISBN 978-981-19-7516-5 ISBN 978-981-19-7517-2 (eBook)


https://doi.org/10.1007/978-981-19-7517-2

© 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.

Singapore Belal Ehsan Baaquie


Leong-Chuan Kwek

v
vi Preface

References

1. Feynman RP (2007) The character of physical law. Penguin Books, USA


2. Feynman RP (2018) Lectures on computation. CRC Press, USA
3. Deutsch D (1985) Quantum theory, the church–turing principle and the universal quantum
computer. Proceedings of the Royal Society
Acknowledgments

We would like to acknowledge and express our thanks to many outstanding


researchers in the field of quantum computing.
We would like to thank our respective families for their unflagging support and
encouragement, without which this book could not have been written.
One of us (BEB) would like to thank George Zweig, Gerald ‘Gerry’ Neugerbauer,
Clifford M. Will, Jon Mathews, Jeffrey E. Mandula, David Mermin, David Ashcroft
and Kurt Gottfried for shaping my views on quantum mechanics. He would also like
to thank M. Mahmudul Karim, Behzad Mansouri and Frederick H. Willeboordse for
many stimulating discussions on computation and algorithms. He had the privilege
of having enlightening discussions on quantum mechanics with peerless scholars and
visionaries Richard P. Feynman and Kenneth G. Wilson, for which he is eternally
indebted to them.
The other author (KLC) would like to thank Luigi Amico, Berge Englert, Jiangfeng
Du, Thomas Durt, Artur Ekert, Rosario Fazio, Fan Heng, David Hutchinson,
Myungshik Kim, Jose Ignacio Latorre, Aiqun Liu, Christian Miniatura, Bill Munro,
C. H. Oh, Xiangbin Wang, Vlatko Vedral, Marek Zukowski and many others for
their constant encouragement and advice. He has also benefited a lot from numerous
stimulating discussions with many of his current and past students, post-doctoral
fellows and group members (A partial list follows: Davit Aghamalyan, Joonwoo Bae,
Kishor Bharti, Shaohen Chew, Andy Chia, Keng Wah Choo, Tobias Haug, Masahito
Hayashi, Hermanni Heimonen, Mingxia Huo, Alexander Hue, Kelvin Koor, Thiha
Kyaw, Elica Kyoseva, Chee Kong Lee, Ying Li, Cao Lin, Jonathan Lau, Wei Luo,
Kian Hwee Lim, David A. Herrera-Martí, Dariel Mok, Ewan Munro, Tiong Eng Ng,
Wei Nie, Yuan Shen, Harshank Shrotriya, Sivakumar M. Maniam, Sai Vinjanam-
pathy, Lingxiao Wan, Gong Zhang, Hui Zhang, Zisheng Wang, Janus H. Wesenberg
and so forth).

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

3.11 Matrices of Full-Adder Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65


References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4 Principles of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1 Degrees of Freedom: Indeterminate . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.2 Hilbert Space; State Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.2.1 Continuous Degrees of Freedom . . . . . . . . . . . . . . . . . . . . 77
4.2.2 Discrete Degrees of Freedom: Qubits . . . . . . . . . . . . . . . . 78
4.3 Hermitian and Unitary Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.4 The Schrödinger Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.4.1 Key Features of the Schrödinger Equation . . . . . . . . . . . . 84
4.5 Quantum Measurement: Born Rule . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.6 Quantum Measurements and Degrees of Freedom . . . . . . . . . . . . . 90
4.7 No-Cloning Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.8 Copenhagen Interpretation: Open Questions . . . . . . . . . . . . . . . . . . 92
4.9 Summary of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.10 Generalized Born Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.10.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.11 Consistency of Generalized Born Rule . . . . . . . . . . . . . . . . . . . . . . 100
4.12 Quantum Mechanics and Quantum Computers . . . . . . . . . . . . . . . . 102
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5 Quantum Superposition and Entanglement . . . . . . . . . . . . . . . . . . . . . . 107
5.1 Quantum Superposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
5.1.1 The Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5.1.2 Experiment with Detectors 1 and 2: No
Interference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.1.3 Experiment Without Detectors 1 and 2:
Indeterminate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
5.2 Quantum Superposition and Quantum Algorithms . . . . . . . . . . . . . 114
5.3 Partial Trace for Tensor Products . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
5.4 Density Matrix ρ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
5.4.1 Pure Density Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
5.4.2 Mixed Density Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
5.4.3 Density Matrix for a Two-State System . . . . . . . . . . . . . . 118
5.5 Reduced Density Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
5.6 Separable Quantum Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
5.7 Entangled Quantum States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.8 Entanglement for Composite Systems . . . . . . . . . . . . . . . . . . . . . . . 123
5.9 Entangled State: Two Binary Degrees of Freedom . . . . . . . . . . . . . 124
5.10 Quantum Entropy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
5.11 Maximally Entangled States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
5.11.1 An Entangled State of Two Binary Degrees
of Freedom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
5.12 Pure and Mixed Density Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Contents xi

6 Binary Degrees of Freedom and Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . 131


6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
6.2 Degrees of Freedom and Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
6.3 Single Qubit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
6.3.1 Density Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
6.4 Bell Entangled Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
6.5 Bell States: Maximally Entangled . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7 Quantum Gates and Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.1 Quantum Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
7.2 Superposed and Entangled Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . 143
7.3 Two- and Three-Qubit Quantum Gates . . . . . . . . . . . . . . . . . . . . . . 146
7.4 Arithmetic Addition of Binary Qubits . . . . . . . . . . . . . . . . . . . . . . . 147
7.5 Quantum Measurements of Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . 148
7.5.1 Partial Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
8 Phase Estimation and quantum Fourier Transform (qFT) . . . . . . . . . 155
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.2 Eigenvalue of Unitary Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
8.3 Phase Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
8.3.1 Phase Estimation for n = 3 . . . . . . . . . . . . . . . . . . . . . . . . . 158
8.4 quantum Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
8.4.1 quantum Fourier Transform for n = 3 . . . . . . . . . . . . . . . 164
8.5 Quantum Circuit of qFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

Part II Quantum Algorithms


9 Deutsch Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
9.1 The Deutsch Quantum Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
10 Deutsch–Jozsa Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
11 Grover’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
11.1 Phase Inversion and Amplitude Amplification . . . . . . . . . . . . . . . . 186
11.2 Grover’s Quantum Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
11.3 Grover Algorithm: Two-Qubit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
11.4 Grover Algorithm: Phase Inversion . . . . . . . . . . . . . . . . . . . . . . . . . 192
11.5 Grover Diffusion Gate W . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
11.6 Grover Recursion Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
11.7 Single Recursion: Two Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
11.8 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
xii Contents

12 Simon’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203


12.1 Quantum Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
12.2 An Illustrative Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
13 Shor’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
13.2 Understanding the Classical Algorithm . . . . . . . . . . . . . . . . . . . . . . 210
13.3 Quantum Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
13.3.1 How Then Does the Quantum Algorithm Work? . . . . . . . 211
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

Part III Applications


14 Quantum Algorithm for Option Pricing . . . . . . . . . . . . . . . . . . . . . . . . . 221
14.1 Review of Option Pricing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
14.2 Quantum Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
14.3 Quantum Algorithm for Expectation Value . . . . . . . . . . . . . . . . . . . 224
14.4 Algorithm for Quadratic Improvement . . . . . . . . . . . . . . . . . . . . . . . 225
14.5 Eigenvalues of Diffusion Operator Q . . . . . . . . . . . . . . . . . . . . . . . . 228
14.6 Amplitude Amplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
14.7 Call Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
14.8 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
15 Solving Linear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
15.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
15.2 Harrow–Hassidim–Lloyd Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 240
15.3 Specific Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
15.4 Why Do We Not Need the Eigenvalues? . . . . . . . . . . . . . . . . . . . . . 245
15.5 Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
16 Quantum-Classical Hybrid Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 249
16.1 Why Bother? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
16.2 Variational Quantum Eigensolvers . . . . . . . . . . . . . . . . . . . . . . . . . . 249
16.3 Quantum Approximate Optimization Algorithm . . . . . . . . . . . . . . 252
16.4 MaxCut Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
17 Quantum Error Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
17.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
17.2 Simple Quantum Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
17.3 Kraus Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
17.4 Nine-qubit Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
17.5 General Properties of Quantum Error-Correcting Codes . . . . . . . . 261
17.6 Classical Linear Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Contents xiii

17.7 An Example of a Linear Code: Hamming Code . . . . . . . . . . . . . . . 265


17.8 Quantum Linear Codes: CSS Codes . . . . . . . . . . . . . . . . . . . . . . . . . 267
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
18 One-Way Quantum Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
18.1 Measurement-Based Quantum Computation . . . . . . . . . . . . . . . . . . 271
18.2 The Cluster State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
18.3 Simulation of Basic Quantum Gates . . . . . . . . . . . . . . . . . . . . . . . . . 275
18.4 Resource States for MBQC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

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

Belal Ehsan Baaquie is an adviser to Helixtap Tech-


nologies, Singapore. He is a former professor of Finance
at INCEIF University, Malaysia, and a former professor
of Physics at the National University of Singapore. He
has a Bachelor of Science degree from the California
Institute of Technology and a PhD from Cornell Univer-
sity in theoretical physics, specializing in quantum
field theory. He later developed an interest in finance
and economics and started applying quantum math-
ematics to these fields. He has written four books
on quantum finance: Quantum Finance (Cambridge,
2007), Interest Rates and Coupon Bonds in Quantum
Finance (Cambridge, 2009), Quantum Field Theory
for Economics and Finance (Cambridge, 2018) and
Mathematical Methods and Quantum Mathematics for
Economics and Finance (Springer, 2020). In addition,
he has written several books focusing on topics from
quantum mechanics and mathematics to books on the
leading ideas in science, including The Theoretical
Foundations of Quantum Mechanics (Springer, 2013),
with his most recent coauthored book being Quantum
Computers: Theory and Algorithms (Springer, 2023).
(Amazon author page at https://www.amazon.com/-/e/
B07GCC7WQ4).

xv
xvi About the Authors

Leong-Chuan Kwek is a principal investigator at


the Center for Quantum Technologies, NUS, the Co-
director of the Quantum Science and Engineering Center
at NTU and a faculty of the National Institute of Educa-
tion, Singapore. He is the Immediate Past President
of the Institute of Physics, Singapore and a Council
Member of the Association of Asia Pacific Physical
Societies. He is also an elected Fellow of the American
Association for the Advancement of Science (AAAS)
and the Institute of Physics, UK (IOP).
Chapter 1
Introduction

Quantum mechanics describes and explains the workings of nature—and is by far


the most successful theory of science. Although quantum mechanics has qualita-
tively changed our view of nature, a satisfactory understanding of it is still far from
complete. The ‘enigmatic’ aspects of quantum mechanics—specially the pivotal and
non-classical role that measurements plays in connecting the mathematical formal-
ism with observations—are discussed in the context of quantum computers in the
concluding chapters. In fact, the workings of quantum computers throw new light on
the mysteries and conundrums of quantum mechanics.
Similar to the application of quantum mechanics for the understanding of nature,
quantum mechanics embodies a radical shift of paradigm from classical information
science to quantum information science. The book focuses on bringing this shift of
paradigm to the forefront.
According to quantum mechanics, the state vector encodes all the information
about a physical system. For example, if one asks: ‘What is a hydrogen atom?’—
then a response based on quantum mechanics is that it is a specific state vector. In
general, all physical entities are represented by state vectors.
The rather unexpected and counterintuitive result of quantum information sci-
ence is that the state vector can be designed, using the laws of quantum physics, to
encode information that originates from non-physical sources—in particular from
algorithms that arise in information and computer science. Furthermore, unitary
(reversible) transformations can be carried out on an initial state vector, again using
the laws of quantum physics, that execute (quantum) algorithms designed and based
on the requirements of computer science. What is noteworthy is that due to the enig-
matic ‘quantum parallelism’ of quantum mechanics, the evolution of the state vector
executes algorithms much faster that any classical computer—and in some cases
even exponentially faster.

© 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

to information processing quantum algorithms based directly on the principles of


quantum mechanics: algorithms that carry out computational operations that are not
allowed in a classical computer are at the core of a quantum computer.
It will be seen that the algorithms in quantum computers are expressed in terms
of quantum gates that refer to specific quantum circuits (hardware) that encode these
quantum gates; the algorithms are directly based on the underlying quantum cir-
cuits that realize these algorithms. This is the reason that a high-level programming
language like C++ has not yet emerged for quantum computers because these are
largely based on intuition and thinking derived from everyday life—and which does
not refer to any of the underlying gates and circuits. The current level of understand-
ing of quantum algorithms has a logical structure that is quite counterintuitive and
not similar to the algorithms employed in classical computers.
The hardware required to build a quantum computer is not discussed in this book
as it belongs to the domain of quantum physics and engineering—whereas the focus
of this book is on information theory and algorithms that emerges out of quantum
mechanics. There are still many challenges in hardware implementation of quantum
algorithms, and hardware continues to be the bottle-neck in constructing a work-
ing quantum computer. A scalable quantum computing device poses a number of
formidable, but not insurmountable, technological problems. Since the primary focus
of this introduction is to understand the logic of a quantum computer, there is no need
for a detailed discussion on how to build such a device. This is similar to studying
classical computers, where mastering the logic of the codes does not require any
knowledge of semiconductors and electronics that run these codes.
In this book, we provide a brief introduction to quantum computation. All the
necessary concepts are derived from first principles, and this book is self-contained
in its presentation.
Part I of the book is focused on the foundations of the subject. The concept of clas-
sical computers and classical circuits and gates is reviewed, as classical algorithms
provide a platform for introducing quantum algorithms. A brief review of quantum
mechanics is provided as it forms the necessary foundation for understanding both
quantum algorithms as well as the hardware that is required for these algorithms;
however, as mentioned above, we will not discuss the hardware aspect of quantum
computers. The concepts of quantum superposition (also called quantum parallelism)
and quantum entanglement are discussed in order to understand the key advantages
of a quantum over a classical computer. A detailed discussion of quantum gates is
given as well as a derivation of phase estimation and quantum Fourier transforms,
as these form the bedrock for many of the algorithms that we discuss later.
Part II discusses some well-known quantum algorithms, including the Deutsch
and the Deutsch–Jozsa algorithm. The Shor and Grover algorithms, considered to be
major milestones of the subject, are discussed in detail to exemplify the techniques
used in quantum algorithms.
4 1 Introduction

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].

1.1 Interview on Quantum Computers

One of us (BEB) spoke to Future of Finance cofounder Dominic Hobson in 2021


about the near as well as the long-term prospects of quantum computers.3 It is rec-
ommended that the interview be re-read after having gone through this book, as the
technical aspects of the interview, which are not spelt out, should then be clearer.
The interview has been modified for inclusion in this book (Fig. 1.1).
Hobson: How long must we wait for quantum computers to be adopted and
applied?
Baaquie: 30 years have passed since the beginning of quantum computers in
1982, without, even now, any practical application. A linear progression would place
applications in the distant future. However, progress in science happens through
sudden discontinuous advances and hence a breakthrough can be expected. It is
difficult to put a time scale on it.
Hobson: What engineering problems remain to be solved in quantum computing?
Baaquie: The fundamental problem is that quantum qubits are very fragile, with
the smallest disturbance breaking what is the called quantum superposition that is the
basis of quantum parallelism—and which is responsible for the exponential speeding
up of a quantum algorithm. The breaking of quantum superposition is also called
decoherence. This is a hardware problem that needs basic understanding of quantum
physics to obtain a solution.
Hobson: Do we have enough engineers with that basic understanding of quantum
physics?
Baaquie: The semiconductor industry (which had US$430 billion sales in 2019)
requires quantum mechanics. The design of all semiconductor devices is based on
quantum effects in materials. Semiconductor engineers could foreseeably master the
physics of quantum computers if such an undertaking becomes sufficiently reward-
ing.
Hobson: Who—governments, venture capitalists, technology vendors and
corporates—do you see investing in quantum computing at the moment and why?

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

correction. If one adds the quantum decoherence of the fragile quantum-superposed


state, it is estimated that one needs 50 qubits to obtain a single error free qubit.
This is the formidable problem—posed by errors in transmission and by quantum
decoherence—for a quantum computer.
Hobson: What does quantum computing cost at the moment—measured by, say,
an hour of computing time—and will that cost fall over time?
Baaquie: Rigetti apparently charges US$1000 per hour for a 36-qubit system.
One expects the cost of quantum computing to fall, but again predictions are difficult
to make as to when breakthrough technologies will occur that lower the cost.
Hobson: Is a hybrid of quantum and digital computing the immediate solution or
the long-term path forward?
Baaquie: Hybrid computing is currently one of the favored approaches, with
parameters provided by a classical algorithm and the simulation being carried out
on a quantum computer. In the long run, there is no need for hybrid computing since
classical computers are a special case of the quantum computer, and its algorithms
can be factored into the quantum algorithm. Since qubits are much more expensive
than classical bits, hybrid algorithms are a matter of cost efficiency.
Hobson: Are quantum computers indifferent to the physical substrate or device
they run on?
Baaquie: Most quantum computers are devices that can support qubit states.
Currently, the preferred device for a qubit is the Josephson junction. This is a two-state
system based on a superconductor and hence requires low temperature. Other devices
can run on photons and with the advantage of functioning at room temperature.
Photonic quantum computers are based on chip-integrated silicon photonic devices
and claim to be scalable and error-resistant. The most efficient device for a quantum
computer at present is difficult to discern.
Hobson: What can quantum computers do now that digital computers cannot?
Baaquie: There are two famous quantum algorithms. The first is the Grover √
algorithm that searches for a particular entry in a database of size N —and takes N
steps compared to N steps of a classical computer. For example, to find an entry in
a ledger of 1 million entries, Grover’s algorithm would take only 1000 instead of a
million steps. The second is the Shor’s algorithm, which can factorize a number into
its primes (used in all encryption and secure communications) exponentially faster
than a classical computer. The problem is that, for any practical problem, Grover’s
algorithm can only efficiently search databases with N = 7 and Shor’s algorithm, as
of now, can only factorize 21 = 3×7. This is because of the currently limited number
of qubits and the noise problem.
Hobson: How do you write code on a quantum computer?
Baaquie: A classical computer’s code is written according to one’s day-to-day
thinking. For instance, if one wants to add two numbers, one takes the first number
and then adds to it the second number. A quantum computer code is counterintuitive,
being based on the laws of quantum mechanics. To add two numbers, one has first
to write the numbers in terms of the qubits. All operations (or gates, to use the
classical computing term) in a quantum algorithm are special matrices called unitary
transformations and so one has to decide how the operation of addition is represented
1.1 Interview on Quantum Computers 7

by unitary matrices. For example, to add 1 + 1 using a quantum algorithm, as discussed


in Chap. 7, one would need to employ a 16times16 matrix.
Quantum algorithms are at the rudimentary level of machine language with codes
written in terms of gates; it is hoped that high-level languages will be developed
for quantum computers that are independent of how the quantum computer realizes
the algorithms, with the high-level language being task-oriented and not being tied
to the hardware. When a high-level language for quantum computers is developed,
it will make quantum algorithms easily accessible for applications to professionals
working in many fields.
Hobson: What impact will quantum computing have on the current state of arti-
ficial intelligence (AI) and machine learning (ML)?
Baaquie: An application of machine learning is, for example, taking the present
day value of stocks and applying an algorithm to generate a prediction for tomor-
row’s prices. Quantum algorithms are being developed to address machine learning.
Similarly for AI and deep learning.
Hobson: How can firms actually access quantum computing services? For exam-
ple, are they accessible from the Cloud?
Baaquie: IBM’s Qiskit and Amazon’s Braket provide a few qubits free of charge
to the public.
Hobson: What practical applications of quantum computing are taking place in
financial services today?
Baaquie: It is the view of many experts that the breakthrough for quantum algo-
rithms is going to take place in finance. Unlike in devices such as solar panels
where the algorithmic content is negligible compared to the hardware component, in
finance, efficient algorithms can have a far greater impact. The reason is that even the
slightest improvement in the performance of a quantum algorithm over the classical
algorithms will lead to substantial gains in finance, given the massive volume of the
debt and capital markets, with global debt reaching $226 trillion by the end of 2020.4
Furthermore, due to the financial markets constantly providing up-to-date data,
quantum algorithms can be calibrated and tested far more efficiently than for
hardware-oriented devices.
Hobson: In what areas of financial services will quantum computing have an
effect and why?
Baaquie: There is an almost universal consensus amongst experts that two areas
of finance hold the best promise for applying quantum algorithms. The first is port-
folio optimization. A large hedge fund usually has a collection of 10,000 to 20,000
instruments in its investment universe from which to form its portfolio. Typically,
the fund managers would like to run their models over a 30-year period.
The optimization is to maximize returns, subtracting the dispersion of the portfo-
lio as well as transaction costs, and with a budget constraint. Classical computers are
quite inadequate to exhaustively study all the different possibilities, including gen-
erating the outliers that are so important to fund managers. A quantum computer can
simulate outliers since its powerful algorithms can scan all possibilities, even those

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

control an autonomous AGI. But if AGI is enhanced and empowered by a quantum


computer, it will have algorithms and computing power that no human being can
match or fathom and can give rise to artificial superintelligence (ASI).
The quantum computer will give ASI access to unknown algorithms, patterns
and predictions that no human being can understand, let alone control. The danger
is that we may (inadvertently) mishandle a quantum computer-empowered ASI,
since we have no clue about what it is doing. An out-of-control quantum computer-
empowered ASI can wreak havoc on human society and on the environment. It
is superintelligence, a quantum computer-empowered ASI, that carries the greatest
threat to humanity. The development of ASI should definitely be watched closely,
especially when it is combined with a quantum computer.
Hobson: What are quantum computers teaching us about our quantum mechanical
universe?
Baaquie: This question is answered in the concluding Sect. 19, as one can use the
formalism developed in this book to give an accurate answer.

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

2.1 Binary Representation

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 = 200 + 0 + 3 = 2 × 102 + 0 × 101 + 3 × 100

The binary 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 2n−1 + x2 2n−2 · · · + xi 2n−i + · · · + xn−1 21 + xn 20


n
= x j 2n− j ; x j = 0, 1 (2.2)
j=1

The integer x has the binary representation

x = x1 x2 x3 · · · x j · · · xn−1 xn

The minimum is for all xi = 0 since

xi = 0 ⇒ x = 0

The maximum is for all xi = 1 since


2.1 Binary Representation 15

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)

The 2n distinct values for the integer x is given by

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

|x = |x1 x2 x3 · · · x j · · · xn−1 xn 

For example,

|0 = |00000 · · · 00 ; |1 = |00000 · · · 01 ; |2 = |00000 · · · 10


|3 = |00000 · · · 11; · · · ; |2n − 1 = |11111 · · · 11 (2.4)

The finite binary expansion for number x < 1

x = x1 2−1 + x2 2−2 · · · + xi 2−i · · · + xn 2−n


≡ 0 · x1 x2 · · · xi · · · xn
n
= x j 2− j ; x j = 0, 1 (2.5)
j=1

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

Consider the binary expansion of x < 1


16 2 Binary Numbers, Vectors, Matrices and Tensor Products

x = 0 · x1 x2 · · · xm · · ·

Multiplying the binary expansion of x < 1 by 2k yields (m > k)

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)

Hence, for example


 
exp(2πi · 2k x) = exp 2πi(x1 x2 . . . xk + 0.xk+1 xk+2 . . . xm . . .)
 
= exp 2πi(0.xk+1 xk+2 . . . xm . . .) (2.7)

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

203 = 11001011 ; 0.6875 = 0.1011 ⇒ 203.6875 = 11001011.1011

Binary numbers can be added, and all other arithmetic operations—including


subtraction, division and multiplication—can be reduced to the procedure of addition.
Binary addition, denoted by ⊕, is ordinary addition mod 2, and there is carry over,
as is the case for ordinary addition. The basic binary addition, that can be used
recursively to add any two binary numbers, is given by the following.

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

Fig. 2.1 Vector u. y


Published with permission of
© Belal E. Baaquie 2020. All
Rights Reserved
x
u
(3,-2)

7 + 1 = 8 ⇒ 111 ⊕ 01 = 111 ⊕ 001 = 1000

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.

2.2 Linear Vector Space

A vector is a collection of numbers; an example of a two-dimensional vector is the


position of a particle on a plane and denoted by 3, −2. as in Fig. 2.1. A vector can
be geometrically thought of as an arrow in space. An arrow has both length and
direction. How does one mathematically represent the arrow? An arrow is a straight
line from its base to its tip.
For simplicity, consider a two-dimensional space, denoted by E 2 , and consider an
x y-grid, with sides of unit length. Let u be a vector that can point in any direction,
and is shown in Fig. 2.1. A vector, such as u, will be denoted by a boldface letter to
differentiate it from a single number.
There two rudimentary and fundamental operations that one can perform with
vectors, which are the following.
• Vector addition: From two vectors u, v, one can form a third vector which is their
vector sum and given by
w=u+v

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

Vector addition, which was described geometrically, is expressed by adding the


coordinates in the x and y-directions separately and yields
18 2 Binary Numbers, Vectors, Matrices and Tensor Products
 
a+c
w=u+v= (2.8)
b+d

Vector addition is associative in the sense that

(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

By scalar multiplication, the length of a given vector is changed. If λ = 2, the vector


w has twice the length of v and points in the same direction and for λ = −2, the
vector w has twice the length of v but points in the opposite direction. In general,
λ can be a complex number.
• Scalar product: To define the scalar product one needs to define Hermitian con-
jugation, denoted by †. In general, the components of a vector can be complex
numbers. The Hermitian conjugation of a complex vector is given by taking its
transpose complex conjugating its components and yields
   
u† = a ∗ b∗ ; v† = c∗ d ∗

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

For u, v having n-components having complex values, we have


n
 ∗
u† · v = u i∗ vi = v† · u
i=1

The norm of a n-dimensional vector is defined by the following


n
|u|2 = u† · u = u i∗ u i > 0 (2.9)
i=1

2.3 N-Dimensional Complex Linear Vector Space

The discussion for two-dimensional vector space E 2 generalizes to N -dimensions.


Let ei , i = 1, 2 . . . , N be N orthogonal basis states with unit norm. Then
2.3 N -Dimensional Complex Linear Vector Space 19

ei† · e j = 0 : i = j ; ei† · ei = 1 (2.10)

A realization of the basis vectors is given by


⎡ ⎤
0
⎢ .. ⎥
⎢.⎥
⎢ ⎥
⎢1⎥  
en = ⎢ ⎥
⎢ 0 ⎥ ; en =  0 . . . 

1 0 ... (2.11)
⎢ ⎥ 
⎢.⎥
⎣.⎦. n−th position

A compact way of writing Eq. 2.10 is the following



1n=m
e†m · en = δn−m ≡ : m, n = 1, . . . , N (2.12)
0n=m

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 )

In terms of the basis vectors, x can be represented by


N 
N
x= x(i)ei ; x† = x ∗ (i)ei†
i=1 i=1

The scalar product for vectors x, y, using Eq. 2.10, is given by


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

The angle θ , which in principle can be complex, between two vectors x, y in


the N -dimensional complex vector space is defined, as one would expect, by the
following
 
x · y = |x||y| cos(θ ) ; |x| =

x ∗ (i)x(i) ; |y| = y ∗ (i)y(i)
i i

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

A matrix that is 1 × M, and denoted by the column vector v, is given by


⎡ ⎤
v(1)
⎢ v(2) ⎥
v=⎢
⎣ ... ⎦

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

Since v is arbitrary, matrix addition is done element by element

(A + B) = A + B ⇒ (A + B)i j = Ai j + Bi j

One has the null matrix


⎡ ⎤
0 0 ... 0
⎢ 0 0 ... 0⎥
⎢ ⎥
(A − A) = A − A = 0 = ⎢ . ⎥
⎣ .. ⎦
0 0 ... 0

• The result of multiplying A by a scalar λ results in λA, which in components is


given by
(λA)i j = λAi 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

Matrix multiplication requires the number of columns in A be equal to the number


of rows in B. The general result for AB yields a M × L matrix and is given by
⎡   ⎤
 a 1i bi1  a 1i bi2 . . .  a 1i bi L
⎢ a2i bi1 a2i bi1 . . . a2i bi L ⎥   M
AB = ⎢

⎥ ;
⎦ ≡
 ...   i=1
a Mi bi1 a2i bi1 . . . a Mi bi L

The unit matrix I leaves the matrix unchanged on multiplication


⎡ ⎤
1 0 ... 0
⎢ 0 1 ... 0⎥
AI = IA ; I = ⎢
⎣...

⎦ (2.15)
0 0 ... 1

Consider the M × L matrix B; it acts on a L × 1 (vector) v and yields a matrix


(vector) M × 1, given byv. In
matrix notation, the action of the matrix B on v is
L
represented as follows ( ≡ i=1 )
⎡ ⎤ ⎡ ⎤⎡ ⎤ ⎡ ⎤
v(1) b11 b12 . . . b1L v(1)  b1i v(i)
⎢ v(2) ⎥ ⎢ b21 b22 . . . b2L ⎥ ⎢ v(2) ⎥ ⎢ b2i v(i) ⎥
B⎢ ⎥ ⎢
⎣ ... ⎦ = ⎣ ...
⎥⎢ ⎥ ⎢
⎦⎣ ... ⎦ = ⎣


 ...
v(L) b M1 b N 2 . . . b M L v(L) b Mi v(i)

In vector notation


L
Bv = w ⇒ w(i) = bi j v( j) ; i = 1, . . . , M
j=1

In other words, B maps a L dimensional vector v to a M dimensional vector w. In


terms of complex vector space, B maps linear vector space C L to vector space C M ,
and yields
B : CL → CM
2.5 Properties of N × N Matrices 23

2.5 Properties of N × N Matrices

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

• Matrix multiplication is associative with

(AB)C = A(BC) = ABC

To illustrate the non-commutativity of matrices, consider two matrices


   
1 −3 1 4
A= ; B=
2 5 −2 3

Then    
7 −5 9 17
AB = = BA = ⇒ AB − B A = 0
−8 23 4 21

The non-commutativity of matrices has far-reaching consequences.

2.5.1 Hermitian Conjugation

The Hermitian conjugation of a vector is a special case of the Hermitian conjugation


of a matrix. Similar to the case of a vector, where Hermitian conjugation entails
mapping a column vector into a row vector and complex conjugating, in case of
a matrix, all the columns and rows are interchanged and complex conjugated. In
symbols, the Hermitian conjugation of a matrix A and vector v is defined by

(A† )i j = (A)∗ji : Transpose and complex conjugate (2.16)


(A + B) = A + B
† † †

(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

where C2 is a two-dimensional complex manifold. Hence the determinant has the


following property

det(A)∗ = det(A† ) (2.18)

2.6 Tensor (Outer) Product

Consider the following set of x y-basis states


   
1 0
e1 = ; e2 =
0 1

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

In general, for N -component vectors wi , v j , the outer product, denoted by A, is given


by
A = w ⊗ v† ; Ai j = wi v j ; i, j = 1, . . . 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

For the 2 × 2 matrices, one has


     
10 00 10
e1 ⊗ e†1 + e2 ⊗ e†2 = + = =I
00 01 01

Completeness equation Eq. 2.19 yields the following


N 
N
v = Iv = ei ⊗ (ei† · v) = vi ei (2.20)
i=1 i=1

where
vi = ei† · v : components of v

Due to the completeness equation, for an arbitrary matrix1


 
A= Ai j ei ⊗ e†j = Ai j ei e†j (2.21)
ij ij

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

In the notation of tensor product, the action of A on a general vector is given by

1 Where the symbol ⊗ is sometimes dropped if the expression has no ambiguity.


26 2 Binary Numbers, Vectors, Matrices and Tensor Products

   
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

Then, from Eq. 2.22


 
w I = e†I · w = Ai j v j (e†I · ei ) = Ai j v j δi−I
ij ij

⇒ wI = AI j v j (2.24)
j

From the definition of Hermitian conjugation


⎛ ⎞†
 
A† = ⎝ Ai∗j ei ⊗ e†j ⎠ = Ai∗j (ei ⊗ e†j )†
ij ij
 
= Ai∗j e j ⊗ ei† = A†ji e j ⊗ ei† ; A†ji ≡ Ai∗j (2.25)
ij ij

The tenor product of two matrices is defined the following manner


     
a a b11 b12 a11 B a12 B
A = 11 12; B= ⇒ A⊗B =
a21 a22 b21 b22 a21 B a22 B
⎡ ⎤
a11 b11 a11 b12 a12 b11 a12 b12
⎢ a11 b21 a11 b22 a12 b21 a12 b22 ⎥
⇒ A⊗B =⎢ ⎥
⎣ a21 b11 a21 b12 a22 b11 a22 b12 ⎦
a21 b21 a21 b22 a22 b21 a22 b22

One also has


 
   
b11 b12 a11 a12 b11 A b12 A
B⊗A= ⊗ = = A⊗B
b21 b22 a21 a22 b21 A b22 A

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

Table 2.1 Matrix A and related matrices


Matrix Symbol Components Example
 
1 2+i
A Ai j
−i 2
 
1 −i
Transpose AT AiTj
2+i 2
 
1 2−i
Complex conjugate A∗ Ai∗j
+i 2
 
1 i
Hermitian conjugate A† = (A∗ )T Ai†j
2−i 2
 
2 −(2 + i)
Inverse A−1 Ai−1
j
1
1+2i
i 1

2.7 Square Matrices

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

2.8 Dirac Bracket: Vector Notation

Euclidean space E N is an N -dimensional linear vector space. Vectors are elements of


E N and matrices are linear transformations from E N to E M . The synthesis of linear
algebra with calculus is most easily carried out by expressing vectors and matrices
in Dirac’s notation. Although the notation can also be applied to the general case, the
discussion is confined to square matrices that are linear transformations from E N to
E N since all matrices in quantum algorithms are square matrices.
The basic ingredient of the Dirac bracket notation is the following

ket : |.. = vector ; bra : ..| = dual vector

Taken together they form the complete bracket given by

bracket : ..|.. = scalar product = complex number

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|

The canonical basis and its dual vectors are given by

ei = |i ; ei† = i|

Linear superposition is written as expected

u = av + bw ⇒ |u = a|v + b|w

with the dual expression given by

u† = a ∗ v† + b∗ w† ⇒ u| = a ∗ v| + b∗ w|

The expansion of a vector into its components is


 
v= v(i)ei ⇒ |v = v(i)|i
i i

where
v(i) = i|v

is defined more precisely later in Eq. 2.27.


2.8 Dirac Bracket: Vector Notation 29

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

v† · w = ( v|)(|w) = v||w = v|w

Furthermore

w† · v = (v† · w)∗ = v|w∗ ⇒ w† · v = v|w∗ = w|v

For the orthonormal basis states



0i = j
ei† · e j = i| j = δi− j =
1i= j

Hence, the component of a vector is given by

v(i) = ei† · v = i|v (2.27)

The outer product is another notation for the tensor product and given by

u ⊗ v† = |u v|

A matrix has the following expression


 
A= Ai j ei ⊗ e†j = Ai j |i j| (2.28)
ij ij

where, using j|k = δ j−k , yields

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

i|v = v(i) ; i|A| j = Ai j

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

The completeness equation for the canonical basis is given by


N 
N
I= e I ⊗ e†I = |I  I | (2.31)
I =1 I =1

Any complete basis states v I yield


N 
N
I= v I ⊗ v†I = |v I  v I | (2.32)
I =1 I =1

Suppose v I are eigenfunctions of the matrix S; the eigenfunction equation is given


by
Sv I = λ I v I ⇒ S|v I  = λ I |v I  : I = 1, . . . N

The spectral decomposition of matrix S is given by


N 
N
S= λ I v I ⊗ v†I = λ I |v I  v I | (2.33)
I =1 I =1

Unitary matrix U yields

|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

A Hermitian matrix S is diagonalized by a unitary matrix U matrix such that [1]


N 
N
U SU =

λI eI ⊗ e†I = λ I |I  I |
I =1 I =1

Conversely, Eq. 2.34 yields the spectral decomposition


N 
N
S= λ I U|e I  e I |U † = λ I |v I  v I | (2.35)
I =1 I =1

Consider the expression


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

Hence, one has in Dirac’s notation


N
Sn = λnI |v I  v I | (2.37)
I =1

In general, for any function F(S), one has


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

2.9 Tensor and Outer Product: Strings and Gates

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

The NOT gate, represented by X , is given by the following mapping

X |0 = |1 ; X |1|0

In matrix notation, the NOT gate is given by


 
01
X=
10

One can verify that, as expected


         
01 1 0 01 0 1
= ; =
10 0 1 10 1 0

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

|00 → |11 ; |01 → |10 ; |10 → |01 ; |11 → |00

Hence, one can check that


⎡ ⎤ ⎡ ⎤
1 0
⎢ 0 ⎥ ⎢ ⎥
X ⊗2 |00 = X ⊗2 ⎢ ⎥ ⎢0⎥
⎣ 0 ⎦ = ⎣ 0 ⎦ = |11
0 1
⎡ ⎤ ⎡ ⎤
0 0
⎢ 1 ⎥ ⎢ ⎥
X ⊗2 |01 = X ⊗2 ⎢ ⎥ ⎢0⎥
⎣ 0 ⎦ = ⎣ 1 ⎦ = |10
0 0
⎡ ⎤ ⎡ ⎤
0 0
⎢ 0 ⎥ ⎢ ⎥
X ⊗2 |10 = X ⊗2 ⎢ ⎥ = ⎢ 1 ⎥ = |01
⎣1⎦ ⎣0⎦
0 0
⎡ ⎤ ⎡ ⎤
0 1
⎢ 0 ⎥ ⎢ ⎥
X ⊗2 |11 = X ⊗2 ⎢ ⎥ = ⎢ 0 ⎥ = |00 (2.42)
⎣0⎦ ⎣0⎦
1 0

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

|c⊗n ≡ |c1  ⊗ |c2  · · · ⊗ |cn  ≡ {0, 1}⊗n


  
n bits

The tensor product is written as follows

|c1  ⊗ |c2  · · · ⊗ |cn  = |c1 c2 · · · cn  ; ci = 0, 1


34 2 Binary Numbers, Vectors, Matrices and Tensor Products

Writing out the n−bits strings yields the following

|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

|x = 0 = |0 = |000 . . . 000, . . . , |x = 2n − 1 = |2n − 1 = |111 . . . 111

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

The scalar product of two vectors is defined only if k = n and is given by


⎡⎤
v1
  ⎢ v2 ⎥  n
w|v = w1∗ w2∗ · · · wn∗ · ⎢
⎣···⎦
⎥= wi∗ vi
i=1
vn

The outer product is given by the following


⎡ ⎤
v1
⎢ v2 ⎥  ∗ ∗ 
|v w| = ⎢ ⎥
⎣ · · · ⎦ ⊗ w1 w2 · · · 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

For the bits, the scalar product is given by


 
  0
1|1 = 0 1 · =1
1
2.9 Tensor and Outer Product: Strings and Gates 35

whereas the outer product of a bit is given by


   
0   00
|1 1| = ⊗ 01 =
1 01

The identity matrix and the NOT gate are given by

I = |0 0| + |1 1| ; X = |1 0| + |0 1|

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.

2.9.1 3-Bits String

Three bits are organized as follow:

000 ; 001 ; 010 ; 011 ; 100 ; 101 ; 110 ; 111 (2.46)

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

An algorithm is defined to be a well-defined finite set of instructions that are carried


out systematically in a given number of steps for solving a well-defined problem. An
algorithm, in particular, can have the purpose of carrying out a specific information
processing task. The algorithm is applied to an input (initial data) and the result of
applying the computational steps constituting an algorithm yields the output (result).
In effect, an algorithm is a function that produces an output from a given input.
A computer is a physical device designed for carrying out a set of computational
instructions encoded in an algorithm. The question that naturally arises is: What is
the collection of functions that an algorithm can, in principle, utilize in carrying out
its computation? To answer this question, one needs an idealized model of what
constitutes a computer. There are two aspects to the idealized model of a computer,
the first—which stems from the point of view of computer science—is to define what
constitutes a collection of computable functions; the second aspect is the relationship
of the physical device that carries out this computation to physics, since all real
computing devices must be based on the laws of physics.
The idealized computer that emerges from information science is called the Tur-
ing machine, named after its inventor Alan Turing. It is this idealized computer that
is the basis of designing complex algorithms and protocols for information pro-
cessing tasks and computing various functions. So far, all algorithms encountered
in information science and Nature belong to the collection of functions defined by
the Church–Turing theorem and they can all be used for computing by a Turing
machine. There may appear, in the future, non-Turing-computable-functions, which
would then require an extension of computable functions to a larger class of functions
not covered by the Church–Turing theorem.
Classical algorithms are based on logical truth tables that are in turn realized by
gates. A rather detailed analysis is carried out of classical gates as these are the
necessary precursors to understanding quantum gates and quantum 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].

3.1 Classical Algorithm

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

{0, 1} ⊗ {0, 1} · · · ⊗ {0, 1} ≡ {0, 1}⊗m


  
m bits

We can now define a classical algorithm by the following: a computer is a physical


device that transforms an input string of length m into an output string of length n
using an algorithm. In other words

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.

3.2 Classical Gates

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

Table 3.1 Identity and NOT gate truth tables


Input Output
A Z
0 0
1 1
Input Output
A Z
0 1
1 0

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

X |0 = |1 ; X |1 = |0


42 3 Classical Gates and Algorithms

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

3.3 2-Bits String Gates

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

Table 3.2 AND truth table


Input Target Input Output
A B A Za
0 0 0 0
0 1 0 0
1 0 1 0
1 1 1 1

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

G : G(|A ⊗ |B) = G|AB

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

A|AB = |A, Z a = AB = |AZ a  (3.1)

where AB = Z a is binary multiplication.


In terms of the 2-bits string, the action of A given in the truth table, Table 3.2, by
the following

|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

A = |0000| + |0001| + |1010| + |1111|


⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤
1 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 0 0⎥ ⎢0 0 0 0⎥
=⎢
⎣0
⎥+⎢ ⎥+⎢ ⎥+⎢ ⎥ (3.2)
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

Hence, from Eq. 3.2 ⎡ ⎤


1 1 0 0
⎢0 0 0 0⎥
A=⎢
⎣0
⎥ : AND gate (3.3)
0 1 0⎦
0 0 0 1

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

and so on. Note that A is not invertible.


The logic gates of a classical computer are in general irreversible because, except
for the NOT and XOR gates, they correspond to a transformation of the target bits
with an equal number of 0’s and 1’s into the output bits with an unequal number of
0’s and 1’s. Hence, one cannot obtain the target bits state from the final 1-bit output
bits, even if one retains one of the input bits. Note from Fig. 3.4, the XOR and XNOR
gates have an output with equal number of 0’s and 1’s and hence they are invertible
if we retain one of the input bits.
3.3 2-Bits String Gates 45

Table 3.3 NAND truth table


Input Target Input Output
A B A Zn
0 0 0 1
0 1 0 1
1 0 1 1
1 1 1 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

N |AB = |AZ n  (3.5)

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

|AB → A|AB → (I ⊗ X )(A|AB) ⇒ |AZ n  = (I ⊗ X )A|AB (3.6)

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

Fig. 3.6 XOR Gate.


Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

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

Is the sequential application of the gates mathematically realized by the matrix


multiplication of the two individual gates? The answer is a Yes and shows the utility
of using vectors and matrices to represent bits and gates. Hence, the realization of
the circuit for the NAND gate given in Eq. 3.6 is the following matrix product of two
gates

N = (I ⊗ X )A = X 2 A (3.9)

and yields the result given in Eq. 3.4.

3.4 XOR Reversible Gate

To foreground the representation of quantum algorithms by quantum circuits, we


represent a classical circuit using the same framework as the one we will use for
quantum circuits. The notation for the circuit diagrams, as shown in Fig. 3.6, is to
represent bits by horizontal lines; the gates are represented by vertical lines. The bits
on which the gate acts are marked, as in Fig. 3.6 by a heavy dot for the bit that is
unchanged (conditions the gate) and an empty circle with a crossing for the bit that is
transformed. This notation is used consistently for both classical and quantum gates
for all the circuits in this book.
The XOR gate, like the NOT gate X , is a classical reversible gate. The XOR is
the classical analog of the CNOT quantum gate discussed later. This is the reason, as
will be seen in later discussions, all classical reversible gates can be finally expressed
in terms of the XOR and NOT gates.
3.4 XOR Reversible Gate 47

Table 3.4 XOR truth table


Input Target Input Output
A B A Z
0 0 0 0
0 1 0 1
1 0 1 1
1 1 1 0

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 XOR truth table is given in Table 3.4.


The matrix representation of X OR gate can be directly verified by acting on the
state vector representation of the 2-bits strings to be given by
⎡ ⎤
1 0 0 0  
⎢0 0⎥
X OR ⎢
=⎣
1 0 ⎥= I 0 (3.10)
0 0 0 1⎦ 0X
0 0 1 0

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

A⊕ B = Z ⇒ 0⊕0=0 ; 0⊕1=1 ; 1⊕0=1 ; 1⊕1=0 ;

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

3.4.1 X OR : 3-Bits String

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

X OR (A, B) = |0000| + |0101| + |1110| + |1011|


= |0|0| ⊗ |00| + |0|0| ⊗ |11| + |1110| + |1011|
 
= |0|0| ⊗ |00| + ⊗|11| + |11| ⊗ |10| + |11| ⊗ |01|
 
= |0|0| ⊗ I + |11| ⊗ |01| + |01|
= |0|0| ⊗ I + |11| ⊗ X (3.12)

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

Fig. 3.8 Toffoli gate.


Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

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

X OR (A, B, C) = |0|0| ⊗ I ⊗ I + |11| ⊗ I ⊗ X (3.13)

3.5 3-Bits String: Toffoli Gate

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

T |ABC = |AB, Z  (3.14)

Denoting binary multiplication by AB and addition by ⊕, the Toffoli gate is given


by

T |ABC = |AB, Z = C ⊕ AB (3.15)

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

Table 3.5 Tofflli gate truth table


Input Input Target Input Input Output
A B C A B Z
0 0 0 0 0 0
0 0 1 0 0 1
0 1 0 0 1 0
0 1 1 0 1 1
1 0 0 1 0 0
1 0 1 1 0 1
1 1 0 1 1 1
1 1 1 1 1 0

• Recall from Eq. 3.15

T |ABC = |AB, Z = C ⊕ AB

• Equivalent to the AND gate for A, B

T |AB0 = |AB, Z = AB

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

For the case of A = 1 = B, T is equivalent to NOT gate for C.


• Equivalent to the XOR gate for A, C or B, C

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

Hence, using the notation T |ouputinput| yields

T = |000000| + |001001| + |010010| + |011011|


+|100100| + |101101| + |111110| + |110111| (3.17)

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

Hence, T can be rewritten as follows

T = |0000| ⊗ |00| + |0000| ⊗ |11|


+ |0101| ⊗ |00| + |0101| ⊗ |11| + |1010| ⊗ |00|
+ |1010| ⊗ |11| + |1111| ⊗ |10| + |1111| ⊗ |01|
   
= |0000| ⊗ |00| + |11| + |0101| ⊗ |00| + |11|
   
+ |1010| ⊗ |10| + |01| + |11| ⊗ |10| + |01|

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.

3.6 Unitary AND, NAND and NOT Gates for 3-Bits

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)

Recall for the Toffoli gate, from Eq. 3.15

T |ABC = |AB, Z = C ⊕ AB


3.6 Unitary AND, NAND and NOT Gates for 3-Bits 53

Note that for C = 0, the Toffoli gate yields

T |AB, C = 0 = |AB, Z = AB (3.19)

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)

The Toffoli gate in block matrix notation is given by the following


⎡ ⎤
I 0 0 0
⎢0 I 0 0⎥
T =⎢
⎣0
⎥ (3.22)
0 I 0⎦
0 0 0 X

Hence, using X 2 = I, Eq. 3.21 yields


54 3 Classical Gates and Algorithms

Table 3.6 NAND gate truth table for 3-bits strings


Input Input Target Input Input Output Mapping
A B C A B Z
0 0 0 0 0 1 |000 → |001
0 0 1 0 0 0 |001 → |000
0 1 0 0 1 1 |010 → |011
0 1 1 0 1 0 |011 → |010
1 0 0 1 0 1 |100 → |101
1 0 1 1 0 0 |101 → |100
1 1 0 1 1 0 |110 → |110
1 1 1 1 1 1 |111 → |111

⎡ ⎤ ⎡ ⎤ ⎡ ⎤
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

Writing out the 8 × 8 matrix yields


⎡ ⎤
0 1 0 0 0 0 0 0
⎢1 0 0 0 0 0 0 0⎥
⎢ ⎥
⎢0 0 0 1 0 0 0 0⎥
⎢ ⎥
⎢0 0 1 0 0 0 0 0⎥
N3 = ⎢
⎢0
⎥ (3.24)
⎢ 0 0 0 0 1 0 0⎥⎥
⎢0 0 0 0 1 0 0 0⎥
⎢ ⎥
⎣0 0 0 0 0 0 1 0⎦
0 0 0 0 0 0 0 1

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

3.7 Unitary OR and NOR Gates

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

3.8 Classical Binary Addition

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.9 Binary addition.


Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved
3.9 Half-Adder 57

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

Fig. 3.11 Half adder for


adding two bits. Published
with permission of © Belal
E. Baaquie and L. C. Kwek.
All Rights Reserved

Table 3.7 Logic table for the half adder


A B Sum Carry-out
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

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

H|AB0 = (X OR ⊗ I)A3 |AB0 = (X OR ⊗ I)|ABCout  = |ASCout  (3.29)

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

Hence, the half-adder should yield

H|110 = H|ABCin  = |ASCout  = |101 (3.32)

The incoming and outgoing 3-bits string are


⎡ ⎤
        0
0 0 1 0 ⎢0⎥
|110 ≡ |1 ⊗ |1 ⊗ |0 = ⊗ ⊗ = ⊗⎢
⎣1⎦

1 1 0 1
0
 T
⇒ |110 = 0 0 0 0 0 0 1 0

and similarly
 T
|101 = 0 0 0 0 0 1 0 0

The expression for A3 given in Eq. 3.16 yields


 T
A3 |110 = 0 0 0 0 0 0 0 1

The half-adder, using Eq. 3.30, is given by the following


⎡ ⎤
I000
⎢0 I 0 0 ⎥  T
H|110 = ⎢ ⎥
⎣0 0 0 I ⎦ 0 0 0 0 0 0 0 1
00I0
 T
= 00000100 ⇒ H|110 = |101

Hence, Eq. 3.32 has been explicitly verified.


60 3 Classical Gates and Algorithms

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.9 Truth table for full adder


Input 1 Input 2 Input 3 Output 1 Output 2
A B Cin Cout S
0 0 0 0 0
0 1 0 0 1
1 0 0 0 1
1 1 0 1 0
0 0 1 0 1
0 1 1 1 0
1 0 1 1 0
1 1 1 1 1

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

F|ABCin 0 = |ABCout S ; A, B = 0 or 1 (3.33)

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

F = Swap · Gate5 · Gate4 · Gate3 · Gate2 · Gate1

with the full 16 × 16 matrix given in Sect. 3.11. Collecting all the results, the full-
adder gate F is given by

F|ABCin 0 = |ABCout S (3.34)

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

F|1100 = |1110 ; F|1110 = |1111 ; F|0010 = |0001 (3.35)

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

F|ABCin 0 = Fn · · · F j+1 F j · · · F2 F1 |ABCin 0 = |ABCout S

Let A, B be two 4-bits string

|AB = |A0 B0 |A1 B1 |A2 B2 |A3 B3 

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

3.11 Matrices of Full-Adder Gates

In matrix representation, Gate 1 is given by the 16 by 16 matrix:


 
Gate 1 = |0000| + |0101| + |1010| ⊗ I ⊗ I + |1111| ⊗ I ⊗ X
⎛ ⎞
1000000000000000
⎜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 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 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 1⎠
0000000000000010

The other gates are given by

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 3 = I ⊗ T (B, Cin , 0)


⎛ ⎞
10000000 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 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 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 1⎠
00000000 0 0 0 0 0010

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

G = Product of Gates = Gate 5 · Gate 4 · Gate 3 · Gate 2 · Gate 1


⎛ ⎞
1000000 000000000
⎜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 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 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 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 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 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 1⎠
0000000 000000010

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

S = SWAP Gate = I ⊗ I ⊗ SWAP12


⎛ ⎞
100000000000000 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 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 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 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 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 1 0⎟
⎜ ⎟
⎝0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0⎠
000000000000000 1

The full adder is given by the matrix

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

|(input A)(input B)(carry in or out ) ( Sum)

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

1. Feynman RP (2018) Lectures on computation. CRC Press, USA


2. Mermin ND (2007) Quantum computer science. Cambridge University Press, UK
Chapter 4
Principles of Quantum Mechanics

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 process of measurement, with repeated observations yielding the expectation


value of the operators, namely E V [Oi (F)].

4.1 Degrees of Freedom: Indeterminate

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

F ⊗2 = {0, 1} ⊗ {0, 1} = (x1 , x2 ) = {00, 01, 10, 11}; x1 , x2 = 0, 1

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

F ⊗3 = {0, 1}⊗3 = {0, 1} ⊗ {0, 1} ⊗ {0, 1} (4.1)


= {000, 001, 010, 011, 100, 101, 110, 111}

The 23 = 8 points are organized as the corners of a three-dimensional cube and


shown in Fig. 4.2.
If the system has n-bits, then the quantum degrees of freedom F ⊗n is

F ⊗n = {0, 1} ⊗ {0, 1} · · · {0, 1} = {0, 1}⊗n

The specific values n-degrees of freedom F ⊗n are denoted by

(x1 , x2 , . . . , xn ) : xi = 0, 1; i = 1, 2, . . . , n

The n-binary degrees of freedom F ⊗n consist of a discrete space of 2n points that


form the corners of a 2n hypercube and is denoted by
4.1 Degrees of Freedom: Indeterminate 73

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].

4.2 Hilbert Space; State Vectors

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

The norm of a state vector is defined in Eq. 2.9.


Hilbert space consists of all possible functions of the degrees of freedom space
F that have unit norm. Elements of Hilbert space are the quantum state vectors. The
state vector, denoted by ψ, is a function of time t and the degrees of freedom and is
given by ψ(t, F) ∈ V. Hence, as given in Eq. 2.14

ψ(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

Fig. 4.3 Degree of freedom


F enclosed by the state
vector (F ). Published
with permission of © Belal
E. Baaquie 2012. All Rights
Reserved

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

x|ψi  = ψi (x) = ψi (x1 , x2 , . . . , xn ), i = 1, 2, . . . , m

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

• The tensor product Hilbert space is a mapping of F ⊗m to the complex numbers


C; hence
V ⊗m : F ⊗m → C

• The tensor product of state vectors exists in the product space V P


m
F ⊗k = x ⊗k ; | P = αi j...k |ψi  ⊗ |ψ j  · · · ⊗ |ψk  : Entanglement
i j...k=1

• The coordinate representation of a general product state vector is given by


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.

4.2.1 Continuous Degrees of Freedom

For ease of notation, consider z 1 , z 2 , . . . , z n to be real variables taking values in the


n-dimensional Euclidean space given by Rn ≡ R ⊗ · · · ⊗ R; the z i ’s are continuous
degrees of freedom. The quantum state vector |ψ of z 1 , z 2 , . . . , z n degrees of freedom
is given by
 
n
|ψ = dzψ(z 1 , z 2 , . . . , z n )|z 1 , z 2 , . . . , z n  : dz = dz i (4.2)
Rn i=1

where the probability amplitude is given by the complex-valued wave function


ψ(z 1 , z 2 , . . . , z n ). All information about a quantum system is contained in ψ(z 1 , z 2 ,
. . . , z n ); measurement needs to be carried out repeatedly by devices that respond
to particular values of the degrees of freedom (see Sect. 4.5 on measurements). On
measuring the degrees of freedom, the device in the laboratory records an observa-
tion corresponding to a particular and determinate value of the degree of freedom,
denoted by z 1(0) , z 2(0) , . . . , z n(0) . The measurement process is the following

|ψ → |z 1(0) , z 2(0) , . . . , z n(0) 

The probability of a measurement resulting in the detector recording the said


outcome—as postulated by Max Born [2]—is given by

|ψ(z 1(0) , z 2(0) , . . . , z n(0) )|2

Note that both the following state vector

ψ(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

4.2.2 Discrete Degrees of Freedom: Qubits

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

|ψ(t, F) = |q = |q(x1 , x2 , . . . , xn )

For the n-binary discrete degrees of freedom—which is the foundation of quantum


computing—a widely used and convenient basis is the computational basis states,
given by |x, x = 0, 1, 2, . . . , 2n − 1. The state vector |ψ of the n-binary degrees
4.3 Hermitian and Unitary Operators 79

of freedom can be represented by the following expansion,

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

Both these representations are used throughout this book.


The 2n dimensional Hilbert space Hn is given by

Hn ≡ S 2 ⊗ ·
· · ⊗ S2 (4.7)
n-fold tensor product

As will become clear in the discussion on superposition and entanglement, the


intermediate steps in the quantum algorithm all take place in Hilbert space and
cannot, in principle, be observed: all that one can observe is the initial state and the
final output state. Hence, to understand the mathematics of quantum algorithms, it
is necessary to study the properties of Hilbert space.

4.3 Hermitian and Unitary Operators

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

where a, b are constants.


80 4 Principles of Quantum Mechanics

Fig. 4.4 An operator O


acting on element |ψ of the
state space V and mapping it
to O|ψ. Published with
permission of © Belal E.
Baaquie 2012. All Rights
Reserved

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

All physical quantities of a degree of freedom such as position, momentum,


energy, angular momentum, spin, charge and so on are represented by Hermitian
operators. Hermitian operators O map the space V onto itself.
For a single binary degree of freedom, the state space is given by the Bloch sphere,
discussed in Sect. 6.3, and operators are 2 × 2 complex-valued Hermitian matrices.
A Hermitian matrix is only defined for complex square matrices N × N with Mi j
with i, j = 1, 2, . . . , N and Mi j satisfies

M † = (M T )∗ = M ⇒ M ∗ji = Mi j ; i, j = 1, 2, . . . , N : Hermitian (4.8)

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

ψ|O† |χ  ≡ χ |O|ψ∗ : Hermitian conjugation

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

O† = O ⇒ ψ|O|χ  ≡ χ |O|ψ∗ : Hermitian operator (4.9)

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

ψ|O|ψ = ψ|O† |ψ = ψ|O|ψ∗ : Real (4.10)

Furthermore, similar to matrices, Hermitian conjugation is a linear operation and


yields, for a sum and products of operators, the following

(c1 O1 + c2 O2 + · · · )† = c1∗ O1† + c2∗ O2† . . . ; (O1 O2 . . .)† = . . . O2† O1†

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|
−∞

Trace is a linear operation on O and is defined by

∞  ∞
Tr(O) = Tr(OI) = dx Tr O|xx| = dxx|O|x (4.11)
−∞ −∞

The properties of the trace operation are summarized below.

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

Cyclicity of the trace makes it invariant under unitary transformations U , namely

Tr[U OU † ] = Tr[OU † U ] = Tr[O]

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.

4.4 The Schrödinger Equation

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

|ψ(t) = e−  tH |ψ = U (t)|ψ


i
(4.15)

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) is unitary since H is Hermitian; more precisely

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,

ψ(t)|ψ(t) = ψ|U † (t)U (t)|ψ = ψ|ψ = 1

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.

4.4.1 Key Features of the Schrödinger Equation

• 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.

4.5 Quantum Measurement: Born Rule

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|ψ

To mathematically represent a measurement, one needs to form the density matrix


ρ. The density matrix is discussed in Sect. 5.4. Let the state vector be denoted by
|ψ; the density matrix, from Eq. 5.6, is defined by

ρ = |ψψ| (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 

Hence, the measurement gates are given by


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

and results in the following transformation of the density matrix


4.5 Quantum Measurement: Born Rule 87


N
ρ → preparation → ρout = cn cm∗ |ψn ψm | ⊗ |Dn Dm |
m,n=1

The collapse of the wave function due to a measurement results is an unpredictable


outcome and the Born rule states that the state function collapses to a specific eigen-
state |Dn  of the measuring device. The final result of the measurement is the fol-
lowing [1]
 N
ρout → Measurement → ρfinal = |cn2 |Dn Dn |
n=1

Hence, the process of measurement yields the following


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].

|ψ → Measurement → |Dn 


Probability of outcome = |cn |2 (4.19)

We focus henceforth on the role of quantum measurements for a quantum com-


puter. All quantum algorithms provide the sought for solution of a problem in the
form of an output state, and with the quantum computation being terminated by
irreversible measurement gates M.
The n-binary degrees of freedom computational basis states are represented by

|z 0 , z 1 , . . . , z n−1 

where the bits z i = 0, 1 : i = 1, . . . , n have 2n possible determinate values. The


n-qubits string state vector |ψ is given by Eq. 4.4
88 4 Principles of Quantum Mechanics

2
n
−1 2
n
−1
|ψ = α(x)|x; |α(x)|2 = 1 (4.20)
x=0 x=0

The density matrix is the following

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

Consider measurements performed on the n binary degrees of freedom quantum


state |ψ. For the measurements to be performed using the computational basis
states |z 0 , z 1 , . . . , z n−1 , we need a physical device that can measure all values of
z i = 0, 1; i = 1, 2, . . . , n − 1 that are in the range of the degrees of freedom. The
physical device consists of a collection of measurement gates. The mathematical
representation of the measurement gates is Hermitian projection operators:

M; M = M2

The Hermitian operator representing the measurement process in Hilbert space is


given by  
O= λ(z)Mz ; Mz = I
z z

The eigenvalues λ(z) are not required for the measurements. In the computational
basis states, there are 2n projection operators Mz that are given by

Mz = |z 0 , z 1 , . . . , z n−1 z 0 , z 1 , . . . , z n−1 | : z i = 0, 1; i = 1, 2, . . . , n − 1

The post-measurement state is completely arbitrary and, in principle, cannot be pre-


dicted. What quantum mechanics tells us is that if the measurement process is identi-
cally repeated many times (in principle, infinitely many times), then the probability
of the outcome is given by the state vector and the measurement operator.
In summary, the result of a measurement is that, with some likelihood, the state
vector |ψ collapses to a particular eigenstate of the operator O representing the
measuring device and is given by

|z 0(0) , z 1(0) , . . . , z n−1


(0)
 (4.21)

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

is that the device’s counters have determinate value, given by z i(0) ; i = 0, 1; i =


1, 2, . . . , n − 1, in which particular eigenstate (device’s counter-readings) the state
vector collapses completely random and unpredictable. One can only know the like-
lihood of (a) the collapse in Hilbert space to one the eigenstates of the operator O and
(b) which corresponds, for the device, the collapse to determinate counter-readings.
After repeated measurements on identically prepared quantum states, the number
of times a particular computational basis state has been observed in the measuring
device is collected for all the gates: the normalized frequency table yields the proba-
bility of a measurement gate registering a reading. In principle, the experiment needs
to be carried out infinitely many times, but in most cases a large sample is sufficient.
As mentioned earlier, the measurement process collapses the quantum state vector
to one of the possible computational basis states. Recall from Eq. 4.5

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

Tr(Mz ρfinal ) = |z 0(0) , z 1(0) , . . . , z n−1


(0)
|ψ|2 = |ψ(z 0(0) , z 1(0) , . . . , z n−1
(0)
)|2

The quantum theory of measurement is summed up as follows: the quantum


state |ψ, when subjected to a measurement, leads to the following non-unitary and
discontinuous collapse

|ψ → Measurement → |z 0(0) , z 1(0) , . . . , z n−1


(0)
 (4.23)
Probability of outcome = |ψ(z 0(0) , z 1(0) , . . . , z n−1
(0)
)|2

If another measurement is performed immediately after the collapse of the state


vector to |ψn , then the system will still be in the state |z 0(0) , z 1(0) , . . . , z n−1
(0)
—and
remains in that state as long as there is no interaction of the system with the outside
environment.
The quantum state of n-qubits subjected to the measurement results in the mea-
suring device being in a state such that all the n 1-bits in the measuring device have
definite values. For example, one possible outcome for the measuring device is given
by
|z 0(0) , z 1(0) , . . . , z n−1
(0)
 = |10001110110 . . . 01101
  
n-bits computational basis state
90 4 Principles of Quantum Mechanics

4.6 Quantum Measurements and Degrees of Freedom

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

z 0(0) , z 1(0) , . . . , z n−1


(0)

is one possible determinate value of the degrees of freedom. In other words, no


experiment can observe, as such, the indeterminate form of the degrees of freedom:
instead, experiments—repeatedly carried out—can enumerate, one by one, all the
possible determinate values of the degrees of freedom. The design of the experiments
required for carrying out the observations on, as well as the enumeration of, the
possible determinate values are largely guided by the mathematical models made
for the degrees of freedom. In effect, quantum measurements sample the possible
determinate values of the indeterminate degrees of freedom.
It is important to note that the enumeration of the possible determinate values of
the indeterminate degrees of freedom is not unique: rather, it depends on the choice of
the eigenstates of the measuring gates. For the case of a quantum computer, another
useful basis for the measuring gates are the Bell states, discussed in Sect. 6.4. Using
the Bell states to measure the state vector will result in a different enumeration of
the possible determinate values of the degrees of freedom. All the distinct possible
enumerations of the possible determinate values of the indeterminate degrees of
freedom are related by unitary transformations.
Due to the irreversibility of the measurement process, the post-measurement
state |z 0(0) , z 1(0) , . . . , z n−1
(0)
 has less information about the degrees of freedom than
4.7 No-Cloning Theorem 91

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

Experimental devices exist in spacetime and Hermitian operators representing


the devices act on the degree of freedom’s Hilbert space, which is a mathematical
construct that ‘exists’ outside spacetime.
Quantum measurements are realized by Hermitian operators acting on quantum
states—and collapsing these states in Hilbert space; due to the entanglement of the
devices’ state vectors with the state being observed, the readings of the measuring
device record the corresponding collapsed state of Hilbert space. The likelihood of
the measurement observing a particular state vector of the degrees of freedom is
determined by the Born rule that depends on the operators and state vectors of the
device being used for making the measurement.
Once a measurement is completed, the particular observed state vector persists; if
a second measurement is performed, it will find the same previously observed state
vector. The observed state vector persists until it is affected by an interaction; in the
real world, the state vector persists for a very short time, and this lack of persistence
is called decoherence.

4.7 No-Cloning Theorem

The result of any measurement of the degrees of freedom results in an uncertain


outcome. To find the probabilities of the various outcomes, one needs to repeat the
experiment many times. If it was possible to easily make many copies of the quantum
state, then one could simultaneously carry out experiments on all the copies and obtain
the result in, effectively, a single measurement. Unfortunately, making exact copies
of the state vector is forbidden in quantum mechanics and is called the no-cloning
theorem [2].
This theorem essentially states that it is impossible to create an independent and
identical copy of an arbitrary unknown quantum state. The no-cloning theorem is a
direct result of the structure of Hilbert space, and all operations on the elements of
Hilbert space need to be carried out using unitary operators.
The history of how the no-cloning theorem was discovered makes a good read
[10]. Let us first presume that we indeed have a copying machine that faithfully
copies the state |0 and |1; i.e., there exists a unitary transformation that realizes

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

|ψ = α|0 + β|1; |α|2 + |β|2 = 1

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.

4.8 Copenhagen Interpretation: Open Questions

There a number of interpretations of quantum mechanics besides the Copenhagen one


and have been summarized in [1]. All these interpretations arise from the differing
views on the ontological status of the state vector, as well as the underlying assump-
tions that connect the results of measurements with the state vector. The central
mystery of quantum mechanics, and which has led to many of its various interpre-
tations, is the so-called collapse of the state vector. Some of the questions that arise
in quantum mechanics are discussed, with the responses based on the Copenhagen
interpretation.
• What constitutes a measurement? Since all physical entities should obey the laws
of quantum mechanics, how does the measuring device yield determinate values
for the degrees of freedom being observed? The response of Niels Bohr was that the
measuring device needs to be treated like a classical determinate object—which
is not a very satisfactory answer since there are no classical objects in a quantum
mechanical Universe.
• A more precise answer has been given by John Bell, whose view is that any object
with more than 107 atoms can function effectively as a measuring device. The
reason being the state vector of an object with 107 atoms has destructive quantum
interference and results in decoherence that leads, in effect, to the collapse of the
4.8 Copenhagen Interpretation: Open Questions 93

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(

to set up experiments for differentiating between the various interpretations,6 but so


far there have been no unequivocal results.7 For those who are interested, the various
interpretations of quantum mechanics are discussed in [1].

4.9 Summary of Quantum Mechanics

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.

• Superstructure of the Degrees of Freedom: Fig. 4.5.


1. The superstructure of the degree of freedom shown in Fig. 4.3 is completed in
Fig. 4.5.
2. The core of quantum mechanics is the degree of freedom that is intrinsically
indeterminate and in principle unobservable—and constitutes a discrete set or
a continuous space.
3. The first shell encompassing the degree of freedom F is Hilbert space its V(F),
first shown in Fig. 4.3. All possible information about the degree of freedom is
carried by the state vectors |ψ of Hilbert space V(F).

4. The second shell consists of operators O(F) that are mappings of Hilbert space
onto itself.

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].

4.10 Generalized Born Rule

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

|ψ ⇒ x1 , x1 , . . . , xn |ψ = ψ(x1 , x2 , . . . , xn )

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.

ψ(x1 , x2 , . . . , xn ) = ψ12 (x1 , x2 ) . . . ψn (xn )

• Entangled. The state vector is not factorizable into state vectors depending on
separate degrees of freedom.

ψ(x1 , x2 , . . . , xn ) = ψ(x1 )ψ(x2 ) . . . ψ(xn )

Consider a non-entangled state vector depending on two degrees of freedom and


given by

|ψ = |ψ1 |ψ2  ⇒ x, x2 |ψ = ψ(x1 , x2 ) = ψ1 (x1 )ψ2 (x2 )

Consider a device that measures only the x1 degree of freedom. The process of
measurement yields

|ψ → Measurement → |x1 |ψ2 

The value of the observed |x1  is completely arbitrary; the probability of a specific
value of |x1  detected by the observation given by

Tr(M(x1 )|ψψ|) = |ψ1 (x1 )|2

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

|ψn+m → Measurement → |zn |(z)m (4.28)

The probability of observing the state |zn |(z)m is given by



p(z) = Tr Mz |ψn+m n+m ψ| (4.29)
   
= αx y αx∗ y  Tr |zn n z| ⊗ Im |x  n n x| ⊗ |y  m m y|
x y,x  y 
 

⇒ p(z) = αzy αzy = |αzy |2 (4.30)
y y

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

In summary, in general the measurement of x degrees of freedom results in a post-


measurement quantum state yielding the conditional probability amplitude |(z)m :
an amplitude given that the state vector depending only on the n degrees of freedom
are in an eigenstate |zn . The post-measurement state is given by the generalization
of Eq. 4.19 and from Eq. 4.28 yields
4.10 Generalized Born Rule 99

|ψn+m → Measurement → |xn |(x)m ; m (x)|(x)m = 1 (4.32)

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

The probability of observing the state |i, i = 0, 1 is given by


 
p(0) = |ax |2 ; p(1) = |bx |2
x x

From Eq. 4.34, and as required by Eq. 4.18, we have


 
p(0) + p(1) = |ax |2 + |bx |2 = 1
x
100 4 Principles of Quantum Mechanics

In anticipation of the post-measurement state, we rewrite the initial state vector as


follows  
|ψn+1 = p(0)|0|0 n + p(1)|1|1 n

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

Note |0 , |1 n are not orthogonal since

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

|ψn+1 → Measurement → |z|(z)n ; z = 0, 1 (4.35)

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.

4.11 Consistency of Generalized Born Rule

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

Measuring n + m degrees of freedom, the probability of observing |xn |ym is


given by 
p(x y) = |αx yz |2
z

We obtain the post-measurement state vector, using the result given in Eq. 4.33

|xn |ym |(x y)s

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

|ψn+m+s → |xn |(x)m+s

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)

From Eqs. 4.38 and 4.40 we have


 2s −1

1 1 
(y|x)s = √
| √ αx yz |zs = |(x y)s (4.41)
p(y|x) p(x) z=0

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].

4.12 Quantum Mechanics and Quantum Computers

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

Fig. 4.7 A rotation of the


initial state vector |ψ I  into
the final state vector |ψ F  by
the unitary operator U .
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

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

1. Baaquie BE (2013) The theoretical foundations of quantum mechanics. Springer, UK


2. Mermin ND (2007) Quantum computer science. Cambridge University Press, UK
3. Nicolas G, Grégoire R, Wolfgang T, Hugo Z (2002) Quantum cryptography. Rev Mod Phys
74(1):145
4. Kwek L-C, Cao L, Luo W, Wang Y, Sun S, Wang X, Liu AO (2021) Chip-based quantum key
distribution. AAPPS Bull 31(1):1–8
5. Baaquie BE (2004) Quantum finance: path integrals and Hamiltonians for options and interest
rates. Cambridge University Press
6. Gottfried K, Yan T-M (2003) Quantum mechanics, 2nd edn. Springer, Germany
7. Baaquie BE (2014) Path integrals and Hamiltonians: principles and methods. Cambridge
University Press
8. Nielsen MA, Chang IL (2000) Quantum computation and quantum information. Cambridge
University Press, UK
9. Berman GP, Doolen GD, Mainieri R, Tsifrinovich VI (1998) Introduction to quantum com-
puters. World Scientific, Singapore
10. Juan O (2018) Twelve years before the quantum no-cloning theorem. Am J Phys 86(3):201–
205
11. Baaquie BE (2020) Mathematical methods and quantum mathematics for economics and
finance. Springer, Singapore
12. Manin YI (1980) Computable and noncomputable. Soviet Radio 2(4):13–15
13. Feynman RP (1982) Simulating physics with computers. Int J Theor Phys 21:467–488
14. Deutsch D (1985) Quantum theory, the Church-Turing principle and the universal quantum
computer. Roy Soc Lond Proc Ser A 400:97–117
Chapter 5
Quantum Superposition
and Entanglement

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

5.1 Quantum Superposition

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

5.1.1 The Experiment

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

5.1.2 Experiment with Detectors 1 and 2: No Interference

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

φ1 : the probability amplitude for determinate path 1


φ2 : the probability for amplitude determinate path 2
φ : the general probability amplitude

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

PD = |φ1 |2 + |φ2 |2 = P1 + P2 : collapse at barrier (5.2)

and one obtains the result given in Eq. 5.1.


The result given in Eqs. 5.1 and 5.2 is equivalent to the classical result obtained
by shooting classical particles through the two slits. The reason is that observations
made by detectors 1 and 2 at the two slits determines which slit the electron went
through by collapsing the probability amplitude, and in doing so causes the electron
to take a determinate path, namely going through either slit 1 or slit 2.
Having the information of which path is taken is equivalent to the classical descrip-
tion of a particle, since the classical particle always takes a unique path from its initial
to final position.

5.1.3 Experiment Without Detectors 1 and 2: Indeterminate

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

φ = φ1 + φ2 : trans-empirical probability amplitude at the screen


5.1 Quantum Superposition 113

Note that to obtain φ one is not superposing material displacements of a medium as


is the case for classical waves, but instead one is superposing probability amplitudes
φ1 and φ2 for determinate paths to obtain the probability amplitude φ = φ1 + φ2 for
the electron taking an indeterminate path; φ is said to be wave-like since it is spread
over space.
Quantum superposition is qualitatively different from superposing, for example,
water waves in which one is adding the physical displacement of the underlying water.
Quantum superposition is the superposition of information carried by the probability
amplitude, and it is this aspect of quantum superposition that comes to the forefront
in quantum algorithms.
On reaching the screen, the measurement of the electron at the screen-detector
collapses the probability amplitude φ to its empirical manifestation |φ|2 and yields
the empirical probability PI . Hence,

PI = |φ|2 = |φ1 + φ2 |2 : collapse at the screen



⇒ PI = |φ1 |2 + |φ2 |2 + φ1 φ2∗ + φ1∗ φ2 ; dx PI (x) = 1 (5.3)

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

A cardinal point to note is the crucial role of measurement in producing two


qualitatively different results—namely of PD with the detection of the electron’s
path and of PI without detection of its path. Measurement causes a transition of the
electron from its indeterminate state to its empirical manifestation, and the two-slit
experiment shows this difference in a stark and clear manner.
In conclusion, the two-slit experiment shows that both quantum states and quan-
tum paths display empirical and indeterminate behavior—depending on whether a
measurement is carried out or not. Furthermore, measurement has a central role in
determining whether the electron behaves as an empirical entity or as an indeter-
minate state. When it is not observed, the electron evolves on indeterminate paths
and displays wave-like behavior that reflects its indeterminate form; and when the
electron is observed, it is an empirical condition and behaves like a classical particle.

5.2 Quantum Superposition and Quantum Algorithms

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

5.3 Partial Trace for Tensor Products

Consider the outer product of two state vectors given by

O = |ψχ | ; x  |O|x = ψ(x  )χ ∗ (x)

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)

If the state vectors are elements of an N -dimensional Euclidean space, then O is


simply and N × N matrix and the trace  of O is the sum of it’s diagonal elements,
since for matrix Mi j , trace is defined by i Mii ; hence, it follows that


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

O = |ψ1 ψ1 | ⊗ |ψ2 ψ2 |

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

5.4 Density Matrix ρ

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

5.4.1 Pure Density Matrix

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.

5.4.2 Mixed Density Matrix

A mixed density matrix is defined for a collection of orthonormal projection operators


|ψi ψi | and is given by


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

Another important application of the mixed density matrix is in the description


of quantum mechanical states that, in addition to quantum indeterminacy, also have
classical randomness—as is the case for the thermodynamics of a quantum system—
and is discussed in Sect. 5.12.

5.4.3 Density Matrix for a Two-State System

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

The density matrix for the pure state is

1 3
ρ P = |ψψ| = [I + i n̂ i σi ] ; trρ 2P = n̂ 2 = 1 (5.12)
2 i=1

where the σi are the Pauli spin matrices given by

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

n̂ = (sin θ cos φ, cos θ cos φ, sin φ) ; 0 ≤ θ ≤ π ; 0 ≤ φ ≤ 2π

A vector lying inside the Bloch sphere 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.

5.5 Reduced Density Matrix

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

ψiI |ψ jI  = δi− j = ψiI I |ψ jI I 

The pure density matrix for the system is given by


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

x1 , x2 |ψ = ψ(x1 , x2 ) = ψ1 (x1 )ψ2 (x2 )


ρ = |ψψ| ; x1 , x2 |ρ|x1 , x2  = ψ(x1 , x2 )ψ ∗ (x1 , x2 ) (5.17)

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].

5.6 Separable Quantum Systems

A separable quantum system is defined to a system in which the degrees of freedom


can be exactly factorized in the sense that the state vector for the degrees of freedom
is a tensor product, as given below

|ψ = |ψ I |ψ I I  ; x1 , x2 |ψ = ψ I (x1 )ψ I I (x2 ) (5.19)

and yields the pure density matrix given by

ρ P = |ψψ| = |ψ I ψ I | ⊗ |ψ I I ψ I I |


5.7 Entangled Quantum States 121

The reduced density matrix, as discussed in Eq. 5.16, is obtained by performing a


partial trace over the x2 degree of freedom, and for the separable quantum system is
given by4

ρ P,R = Tr2 |ψψ| = |ψ I ψ I | ψ I I |ψ I I 


= |ψ I ψ I | ; Tr(ρ P,R ) = 1 = Tr(ρ 2P,R )

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

5.7 Entangled Quantum States

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

| E  is an entangled state; in general, the two or more degrees of freedom for an


entangled state need to be treated as one non-decomposable and inseparable system,
with the identities of the individual degrees of freedom, taken in isolation, being
meaningless. In contrast, for a separable system, each degree of freedom can be
considered to be a distinct entity and separate from the other degrees of freedom.

5.8 Entanglement for Composite Systems

The criterion of entanglement for a pure density matrix ρ p = |ψψ| is given by


examining its reduced density matrix ρ R ; if Tr(ρ R2 ) < 1, then the state |ψ is entan-
gled. This criterion does not hold for density matrix of systems that are the composite
of two or more different systems. In particular for bipartite states


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].

5.9 Entangled State: Two Binary Degrees of Freedom

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

| E = a|u 1 |d2  + b|d1  |u 2  ; |a|2 + |b|2 = 1 (5.25)


⎛ ⎞
        0
1 0 0 1 ⎜a ⎟
=a ⊗ +b ⊗ ⎜
=⎝ ⎟
0 1 1 0 b⎠
0

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

trρ E R = |a|2 + |b|2 = 1 : Normalization


tr (ρ E2 R ) = |a|4 + |b|4 = 1 − 2|ab|2 < 1 (5.28)

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

| E = a|u 1 |d2  + b|d1  |u 2  : Entangled

5.10 Quantum Entropy

Entropy is a measure of the ignorance regarding a system. The concept of entropy


in statistical physics has a natural analog for quantum systems S and, following von
Neumann, is defined as follows


N
S = −Tr(ρ ln ρ) = − pi ln pi (5.29)
i=1
ρ = U diag( p1 , p2 , . . . , p N )U † ; UU † = I

Consider a pure state with p1 = 1 and pi = 0; i = 1; then

ρ = |ψψ| ⇒ 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

Hence, for a N -state maximally uncertain system

1
ρmax = I ⇒ Tr(ρmax ) = 1
N
1
Smax = −Tr(ρ ln ρ) = ln(N )Tr(I)
N
⇒ S = ln(N ) : maximum entropy (5.30)

5.11 Maximally Entangled States

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

ψiI |ψ jI  = δi− j = ψi |ψ j 


II II

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

Since the completeness of the eigenfunctions of a Hermitian operator gives a reso-


lution of the identity operator,5 one obtains

1 1
|ci |2 = ⇒ ci = √ eiφi
N N

and yields the maximally entangled state given by6

1  iφi I
N
| E  = √ e |ψi |ψiI I  (5.32)
N i=1

An example of a pair of maximally entangled spins is given by the following


density matrix of a non-separable system

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

5.11.1 An Entangled State of Two Binary Degrees


of Freedom

An entangled state for two spin degrees of freedom, from Eq. 5.25, is given by

| E = a|u 1 |d2  + b|d1  |u 2  ; |a|2 + |b|2 = 1 (5.33)

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

with the reduced density matrix, from Eq. 5.27, given by

ρ 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

Hence, from Eq. 5.29, the entropy of this state is given by

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)

For the following special case, and from Eq. 5.30

1
|a| = √ = |b|
2
⇒ S = ln(2) : Maximum entropy (5.37)

Hence, a maximally entangled state of two spins is given by

1 
| E = √ eiφ |u 1 |d2  + |d1  |u 2  (5.38)
2

5.12 Pure and Mixed Density Matrix

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 measurement of the expectation value of observable O can be expressed in


terms of the density matrix of a pure state ρ p as follows

E χ [O] ≡ χ |O|χ  = Tr(O|χ χ |) = Tr(Oρ P ) (5.40)

The expectation value of an operator O with eigenvectors O|ψi  = λi |ψi  can be


rewritten in terms of the mixed density matrix ρ M as follows
5.12 Pure and Mixed Density Matrix 129

E ψ [O] = ψ| Ô|ψ = Tr( |ci |2 O|ψi ψi |) = Tr(Oρ M )
i

⇒ ρM = pi |ψi ψi | ; pi = |ci |2
i

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

A quantum system with thermal uncertainty is described by the density matrix ρT


given by

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

1. Belal E (2013) Baaquie. The theoretical foundations of quantum mechanics. Springer, UK


2. Feynman RP (2007) The character of physical law. Penguin Books, USA
3. Baaquie BE (2020) Mathematical methods and quantum mathematics for economics and
finance. Springer, Singapore
4. Nielsen MA, Chang IL (2000) Quantum computation and quantum information. Cambridge
University Press, UK
Chapter 6
Binary Degrees of Freedom and Qubits

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

|x0 , x1 , . . . , xn−1 x0 , x1 , . . . , xn−1 | ; xi = 0, 1 : i = 1, 2, . . . , n

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

|q ⇒ q(x0 , x1 , . . . , xn−1 ) = x0 , x1 , . . . , xn−1 |q

determines the probability, which is given by the normalized frequency distribution


of the various measurement gates registering a signal and is equal to

|q(x0 , x1 , . . . , xn−1 )|2

© 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

6.2 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.

6.3 Single Qubit

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 column vector notation, a qubit is given by the following


   
1 0
|q = α|0 + β|1 = α +β (6.2)
0 1

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

and yields the general single qubit


         
θ θ θ 1 θ 0
|q(θ, φ) = cos |0 + e sin

|1 = cos + e sin

2 2 2 0 2 1
(6.3)

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.

6.3.1 Density Matrix

There is another way to visualize the qubit: by expressing it in terms of a density


matrix. For any pure state |q, one can associate a density matrix ρ ≡ |qq| with
the state and is given by
  
cos( θ ) θ θ
|ρ = |qq| = iφ 2 θ cos( ) e−iφ sin( )
e sin( 2 ) 2 2
 2 θ −iφ θ θ

cos ( 2 ) e cos( 2 ) sin( 2 )
= iφ
e cos( θ2 ) sin( θ2 ) sin2 ( θ2 )
 
1 1 + cos θ e−iφ sin θ
=
2 eiφ sin θ 1 − cos θ
      
1 01 0 −i 1 0
= I + sin θ cos φ + sin θ sin φ + cos θ
2 10 i 0 0 −1
1  
= I + sin θ cos φσx + sin θ sin φσ y + cos θ σz
2
where σx , σ y and σz are Pauli’s spin matrices given by
     
01 0 −i 1 0
σx = , σy = , σz = . (6.4)
10 i 0 0 −1

One can rewrite the density matrix as follows:

ρ = |qq| = 1
2 (I + n · σ ) n · n = 1

where the unit vector n is given by


⎡ ⎤ ⎡ ⎤ ⎡ ⎤
nx sin θ cos φ σx
n = ⎣ n y ⎦ = ⎣ sin θ sin φ ⎦ , σ = ⎣ σ y ⎦ .
nz cos θ σz
136 6 Binary Degrees of Freedom and Qubits

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

6.4 Bell Entangled Qubits

The case of n = 2 consists of two binary degrees of freedom {0, 1} ⊗ {0, 1}. The
computational basis yields the following basis states

|00 ; |01 ; |10 ; |11

A general expansion of the two qubits state vector is given by

|ψ = α|00 + β|01 + γ |10 + δ|11 (6.5)


|α|2 + |β|2 + |γ |2 + |δ|2 = 1

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

A succinct notation for the Bell states is given by

1
|x y B = √ (|0y + (−1)x |1 ȳ) ; x, y = 0, 1
2

where ȳ is NOT y.

6.5 Bell States: Maximally Entangled

Consider the basis states |u 1 , |d1  and |u 2 , |d2  being defined by


   
1 0
|01 = |u 1  = ; |11 = |d1  =
0 1 1 1

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

For N = 2, denoting two-dimensional column vectors by u 1 , d1 , u 2 , d2 , we have the


following  I    II   
ψ1 u1 ψ1 u2
= ; =
ψ2I d1 ψ2I I d2

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

Choosing φ = 0 and φ = π , Eq. 6.7 yields, respectively

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

Choosing φ = 0 and φ = π Eq. 6.8 yields, respectively

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

Fig. 7.2 CNOT quantum


gate. Published with
permission of © Belal E.
Baaquie and L. C. Kwek. All
Rights Reserved

7.1 Quantum Gates

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.

X |0 = |1; X |1 = |0

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

Rx (θ ) = exp iθ X = cos(θ )I + i sin θ X


R y (θ ) = exp iθ Y = cos(θ )I + i sin θ Y
Rz (θ ) = exp iθ Z = cos(θ )I + i sin θ Z (7.2)

The unitary Hadamard gate H is given by


 
1 1 1
H=√ = H†
2 1 −1

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

The Hadamard gate is unitary since


 
10
HH = H =
† 2
= I ⇒ H 2 |0 = |0 : H 2 |1 = |1
01

From Eq. 7.3

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

Hence, for |x = |x1 x2 . . . xn , Eq. 7.5 yields

1 
1
H |x = √ (−)x y |y; x y = x1 y1 ⊕ x2 y2 · · · ⊕ xn yn ; xi , yi = 0, 1
2n y=0
(7.6)

The Hadamard gate H is used extensively in many quantum algorithms. Most


computations start with the initial state |0; the Hadamard gate is applied to the
input state |0 to render it into a superposed state of the two basis states with equal
amplitudes, since

1
H |0 = √ [|0 + |1] (7.7)
2

Consider the Hadamard gate acting on 2-qubits |q1 q2 ; using the tensor product
notation

H ⊗2 |q1 q2  = (H ⊗ H )(|q1  ⊗ |q2 ) = H |q1  ⊗ H |q2 


1
⇒ H ⊗2 |00 = √ [|0 + |1][|0 + |1]
22
1
= √ [|00 + |01 + |10 + |11] (7.8)
22
7.2 Superposed and Entangled Qubits 143

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

⊗⊗n |0 = |0000 . . . 00


 
n-fold tensor product

Hence, similar to Eq. 7.8

1
H ⊗n ⊗⊗n |0 = √ [|0 + |1][|0 + |1] · · · [|0 + |1]
2n
2n −1
1 
= √ |x (7.9)
2n x=0

7.2 Superposed and Entangled Qubits

Consider the general single qubit

|q = a|0 + b|1; a 2 + b2 = 1

We can construct this state starting from the initial state of |0 in the following
manner. Consider the rotation matrix

R y (θ )|0 = (cos θ I + i sin θ Y )|0 = cos θ |0 + sin θ |1 (7.10)

Hence, choosing
a = cos θ ; b = sin θ

yields
|q = R y (θ )|0

The quantum circuit diagram is shown in Fig. 7.3.

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

|ψ = α|00 + β|01 + γ |10 + δ|11


   
α|0 + β|1 γ |0 + δ|1
= α + β |0
2 2 + γ2 + δ 2 |1 (7.11)
α2 + β 2 γ 2 + δ2
|α|2 + |β|2 + |γ |2 + |δ|2 = 1

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

Such a U exists since both states


1
|φ1  = α 2 + β 2 |0 + γ 2 + δ 2 |1; |φ2  = (α|0 + β|1)
α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 

= α 2 + β 2 |0|φ2  + γ 2 + δ 2 |1U |φ2 


= |0(α|0 + β|1) + +|1(γ |0 + δ|1)
= α|00 + β|01 + γ |10 + δ|11 (7.13)

where the Control-U gate is given by

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)

Hence, from Eq. 7.12, the 2-qubit state is given by


7.2 Superposed and Entangled Qubits 145

Fig. 7.4 Preparation of a


general 2-qubits state.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

Fig. 7.5 Preparation of a


general 2-qubits entangled
state and the special case of
the Bell state |B1 .
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

|ψ = 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

Prepare initial unentangled (factorized) of two 1-qubits state given by

|ψi  = (α|0 + δ|1)|0 = α|00 + δ|10

Consider the CNOT gate

X = |0 0| ⊗ I + |1 1| ⊗ X

Applying the CNOT gate to the initial state yields the entangled state

X |ψi  = α|0|0 + δ|1X |0 = α|00 + δ|11 = |ψ E 

The circuit diagram is given in Fig. 7.5. √


Note that in the derivation above, by setting α = δ = 1/ 2, we have a mapping
of Bell states, given in Eq. 6.6 into computational basis. Consider the following Bell
state
146 7 Quantum Gates and Circuits

1 1  
|B1  = √ (|00 + |11) = √ X (|0 + |1)|0
22 22
1   1
⇒ |B1  = √ X H |0 ⊗ |0 = √ X (H ⊗ I)|00
2 2

since the Hadamard gate yields,

1
H |0 = √ (|0 + |1)
2

All the other Bell states can similarly be mapped into the computational basis.

7.3 Two- and Three-Qubit Quantum Gates

An example of a two-qubit gate is the Control-Not (CNOT) gate 7.2, given by


⎡ ⎤
1 0 0 0
⎢0 1 0 0⎥
CNOT = ⎢
⎣0
⎥. (7.14)
0 0 1⎦
0 0 1 0

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

CNOT = |0 0| ⊗ I + |1 1| ⊗ X (7.15)

where I is the identity matrix.


Another important quantum gate that arises from the development of reversible
computations is the Control-Control-NOT (CCNOT) gate and is a quantum version
of the classical Toffoli gate. The circuit diagram of the CCNOT gate is given in
Fig. 3.8 and reproduced below in for clarity Fig. 7.6. By analogy with the Toffoli
gate, the CCNOT gate is given by the following.

Fig. 7.6 CCNOT quantum


gate. Published with
permission of © Belal E.
Baaquie and L. C. Kwek. All
Rights Reserved
7.4 Arithmetic Addition of Binary Qubits 147
 
CCNOT = |00 00| + |00 00| + |00 00| ⊗ I + |11 11| ⊗ X

⎛ ⎞
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

In the computational basis, CCNOT gate is described by the matrix given in


Eq. 7.16. The Toffoli gate is a universal gate for classical algorithms. For quantum
algorithms, a generalization of the Toffoli gate proposed by Deutsch is the Toffoli
gate together with a matrix built from one qubit and is given by the following unitary
matrix ⎛ ⎞
100000 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 Q = ⎜ ⎜0 0 0 0 1 0 0
⎟ (7.17)
⎜ 0 ⎟ ⎟
⎜0 0 0 0 0 1 0 0 ⎟
⎜ ⎟
⎝ 0 0 0 0 0 0 i sin θ cos θ ⎠
0 0 0 0 0 0 cos θ i sin θ

7.4 Arithmetic Addition of Binary Qubits

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

|A = α1 |0 + β1 |1


|B = α2 |0 + β2 |1 (7.19)

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)

We analyze the two cases for the quantum adder.


Case I: Cin = 0
Using the result for the classical full-adder, such as in the examples given in Eq.
3.35, we have the following
 
|ψ = F (α1 |0 + β1 |1) ⊗ (α2 |0 + β2 |1) ⊗ |0 ⊗ |0
= α1 α2 F(|0000) + α1 β2 F(|0100)
+β1 α2 F(|1000) + β1 β2 F(|1100)
|ψ = α1 α2 |0000 + α1 β2 |0101 + β1 α2 |1001 + β1 β2 |1110 (7.21)

Case II: Cin = 1


Using the result for the classical full-adder, such as in the examples given in Eq.
3.35, we have the following
 
|ψ = F (α1 |0 + β1 |1) ⊗ (α2 |0 + β2 |1) ⊗ |1 ⊗ |0
= α1 α2 F(|0010) + α1 β2 F(|0110)
+β1 α2 F(|1010) + β1 β2 F(|1110)
|ψ = α1 α2 |0001 + α1 β2 |0110 + β1 α2 |1010 + β1 β2 |1111 (7.22)

7.5 Quantum Measurements of Qubits

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

qubits, and a detailed discussion is given of measurements performed on 1 qubit and


2 qubits.
For a single qubit given by

|q = α|0 + β|1

the density matrix is given by

ρ = |q q| = |α|2 |0 0| + αβ ∗ |0 1| + α ∗ β|1 0| + |β|2 |1 1|

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

M0 = |0 0|; M1 = |1 1|

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|

The measurement of a single qubit is given in Fig. 7.8.


• Consider the following Born measurement

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

|q → Measurement → |x; x = 0 or 1

• 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

|ψ = α|00 + β|01 + γ |10 + δ|11; ρ = |ψ ψ|

Similar to the single qubit case, we have the following projection operators required
for carrying out a quantum measurement on a 2-qubits string.

M00 = |0 0| ⊗ |0 0|; M01 = |0 0| ⊗ |1 1|

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

|ψ → Measurement → |x1 |x2 ; x1 , x2 = 0 or 1

The outcome of the measurement is indicated by e in Fig. 7.10. The probability of a


specific result |x1 |x2  is given by

p(i j) = Tr(Mi j ρ); x1 , x2 = 0, 1 (7.23)

and yields the following probability of occurrence of the state |x1 |x2 

p(00) = |α|2 ; p(01) = |β|2 ; p(10) = |γ |2 ; p(11) = |δ|2

7.5.1 Partial Measurement

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)

The measurement of the first qubit yields the following

|ψ → |x1 | 1 (x) (7.28)

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

Fig. 7.11 Measuring the


first qubit and then the qubit.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

Fig. 7.12 Measuring the


second qubit and then the
first qubit. Published with
permission of © Belal E.
Baaquie and L. C. Kwek. All
Rights Reserved

Another measurement carried out on state |x1 | 1 (x), as shown in Fig. 7.11,
yields

|x1 | 1 (x) → |x1 |x2  (7.29)

with
• Probability of state |01 |01 occurring being given by

|α|2
p1 (0) = |α|2 = p(00)
p1 (0)

• Probability of state |01 |11 occurring being given by

|β|2
p1 (0) = |β|2 = p(01)
p1 (0)

• Probability of state |11 |01 occurring being given by

|γ |2
p1 (1) = |γ |2 = p(10)
p1 (1)
References 153

• Probability of state |11 |11 occurring being given by

|δ|2
p1 (1) = |δ|2 = p(11)
p1 (1)

In summary, the two successive measurements are given by the following

|ψ → |x1 | 1 (x) → |x1 |x2 

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 

with the result given in Eq. 7.23.


One can also choose to perform the successive measurements by first measuring
the second degree of freedom |x2  and then the first degree of freedom, as shown in
Fig. 7.12. One then has, in a similar notation as above

|ψ → | 2 (x)|x 2  → |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].

8.2 Eigenvalue of Unitary Operator

Consider a unitary operator U that has an eigenvector |u such that

U |u = e2πiω |u

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

U y |u = e2πiωy |u; y = 0, 1, 2, . . . , 2n − 1

Form the state vector |ψ given by

2 −1
1 
n

|ψ = √ exp{2πiωy}|y : |y = |y1 . . . yn ; yi = 0, 1 (8.1)


2n y=0

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 ω.

8.3 Phase Estimation

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

In binary notation, ω is written as follows

ω = 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

|ψ = √ exp{2πiωy}|y : |y = |y1 . . . yn ; yi = 0, 1 (8.3)


2n y=0
8.3 Phase Estimation 157

Furthermore


n
y= yi 2n−i = 2n−1 y1 + 2n−2 y2 + · · · + 2yn−1 + 20 yn
i=1

We have the following


n 
yω = yi 2n−i × 0.x1 x2 . . . xn (8.4)
i=1

Recall from Eq. 2.7

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

2n−i yi × 0.x1 x2 . . . xn = integer + yi × 0.xn−i+1 . . . xn


n
⇒ yω = yi × 0.xn−i+1 . . . xn + integer; yi = 0, 1 (8.6)
i=1

For n = 3, Eq. 8.6 yields

ωy = y1 (0.x3 ) + y2 (0.x2 x3 ) + y3 (0.x1 x2 x3 ); y1 , y2 , y3 = 0, 1

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

8.3.1 Phase Estimation for n = 3

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

The Hadamard gate yields the following

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)

We have the following

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

Note that, for x3 = 1


     
R−1
2 |0 + e2πi(0.x2 1) |1 = |0 + e2πi(0.x2 1−0.01) |1 = |0 + e2πi(0.x2 ) |1
2 2 2

and hence, from Eq. 8.14


     

U12 |x3 1 |0 + e2πi(0.x2 x3 ) |1 = |x3 1 |0 + e2πi(0.x2 ) |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 }

Furthermore, similar to Eq. 8.16

1  

U13 †
H2 U12 H1 |ψ3  = √ |x3 1 |x2 2 |0 + e2πi(0.x1 x2 ) |1 (8.20)
2 3

Define unitary gate



U23 = I ⊗ |00| ⊗ I + I ⊗ |11| ⊗ R−1
2 (8.21)

which yields from Eq. 8.22


 
† †
U23 †
U13 H2 U12 H1 |ψ3  = √1 |x 3 1 |x 2 2
2
|0 + e2πi(0.x1 ) |1 (8.22)
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  = |ω

where the phase ω is given, as expected, by

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)

Note that, since P3 is unitary, from Eq. 8.24

P3−1 = P3† = H1 U12 H2 U13 U23 H3 S3 (8.25)

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

P|ψ = |x1 x2 x3 . . . xn  = |ω ⇒ |ψ = P † |ω (8.26)

where P is unitary gate given by a 2n × 2n matrix and |ψn  is an 2n -dimensional


complex-valued state vector. The result Eq. 8.26 can be written in the following more
formal manner

 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)

• Apply the quantum gate P to |ψ and obtain

 1 2n
−1 
P √ exp{2πiωy}|y
2n y=0

• The final result is given by

 1 2
n
−1 
P √ exp{2πiωy}|y = |ω
2n y=0

8.4 quantum Fourier Transform

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

x = x1 2n−1 + x2 2n−2 + · · · + x j 2n− j + · · · + xn 20 ; x j = 0, 1


x 1 1 1
ω = n = x1 + x2 2 + · · · + xn n
2 2 2 2
⇒ ω ≡ 0.x1 x2 . . . xn
y = yn 20 + yn−1 21 + · · · + y j 2n− j + · · · + y1 2n−1 ; y j = 0, 1

and hence for x y being ordinary multiplication


xy x
= n y = ωy
2n 2
Note due to the choice of the binary expansion, we have two equivalent notations for
the computational basis

|x = |x1 x2 . . . xn ; |y = |y1 y2 . . . yn ; x, y = 0, 1, . . . , 2n − 1

A quantum Fourier transform is a unitary transformation that maps the compu-


tational basis |x to another equivalent basis |y. The discrete Fourier transform is
a unitary transformation F of the computational basis |x of the n-qubit to a new
computational basis denoted by |y. Hence, we have the definition of a quantum
Fourier Transform (qFT) denoted by F and given by

  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)

The quantum Fourier transform is unitary since

F · F † = I2n ×2n

Equations 8.28 and 8.3 yield

2 −1
1 
n

P |x1 x2 x3 . . . xn  = |ψn  = √

exp{2πi x y/2n }|y
2n y=0

Hence, Eqs. 8.26 and 8.29 yield

2 −1
1 
n

F|x = √ exp{2πi x y/2n }|y


2n y=0

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)

• The quantum Fourier transform

2 −1
1 
n

√ exp{2πi x y/2n }|y


2n y=0

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

F|x = √ exp{2πi x y/2n }|y


2n y=0

8.4.1 quantum Fourier Transform for n = 3

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)

From Eqs. 8.25 and 8.30

F3 = P3† = H1 U12 H2 U13 U23 H3 S3 (8.32)

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

Hence, for Hi acting on the computational basis


  
1 2πi
Hi |x1 x2 . . . xn  = √ |x1 x2 . . . |0 + exp xi |1 | . . . xn−1 xn  (8.34)
2 2 i

From Eq. 8.32, the n = 3 quantum Fourier transform is given by

F3 |x1 x2 x3  = H1 U12 H2 U13 U23 H3 S3 |x1 x2 x3 


 
= H1 U12 H2 U13 U23 H3 |x3 1 |x2 2 |x1 3 (8.35)

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 †

Taking the Hermitian conjugation of Eq. 8.13 yields

U12 = |00| ⊗ I ⊗ I + |11| ⊗ R2 ⊗ I (8.36)

Similarly, taking the Hermitian conjugation of Eq. 8.17 yields

U13 = |00| ⊗ I ⊗ I + |11| ⊗ I ⊗ R3 (8.37)

and lastly from Eq. 8.21

U23 = I ⊗ |00| ⊗ I + I ⊗ |11| ⊗ R2 (8.38)

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

= |x3 1 |02 δ(x2 ) |0 + exp{2πi(0.x1 )}|1


 3

+|12 δ(x2 − 1) |0 + exp{2πi(0.x1 + 0.01)}|1
  3
2πi(0.x1 x2 )
= |x3 1 |x2 2 |0 + e |1 (8.39)
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.

8.5 Quantum Circuit of qFT

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

Ui j = I ⊗ I · · · |00| ⊗ I · · · I ⊗ I ⊕ I ⊗ I · · · |11| ⊗ I · · · ⊗ Rk · · · ⊗ I (8.42)


 
control qubit: |00| jth position Rk acting on ith target qubit
168 8 Phase Estimation and quantum Fourier Transform (qFT)

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

where k = j − i and as mentioned before Rk is a 2 × 2 diagonal matrix given by


 
1 0
Rk = (8.43)
0 exp{2πi/2k }

Hence, as shown in the circuit diagram given in Fig. 8.3, the quantum Fourier trans-
form is given by

F(|x) = Hn Un,n−1 Hn−1 . . . H3 U3,n−1 . . . U3,4 H2 U2,n . . . U2,3 H1 |x (8.44)

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

1. Phillip K, Raymond L, Michele M (2007) Introduction to quantum computing. Cambridge


University Press, USA
2. David M (2008) Quantum computing explained. MIT Press, USA
3. Mermin ND (2007) Quantum computer science. Cambridge University Press, UK
4. Nielsen MA, Chuang IL (2012) Quantum computation and quantum information. Cambridge
University Press, UK
5. Nielsen MA, Chuang I (2002) Quantum computation and quantum information
Part II
Quantum Algorithms
Chapter 9
Deutsch Algorithm

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.

Table 9.1 Binary function of Function x =0 x =1


one bit
Constant
f0 0 0
f1 1 1
Balanced
f3 0 1
f4 1 0

© 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.

9.1 The Deutsch Quantum Circuit

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

U f |x|y = |x|y ⊕ f (x) (9.1)

where
|x : input state; |y : ancillary state

The oracle is unitary since, using binary addition f (x) ⊕ f (x) = 0 yields

U 2f |x|y = U f |x|y ⊕ f (x) = |x|y

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,

Fig. 9.1 a Quantum circuit a


for the Deutsch algorithm.
b The action of the U f gate, ¨ ² H H
also called the oracle. Uf
Published with permission of
© Belal E. Baaquie and ¨ ² H
L. C. Kwek. All Rights t t t t
Reserved b

Uf
9.1 The Deutsch Quantum Circuit 175

a transformation is possible that removes the entanglement and leads to a simpler


quantum algorithm.
In fact for all quantum algorithms considered in this book, the oracle always
behaves like the expression given in Eq. 9.1, with the only difference being in the
nature of the qubit and the function f .
The oracle needs to know the function f ; in the algorithm, we do not know whether
the function is constant or balanced until a measurement is made, but the oracle knows
the properties of the function during the process of the quantum computation.
The initial input and ancillary qubits, at time t0 , are given by |ψ = |0|1. The
following steps are taken sequentially in time, as shown in Fig. 9.1.
• |ψ(t0 ) = |0|1
• |ψ(t1 ) = H ⊗2 |ψ(t0 ) = H ⊗2 |0|1 = (H ⊗ I)(I ⊗ H )|0|1
• |ψ(t2 ) = U f |ψ(t1 )
• |ψ(t3 ) = (H ⊗ I)|ψ(t2 )
• Measurement at time t4 of is only of the input qubit: Tr(|00|ψ(t3 )).
The steps leading to the result are the following. From Eq. 7.4

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)

Hence, using binary addition 0 ⊕ f = f , yields from Eq. 9.2

|ψ(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)

Case (i): f (0) = f (1) = f . From Eq. 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

f (0) = 1 ⊕ f (1); 1 ⊕ f (0) = f (1)

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

A single measurement is performed, ignoring the ancillary qubit, which is one


of the simplest examples of a generalized Born measurement; the result of the mea-
surement, from Sect. 4.10, is given by

1  
|ψ(t3 ) → Measurement → |x √ |0 − |1 ; x = 0, 1
2

The probability for the two possible outcomes is given by

 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

f (0) ⊕ f (1) = 0 : constant; f (0) ⊕ f (1) = 1 : balanced

We can hence rewrite Eqs. 9.6 and 9.8 as follows

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

Hence, from Eqs. 9.10 and 9.11 we obtain

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

and yields the expected result given in Eq. 9.9


⎧  
⎨(−1) f (0) |0 |0−|1
√ : f (0) = f (1) = f
|ψ(t3 ) =  2 
⎩(−1) |1 √
f (0) |0−|1
: f (0) = f (1)
2

The expression given in Eq. 9.12 yields the following

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

The Deutsch–Jozsa algorithm generalizes the Deutsch algorithm to the case of n-


degrees of freedom. The derivation of the more complex quantum Fourier transform
algorithm can be adapted to yield the result. The main reason for analyzing the
Deutsch–Jozsa algorithm is to illustrate the cancelation of amplitudes that arises
from representing the n-qubits as the superposition of the computational basis states.
Consider n qubits together with a single ancillary qubit. On applying the Hadamard
gate to the qubit |0⊗n , the result is all possible combinations of the qubit compu-
tational basis with equal amplitude. There are 2n terms in the expansion, and let
x = {0, 1, 2, . . . , 2n − 1} be a labeling of the states. The notation is based on the
mapping of x to the binary basis, as given in Eq. 2.2, and yields the Dirac ket vector

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

The circuit shown in Fig. 10.1 has the following components.

|ψ(t0 ) = |0⊗n |1

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

Recall from Eq. 9.5

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,

f (x) = constant : constant function

If f (x) is balanced, then

f (x) = equal number of zeroes and ones : balanced function

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

Hence, for the n-qubit, Eq. 10.2 yields

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

|x = |x⊗n = |x1 x2 . . . xn ; xi = 0, 1 : i = 1, 2, . . . , n

Applying H ⊗n to n-qubit state |ψ(t2 ) given in Eq. 10.1 yields

  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

|ψ(t3 ) → |yH |1

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

The constructive or destructive interference of the superposed quantum state given


in Eq. 10.4, and which results in Eq. 10.5, is essentially a quantum effect that has no
analog in classical algorithms. Quantum superposition and quantum entanglement—
two resources unique to quantum algorithms—are, as mentioned earlier, at the root
of the advantage quantum computers and algorithms have over the classical case.
Chapter 11
Grover’s Algorithm

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.

11.1 Phase Inversion and Amplitude Amplification

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

|ψ(t1 ) = |xi  = |00 + |01 + |10 + |11


2n/2 i=0
2

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

|ψ(t2 ) → W |ψ(t2 ) = |10 = |ξ 

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.

11.2 Grover’s Quantum Circuit

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

U f |x|y = |x|y ⊕ f (x) ; x, y = 0, 1, 2, . . . , 2n − 1 (11.2)

where, for N = 2n , we are using the following notation

|x ≡ |x1  ⊗ |x2  · · · ⊗ |xn  ; |y ≡ |y1  ⊗ |y2  · · · ⊗ |yn  : N = 2n


   
n times n times

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

|ψ(t0 ) = |0⊗n H |1 = |0 ⊗ |0 · · · ⊗ |0 H |1


 
n times

• Apply the Hadamard operator on the initial state to yield

|ψ(t1 ) = H ⊗n |0⊗n H |1


N −1
1 
= H |0 ⊗ H |0 · · · ⊗ H |0 H |1 = √ |xH |1
  N x=0
n times

• The oracle is defined similar to the case of the Deutsch–Jozsa algorithm by

U f |x|y = |x|y ⊕ f (x) = O f |x |y

where |y = H |1 is the auxiliary qubit.


• Apply the oracle U f to obtain

|ψ(t2 ) = U f |ψ(t1 ) = U f H ⊗n |0⊗n H |1 = O f H ⊗n |0⊗n H |1

The oracle marks the state being sought by a phase inversion.


• Apply the diffusion operator W to obtain

|ψ(t3 ) = W |ψ(t2 ) = W U f |ψ(t1 )

to increase the amplitude of the marked state. √


• The application of the oracle U f and the diffusion operator W is repeated N
times, each time increasing the amplitude of the marked qubit.
• All the qubits, except for the auxiliary qubit, are subjected to a measurement by
applying projection operators M(x), x = 1, 2, . . . N on all the degrees of freedom
|x
• The probability of the detectors registering a specific determinate value of qubit
x Obs for the outcome is given by Tr M(x Obs )|ψ(t3 ) ψ(t3 )| .

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

11.3 Grover Algorithm: Two-Qubit

As a warm-up to the general case, we provide a more explicit derivation of the


two-qubit case. Applying the Hadamard transformation yields the input state vector

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

U f |x|y = |x|y ⊕ f (x)

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

Fig. 11.3 Amplification by


reflection and diffusion gate
in Grover’s algorithm.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

1, 1, −1, 1 → reflection → 0, 0, 2, 0 (11.5)

The reversible gate W makes the Grover reflection and yields the result

|ψ(t3 ) = W |ψ(t2 ) = |10 = |ξ  (11.6)

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

and the reflected state vector is given by


⎤ ⎡
1
1  1 ⎢1 ⎥
|ψ(t2 ) = |00 + |01 − |10 + |11 = ⎢ ⎥
2 2 ⎣ −1 ⎦
1

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

The state |ξ  is normalized to unity, as required by quantum mechanics. The amplitude


for all the other qubit basis states is zero, as expected from the reflections given in
Eq. 11.5.

11.4 Grover Algorithm: Phase Inversion

To generalize the two-qubit result to the case of n qubits, a considerable bit of


algebra is needed. Consider n qubits together with a single ancillary qubit. Similar to
Eq. 11.3, on applying the Hamamard gate to the qubit |0⊗n , the result is all possible
combinations of the qubit computational basis with equal amplitude. There are 2n
number of terms in the expansion, and let x = {0, 1, . . . , 2n − 1} be a labeling of the
states.

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

Recall from Eq. 9.5

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

From Eq. 11.7, define operator O and qubit state |φ by

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=ξ

The explicit form of operator O is given by

O = I − 2|ξ  ξ | (11.11)

and yields, as expected

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

11.5 Grover Diffusion Gate W

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

Fig. 11.4 Graphical


representation of the Grover
algorithm, with G = W O.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

|ψ(t3 ) = (W ⊗ I)U f H ⊗n |0⊗n H |1 = (W ⊗ I)U f |φH |1

= (W ⊗ I) O|φH |1 = W O|φH |1 ≡ G|φ H |1 (11.12)

where the Grover rotation operator G is defined by

G = W O = 2|φ φ| − I I − 2|ξ  ξ | (11.13)

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

and hence, from Eq. 11.14


   
θ θ
|φ = cos |η + sin |ξ  ; η|ξ  = 0 ; η|η = 1 = ξ |ξ  (11.16)
2 2

A straightforward calculation using Eq. 11.13 yields


 
4 2 2
G|φ = 1 − |φ + √ |ξ  ; G|ξ  = |ξ  − √ |φ (11.17)
N N N

From Eqs. 11.14 and 11.17



N −1 1
G|η = G|φ − √ G|ξ 
N N

2 N −1 1 1
= (1 − ) |η + √ |ξ  + √ |ξ 
N N N N

N −2 N −1
⇒ G|η = |η + 2 |ξ  (11.18)
N N
Similarly, from Eqs. 11.14 and 11.17
 √
2 N −1 1 N −1 N −2
G|ξ  = |ξ  − √ |η + √ |ξ  = −2 |η + |ξ 
N N N N N
(11.19)

Equation 11.15 yields the identities



N −2 2 N −1
= cos(θ ) ; = sin(θ )
N N
and hence, from Eqs. 11.18 and 11.19

G|η = cos(θ )|η + sin(θ )|ξ 


G|ξ  = − sin(θ )|η + cos(θ )|ξ  (11.20)

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

11.6 Grover Recursion Equation

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

Applying G once more yields, from Eq. 11.20

|ψk+1  = G k+1 |φ


= cos(θ )ak + sin(θ )bk |ξ  + − sin(θ )ak + cos(θ )bk |η (11.22)

Note that

|ψk+1  = G k+1 |φ = ak+1 |ξ  + bk+1 |η (11.23)

Equations 11.22 and 11.23 provide the following recursion equation


    
ak+1 cos(θ ) sin(θ ) ak
=
bk+1 − sin(θ ) cos(θ ) bk
   k  
a cos(θ ) sin(θ ) a0
⇒ k = (11.24)
bk − sin(θ ) cos(θ ) b0

The matrix identity


  0 1   cos(θ ) sin(θ ) 
exp θ =
−1 0 − sin(θ ) cos(θ )

yields the following


 k  
cos(θ ) sin(θ ) 0 1
= exp{kθ }
− sin(θ ) cos(θ ) −1 0
 
cos(kθ ) sin(kθ )
= (11.25)
− sin(kθ ) cos(kθ )

Equations 11.21 and 11.25 yield


11.6 Grover Recursion Equation 197
    θ

ak cos(kθ ) sin(kθ ) sin
= 2
θ (11.26)
bk − sin(kθ ) cos(kθ ) cos 2

and we obtain the solution


   
θ θ
ak = sin + kθ ; bk = cos + kθ
2 2

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

The result obtained in Eq. 11.27 is exact.


The recursion is aimed at making the final state |ψk  parallel to |ξ , and for this
the amplitude of the |ξ  qubit should be near one. Note from Eq. 11.15, for large N

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

|ψ K  → Measurement → |xH |1 ≈ |ξ H |1 (11.31)

The probability of observing the device to give a reading corresponding to the


basis state |x is given by
198 11 Grover’s Algorithm

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

The angle θm is defined as


11.7 Single Recursion: Two Qubits 199

   
θm M M
sin = ⇒ θm 2
2 N N

and Eq. 11.33 yields


   
θm θm
|φ = cos |η + sin |ξ 
2 2

Similar to Eq. 11.27, after k recursions


   
θm θm
|ψk  = G k |φ = sin + kθm |ξ  + cos + kθm |η (11.34)
2 2

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

11.7 Single Recursion: Two Qubits

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

Fig. 11.6 The 2-qubit case


for the Grover algorithm.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

Recall
G = 2|φ φ| − I I − 2|ξ  ξ |

Applying operator G to the two-quit bit state given in Eq. 11.38 yields

Gφ = 2|φ φ| − I I − 2|ξ  ξ | |φ = 2|φ φ| − I |φ − |ξ 


⇒ Gφ = |ξ  = |01 (11.39)

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

We revisit the factorization of primes to explain the Grover algorithm.2 To factorize


integer
√ m = pq, with primes p, q, q < p. Since the smaller √ prime q is less than
m, one needs to generate numbers ranging from 1, . . . , m. To apply the Grover

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 =ξ

As mentioned earlier, recognizing the solution means checking whether if x can


divide m—and it does not require knowing the entire factorization of m = pq. Rec-
ognizing the solution without knowing the full answer allows the search algorithm
to ‘mark’ the solution being sought.
The number of steps required for finding the marked basis state for the Grover
algorithm, from Eq. 11.29, is given by
π√
N
4

For the classical algorithm, one has to divide N = m by, in principle, by every √
number from 1, . . . , N to find which number is the prime, and this requires m
steps. In contrast, for the Grover algorithm, the number of steps required
√ to find the
marked state, which is the number we are looking for, is proportional to N = m 1/4 .
This is the famous quadratic acceleration provided by Grover’s algorithm.
The advantage of the Grover algorithm over the classical case lies in the fact that,
due to the superposition principle, one can simultaneously update all the basis states,
as given in Eq. 11.7

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

f (x) = f (y) if and only if x ⊕ y = a. (12.1)

The question is how can we determine a quickly. Note that

x ⊕ y =a ⇒ y = x ⊕a

Classically, as in the Deutsch–Jozsa algorithm, the worst case scenario to find a


with 100 % certainty for a given function f involves checking up to 2n /2 + 1 inputs.
And like the Deutsch–Jozsa algorithm, if we are lucky, we could classically solve
with our first few tries.

12.1 Quantum Algorithm

In the quantum algorithm, we start with the initial state with two registers

|ψ1  = |0⊗n |0⊗n

© 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

We next apply the Hadamard H ⊗n to the first register so that

1 
|ψ2  = √ |i|0⊗n (12.2)
2n i∈{0,1}n

Note that the Hadamard transformation introduces n-degrees of freedom labeled by


i. We then apply the oracle:

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

|ψ3  → |ψ4 (i 0 )| f (i 0 ) ; ψ4 |ψ4  = 1

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

Hence, applying the Hadamard transformation on the first register gives

|ψ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.

12.2 An Illustrative Example

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

f (|000) = f (|101) = |000


f (|001) = f (|100) = |101
f (|010) = f (|111) = |010
f (|011) = f (|110) = |111
206 12 Simon’s Algorithm

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

Figure 12.1 shows one such realization of the algorithm.


Finally, suppose the measurement output on the second register is |010, then the
state of the first register becomes

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

{|000, |010, |101, |111}

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

1. Simon DR (1997) On the power of quantum computation. SIAM J Comput 26(5):1474–1483


Chapter 13
Shor’s Algorithm

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

13.2 Understanding the Classical 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, · · · :

{ 20 Mod(15) = 1, 21 Mod(15) = 2, 22 Mod(15) = 4,


23 Mod(15) = 8, 24 Mod(15) = 1, 25 Mod(15) = 2, · · · }

Note the crucial equation


24 Mod (15) = 1

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.

13.3 Quantum Algorithm

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

The algorithm to compute this quantum Fourier transform is described in Chap. 8.


Let N be the number we would like to factorize into its primes. Like the Grover
search algorithm, we begin with two registers. Let us start with n qubits and let
Q = 2n ; hence, the registers hold all the real integer from 0 to Q − 1; in particular,
the first register can hold a number between 0 to Q − 1. It can be shown (discussed
later) that we can choose Q > N 2 : it is much larger than N , but still polynomial in
N . The second register will also carry integers between 0 to Q − 1. Hence the two
registers will consist of O(log(N )) qubits. Once r has been determined, the prime
N can be factorized using number theory.

13.3.1 How Then Does the Quantum Algorithm Work?

Shor’s algorithm yields the value of cycle r .


Choose an integer a that is coprime with N . We know that if we consider the
sequence:
{a 0 , a 1 , a 2 , a 3 , a 4 , · · · } Mod N

there exists an r such that a r Mod N = 1. This is sometimes known as Euler’s


theorem, a generalization of Fermat’s little theorem that states that for any integer N
and a,
a φ(N ) ≡ 1 Mod N

where φ(N ) is Euler’s quotient function.


Shor’s algorithm relies on this result and starts with the function

f (x) = a x Mod N

Note that

f (x + r ) = a x+r Mod N = a x Mod N × a r Mod N = a x Mod N = f (x)

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. We first start with the state

|ψ0  = |0⊗n ⊗ |0⊗n


212 13 Shor’s Algorithm

Apply the Hadamard transformation H ⊗ H ⊗ H · · · H = H ⊗n to the initial state


to obtain

  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

whenever (since j is an integer)

r k1
is some integer m 1
Q
214 13 Shor’s Algorithm

Note that exp(2πi x0Qk1 ) = 1 and A−1 j=0 exp(2πi Q ) =


jr k1 A−1
j=0 1 = A.
The fraction k1 /Q is approximated by a fraction with denominator smaller than
N , using the (classical) method of continued fractions. Thus, we see that

k1 m1
⇐⇒ r k1 ≡ 0 Mod Q
Q r

8. Repeat all previous steps poly(log(N )) number of times to get


m1 m2
k1 = Q, k2 = Q, · · ·
r1 r2

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

Fig. 13.1 Plots of the


probabilities Prob(k) as a
function of k. Note that the
probabilities of getting the
peaks are exactly
1/r = 1/5 = 0.2. Published
with permission of © Belal
E. Baaquie and L. C. Kwek.
All Rights Reserved

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

This is a geometrical series.


There are two cases:
• exact periodicity and
• imperfect periodicity.
In the case of exact periodicity, i.e., that r divides Q exactly, we have A = Q/r .
In this case, the above geometrical series is equal to zero, unless e2πikr/Q = 1. Thus,
we measure with probability 1 only k’s such that kr = 0 mod Q. We can write
kr = m Q, for some integer m, or k/Q = m/r . We know Q, and we know k since we
have measured it. Therefore, we can reduce the fraction k/Q. If m and r are coprime.
the denominator will be exactly r which we are looking for! By the prime number
theorem, there are approximately n/log(n) numbers smaller than n and coprime with
n, so since m is chosen randomly, repeating the experiment a large enough number of
times we will with very high probability eventually get m coprime to r . Sometimes,
one says that this is the case of constructive interference: and the ones that we see
are all integer multiples of Q/r .
For concreteness, if we consider an example of Q = 200 with r = 5 and plot the
values of Prob(k) as a function of k, we get Fig. 13.1 which give nonzero probabilities
for k = {0, 40, 80, 120, 160}. Dividing by Q gives the fractions

1 2 3 4
0, , , ,
5 5 5 5

Clearly, r = 5 in this case.


216 13 Shor’s Algorithm

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:

− r/2 ≤ kr Mod Q ≤ r/2 (13.11)

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

Fig. 13.2 Plots of the


probabilities Prob(k) as a
function of k. Published
with permission of © Belal
E. Baaquie and L. C. Kwek.
All Rights Reserved

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

In general, recall that Q is chosen to be much larger than N , say Q ≥ N 2 . This


means that Qk , a fraction with denominator ≥ N 2 , can be approximated by mr , a
fraction with denominator smaller than N , to within N12 . Umesh Vazirani presents
another simple argument. In this argument, one notes that the number of copies of
Q Q
the period is and as long as this ratio is greater than the period, r , i.e., > r or
r r
Q > r 2 . But then r < N , so if we ensure that Q > N 2 > r 2 , we are done.
218 13 Shor’s Algorithm

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].

14.1 Review of Option Pricing

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

C(x, T, T ) = e−r τ ν(x)

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)

= e−r τ E[ν] (14.1)

where

p(x) = P(x0 , x; τ ) (14.2)

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

μ = E[e−x0 ν] < 1 (14.4)

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

The quantum algorithm, after amplitude amplification, gives a quadratic improve-


ment and yields

N −1
 σν
E[ν] = p(x (i) )ν(x (i) ) ± with 66% likelihood
i=0
N
14.2 Quantum Algorithm 223

In simplified notation, the summation is rewritten as

N −1
 σν
E[ν] = p(x)ν(x) ± with 66% likelihood (14.5)
x=0
N

This improvement by a factor of a square root is similar to the improvement of


the Grover algorithm, and the quantum algorithm discussed in this chapter is closely
related to the Grover algorithm.

14.2 Quantum Algorithm

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.

14.3 Quantum Algorithm for Expectation Value

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

The algorithm A acts on the input qubits state and yields

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)

Note no amplification of any states is carried out. In preparation for a generalized


Born measurement on only the ancillary qubits, we rewrite the state |η as follows
 
|η = p(0)|0| 0  + p(1)|0| 1 
14.4 Algorithm for Quadratic Improvement 225

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

Performing a generalized Born measurement on only the ancillary qubit state,


discussed in Sect. 4.10, yields

|η → Measurement → |a| a : a = 0, 1

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.

14.4 Algorithm for Quadratic Improvement

Application of quantum algorithms to option price has been discussed in [5–8]. To


get a quadratic improvement in the accuracy of the computed value of μ, we discuss
the quantum algorithm for option price developed by Patrick et al. [5]—based on an
oscillating phase.
226 14 Quantum Algorithm for Option Pricing

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 implementation of the oscillating phase approach is similar in spirit to the


Grover algorithm, but the details are quite different. Note that the angle θ (defined
below) is not known for option pricing, whereas in the Grover algorithm the angle
θ , as in Eq. 11.16, is fixed by the total number of configurations of the degrees of
freedom. What is similar to both approaches is that there is a rotation of an angle 2θ .
For the option price, the rotation yields the final output qubits for which the qubit
that is most likely to be observed is the qubit yields the best value for θ .
To perform the rotation, define the following unitary operator

V = I2n+1 − 2I2n ⊗ |11| = V † ; V 2 = I2n+1

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

Z = I2n+1 − 2|0⊗(n+1) 0|⊗(n+1)

In terms of operator F introduced in Eq. 14.8, we have

U = FZF †

since

U = R(A ⊗ I2 ) I2n+1 − 2|0⊗(n+1) 0|⊗(n+1) (I2 ⊗ A† )R †


= I2n+1 − 2|ηη| (14.11)

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

The gates for operator Q are shown in Fig. 14.2.


228 14 Quantum Algorithm for Option Pricing

Fig. 14.2 Gates for operator Q. Published with permission of © Belal E. Baaquie and L. C. Kwek.
All Rights Reserved

14.5 Eigenvalues of Diffusion Operator Q

The repeated application of the Grover diffusion operator G was evaluated by a


recursion equation, given in Sect. 11.6. For the option pricing diffusion operator Q,
the eigenvalues are evaluated, as this will allow us to isolate the angle θ that, via the
relation cos π θ = 1 − 2μ, will yield the option price.
Define the vector |η⊥  by
η|η⊥  = 0

Using the identities

η|V |η = 1 − 2μ = cos π θ ; η|η = η|V 2 |η = 1

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

|ψ = a|η + bV |η

The action of Q on this state vector is given by

Q|ψ = a Q|η + bQV |η (14.13)

Recall from Eq. 14.12


  
Q = I2n+1 − 2|ηη| I2n+1 − 2V |ηη|V (14.14)
14.5 Eigenvalues of Diffusion Operator Q 229

Hence
 
Q|η = − 1 + 4 cos2 (π θ ) |η − 2 cos(π θ )V |η
QV |η = 2 cos(π θ )|η − V |η (14.15)

and from Eqs. 14.13 and 14.15 we obtain


  
Q|ψ = a(−1 + cos2 (π θ ) ) + 2b cos(π θ ) |η
 
+ − 2a cos(π θ ) − b V |η (14.16)

The action of the diffusion operator Q on the space spanned by |η and V |η is closed
and yields

Q|ψ = a Q|η + bQV |η


= ã|η + b̃V |η (14.17)

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

The matrix M, from Eqs. 14.16 and 14.17, is given by



4 cos2 (π θ ) − 1 2 cos(π θ )
Q≡M= ; det M = 1 (14.19)
−2 cos(π θ ) −1

The eigenvalues of M, given by λ, satisfy the equation


 
4 cos2 (π θ ) − 1 − λ 2 cos(π θ )
0 = det(M − λI2 ) = det  (14.20)
−2 cos(π θ ) −1 − λ 

and yields
(1 + λ)2 − (1 + λ) cos2 (π θ ) + cos2 (π θ ) = 0

Hence the eigenvalues of Q are given by

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

Hence, simplifying the eigenvalues given in Eq. 14.21 yields

λ± = cos(2π θ ) ± i sin(2π θ ) = exp{±i2π θ }

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 matrix elements of Q can be obtained easily from Eq. (14.14).


To get the matrix elements of Q, we can also evaluate the matrix elements η|Q|η,
η|Q|η⊥  (and also the other off-diagonal term, η⊥ |Q|η ) and η⊥ |Q|η⊥ : For
instance,

η|Q|η = (4 cos2 (π θ ) − 1) − 2 cos(π θ )η|V |η


= (4 cos2 (π θ ) − 1) − 2 cos2 (π θ )
= 2 cos2 (π θ ) − 1 = cos(2π θ ) (14.22)

The matrix representation of Q is given by


  
10 10
Q= −2
01 00
   
10 cos(π θ )  −iχ

× − 2 iχ cos(π θ ) e sin(π θ )
01 e sin(π θ )
 
−1 0 1 − 2 cos2 (π θ ) −2e−iχ cos(π θ ) sin(π θ )
=
0 1 −2e−iχ cos(π θ ) sin(π θ ) 1 − 2 sin2 (π θ )
 
−1 0 − cos(2π θ ) −e−iχ sin(2π θ )
=
0 1 −eiχ sin(2π θ ) cos(2π θ )
−iχ

cos(2π θ ) e sin(2π θ )
=
−eiχ sin(2π θ ) cos(2π θ )
  
⊥ 1 0
where we have represented {|η, |η } as , , respectively, so that
0 1

cos(π θ )
V |η = iχ
e sin(π θ )

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

|ψ±  = a± |η + b± V |η


14.6 Amplitude Amplification 231

with
   
a± 4α 2 − 1 2α a± a
M = = e±i2πθ ± (14.23)
b± −2α −1 b± b±

Using Eq. 14.23, the eigenvectors are the following

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.

14.6 Amplitude Amplification

The n-qubit |η has the following eigenfunction expansion

|η = β+ |ψ+  + β− |ψ− 

Consider a m-qubit state |y and the n + 1-qubit |η; the input tensor m-qubit ⊗
n + 1-qubit state is given by
|y|η

where recall from Eq. 14.7 that

2
n
−1   
|η = a(x)|x 1 − ν(x)|0 + ν(x)|1 : η|η = 1
x=0

Extend the definition of Q to Qc such that it has a conditional application, which


depends on the m-qubit state |y, and is given by
 
Qc = I2m ⊗ Q ⇒ Qc |y|ψ = |yQ y |ψ

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

The inverse Fourier transform on the |y qubits is given by

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

Hence, from Eq. 14.25

|
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

β± (x) = exp{−2πi(x/2m ∓ θ )y}β±


2m y=0

Note that from Eq. 2.2 x is given by

x = xm 20 + xm−1 21 + xm−2 22 · · · + xi 2i + · · · + x1 2m−1 : 0 ≤ x ≤ 2m − 1

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

β+ (x) = exp{−2πi(x/2m − θm − δ)y}β+


2m y=0

Note
2 −1
1 
m

exp{−2πi(x/2m − θm )y}  δx−2m θm + O(δ/2m )


2m y=0

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δ

Note that, from Eq. 14.26

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

Fig. 14.4 Probability


distribution function for
observing basis state |x.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

On performing a generalized Born measurement of only the x qubits in Eq. 14.27,


we have

| → Measurement → |x| (x) : x = 0, 1, . . . , 2m − 1

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.

14.7 Call Option

The price of a European call option is given by [9]

+∞
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

The random variable x is discretized into 2n points with

x j = −x0 + jx ; x = 2xmax /(2n − 1) ; j = 0, 1, . . . , 2n − 1

The discrete probabilities are given by the following

2−1 n
1
p(x) → p j = p(x j ) ; c = p(x j )
c j=0

The discretized probability distribution is shown in Fig. 14.5.


The payoff function

τ σ x+x0 +τ (r − 21 σ 2 )
ν(x) = e −K
+

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

Equation 14.6 is specialized to

2
n
−1

A|0⊗n = p j | j (14.30)
j=0

The input qubit state, as in the general case, is prepared to yield

2
n
−1
√   
|η = p j | j 1 − ν̃ j |0 + ν̃ j |1 : η|η = 1 (14.31)
j=0

The option price, as in the general case, is given by

  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

Intuitively, for classical probabilistic models, the probability of success increases,


roughly, by a constant on each iteration; by contrast, amplitude amplification roughly
increases the amplitude of success by a constant on each iteration. Because ampli-
tudes correspond to square roots of probabilities,
√ it suffices to repeat the amplitude
amplification process approximately N times to achieve the same accuracy, with
high probability, as the classical case with N iterations.
In summary, the quantum algorithm discussed in this chapter computes the option
price more efficiently than the Monte Carlo simulations. For a simulation√ consisting
of N trials, classical Monte Carlo yields an error that falls like 1/ N , whereas in
the case of a quantum algorithm there is a quadratic improvement and the error falls
like 1/N .

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)

where x is the vector of unknown variables that need to be determined. Essentially, if


we can invert the matrix A, we want to find x = A−1 b. Solving a system of three or
four equations can be done quite easily by hand, for example with Gaussian elimina-
tion. However, when the number of linear equations is large, efficient computational
algorithms are needed, and typically such algorithms are no longer based on Gaus-
sian elimination. Most computers use algorithms based on what is technically called
Lower-Upper (LU) decomposition of the matrixA. For symmetric positive definite
matrix A, one can resort to Cholesky decomposition. For Toeplitz matrices, Levinson
recursion is used. Moreover, it often pays if we know if the matrix A is a sparse or
not.

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.

15.2 Harrow–Hassidim–Lloyd Algorithm

We first start with the quantum mechanical version of Eq. (15.1),

A|x = |b. (15.2)

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

Suppose we know how to diagonalize A, i.e., U AU † = D where D is a diagonal


matrix given by ⎛ ⎞
λ1 0 0 0
⎜ 0 λ2 0 0 ⎟
D=⎜ ⎝
⎟,
··· ⎠
0 0 0 λn

if A is an n × n square matrix and {λi } is the set of eigenvalues of A. We next


apply the quantum phase estimation algorithm, which is simply a Von Neumann
projective measurement in quantum mechanics. In particular, one could think of the
quantum phase estimation part as follows: for the matrix A, if the eigenvalues of A
are {λi } with corresponding eigenvectors {u i }, a projective measurement maps the
eigenvalues λi into the register into the state This is somewhat analogous to the Von
Neumann measurement process where

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)}

along any two axes, i.e., for example,

U = exp(iθ σx /2) exp(iησz /2) exp(iφσx /2).

Note that we have also expanded |b in the eigenvector basis.


As noted earlier, the eigenvalues of U are ei2π λ̃ j with 0 ≤ λ̃ j ≤ 1. By applying
an inverse Fourier transform, we encode λ̃ j as a binary fraction in the p qubits in the
register, i.e., assuming 2− p ≤ λ̃ j ≤ 2−1 so that the state in Eq. (15.4) becomes

n
β j |0a |λ̃ j r |u j m
j=1

using inverse quantum Fourier transform (see Chap. 8).


We then apply a conditional rotation depending on the state |λ̃ j  and rotate the
ancillary qubit to
C2 2 C
1− |0a + |1a for each λ̃ j :
λ j λ̃ j

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

followed by a reverse of the quantum phase transformation resetting the register to


⊗p
|0r :
242 15 Solving Linear Equations

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

if the measurement outcome is |1a .

15.3 Specific Example

As a specific example, we consider the case of a simple set of linear equations


   
3/8 1/8 0
A|x = |x = = |b (15.8)
1/8 3/8 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

We have chosen |b to be a computational state |1. In principle, it could be more


complicating and one needs to prepare the state. In Fig. 15.1, it is not difficult to see
that at step (A), the state of the system is
 2 2 
1 1
|state at (A) = √ √ ] |00 + exp(i2π λ̃ j )|01
2 2 j=1

+ exp(i4π λ̃ j )|10 + exp(i6π λ̃ j )|11 ⊗ |u j ,
 3 2 3
1
= √ exp(i2π λ̃ j k)|k|u j . (15.11)
2 j=1 k=0

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)

In particular for j = 1, λ̃1 = 1/2, this table becomes

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

Finally, we see that


 
1
|state at (B) = √ (|10|u 1  + |01|u 2 )
2

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

In hindsight, this is just a way to implement A−1 |b in a somewhat roundabout


way. Yet, we do not wish to compute A−1 directly. We reiterate once again that there
is no need to know the exact eigenstates of A even though we use it implicitly in the
description of the algorithm.

15.4 Why Do We Not Need the Eigenvalues?

An arbitrary input state |b can always be regarded as a superposition of eigenstates


|u i  of the matrix A. We next apply HHL algorithm to solve trivially the equation
A|x = |u for some |u ∈ {|u i }. Figure 15.4 shows a schematic diagram of the
protocol acting on an eigenstate.
246 15 Solving Linear Equations

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

which is the desired output state.

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

15.5 Other Applications

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

16.1 Why Bother?

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.

16.2 Variational Quantum Eigensolvers

The variational quantum eigensolver (VQE) is a hybrid classical-quantum algorithm


that determines the ground state energy of a Hamiltonian [5]. The quantum computer
determines the expectation value of the energy. This is typically computed by a
quantum algorithm. The minimization of the energy is however performed with a
classical optimization algorithm.
In VQE, we would like to find the minimum value of the expectation of a Hermitian
matrix, H , given by

© 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

ψ(θ )|H |ψ(θ )


V = (16.1)
ψ(θ )|ψ(θ )

where |ψ(θ ) is an unknown eigenstate of H (not necessarily normalized). If H is


the Hamiltonian of a quantum system, |ψ(θ ) and V are the ground state and the
ground state energy respectively.
Here, we consider the case where we are interested in determining the lowest
energy state (ground state) of a system Hamiltonian H . The ground state energy
satisfies
H |G S  = E G S |G S .

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

of problems (typically called languages in computational theory) where a compu-


tationally hard problem can be verified by an untrusted Merlin who can convince
with high probability a verifier (Arthur), who has access only to polynomial-time
computation.
In the original formulation [5], we first write the Hamiltonian for N qubits into
the form  
H= h α Pα = h α ⊗ Nj=1 σαj j (16.2)
i α

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

({θi })| ⊗ Nj=1 σαj j |({θi })

.
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

16.3 Quantum Approximate Optimization Algorithm

The Quantum Approximate Optimization Algorithm (QAOA) is a canonical NISQ


era algorithm that can provide approximate solutions in polynomial time for com-
binatorial optimization problems. Proposed originally by Farhi et al. [7], QAOA is
regarded as a special case of VQE. It is also related to the quantum adiabatic algorithm
[8, 9].
The cost function Ĉ depends on the bit strings that form the computational basis.
The latter is designed to encode a combinatorial problem in those strings. Using the
computational basis vectors,

|ei  = {|00 · · · 00, |00 · · · 01 · · · |11 · · · 11},

one can define the problem Hamiltonian H P as


n
HP ≡ C(ei )|ei , (16.3)
i=1

and the mixing Hamiltonian HM as


n
HM ≡ σ̂xi , (16.4)
i=1

The initial state in the QAOA algorithm is chosen to be an uniform superposition


state
2n −1
⊗n ⊗n 1 
|+n  = H |0 = √ |i (16.5)
2n i=0

The final quantum state is given by applying H P and HM alternately on the initial
state p-times:

|(γ , β) ≡ e−iβ p HM e−iγ p HP · · · e−iβ1 HM e−iγ1 HP |D. (16.6)

A quantum computer evaluates the objective function

Ĉ(γ , β) ≡ (γ , β)|H P (γ , β)|(γ , β), (16.7)


 
and a classical optimizer updates the 2 p angles γ ≡ γ1 , γ2 , · · · , γ p and β ≡
 
β1 , β2 , · · · , β p until the objective function Ĉ is maximized, i.e., Ĉ(γ ∗ , β ∗ ) ≡
maxγ ,β Ĉ(γ , β). Here, p is often referred to as the QAOA level or depth. Since the
maximization at level p − 1 is a constrained version of the maximization at level p,
the performance of the algorithm improves monotonically with p.
16.4 MaxCut Problem 253

16.4 MaxCut Problem

To illustrate QAOA, we apply the algorithm to the MaxCut problem. Consider a


graph with four edges (m vertices) and four vertices (n) as shown in Fig. 16.3a. The
problem is to partition the four vertices into two sets A and B which will maximize
the (cost) function
 n
C(z) = Cα (z) (16.8)
α=1

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.

Fig. 16.3 a An example of a


graph with four vertices and
four edges: in the MaxCut
Problem, one wishes to
partition the vertices into two
distinct sets A and B. One
such solution is given in b.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved
254 16 Quantum-Classical Hybrid Algorithms

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,

|γ , β = U B p UC p U B p−1 UC p−1 · · · U B1 UC1

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

on quantum circuit as shown in Fig. 16.4a, b. The single-qubit operation e−iβk σ j is


z

straightforward. It is just a rotation matrix along the Pauli-x axis. For the two-qubit
gate, we see that

e−iγk (1−σm σn )/2 = CNOTmn · e+iγk σm /2 · CNOTmn .


z z z
(16.11)

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

CNOTmn · e+iγk σn /2 · CNOTmn


z

 
= |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

= |0m m 0| ⊗ e+iγk σn /2 + |1m m 1| ⊗ e−iγk σn /2 ,


z z
(16.12)

where we have used σ x e A σ x = eσ


x
Aσ x
and σx σ z σ x = −σ z . But now we need to
know a small trick,

|0m m 0| + |1m m 1| = I


|0m m 0| − |1m m 1| = σmz , (16.13)

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

CNOTmn · e+iγk σn /2 · CNOTmn


z

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

= eiγk /2 e−iγk (I −σm ⊗σn )/2 ,


z z
(16.14)

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

Fig. 16.5 Evolution of the


state |+4  to the desired state
on the plane spanned by the
two optimal solutions.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

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

Fault-tolerant quantum computation essentially relies on quantum error-correcting


codes. By repeated measurements of the error syndromes and the application of
the corresponding correction operations, encoded states can be stored reliably for
extended periods of time The field of quantum error correction is motivated almost
entirely from classical error correction [1–4]. In classical error correction, coding
essentially relies on extensive data copying. The design of many error-correcting
codes depends on the concept of adding redundancy. However, this is not exactly
possible in quantum theory since it is easily shown that it is impossible to copy an
unknown state [5], see also Chap. 7 Sect. 4.7 and any measurement on a quantum
state destroys the state itself.

17.2 Simple Quantum Errors

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 general, X acts on an arbitrary qubit α|0 + β|1 = |ψ:

X |ψ = α|1 + β|0 (17.2)

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)

A phase-flip error is described by the Pauli Z operator. The operator Z acts on an


arbitrary qubit α|0 + β|1 = |ψ:

Z |ψ = α|0 − β|1. (17.4)

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 .

17.3 Kraus Operators

In introductory quantum mechanics, one typically considers quantum states and


its evolution within a closed system, i.e., the system is sufficiently isolated from its
surrounding. In quantum information, one needs to be concerned not just with closed
system, but also systems that interact with the environment. So suppose we prepare
a system with state |ψ = α|0 + β|1. And the environment at time t = 0 is some
pure state |ξ .
After a finite interval of time, let us assume that the quantum system undergoes a
bit flip or a phase flip or both. Let the probabilities associated with these operations,
X , Y and Z be p1 , p2 and p3 respectively.
The state of the system after this interval is described by:
√ √ √
|ψ|ξ  → p1 (X |ψ) |ξ1  + p2 (Y |ψ) |ξ2  + p3 (Z |ψ) |ξ3  +

1 − p1 − p2 − p3 (I |ψ) |ξ4 . (17.5)

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

ρ → p1 X |ψX + p2 Y |ψY p3 Z |ψZ


(1 − p1 − p2 − p3 )|ψ, (17.6)

which we can rewrite as



4
ρ→ K i ρ K i† (17.7)
i=1

√ √
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

17.4 Nine-qubit Code

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:

α|0̄ + β|1̄ (17.11)


260 17 Quantum Error Correction

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,

|010 ± |101 → |000 ± |111. (17.12)

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)

The first operation provides information on an bit-flip error on qubit 1 or 2, while


the second operation tells us that a bit-flip occurs on qubit 2 or 3. It is now a bit
of simple detective work: the two pieces of information tells us precisely where the
error occurs. We then repeat the procedure for the other two sets of three qubits. Note
that it is important that we do not collapse the superposition used in the code. To do
this, we attached an ancillary qubit and perform the controlled-Z operations to the
first and second qubit as follows:
 
(|0 + |1) αi jk |i jk → αi jk (|0|i jk + (−1)i⊕ j |1|i jk)
i jk i jk
  
= ci jk |0 + (−1)parity(i, j) |1)|i jk,
i jk
 
= |0 + (−1)parity(i, j) |1) ci jk |i jk
i jk

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.

17.5 General Properties of Quantum Error-Correcting


Codes

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:

0̄|E 1† E 2 |1̄ = 0. (17.16)

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 :

0̄|E 1† E 2 |0̄ = 1̄|E 1† E 2 |1̄ = 0 (17.17)

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

0̄|F1† F2 |0̄ = 1̄|F1† F2 |1̄ = 0 (17.18)

There is an additional requirement that the errors can be inverted:

0̄|E i† E i |0̄ = 1̄|E i† E i |1̄ (17.19)

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)

where |k L  = |0 L or |1 L for k = i, j.

17.6 Classical Linear Codes

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

where αi ∈ {0, 1} and addition is just modulo 2.


The k basis vectors may be assembled into a k × n matrix:


v1
⎜ v2 ⎟
G=⎜ ⎟
⎝···⎠. (17.28)
vk

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)

where G T is the transpose of matrix G.


For a classical bit, the only kind of error is a bit flip. A string v under a bit-flip
error e is expressed as:
v → v + e. (17.31)
264 17 Quantum Error Correction

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

Errors can be detected by applying the parity check matrix:

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)

For any two errors e1 = e2 , if H e1 = H e2 , we may mistake e1 error as e2 error, then


our attempt at recovery will yield a damaged code:

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

17.7 An Example of a Linear Code: Hamming Code

We digress a little here to discuss an example of a linear code: a Hamming Code


with seven bits. Hamming codes are codes that can correct a single error. A good
reference is Ref. [10]. As an example, let us consider the following four-bit codes
(x1 , x2 , x3 , x4 ), augmented by a three-bit parity check ( p1 , p2 , p3 ):

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

where the three check bits are given by

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

Another way to describe the [7, 4, 3] code is


⎛ ⎞ ⎛ ⎞
x1 1 0 00
⎜ x2 ⎟ ⎜ 0 1 0 0⎟ ⎛ ⎞
⎜ ⎟ ⎜ ⎟ x1
⎜ x3 ⎟ ⎜ 0 0 1 0⎟
⎜ ⎟ ⎜ ⎟ ⎜ x2 ⎟
⎜ x4 ⎟ = ⎜ 0 0 0 1⎟ ⎜ ⎟ (17.39)
⎜ ⎟ ⎜ ⎟ ⎝ x3 ⎠
⎜ p1 ⎟ ⎜ 1 1 ⎟
1 0⎟
⎜ ⎟ ⎜ x4
⎝ p2 ⎠ ⎝ 0 1 1 1⎠
p3 1 1 01

which follows from Eqs. (17.36)–(17.38).


When the transmitted message arrives at the intended recipient, the recipient
subjects the received message (x1 , x2 , x3 , x4 , p1 , p2 , p3 ) to a decoder by computing

s1 = p1 ⊕ x1 ⊕ x2 ⊕ x3 , (17.40)


s2 = p2 ⊕ x2 ⊕ x3 ⊕ x4 , (17.41)
s3 = p3 ⊕ x1 ⊕ x2 ⊕ x4 . (17.42)

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

Note that the syndrome is determined by another matrix multiplication on the


received message:
⎛ ⎞
x1
⎜ x ⎟
⎛ ⎞ ⎛ ⎞ ⎜ 2 ⎟
s1 1110100 ⎜ ⎜ x3 ⎟

⎝ s2 ⎠ = ⎝ 0 1 1 1 0 1 0 ⎠ ⎜ x4 ⎟ (17.43)
⎜ ⎟
s3 1101000 ⎜ p
⎜ 1 ⎟

⎝ p2 ⎠
p3
17.8 Quantum Linear Codes: CSS Codes 267

17.8 Quantum Linear Codes: CSS Codes

Finally we conclude with a short description of a family of quantum error-correcting


linear codes known as the Calderbank-Shor-Steane (or CSS) codes.
Suppose C1 be a classical linear code with (n − k1 ) × n parity check matrix H1
and C2 is a subcode of C1 with (n − k2 ) × n parity check matrix H2 , where k2 < k1 .
The first (n − k2 ) rows of H2 are the same as the rows of H1 but there are still
(k1 − k2 ) rows in H1 that are linearly independent in C1 but not in C2 . The subcode
C2 then defines an equivalence relation in C1 . For any u 1 , U2 ∈ C1 , we say that u 1
and u 2 are equivalent (u 1 ≡ u 2 ) if then there exist a ũ ∈ C2 such that u 1 = u 2 + ũ.
The equivalence classes form the cosets of C2 in C1 .
The Calderbank-Shor-Steane (CSS) code is a family of linear codes [2r − 1, 2r −
1 − 2r, 3] for r ≥ 3 that makes full use of classical theory of linear (Hamming) codes
to correct bit-flip errors (X errors) and the dual code to correct phase-flip errors (Z
errors) [11, 12]. Steane investigates the case of r = 3 corresponding to [7, 1, 3] in
his 1996 paper.
The parity check matrix for the [7, 4, 3] classical code is
⎛ ⎞
1010101
H = ⎝0 1 1 0 0 1 1⎠ (17.44)
0001111

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

If a set of quantum gates is sufficient to construct any arbitrary quantum circuit, we


say that this set is universal for quantum computing. An important universal set of
quantum gates is composed by the controlled-NOT gate and arbitrary single-qubit
quantum gates. It is also interesting to note that in this model, most computations
proceed with unitary, and therefore reversible, evolutions until measurements are
made.
As we have seen in earlier chapters, in circuit model, a typical circuit diagram
given in Fig. 18.1 comprises of the inputs, and time flows from the left to the right.
In this specific example, there are a total of three qubits as inputs. The left end of
the circuit shows the initial state of the qubits, which is |ψ ⊗ |0 ⊗ |0, where |ψ
is a single-qubit state.
 The very right side gives the final
 state of the qubits, which is
Z |m 1  ⊗ H |m 2  ⊗ ψ  , where m 1 , m 2 ∈ {0, 1} and ψ  is some single-qubit state
whose actual value depends on |ψ and θ . Each quantum gate in Fig. 18.1 is explained
in Fig. 18.2.

© 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 order to design and build efficient quantum circuits, it is useful to exploit


special features of quantum systems that will optimize the performance. It is believed
that entanglement, as one of the main pillars of quantum information, provides an
important key for the speedup of quantum algorithms overs their classical analogs
[1, 2]. It is also likely that efficient quantum algorithms require a minimal amount
of the entanglement, and otherwise the quantum algorithm should be simulable with
classical computers. The inputs to a typical quantum circuit usually take the form
|0 ⊗ |0 · · · ⊗ |0, which can be written concisely as |00 · · · 0. Such inputs are not
entangled. Thus, the entanglement needed for the computation must be generated
within the circuit. This means that some quantum gates used in the quantum circuit
model should be capable of generating entanglement for quantum circuits. These
gates are called quantum entangling gates. One important example is the controlled-
NOT gate, which we have just mentioned earlier.
The realization of quantum circuits in various physical systems has been exten-
sively studied. These approaches include implementation through nuclear magnetic
resonance (NMR) [3], the manipulations of atoms or ions in ion traps [4], the
manipulation of neutral atom [5], implementation with cavity QED [6], the optical
platform with linear or nonlinear optical devices [7], manipulation of electrons or
atoms in the solid state [8], superconducting devices [9], and a ‘unique’ approach to
quantum information proposed in the quantum information roadmap [10]. Regard-
less of the approach to the realization of large-scale quantum computing, DiVincenzo
has elegantly summarized five important criteria for the physical implementation of
future quantum computers [11], and each one of these criteria has been carefully
examined [4–11]. These criteria are:
• A scalable physical system equipped with well-characterized qubit;
• An ability to initialize the state of the qubits to a simple fiducial state;
• Long relevant decoherence times;
18.1 Measurement-Based Quantum Computation 271

• A ‘universal’ set of quantum gates; and


• A capability to perform relevant measurement.
To date, none of these systems is fully capable of realizing a large-scale fully pro-
grammable quantum computer in the foreseeable future without any glitches: each
system presents its own unique set of challenges and problems, including noises. One
important stumbling block in many of these systems is that all quantum entangling
gates cannot be implemented with high fidelity [12]. Thus, it is desirable to reduce
the number of quantum entangling gates needed for quantum computation to the bare
minimum.
To overcome some of these limitations, researchers have actively sought other
paradigms of quantum computation. Although these alternative paradigms are equiv-
alent to the quantum circuit model in terms of computational power, they are very
different in terms of real physical realization. Among these alternative paradigms,
some of more promising ones are measurement-based quantum computing [13],
topological quantum computing [14] and adiabatic quantum computing [15]. In this
chapter, we focus on the measurement-based quantum computing (MBQC) model
as introduced by Raussendorf and Briegel in 2001 [13]. In MBQC, we start with
highly entangled states and only single-qubit measurements are performed to realize
the quantum algorithms. These measurements ‘collapse’ the wave functions of the
initially highly entangled resource, and the scheme is therefore no longer reversible.

18.1 Measurement-Based Quantum Computation

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

Fig. 18.3 Measurement-


based quantum computing.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

Fig. 18.4 Honeycomb


lattice. Published with
permission of © Belal E.
Baaquie and L. C. Kwek. All
Rights Reserved

18.2 The Cluster State

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

• First, we initialize the three qubits as ψ1 = |0 ⊗ |0 ⊗ |0.


• Next, we apply Hadamard to each qubit so that we get

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

Fig. 18.6 An arbitrary


five-qubit graph state.
Published with permission of
© Belal E. Baaquie and L. C.
Kwek. All Rights Reserved

X |0 = |1 , X |+ = |+ ,


X |1 = |0 , X |− = − |− ,
Z |0 = |0 , Z |+ = |− ,
Z |1 = − |1 , Z |− = |+

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,

Xj Z k |C  = |C  (18.2)


k∈nb( j)
18.3 Simulation of Basic Quantum Gates 275

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)

|C  = S23 S12 H1 H2 H3 |000 , (18.3)

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)

To show this, observe the following identities:

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.

18.3 Simulation of Basic Quantum Gates

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

In this case, we have


X m H Z θ |ψ

depending on the outcome m of the first qubit.


We are now ready to show that any arbitrary single-qubit gate can be performed
on a quantum state. To do so, we simply concatenate the ‘generalized’ teleportation
circuit in Fig. 18.7b as in Fig. 18.8.
18.3 Simulation of Basic Quantum Gates 277

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

In Fig. 18.8, the output states in the concatenated circuit are



φoutput = X m3 H Z ζ X m2 H Z η X m1 H Z θ |ψ . (18.8)

We then note that X Z = −Z X and H X = Z H to get



φoutput = X m3 H Z ζ X m2 H Z η X m1 H Z θ |ψ
= (−1)m2 X m3 Z m2 H Z ζ H Z η X m1 H Z θ |ψ
= (−1)m2 (−1)m1 X m3 Z m2 X m1 H Z ζ H Z η H Z θ |ψ
= (−1)m2 (−1)m1 X m3 Z m2 X m1 X ζ H H Z η X θ H |ψ
= (−1)m1+m2 X m3 Z m2 X m1 X ζ Z η X θ H |ψ (18.9)

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)

We then perform measurements on qubit 1 and qubit 2 in the X basis. Suppose we


get | + + = |+1 ⊗ |+2 . We see that the state of qubit 3 and 4 becomes

αα  |00 + αβ  |11 + βα  |10 + ββ  |01


= α  (α|0 + β|1)3 |04 + β  (α|1 + β|0)3 |14 (18.12)

Clearly, this is a CNOT gate acting the original separable state

(α|0 + β|1)3 ⊗ (α  |0 + β  |1)4

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

αα  |10 + αβ  |01 + βα  |00 + ββ  |11


= (X ⊗ X ) CNOT43 (X ⊗ X ) (α|0 + β|1)3 (α  |0 + β  |1)4 (18.13)

For the outcome | − +12 , qubits 3 and 4 become

αα  |00 + αβ  |11 − βα  |10 − ββ  |01


= (Z ⊗ Z ) CNOT43 (α|0 + β|1)3 (α  |0 + β  |1)4 , (18.14)
18.4 Resource States for MBQC 279

Finally, for the outcome | − −12 , qubits 3 and 4 become

αα  |10 + αβ  |01 − βα  |00 − ββ  |11


= − (Z ⊗ Z ) CNOT43 (X ⊗ I d) (α|0 + β|1)3 (α  |0 + β  |1)4 . (18.15)

So regardless of the measurement outcome, we see that we have performed a


controlled-NOT operation on qubit 3 and qubit 4 with the latter (qubit 4) as the
control bit.

18.4 Resource States for MBQC

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

To understand why the workings of a quantum computer is radically different from a


classical computer—a difference that makes it far more powerful than any possible
classical computer—some of the results obtained are summarized.

19.1 Quantum Algorithms

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

1 2100 is more than the atoms in the Universe.


19.1 Quantum Algorithms 287

G|φ = G|ξ  + G|η

and which is only possible due to quantum superposition.


Repeated applications of G on all the n-qubits bit is possible only if the interme-
diate states are not measured: if any measurement is performed before the final
output state is ready, the quantum superposition would be destroyed. The repeated
application of G allows for the amplification of the amplitude of the sought for
qubit |ξ .
• The Shor algorithm. This algorithm uses the subtle properties of quantum mea-
surement and entangled states to pick out the numerical value of A, which is
required for factorization into primes. From Eq. 13.4, we have the superposed and
entangled state given by

r −1 A−1

1  
|ψ f  = √ |xi + kr  ⊗ | f (xi ) (19.3)
Q i=0 k=0

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

|ψ f  → Measurement → |ψ3 (x0 )| f (x0 ) (19.4)

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

Equation 19.3 is the quantum superposition of entangled states of a large number


of qubits (Q > N 2 ). It is this quantum superposition and entanglement that lies
at the root of the exponential speeding up of the Shor algorithm compared to any
classical algorithm. Furthermore, as shown by the Shor algorithm, quantum theory
of measurement plays a key role in all quantum algorithms.

19.2 Memory and Speed of Quantum Computations

Memory of a computer, which depends on the amount of information that can be


stored in the computer, is one factor in the speed of an algorithm. The other factor is
how fast are the computer circuits updated. In 2022, the largest memory of a classical
computer was 1024 × 1015 bytes, where one byte is eight bits. For an algorithm using
n-bits, the classical algorithm requires a memory of 2n bits, as discussed in Sect. 4.12,
and all the 2n bits for a classical computer have to be updated individually—whether
it be sequential or in parallel. The world’s fastest supercomputer, as of June 2021, was
Japan’s Fugaku at a speed of 442 petaflops, where one petaflop is 1015 floating-point
operations2 per second.
The quantum computer has the following three advantages over a classical com-
puter that are a consequence of quantum superposition, entanglement, and quantum
measurement theory. The are the following three sources of the great speed of quan-
tum computations.
• The storage for memory of a quantum computer is not 2n bits but n-bits due to
quantum superposition and is discussed in Sect. 4.12.
• A classical algorithm has only one register (computational basis state) at every
stage of the calculation, whereas the quantum algorithm has a superposition of
many qubits, which in particular can be elements of the computational basis states.
• Born’s theory of quantum measurement, discussed in detail in Sect. 4.5, is the key
element that separates classical from quantum superposition. Quantum measure-
ment causes the projection of one of the component states from a superposed state
in Hilbert space to the observed state in the experimental apparatus. This is one of
the reasons why quantum parallelism is possible.
• The updating of the quantum system evolves the entire state vector. In particular, it
does not involve the updating of the individual components in its representation by
a superposition in terms of the qubits (such as the 2n computational basis states).
See Sect. 4.12 and Eq. 4.42.
• The quantum superposition of many qubits as well as the simultaneous updating
of all the superposed states are two sources of quantum parallelism: this greatly
decreases the memory required and increases the speed of quantum algorithms in
comparison with the classical case.

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

The points above are discussed in some detail below.


1. As mentioned earlier, it is misleading to think that the quantum computer is
simultaneously evaluating f for all possible value of the degree of freedom in
Eqs. 19.1 and 19.2: to obtain this information about f in the laboratory, we need to
make many measurements. However, it is also true is that the quantum algorithm
employs the values of f for every x in the superposed state. For example, in the
Deutsch–Jozsa algorithm in Eq. 19.1 and the Grover algorithm in Eq. 19.2 f (x)
for all values of x are simultaneously employed in obtaining the output qubit
(state vector). What is remarkable is that even with without knowing the value of
f (x) in the laboratory, the quantum algorithm can use this information. This is
because the value of f for every x exists in Hilbert space.
2. The allowed states for the n-qubits are all elements of Hilbert space, which is
S 2 ⊗ · · · ⊗ S 2 . The information and memory of a quantum computer is stored
in Hilbert space, in the form of state vectors. All the steps in the execution of
the quantum algorithm take place in Hilbert space. Quantum superposition and
entanglement—which are the key features of a quantum computer that makes it
superior to a classical computer—are both properties of state vectors that exist in
Hilbert space. A more detailed discussion of this point is given in Sect. 19.3.
For a quantum computer, all the n qubits—when they are in a superposed state—
evolve simultaneously in Hilbert space. To understand quantum algorithms, one
needs to locate the arena of quantum computations and quantum algorithms in
Hilbert space. This point is discussed more elaborately in the following Sect. 19.3.
3. We review the results discussed in Sect. 4.12. A major resource of the quantum
computer is the way information is stored. A classical computer has to physi-
cally store the value of every bit. For n binary degrees of freedom, the number of
allowed configurations of a classical computer is 2n : the memory required for the
all possible configurations of the degrees of freedom is 2n deterministic bits.
A classical computer carrying out computations with n binary bits needs a physical
memory device with 2n units of memory. For large n, the physical memory device
needed becomes huge. In contrast, the quantum computer needs only n-qubits,
even though all the 2n configurations for the degrees of freedom are employed in
the quantum algorithm.
The reason that the quantum computer needs only n-qubits is because, as men-
tioned earlier, only the initial and output states of the quantum computation are
observable: the execution of the quantum algorithm takes place in Hilbert space.
For example, for a n-qubit calculation, one needs to record, for example, only the
following two computational basis states:

|input = |00110011 . . . 11001; |output = |10100001 . . . 1100

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].

19.3 Where Does Quantum Computation Take Place?

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

{000, 001, 010, 011, 100, 101, 110, 111}


19.3 Where Does Quantum Computation Take Place? 291

The input and output for both the classical and quantum computation is a determinate
3-bits string, which could, for example, be

Input : 011; Output : 100

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

Quantum computing represents a paradigm shift in theoretical computer science.


Since all classical algorithms can run on a quantum computer, classical algorithms
are a special case of quantum algorithms. Information science can now be seen as
an application of the underlying principles of quantum mechanics.
As our discussion on quantum mechanics shows, quantum computations provide
an example, in the setting of information science, that once again brings out the
mysteries, paradoxes and conundrums of quantum mechanics.
Quantum superposition plays a major role in the efficiency of a quantum computer
and quantum entanglement has played a minor role. Entanglement usually came into
play when the input state is subjected to the oracle’s unitary transformation—and
which results in the input state becoming entangled with its ancillary qubit. The
ancillary qubits are sometimes used to store the computation’s output. At present,
most quantum computers do not rely on quantum entanglement, which is currently
used for error corrections and in building hardware. Moreover, one needs to prove
that, even without error corrections, the quantum algorithms yield an improvement
over classical computations.
Both software and hardware need to be developed for quantum computing to
make progress. For programmers, the ‘hardware description language’ using gates
and circuits is cumbersome and error prone and requires that each and every step
be clearly defined in terms of quantum gates to implement a quantum algorithm.

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

A Density matrix, 116


Algorithms bipartite, 121
quantum, 114, 139, 161, 173, 179, 185, mixed, 117, 128
203, 209, 221, 240, 249, 285 pure, 116, 128
reduced, 119
thermal, 129
B
two state, 118
Baaquie
Destructive interference, 93, 182
quantum mechanics, 93
Deutsch algorithm, 173, 175
Baaquie interview, 4
Bell states, 136 balanced function, 173, 177
Binary Born measurement, 177
addition, 16 catalyst, 176
numbers, 13 constant function, 173
Bit flip, 257 Deutsch-Josza algorithm, 179
Born measurement, 85 Deutsch-Jozsa, 178, 179
Born rule, 85 balanced, 182
generalized, 96 constant, 182
interference, 183
Dirac
C notation, 28
Cluster state, 272 DiVincenzo, 270
Cold atoms, 280
Computational complexity, 250
Constructive interference, 182
Copenhagen interpretation E
measurements, 85, 95
Entangled state, 121
open questions, 92
bipartite system, 123
quantum mechanics, 71
composite system, 123
summary, 94
maximal, 126
pair of spins, 124
D Schmidt decomposition, 122
Decoherence, 93 two spins, 127
Degree of freedom, 72 Entanglement, 107
measurement, 90 Error syndromes, 257, 264

© 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

F Linear codes, 262, 265


Fault tolerant, 257
Feynman, 108
Fourier transform M
quantum, 162 Matrices
N × N , 23
addition, 21
G outer product, 24
Generalized Born measurement, 96 tensor product, 24
Shor, 213 transpose, 23
Generalized Born rule Measurement, 90
consistency, 100 Born rule, 85
Graph, 253 degree of freedom, 90
Grover algorithm gates, 87
generalized, 198 generalized Born rule, 96
n-qubits, 192 irreversible, 85
two-qubits, 190, 199 Measurement-based quantum computing,
Grover diffusion gate, 193 271
Grover recursion equation, 196 arbitrary single-qubit gate, 276
Grover’s algorithm, 185 cluster states, 272
amplication, 187 large scale photonic, 280
applications, 185 no-go theorem, 280
database, 185 Two-qubit gate, 277
diffusion, 189 Monte Carlo, 221, 222, 225
inverse function, 188
knowing and recognizing, 185
phase inversion, 187, 192 N
reflection, 190 NISQ, 249
steps, 186 No-Cloning Theorem, 91
Noisy, 249
Nondeterministic, 250
H Number
Hamiltonian, 82, 83 cycle length, 210
Hamming distance, 262 Shor, 211
Hermitian matrix, 80
Hilbert space, 20, 74, 78, 261
discrete, 78 O
measurements, 292 One-way quantum computer, 269
spacetime, 291 Operators
Hybrid algorithm, 249 Hermitian, 79
cost function, 252 Optimization, 249, 255
MaxCut problem, 253 Option price, 221
QAOA, 252 quadratic improvement, 225
variational quantum eigensolver, 249 quantum algorithms, 221, 223
quantum evaluation, 236
Oracle, 174, 188, 189, 203, 292
K
Kraus operators, 258
P
Parity check, 263
L Phase estimation, 156
Linear n = 3, 158
vector space Phase flip, 258
complex, 18 Prime factorization
Index 297

classical algorithm, 210 properties, 84


quantum algorithm, 210 Separable system, 120
Shor
generalized Born measurement, 213
Q Shor’s algorithm, 185, 209
Quantum algorithms, 285 cycle, 212
Quantum computation Fourier transform, 213
memory, 288 Simon’s algorithm, 203
speed, 288 example, 205
location, 290 Solving linear equations, 239
Quantum computer applications, 247
efficiency, 285 Atanasoff-Berry, 239
Quantum entropy, 125 Cholesky, 239
maximum, 126 condition numbers, 240
Quantum error correction, 257 Gaussian elimination, 239
Calderbank-Shor-Steane codes, 267 HHL algorithm, 240
general properties, 261 Levinson, 239
Hamming code, 267 Nine chapters, 239
Nine-qubit code, 259 phase estimation, 241
parity check, 267 sparsity, 240
Quantum Fourier transform, 162 Superposition, 107
Quantum mechanics quantum interference, 108
measurement, 95
principles, 71
summary, 91
T
superstructure, 94
Teleportation, 277
Quantum Merlin-Arthur, 250
Tensor product
Quantum superposition, 108
partial trace, 115
Qubit
state space, 80
quantum mechanics, 132
single, 133 Two slit experiment, 108
with detectors, 111
without detectors, 112
R
Reversible, 269
RSA cryptography, 209 V
Vector
addition, 17
S scalar multiplication, 18
Scalar, 18 space
Schrödinger equation, 82 complex, 18

You might also like