arXiv:1907.09415v5 [quant-ph] 16 Jan 2023

Quantum Computing:
Lecture Notes

Ronald de Wolf
QuSoft, CWI and University of Amsterdam

Dedicated to the memory of my father
Abraham de Wolf (1942–2019)ii

Preface from 2011
These lecture notes were formed in small chunks during my “Quantum computing” course at the
University of Amsterdam, Feb-May 2011, and compiled into one text thereafter. Each chapter
was covered in a lecture of 2 × 45 minutes, with an additional 45-minute lecture for exercises andhomework. The first half of the course (Chapters 1–7) covers quantum algorithms, the second halfcovers quantum complexity (Chapters 8–9), stuff involving Alice and Bob (Chapters 10–13), anderror-correction (Chapter 14). A 15th lecture about physical implementations and general outlook
was more sketchy, and I didn’t write lecture notes for it.
These chapters may also be read as a general introduction to the area of quantum computationand information from the perspective of a theoretical computer scientist. While I made an effort
to make the text self-contained and consistent, it may still be somewhat rough around the edges; I
hope to continue polishing and adding to it. Comments & constructive criticism are very welcome,and can be sent to rdewolf@cwi.nl
Those who want to read more (much more. . . ): see the book by Nielsen and Chuang [196] forthe general area, the book of John Watrous [247] for quantum information theory, and the lecturenotes of John Preskill [200] for the theoretical physics perspective.

Attribution, acknowledgments, subsequent updates
Most of the material in Chapters 1–6 [chapter numbers in this paragraph are for the 2011 version]
comes from the first chapter of my PhD thesis [248], with a number of additions: the lower bound forSimon, the Fourier transform, the geometric explanation of Grover. Chapter 7 is newly written forthese notes, inspired by Santha’s survey [216]. Chapters 8 and 9 are largely new as well. Section 3of Chapter 8, and most of Chapter 10 are taken (with many changes) from my “quantum proofs”
survey paper with Andy Drucker [100]. Chapters 11 and 12 are partly taken from my non-locality
survey with Harry Buhrman, Richard Cleve, and Serge Massar [72]. Chapters 13 and 14 are new.
Thanks to Giannicola Scarpa (the teaching assistant for the first two editions of this course) for
useful comments on some of the chapters.
January’13 : Updated and corrected a few things for the Feb-Mar 2013 version of this course, andincluded exercises for each chapter. Thanks to Harry Buhrman, Florian Speelman, and Jeroen
Zuiddam for spotting some typos in the earlier version.
April’13 : More updates, clarifications and corrections; moved some material from Chapter 2 to 1;changed and added some exercises. Thanks to Jouke Witteveen for useful comments.
April’14 : Fixed and clarified a few more things. Thanks to Maarten Wegewijs for spotting a typoin Chapter 4.
March’15 : Updated a few small things.
July’15 : Updated and corrected a few small things, added more exercises. Thanks to Srinivasan
Arunachalam, Carla Groenland, and Koen Groenland for useful comments.
May’16 : A few more corrections, thanks to Ralph Bottesch for useful comments.
January’18 : Many more corrections, more exercises, a new chapter about the Hidden Subgroupiii

Problem (Chapter 6; the above-mentioned chapter numbers are for the earlier version of the notes),and moved the hints about exercises to an Appendix for students who want to try the exercises
first without hints. Thanks to Joran van Apeldoorn, Srinivasan Arunachalam, Rens Baardman,
Alexander Belov, Koen de Boer, Daniel Chernowitz, András Gilyén, Ronald de Haan, Leon Ingelse,
Stacey Jeffery, Rafael Kiesel, Jens Klooster, Sam Kuypers, Christian Nesenberend, and ChristianSchaffner for useful comments.
January’19 : More corrections, clarifications and exercises, and new chapters about Hamiltonian
simulation (Chapter 9) and the HHL algorithm (Chapter 10). These two chapters can be taught
together in two lectures, with the longer Chapter 9 spilling over into the second lecture if necessary.
I marked by ‘(H)’ the exercises having a hint in Appendix C, and removed citations from exercises to prevent students looking up the original papers when doing the exercises (which is neither
necessary nor helpful). Those references are [49, 96, 103, 67, 102, 115, 75, 37, 50, 35, 118, 86, 19].
Thanks to Arjan Cornelissen, Sven Cornets de Groot, Gerrit Vos, and Harm de Vries for usefulcomments, and to András Gilyén for much help with Chapters 9 and 10. Thanks to my father
and Mieke Beer for hosting me for two months while I was recovering from an ankle fracture in awheelchair, from which much of these two chapters was written.
July’19 : More corrections, clarifications and exercises. Thanks to Joran van Apeldoorn, András
Gilyén, Stephanie Gonzalez, Sander Gribling, Jaco ter Hoeve, Arnold Kole, Lotte Mertens, Stefano
Pironio, Merel Schalkers, Jim Skulte, Iris Smit, Manuel Van, and Sebastian Zur for useful comments. Thanks to Barbara Terhal for suggesting the possibility of dedicating these notes.
January’21 : More corrections, clarifications and exercises, and a new chapter about QMA and the
local Hamiltonian problem (Chapter 14). Thanks to Dorit Aharonov, Tomas Ehrencron, Alex Grilo,
Joris Kattemölle, Stan de Lange, Noah Linden, Tessel Majtlis, Nikhil Mande, Andrea Mazzocco,
Robert Modderman, Thomas Preu, Philip Verduyn Lunel, Baer Ververgaert, and Carel Wagenaar
for useful comments.
January’22 : More corrections, clarifications and exercises. Thanks to Simon Apers, Christiaanvan Asperen, Yanlin Chen, Lynn Engelberts, Sevag Gharibian, András Gilyén, Diego GonzálezSánchez, Bruno Jedynak, Joris Kattemölle, Julius Krebbekx, Zeph Landau, Noah Linden, Frédéric
Magniez, Ryan Mann, and Yanelle Stolwijk for useful comments.
August’22 : More corrections, clarifications and exercises, and a new chapter about some aspectsof quantum machine learning (Chapter 19). Thanks to Danish Alvi, Srinivasan Arunachalam,
Nikolaos Chatzis, Li Chen, Yanlin Chen, Iordanis Kerenidis, Mikhail Kudinov, Casper Loman,Frédéric Magniez, Galina Pass, Benjamin Shaffrey, Mario Szegedy, and Michael Walter for usefulcomments.
January’23 : More corrections and clarifications, and a new chapter about the generalized adversary bound (Chapter 12). Thanks to Srinivasan Arunachalam, Martijn Brehm, Yanlin Chen,
Lynn Engelberts, Noah Linden, Frédéric Magniez, Mehrdad Tahmasbi, Quinten Tupker, and Jordi
Weggemans for useful comments.

© Ronald de Wolf, January 2023, Amsterdamiv

Contents
1 Quantum Computing
1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Quantum mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Superposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.2 Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.3 Unitary evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Qubits and quantum memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Elementary gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Example: quantum teleportation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 The Circuit Model and the Deutsch-Jozsa Algorithm
2.1 Quantum computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1 Classical circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2 Quantum circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Universality of various sets of elementary gates . . . . . . . . . . . . . . . . . . . . .
2.3 Quantum parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 The early algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4.1 Deutsch-Jozsa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4.2 Bernstein-Vazirani . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13
13
13
14
16
16
17
18
19

3 Simon’s Algorithm
3.1 The problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 The quantum algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Classical algorithms for Simon’s problem . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.1 Upper bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.2 Lower bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23
23
23
24
24
25

4 The Fourier Transform
4.1 The classical discrete Fourier transform . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 The Fast Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Application: multiplying two polynomials . . . . . . . . . . . . . . . . . . . . . . . .
4.4 The quantum Fourier transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 An efficient quantum circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6 Application: phase estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29
29
30
31
31
32
33

v

5 Shor’s Factoring Algorithm
5.1 Factoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Reduction from factoring to period-finding . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Shor’s period-finding algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4 Continued fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37
37
37
39
41

6 Hidden Subgroup Problem
6.1 Hidden Subgroup Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.1 Group theory reminder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.2 Definition and some instances of the HSP . . . . . . . . . . . . . . . . . . . .
6.2 An efficient quantum algorithm if G is Abelian . . . . . . . . . . . . . . . . . . . . .
6.2.1 Representation theory and the quantum Fourier transform . . . . . . . . . . .
6.2.2 A general algorithm for Abelian HSP . . . . . . . . . . . . . . . . . . . . . . .
6.3 General non-Abelian HSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.1 The symmetric group and the graph isomorphism problem . . . . . . . . . .
6.3.2 Non-Abelian QFT on coset states . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.3 Query-efficient algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45
45
45
46
47
47
48
50
50
50
51

7 Grover’s Search Algorithm
7.1 The problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Grover’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Amplitude amplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.4 Application: satisfiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

53
53
53
56
58

8 Quantum Walk Algorithms
8.1 Classical random walks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Quantum walks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.1 Grover search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.2 Collision problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.3 Finding a triangle in a graph . . . . . . . . . . . . . . . . . . . . . . . . . . .

63
63
64
67
67
67
68

9 Hamiltonian Simulation
9.1 Hamiltonians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 Method 1: Lie-Suzuki-Trotter methods . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3 Method 2: Linear combination of unitaries (LCU) . . . . . . . . . . . . . . . . . . .
9.3.1 Hamiltonian simulation via LCU . . . . . . . . . . . . . . . . . . . . . . . . .
9.4 Method 3: Transforming block-encoded matrices . . . . . . . . . . . . . . . . . . . .
9.4.1 Hamiltonian simulation via transforming block-encoded matrices . . . . . . .

71
71
72
74
75
76
78

10 The HHL Algorithm10.1 The linear-system problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 The basic HHL algorithm for linear systems . . . . . . . . . . . . . . . . . . . . . . .
10.3 Improving the efficiency of the HHL algorithm . . . . . . . . . . . . . . . . . . . . .

83
83
84
85

vi

11 Quantum Query Lower Bounds
11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 The polynomial method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3 The quantum adversary method . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

89
89
90
92

12 Quantum Algorithms from the Generalized Adversary Bound99
12.1 The generalized adversary bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
12.2 The dual of the generalized adversary bound . . . . . . . . . . . . . . . . . . . . . . 101
12.3 ADV± is an upper bound on quantum query complexity . . . . . . . . . . . . . . . . 102
12.4 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
12.5 Perfect composition and AND-OR trees . . . . . . . . . . . . . . . . . . . . . . . . . 105
13 Quantum Complexity Theory107
13.1 Most functions need exponentially many gates . . . . . . . . . . . . . . . . . . . . . . 107
13.2 Classical and quantum complexity classes . . . . . . . . . . . . . . . . . . . . . . . . 108
13.3 Classically simulating quantum computers in polynomial space . . . . . . . . . . . . 110
14 QMA and the Local Hamiltonian Problem
113
14.1 Quantum Merlin-Arthur (QMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
14.2 The local Hamiltonian problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
14.3 Local Hamiltonian is QMA-complete . . . . . . . . . . . . . . . . . . . . . . . . . . 116
14.3.1 Completeness and soundness . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
14.3.2 Reducing the locality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
14.4 Other interesting problems in QMA . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
14.5 Quantum interactive proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
15 Quantum Encodings, with a Non-Quantum Application
125
15.1 Mixed states and general measurements . . . . . . . . . . . . . . . . . . . . . . . . . 125
15.2 Quantum encodings and their limits . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
15.3 Lower bounds on locally decodable codes . . . . . . . . . . . . . . . . . . . . . . . . 128
16 Quantum Communication Complexity
133
16.1 Classical communication complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
16.2 The quantum question . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
16.3 Example 1: Distributed Deutsch-Jozsa . . . . . . . . . . . . . . . . . . . . . . . . . . 135
16.4 Example 2: The Intersection problem . . . . . . . . . . . . . . . . . . . . . . . . . . 136
16.5 Example 3: The vector-in-subspace problem . . . . . . . . . . . . . . . . . . . . . . . 137
16.6 Example 4: Quantum fingerprinting . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
17 Entanglement and Non-Locality
143
17.1 Quantum non-locality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
17.2 CHSH: Clauser-Horne-Shimony-Holt . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
17.3 Magic square game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
17.4 A non-local version of distributed Deutsch-Jozsa . . . . . . . . . . . . . . . . . . . . 148
vii

18 Quantum Cryptography151
18.1 Saving cryptography from Shor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
18.2 Quantum key distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
18.3 Reduced density matrices and the Schmidt decomposition . . . . . . . . . . . . . . . 154
18.4 The impossibility of perfect bit commitment . . . . . . . . . . . . . . . . . . . . . . . 155
18.5 More quantum cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
19 Quantum Machine Learning
159
19.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
19.2 Supervised learning from quantum data . . . . . . . . . . . . . . . . . . . . . . . . . 160
19.2.1 The PAC model of learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
19.2.2 Learning from quantum examples under the uniform distribution . . . . . . . 161
19.2.3 Learning from quantum examples under all distributions . . . . . . . . . . . . 162
19.2.4 Learning quantum states from classical data . . . . . . . . . . . . . . . . . . . 163
19.3 Unsupervised learning from quantum data . . . . . . . . . . . . . . . . . . . . . . . . 163
19.4 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
19.4.1 Variational quantum algorithms . . . . . . . . . . . . . . . . . . . . . . . . . 165
19.4.2 Some provable quantum speed-ups for optimization . . . . . . . . . . . . . . . 165
20 Error-Correction and Fault-Tolerance
169
20.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
20.2 Classical error-correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
20.3 Quantum errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
20.4 Quantum error-correcting codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
20.5 Fault-tolerant quantum computation . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
20.6 Concatenated codes and the threshold theorem . . . . . . . . . . . . . . . . . . . . . 174
A Some Useful Linear Algebra
179
A.1 Vector spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
A.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
A.3 Inner product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
A.4 Unitary matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
A.5 Diagonalization and singular values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
A.6 Tensor products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
A.7 Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
A.8 Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
A.9 The Pauli matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
A.10 Dirac notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
B Some other Useful Math and CS
185
B.1 Some notation, equalities and inequalities . . . . . . . . . . . . . . . . . . . . . . . . 185
B.2 Algorithms and probabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
C Hints for Exercises

189

viii

Chapter 1

Quantum Computing
1.1

Introduction

Today’s computers—both in theory (Turing machines) and practice (PCs, HPCs, laptops, tablets,
smartphones, . . . )—are based on classical physics. They are limited by locality (operations have
only local effects) and by the classical fact that systems can be in only one state at the time. However, modern quantum physics tells us that the world behaves quite differently. A quantum system
can be in a superposition of many different states at the same time, and can exhibit interference
effects during the course of its evolution. Moreover, spatially separated quantum systems may beentangled with each other and operations may have “non-local” effects because of this.
Quantum computation is the field that investigates the computational power and other properties of computers based on quantum-mechanical principles. It combines two of the most importantstrands of 20th-century science: quantum mechanics (developed by Planck, Einstein, Bohr, Heisenberg, Schrödinger and others in the period 1900–1925) and computer science (whose birth may be
dated to Turing’s 1936 paper [237]). An important objective is to find quantum algorithms thatare significantly faster than any classical algorithm solving the same problem.
Quantum computation started in the early 1980s with suggestions for analog quantum computers by Yuri Manin [185] (and appendix of [186]), Richard Feynman [111, 112], and Paul Benioff [47],and reached more digital ground when in 1985 David Deutsch defined the universal quantum Turing machine [97]. See Preskill [201] for more on this early history. The following years saw only
sparse activity, notably the development of the first algorithms by Deutsch and Jozsa [99] and by
Simon [230], and the development of quantum complexity theory by Bernstein and Vazirani [53].
However, interest in the field increased tremendously after Peter Shor’s very surprising discovery
of efficient quantum algorithms for the problems of integer factorization and discrete logarithms in1994 [228], which was inspired by Simon’s work. Since most of current classical cryptography isbased on the assumption that these two problems are computationally hard, the ability to actuallybuild and use a quantum computer would allow us to break most current classical cryptographic
systems, notably the RSA system [210, 211]. In contrast, a quantum form of cryptography due toBennett and Brassard [51] is unbreakable even for quantum computers.
Here are three reasons to study quantum computers, from practical to more philosophical:
1. The process of miniaturization that has made current classical computers so powerful andcheap, has already reached micro-levels where quantum effects occur. Chipmakers tend to go
to great lengths to suppress those quantum effects, forcing their bits and logical operations
1

to behave classically, but instead one might also try to work with them, enabling further
miniaturization.
2. Making use of quantum effects allows one to speed up certain computations enormously(sometimes exponentially), and even enables some things that are impossible for classicalcomputers. The main purpose of these lecture notes is to explain these advantages of quantum
computing (algorithms, crypto, etc.) in detail.
3. Finally, one might say that the main goal of theoretical computer science is to “study thepower and limitations of the strongest-possible computational devices that Nature allowsus.” Since our current understanding of Nature is quantum mechanical, theoretical computerscience should arguably be studying the power of quantum computers, not classical ones.
Before limiting ourselves to theory, let us say a few words about practice: to what extent willquantum computers ever be built? At this point in time, it is just too early to tell. The firstsmall 2-qubit quantum computer was built in 1997 and in 2001 a 5-qubit quantum computer wasused to successfully factor the number 15 [240]. Since then, experimental progress on a numberof different technologies has been steady but slow. The most advanced implementations currently
use superconducting qubits and ion-trap qubits. The largest quantum computation done at thetime of writing is Google’s “quantum supremacy” experiment on 53 qubits [30], which performs
a complicated (but rather useless) sampling task that appears to be no longer simulatable in areasonable amount of the time on even the largest existing classical supercomputer.
The practical problems facing physical realizations of quantum computers seem formidable. The
problems of noise and decoherence have to some extent been solved in theory by the discovery ofquantum error-correcting codes and fault-tolerant computing (see, e.g., Chapter 20 in these notes),
but these problems are by no means solved in practice. On the other hand, we should realizethat the field of physical realization of quantum computing is still in its infancy and that classicalcomputing had to face and solve many formidable technical problems as well—interestingly, often
these problems were even of the same nature as those now faced by quantum computing (e.g.,
noise-reduction and error-correction). Moreover, while the difficulties facing the implementationof a full quantum computer may seem daunting, more limited applications involving quantum
communication have already been implemented with some success, for example teleportation (whichis the process of sending qubits using entanglement and classical communication), and versions of
BB84 quantum key distribution are nowadays even commercially available.
Even if the theory of quantum computing never materializes to a real large-scale physical computer, quantum-mechanical computers are still an extremely interesting idea which will bear fruitin other areas than practical fast computing. On the physics side, it may improve our understanding of quantum mechanics. The emerging theories of entanglement and of Hamiltonian complexity
have already done this to some extent. On the computer science side, the theory of quantum
computation generalizes and enriches classical complexity theory and may help resolve some of its
problems (see Section 15.3 for an example).

1.2

Quantum mechanics

Here we give a brief and abstract introduction to quantum mechanics. In short: a quantum state isa superposition of classical states, written as a vector of amplitudes, to which we can apply eithera measurement or a unitary operation. For the required linear algebra we refer to Appendix A.
2

1.2.1Superposition

Consider some physical system that can be in N different, mutually exclusive classical states.
Because we will typically start counting from 0 in these notes, we call these states |0i, |1i, . . . , |N −1i.
Roughly, by a “classical” state we mean a state in which the system can be found if we observe it.
A pure quantum state (usually just called state) |φi is a superposition of classical states, written|φi = α0 |0i + α1 |1i + · · · + αN −1 |N − 1i.
Here αi is a complex number that is called the amplitude of |ii in |φi. Intuitively, a system inquantum state |φi is “in all classical states at the same time,” each state having a certain amplitude.
It is in state |0i with amplitude α0 , in state |1i with amplitude α1 , and so on. Mathematically,
the states |0i, . . . , |N − 1i form an orthonormal basis of an N -dimensional Hilbert space (i.e., an
N -dimensional vector space equipped with an inner product). A quantum state |φi is a vector inthis space, usually written as an N -dimensional column vector of its amplitudes:


α0


..
|φi = .
.
αN −1Such a vector is sometimes called a “ket.” It conjugate transpose is the following row vector,
sometimes called a “bra”:
∗hφ| = α0∗ , . . . , αN
−1 .
The reason for this terminology (often called “Dirac notation” after Paul Dirac) is that an innerproduct hφ|ψi between two states corresponds to the dot product between a bra and a ket vector(“bracket”): hφ|ψi = hφ| · |ψi.
We can combine different Hilbert spaces using tensor product: if |0i, . . . , |N − 1i are an orthonormal basis of space HA and |0i, . . . , |M − 1i are an orthonormal basis of space HB , then thetensor product space H = HA ⊗ HB is an N M -dimensional space spanned by the set of states
{|ii
⊗ |ji
PM|−1i ∈ {0, . . . , N − 1}, j ∈ {0, . . . , M − 1}}. An arbitrary state in H is of the form
PN −1
j=0 αij |ii ⊗ |ji. Such a state is called bipartite. Similarly we can have tripartite states
i=0
that “live” in a Hilbert space that is the tensor product of three smaller Hilbert spaces, etc.
There are two things we can do with a quantum state: measure it or let it evolve unitarily
without measuring it. We will deal with measurement first.

1.2.2

Measurement

Measurement in the computational basis
Suppose we measure state |φi. We cannot “see” a superposition itself, but only classical states.
Accordingly, if we measure state |φi we will see one and only one classical state |ji. Which specific|ji will we see? This is not determined in advance; the only thing we can say is that we will
see state |ji with probability |αj |2 , which is the squared norm of the corresponding amplitude αj .
This is known as “Born’s rule.” Accordingly, observing a quantum state induces a probability
distribution
on the classical states, given by the squared norms of the amplitudes. This implies
PN −1
2
j=0 |αj | = 1, so the vector of amplitudes has (Euclidean) norm 1. If we measure |φi and getoutcome j as a result1 , then |φi itself has “disappeared,” and all that is left is |ji. In other words,
1

Don’t use the ambiguous phrase “we measure j” in this case, since it’s not clear in that phrasing whether |ji isthe state you’re applying the measurement to, or the outcome of the measurement.

3

observing |φi “collapses” the quantum superposition |φi to the classical state |ji that we saw, andall “information” that might have been contained in the amplitudes αi is gone. Note that theprobabilities of the various measurement outcomes are exactly the same when we measure |φi orwhen we measure state eiθ |φi; because of this we sometimes say that the “global phase” eiθ has no
physical significance.
Projective measurement
For most of the topics in these notes, the above “measurement in the computational (or standard)basis” suffices. However, somewhat more general kinds of measurement than the above are possible
and sometimes useful. The remainder of this subsection may be skipped on a first reading, but will
become more relevant in the later parts of these notes, starting from Chapter 15.
A projective measurement on some space, with m possible outcomes,of projectors
P is a collection
2 These projectors
P=I.
P1 , . . . , Pm that all act on that same space and that sum to identity, mj
j=1
are then pairwise orthogonal, meaning that Pi Pj = 0 if i 6= j. The projector Pj projects on somesubspace Vj of P
the total Hilbert space V , and every state |φi ∈ V can be decomposed in a uniquem
way as |φi =j=1 |φj i, with |φj i = Pj |φi ∈ Vj . Because the projectors are orthogonal, thesubspaces Vj are orthogonal as well, as are the states |φj i. When we apply this measurement to
the pure state |φi, then we will get outcome j with probability k|φj ik2 = Tr(Pj |φihφ|) = hφ|Pj |φiand the measured state will then “collapse” to the newPstate |φj i/k|φj ik = Pj |φi/kPj |φik.3 The
probabilities sum to 1 thanks to our assumption that m
j=1 Pj = I and the fact that trace is alinear function:mX
j=1

Tr(Pj |φihφ|) = Tr((mXPj )|φihφ|) = Tr(|φihφ|) = hφ|φi = 1.

j=1

Note carefully that we cannot choose which Pj will be applied to the state but can only give aprobability distribution. However, if the state |φi that we measure lies fully within one of thesubspaces Vj , then the measurement outcome will be that j with certainty.
For example, a measurement in the computational basis on an N -dimensional state is the specificprojective measurement where m = N and Pj = |jihj|. That is, Pj projects onto the computational
basis state |ji and the corresponding subspace Vj ⊆ V is the 1-dimensional subspace spanned by
P −1|ji. Consider the state |φi = N
j=0 αj |ji. Note that Pj |φi = αj |ji, so applying our measurement
to |φi will give outcome j with probability kαj |jik2 = |αj |2 , and in that case the state collapsesαα
to αj |ji/kαj |jik = |αjj | |ji. The norm-1 factor |αjj | may be disregarded because it has no physicalsignificance, so we end up with the state |ji as we saw before.
Instead of the standard orthonormal basis, with basis states |0i, . . . , |N − 1i, we may consider
any other orthonormal basis B of states |ψ0 i, . . . , |ψN −1 i, and consider the projective measurement
defined by the projectors Pj = |ψj ihψj |. This is called “measuring in basis B.” Applying thismeasurement to state |φi gives outcome j with probability hφ|Pj |φi = |hφ|ψj i|2 . Note that if |φiequals one of the basis vectors |ψj i, then the measurement gives that outcome j with probability 1.
In the previous two examples the projectors had rank 1 (i.e., project on 1-dimensional subspaces), but this is not necessary. For example, a measurement that distinguishes between |ji
2

The m projectors together form one measurement; don’t use the word “measurement” for individual Pj s.
Don’t confuse the outcome of the measurement, which is the label j of the projector Pj that was applied, andthe post-measurement state, which is Pj |φi/kPj |φik.
3

4

Pwith jP< N/2 and |ji with j ≥ N/2 corresponds to the two projectors P1 = j<N/2 |jihj| andP2 = j≥N/2 |jihj|, each of rank N/2 (assume N is even). Applying this measurement to the stateq1√|φi = 3 |1i + 23 |N i gives outcome 1 with probability kP1 |φik2 = 1/3, in which case the statecollapses to |1i. It gives outcome 2 with probability kP2 |φik2 = 2/3, the state then collapses to |N i.
Observables
A projective measurement with projectors
PmP1 , . . . , Pm and associated distinct outcomes λ1 , . . . , λm ∈R, can be written as one matrix M = i=1 λi Pi , which is called an observable. This is a succinct
way of writing down the projective measurement in one matrix, and has the added advantage thatthe expected value of the outcome can be easily calculated: if we are measuring a state |φi, then2
thei is kPi |φik = Tr(Pi |φihφ|), so the expected value of the outcome is
Pmprobability of outcomePλm
is Hermitian: M = M ∗ .
i=1 λi Tr(Pi |φihφ|) = Tr( i=1 λi Pi |φihφ|) = Tr(M |φihφ|). Note that M
Pm
Conversely, since every Hermitian M has a spectral decomposition M = i=1 λi Pi , there is a direct
correspondence between observables and Hermitian matrices.
The Pauli matrices I, X, Y, Z (see Appendix A.9) are examples of 2-dimensional observables,with eigenvalues ±1. For example, Z = |0ih0| − |1ih1| corresponds to measurement in the computational basis (with measurement outcomes +1 and −1 for |0i and |1i, respectively).
Suppose we have a bipartite state. An observable A on the first part of the state corresponds
to an observable A ⊗ I on the bipartite state. Similarly, an observable B on the second part of thestate corresponds to an observable I ⊗ B on the bipartite state. Separately measuring observables
A and B on the two parts of a bipartite state is different from measuring the joint observable
A ⊗ B: the separate measurements give one outcome each, while the joint measurement gives
only one outcome, and the distribution on the post-measurement state may be different. What istrue, however, is that the measurement statistics of the product of outcomes is the same as themeasurement statistics of the outcome of the joint measurement. For example consider the casewhen A = B = Z (these correspond to measurement in the computational basis), and the bipartite
state is |φi = √12 (|0i ⊗ |0i + |1i ⊗ |1i). With the separate measurements, the outcomes will be++ or −− (note that in both cases the product of the two outcomes is +1) and the state |φi will
collapse to either |0i ⊗ |0i or |1i ⊗ |1i. Yet |φi remains undisturbed by a joint measurement with
±1-valued observable Z ⊗ Z, because |φi is a +1-eigenstate of Z ⊗ Z.
POVM measurement
If we only care about the final probability distribution on the m outcomes, not about the resulting post-measurement state, then the most general type of measurement we can do is a so-called
positive-operator-valued measure (POVM). This is specified by m positive semidefinite (psd) matrices E1 , . . . , Em that sum to identity. When measuring a state |φi, the probability of outcome
i is given by Tr(Ei |φihφ|). A projective measurement is the special case of a POVM where themeasurement elements Ei are projectors.4
There are situations where a POVM can do things a projective measurement cannot do.5 For
4Note that if Ei is a projector, then Tr(Ei |φihφ|) = Tr(Ei2 |φihφ|) = Tr(Ei |φihφ|Ei ) = kEi |φik2 , using the factthat Ei = Ei2 and the cyclic property of the trace. These inequalities can fail if Ei is psd but not a projector.
5
Even though POVMs strictly generalize projective measurements, one can show that every POVM can be “simulated” by a projective measurement on a slightly larger space that yields the exact same probability distribution
over measurement outcomes (this follows from Neumark’s theorem).

5example, suppose you have a state in a 2-dimensional space, and you know it is either in state |0i
or in state |+i = √12 (|0i + |1i). These two states are not orthogonal, so there is no measurementthat distinguishes them perfectly. However, there is a POVM measurement that never makes a
mistake, but sometimes gives another outcome 2, meaning “I don’t know.” That is, you would liketo do a measurement with three possible outcome: 0, 1, and 2, such that:• If the state is |0i, then you get correct outcome 0 with probability 1/4, and outcome 2 withprobability 3/4, but never get incorrect outcome 1.
• If the state is |+i, then you get correct outcome 1 with probability 1/4, and outcome 2 withprobability 3/4, but never get incorrect outcome 0.
You cannot achieve this with a projective measurement on the qubit, but the following 3-outcome
POVM does the job:
E0 = 12 |−ih−| (where |−i = √12 (|0i − |1i), which is orthogonal to the |+i state);
E1 = 21 |1ih1| (note that this is orthogonal to the |0i state);
E2 = I − E0 − E1 .
You can check that E0 , E1 , E2 are psd and add up to identity, so they form a valid POVM. None of
the 3 matrices is a projector. The success probability 1/4 can be improved further, see Exercise 9.

1.2.3

Unitary evolution

Instead of measuring |φi, we can also apply some operation to it, i.e., change the state to some|ψi = β0 |0i + β1 |1i + · · · + βN −1 |N − 1i.
Quantum mechanics only allows linear operations to be applied to quantum states. What thismeans is: if we view a state like |φi as an N -dimensional vector (α0 , . . . , αN −1 )T , then applying an
operation that changes |φi to |ψi corresponds to multiplying |φi with an N × N complex-valued
matrix U :

 

α0
β0

  .. ..
U =  . .
.
αN −1

βN −1

P
P
Note that by linearity we have |ψi = U |φi = U ( i αi |ii) = i αi U |ii.
measuring |ψi should also give a probability distribution, we have the constraint
PNBecause−1
2 = 1 on the new state. This implies that the operation U must preserve the norm
|β
|
j
j=0
of vectors, and hence must be a unitary transformation (often just called “a unitary”). A matrix
U is unitary if its inverse U −1 equals its conjugate transpose U ∗ . This is equivalent to saying that
U always maps a vector of norm 1 to a vector of norm 1. Because a unitary transformation always
has an inverse, it follows that any (non-measuring) operation on quantum states must be reversible:
by applying U −1 we can always “undo” the action of U , and nothing is lost in the process. On theother hand, a measurement is clearly non-reversible, because we cannot reconstruct |φi from theobserved classical state |ji.
6

1.3

Qubits and quantum memory

In classical computation, the unit of information is a bit, which can be 0 or 1. In quantum computation, this unit is a quantum bit (qubit), which is a superposition of 0 and 1. Consider a systemwith 2 basis
states, call them |0i and |1i. We identify these basis states with the two orthogonal
 
10
vectorsand, respectively. A single qubit can be in any superposition01
α0 |0i + α1 |1i, |α0 |2 + |α1 |2 = 1.
Accordingly, a single qubit “lives” in the vector space C2 .
Similarly we can think of systems of more than 1 qubit, which “live” in the tensor productspace of several qubit systems. For instance, a 2-qubit system has 4 basis states: |0i ⊗ |0i, |0i ⊗ |1i,
|1i ⊗ |0i, |1i ⊗ |1i. Here for instance |1i ⊗ |0i means that the first qubit is in its basis state |1i andthe second qubit is in its basis state |0i. We will often abbreviate this to |1i|0i, |1, 0i, or even |10i.
More generally, a register of n qubits has 2n basis states, each of the form |b1 i ⊗ |b2 i ⊗ . . . ⊗ |bn i,with bi ∈ {0, 1}. We can abbreviate this to |b1 b2 . . . bn i. We will often abbreviate 0 . . . 0 to 0n . Since
bitstrings of length n can be viewed as integers between 0 and 2n − 1 (see Appendix B.2), we canalso write the basis states as numbers |0i, |1i, |2i, . . . , |2n − 1i. Note that the vector corresponding
to n-qubit basis state |xi is the 2n -dimensional vector that has a 1 at the x-th position and 0s
elsewhere (here we view x as an integer in {0, . . . , 2n − 1} and we count the positions in the vector
starting from position 0). This implies that two n-qubit basis states |xi and |yi are orthogonal iff
x 6= y. A different way to see this orthogonality is to use the rules of tensor product (Appendix A.6):
hx|yi = hx1 |y1 i ⊗ · · · ⊗ hxn |yn i = hx1 |y1 i · · · hxn |yn i.
Since hxk |yk i = δxk ,yk , we see that basis states |xi and |yi will be orthogonal as soon as there is atleast one position k at which the bits of x and y differ.
A quantum register of n qubits can be in any superposition6nα0 |0i + α1 |1i + · · · + α2n −1 |2 − 1i,

n −1
2X

|αj |2 = 1.

j=0

Measuring this in the computational basis, we obtain the n-bit state |ji with probability |αj |2 .
Measuring just the first qubit of a state would correspond to the projective measurement thathas the two projectors P0 = |0ih0| ⊗qI2n−1 and P1 = |1ih1| ⊗ I2n−1 . For example, applying thismeasurement to the state √13 |0i|φi + 23 |1i|ψi gives outcome 0 with probability 1/3; the state thenbecomes |0i|φi. We get outcome 1 with probability 2/3; the state then becomes |1i|ψi. Similarly,
measuring the first n qubits of an (n + m)-qubit state in the computational basis corresponds tothe projective measurement that has 2n projectors Pj = |jihj| ⊗ I2m for j ∈ {0, 1}n .
An important property that deserves to be mentioned is entanglement, which refers to quantum
correlations between different qubits. For instance, consider a 2-qubit register that is in the state1
1√ |00i + √ |11i.
2
2
6

Don’t call such a multi-qubit state or register a “qubit” or an “n-qubit”—the term “qubit” only refers to thestate of a 2-dimensional system. You can use “n-qubit” as an adjective but not as a noun.

7

Such 2-qubit states are sometimes called EPR-pairs in honor of Einstein, Podolsky, and Rosen [106],
who examined such states and their seemingly paradoxical properties. Initially neither of the two
qubits has a classical value |0i or |1i. However, if we measure the first qubit and observe, say, a|0i, then the whole state collapses to |00i. Thus observing the first qubit immediately fixes also
the second, unobserved qubit to a classical value. Since the two qubits that make up the register
may be far apart, this example illustrates some of the non-local effects that quantum systems can
exhibit. In general, a bipartite state |φi is called entangled if it cannot be written as a tensor
product |φA i ⊗ |φB i where |φA i lives in the first space and |φB i lives in the second.7
At this point, a comparison with classical probability distributions may be helpful. Suppose
we have two probability spaces, A and B, the first with 2n possible outcomes, the second with 2mpossible outcomes. A probability distribution on the first space can be described by 2n numbers(nonnegative reals summing to 1; actually there are only 2n − 1 degrees of freedom here) and a
distribution on the second by 2m numbers. Accordingly, a product distribution on the joint spacecan be described by 2n + 2m numbers. However, an arbitrary (non-product) distribution on the
joint space takes 2n+m real numbers, since there are 2n+m possible outcomes in total. Analogously,
an n-qubit state |φA i can be described by 2n numbers (complex numbers whose squared moduli
sum to 1), an m-qubit state |φB i by 2m numbers, and their tensor product |φA i ⊗ |φB i by 2n + 2m
numbers. However, an arbitrary (possibly entangled) state in the joint space takes 2n+m numbers,
since it lives in a 2n+m -dimensional space. We see that the number of parameters required todescribe quantum states is the same as the number of parameters needed to describe probability
distributions. Also note the analogy between statistical independence8 of two random variables A
and B and non-entanglement of the product state |φA i ⊗ |φB i. However, despite the similarities
between probabilities and amplitudes, quantum states are much more powerful than distributions,because amplitudes may have negative (or even complex) parts which can lead to interference
effects. Amplitudes only become probabilities when we square them. The art of quantum computing
is to use these special properties for interesting computational purposes.

1.4

Elementary gates

A unitary that acts on a small number of qubits (say, at most 3) is often called a gate, in analogy
to classical logic gates like AND, OR, and NOT; more about that in the next chapter. The Paulimatrices I, X, Y, Z (Appendix A.9) are examples of 1-qubit gates. For example, the bitflip gate X(a.k.a. NOT-gate) negates the bit in the computational basis, i.e., it swaps |0i and |1i. The phaseflip
gate Z puts a − in front of |1i. Represented as 2 × 2 unitary matrices, these are

X=

0 1
1 0




, Z=

7

1
0
0 −1


.

We often omit the tensor product symbol for such unentangled states, abbreviating |φA i ⊗ |φB i to |φA i|φB i (youshouldn’t abbreviate this further to |φA φB i though, unless both |φA i and |φB i are computational basis states). Notethat there cannot be ambiguity between tensor product and the usual matrix product in this abbreviation, because
both |φA i and |φB i are column vectors and hence their matrix product wouldn’t even be well-defined (the dimensions“don’t fit”).
8
Two random variables A and B are independent if their joint probability distribution can be written as a productof individual distributions for A and for B: Pr[A = a ∧ B = b] = Pr[A = a] · Pr[B = b] for all possible values a, b.

8

Another important 1-qubit gate is the phase gate Rφ , which merely rotates the phase of the |1i-stateby an angle φ:Rφ |0i = |0i
Rφ |1i = eiφ |1iThis corresponds to the unitary matrix

Rφ =

1
0
0 eiφ


.

Note that Z is a special case of this: Z = Rπ , because eiπ = −1. The Rπ/4 -gate is often just called
the T -gate.
Possibly the most important 1-qubit gate is the Hadamard transform, specified by:1
1
H|0i = √ |0i + √ |1i
2
2
1
1
H|1i = √ |0i − √ |1i
2
2
As a unitary matrix, this is represented as
1
H=√
2



1
1
1 −1


.

If we apply H to initial state |0i and then measure, we have equal probability of observing |0i or|1i. Similarly, applying H to |1i and observing gives equal probability of |0i or |1i. However, if we
apply H to the superposition √12 |0i + √12 |1i then we obtain
1
1
1
1
1
1
H( √ |0i + √ |1i) = √ H|0i + √ H|1i = (|0i + |1i) + (|0i − |1i) = |0i.
2
2
2
2
2
2
The positive and negative amplitudes for |1i have canceled each other out! This effect is calledinterference, and is analogous to interference patterns between light or sound waves.
An example of a 2-qubit gate is the controlled-not gate CNOT. It negates the second bit of its
input if the first bit is 1, and does nothing if the first bit is 0:
CNOT|0i|bi = |0i|bi
CNOT|1i|bi = |1i|1 − bi
The first qubit is called the control qubit, the second the target qubit. In matrix form, this is
1 0 0 0
 0 1 0 0 
CNOT =  0 0 0 1 .
0 0 1 0More generally, if U is some n-qubit unitary matrix, then the controlled-U operation corresponds
to the following 2n+1 × 2n+1 unitary matrix:


I 0
,
0 U
where I is the 2n -dimensional identity matrix and the two 0s denote 2n × 2n all-0 matrices.
9

1.5

Example: quantum teleportation

In the next chapter we will look in more detail at how we can use and combine such elementarygates, but as an example we will here already explain teleportation [48]. Suppose there are twoparties, Alice and Bob. Alice has a qubit α0 |0i + α1 |1i that she wants to send to Bob via a classicalchannel. Without further resources this would be impossible, because the amplitudes α0 , α1 may
require an infinite number of bits of precision to write them down exactly. However, suppose Alicealso shares an EPR-pair1√ (|00i + |11i)2
with Bob (say Alice holds the first qubit and Bob the second). Initially, their joint state is1(α0 |0i + α1 |1i) ⊗ √ (|00i + |11i).
2
The first two qubits belong to Alice, the third to Bob. Alice performs a CNOT on her two qubits
and then a Hadamard transform on her first qubit. Their joint 3-qubit state can now be written as
1
2 |00i(α0 |0i + α1 |1i) +1
2 |01i(α0 |1i + α1 |0i) +1
2 |10i(α0 |0i − α1 |1i) +1
2 |11i (α0 |1i − α1 |0i) .

|{z} |
Alice

{z

Bob

}

Alice then measures her two qubits in the computational basis and sends the result (2 randomclassical bits ab) to Bob over a classical channel. Bob now knows which transformation he must
do on his qubit in order to regain the qubit α0 |0i + α1 |1i. First, if b = 1 then he applies a bitflip(X-gate) on his qubit; second if a = 1 then he applies a phaseflip (Z-gate). For instance, if Alicesent ab = 11, then Bob knows that his qubit is α0 |1i − α1 |0i. A bitflip followed by a phaseflip
will give him Alice’s original qubit α0 |0i + α1 |1i. In fact, if Alice’s qubit had been entangled withsome other qubits, then teleportation preserves this entanglement: Bob then receives a qubit thatis entangled in the same way as Alice’s original qubit was.
Note that the qubit on Alice’s side has been destroyed: teleporting moves a qubit from Alice toBob, rather than copying it. In fact, copying an unknown qubit is impossible [249], see Exercise 10.

Exercises
1. (a) What is the inner product between the real vectors (0, 1, 0, 1) and (0, 1, 1, 1)?
(b) What is the inner product between the states |0101i and |0111i?
2. Compute the result of applying a Hadamard transform to both qubits of |0i ⊗ |1i in two ways
(the first way using tensor product of vectors, the second using tensor product of matrices),and show that the two results are equal:
H|0i ⊗ H|1i = (H ⊗ H)(|0i ⊗ |1i).
3. Show that a bitflip operation, preceded and followed by Hadamard transforms, equals aphaseflip operation: HXH = Z.
10

4. Show that surrounding a CNOT gate with Hadamard gates switches the role of the control-bit
and target-bit of the CNOT: (H ⊗ H)CNOT(H ⊗ H) is the 2-qubit gate where the second
bit controls whether the first bit is negated (i.e., flipped).
5. Simplify the following: (h0| ⊗ I)(α00 |00i + α01 |01i + α10 |10i + α11 |11i).
6. Prove that an EPR-pair √12 (|00i + |11i) is an entangled state, i.e., that it cannot be written
as the tensor product of two separate qubits.
7. Suppose we have the state √12 (|0i|φi + |1i|ψi), where |φi and |ψi are unknown normalized
quantum states with the same number of qubits. Suppose we apply a Hadamard gate to thefirst qubit and then measure that first qubit in the computational basis. Give the probabilityof measurement outcome 1, as a function of the states |φi and |ψi.
8. Give the 2-outcome projective measurement on a 2-qubit space that measures the parity (i.e.,sum modulo 2) of 2-bit basis states. Also give the corresponding observable.
9. (H) Show that the success probabilityof the POVM at the end of Section 1.2.2 can be√increased from 1/4 to 1/(2 + 2).
10. (H) Prove the quantum no-cloning theorem: there does not exist a 2-qubit unitary U thatmaps
|φi|0i 7→ |φi|φifor every qubit |φi.
11. Show that unitaries cannot “delete” information: there is no 1-qubit unitary U that maps
|φi 7→ |0i for every 1-qubit state |φi.
12. Suppose Alice and Bob are not entangled. If Alice sends a qubit to Bob, then this cangive Bob at most one bit of information about Alice.9 However, if they share an EPR-pair,|ψi = √12 (|00i + |11i), then they can transmit two classical bits by sending one qubit over thechannel; this is called superdense coding. This exercise will show how this works.
(a) They start with a shared EPR-pair, √12 (|00i + |11i). Alice has classical bits a and b.
Suppose she does an X-gate on her half of the EPR-pair if a = 1, followed by a Z-gate
if b = 1 (she does both if ab = 11, and neither if ab = 00). Write the resulting 2-qubit
state for the four different cases that ab could take.
(b) Suppose Alice sends her half of the state to Bob, who now has two qubits. Show thatBob can determine both a and b from his state, using Hadamard and CNOT gates,
followed by a measurement in the computational basis.
13. Alice and Bob share an EPR-pair, |ψi = √12 (|00i + |11i).
(a) Let C be a 2 × 2 matrix. Show that Tr((C ⊗ I)|ψihψ|) = 12 Tr(C).
(b) (H) Alice could apply one of the 4 Pauli matrices (I, X, Y, Z) to her qubit. Use part (a)to show that the 4 resulting 2-qubit states form an orthonormal set.
9

This is actually a deep statement, a special case of Holevo’s theorem. More about this may be found in Chapter 15.

11

(c) Suppose Alice applies one of the 4 Pauli matrices to her qubit and then sends that qubit
to Bob. Give the 4 projectors of a 4-outcome projective measurement that Bob could
do on his 2 qubits to find out which Pauli matrix Alice actually applied.
cos θ − sin θ
14. Let θ ∈ [0, 2π), Uθ =, |φi = Uθ |0i and |φ⊥ i = Uθ |1i.
sin θ
cos θ
(a) Show that ZX|φ⊥ i = |φi.
(b) Show that an EPR-pair, √12 (|00i + |11i), can also be written as √12 (|φi|φi + |φ⊥ i|φ⊥ i).
(c) Suppose Alice and Bob start with an EPR-pair. Alice applies Uθ−1 to her qubit and thenmeasures it in the computational basis. What pure state does Bob have if her outcome
was 0, and what pure state does he have if her outcome was 1?
(d) Suppose Alice knows the number θ but Bob does not. Give a protocol that uses one
EPR-pair and 1 classical bit of communication where Bob ends up with the qubit |φi(in contrast to general teleportation of an unknown qubit, which uses 1 EPR-pair and 2
bits of communication).

12Chapter 2

The Circuit Model and theDeutsch-Jozsa Algorithm
2.1

Quantum computation

Below we explain how a quantum computer can apply computational steps to its register of qubits.
Two models exist for this: the quantum Turing machine [97, 53] and the quantum circuit model [98,251]. These models are equivalent, in the sense that they can simulate each other in polynomial
time, assuming the circuits are appropriately “uniform.” We only explain the circuit model here,
which is more popular among researchers.

2.1.1

Classical circuits

In classical complexity theory, a Boolean circuit is a finite directed acyclic graph with AND, OR,
and NOT gates. It has n input nodes, which contain the n input bits (n ≥ 0). The internal
nodes are AND, OR, and NOT gates, and there are one or more designated output nodes. The
initial input bits are fed into AND, OR, and NOT gates according to the circuit, and eventually
the output nodes assume some value. We say that a circuit computes some Boolean function
f : {0, 1}n → {0, 1}m if the output nodes get the right value f (x) for every input x ∈ {0, 1}n .
A circuit family is a set C = {Cn } of circuits, one for each input size n. Each circuit has one
output bit. Such a family recognizes or decides a language L ⊆ {0, 1}∗ = ∪n≥0 {0, 1}n if, for everyn and every input x ∈ {0, 1}n , the circuit Cn outputs 1 if x ∈ L and outputs 0 otherwise.1 Such a
circuit family is uniformly polynomial if there is a deterministic Turing machine that outputs Cn
given n as input, using space logarithmic in n.2 Note that the size (number of gates) of the circuits
Cn can then grow at most polynomially with n. It is known that uniformly polynomial circuit
families are equal in power to polynomial-time deterministic Turing machines: a language L canbe decided by a uniformly polynomial circuit family iff L ∈ P [198, Theorem 11.5], where P is theclass of languages decidable by polynomial-time Turing machines.
Similarly we can consider randomized circuits. These receive, in addition to the n input bits,
also some random bits (“coin flips”) as input. A randomized circuit computes a function f if it1

We can think of a language L as a sequence of Boolean functions fn : {0, 1}n → {0, 1}, where fn takes value 1
exactly on the n-bit strings that are in L. The circuit Cn then computes the function fn .
2
Logarithmic space implies time that’s at most polynomial in n, because such a machine will have only poly(n)different internal states, so it either halts after poly(n) steps or cycles forever.

13

successfully outputs the right answer f (x) with probability at least 2/3 for every x (probability
taken over the values of the random bits). Randomized circuits are equal in power to randomized
Turing machines: a language L can be decided by a uniformly polynomial randomized circuit
family iff L ∈ BPP, where BPP (“Bounded-error Probabilistic Polynomial time”) is the class oflanguages that can efficiently be recognized by randomized Turing machines with success probability
at least 2/3. Because we can efficiently reduce the error probability of randomzied algorithms (seeAppendix B.2), the particular value 2/3 doesn’t really matter here and may be replaced by any
fixed constant in (1/2, 1).

2.1.2

Quantum circuits

A quantum circuit (also called quantum network or quantum gate array) generalizes the idea ofclassical circuit families, replacing the AND, OR, and NOT gates by elementary quantum gates. A
quantum gate is a unitary transformation on a small (usually 1, 2, or 3) number of qubits. We saw
a number of examples already in the previous chapter: the bitflip gate X, the phaseflip gate Z,
the Hadamard gate H. The main 2-qubit gate we have seen is the controlled-NOT (CNOT) gate.
Adding another control qubit, we get the 3-qubit Toffoli gate, also called controlled-controlled-not(CCNOT) gate. This negates the third bit of its input if both of the first two bits are 1. The
Toffoli gate is important because it is complete for classical reversible computation: any classicalcomputation can be implemented by a circuit of Toffoli gates. This is easy to see: using auxiliary
wires with fixed values, Toffoli can implement AND (fix the 3rd ingoing wire to 0) and NOT (fix the
1st and 2nd ingoing wire to 1). It is known that AND and NOT-gates together suffice to implement
any classical Boolean circuit, so if we can apply (or simulate) Toffoli gates, we can implement any
classical computation in a reversible manner.
Mathematically, such elementary quantum gates can be composed into bigger unitary operations
by taking tensor products (if gates are applied in parallel to different parts of the register), andordinary matrix products (if gates are applied sequentially). We have already seen a simple example
of such a circuit of elementary gates in the previous chapter, namely to implement teleportation.
For example, if we apply the Hadamard gate H to each bit in a register of n zeroes, we obtain
X
1
√
|ji,
2n j∈{0,1}nwhich is a superposition of all n-bit strings. More generally, if we apply H ⊗n to an initial state |ii,with i ∈ {0, 1}n , we obtainX
1
H ⊗n |ii = √(−1)i·j |ji,
(2.1)
2n j∈{0,1}nwhere i · j =Pnn
k=1 ik jk denotes the inner product of the n-bit strings i, j ∈ {0, 1} . For example:

1
1
1 X
H ⊗2 |01i = √ (|0i + |1i) ⊗ √ (|0i − |1i) =(−1)01·j |ji.
222
j∈{0,1}2
Note that Hadamard happens to be its own inverse (it’s unitary and Hermitian, hence H = H ∗ =H −1 ), so applying it once more on the right-hand side of the above equation would give us back
|01i. The n-fold Hadamard transform will be very useful for quantum algorithms.
14

As in the classical case, a quantum circuit is a finite directed acyclic graph of input nodes,
gates, and output nodes. There are n nodes that contain the input (as classical bits); in addition
we may have some more input nodes that are initially |0i (“workspace”). The internal nodes of thequantum circuit are quantum gates that each operate on at most two or three qubits of the state.
The gates in the circuit transform the initial state vector into a final state, which will generally
be a superposition. We measure some or all qubits of this final state in the computational basis
in order to (probabilistically) obtain a classical output to the algorithm. We can think of themeasurement of one qubit in the computational basis as one special type of gate. We may assume
without much loss of generality that such measurements only happen at the very end of the circuit(see Exercise 7).
What about the more general kinds of measurements discussed in Section 1.2.2? If we want
to apply such a measurement in the circuit model, we will have to implement it using a circuitof elementary gates followed by a measurement in the computational basis. For example, suppose
projectors P0 and P1 form a 2-outcome projective measurement on an n-qubit space (P0 +P1 = I2n ).
Assume for simplicity that P0 and P1 both have rank 2n /2. Then there exists a unitary U thatmaps an n-qubit state |φi to a state whose first qubit is |0i whenever P0 |φi = |φi, and that maps
n-qubit |ψi to a state whose first qubit is |1i whenever P1 |ψi = |ψi. We can now implement the
projective measurement by first applying a circuit that implements U , and then measuring (in thecomputational basis) the first qubit of the resulting state. The minimal-size circuit to implement
U could be very large (i.e., expensive) if the projective measurement is complicated, but that is
how it should be.
To draw quantum circuits, the convention is to let time progress from left to right: we start with
the initial state on the left. Each qubit is pictured as a horizontal wire, and the circuit prescribes
which gates are to be applied to which wires. Single-qubit gates like X and H just act on one
wire, while multi-qubit gates such as the CNOT act on multiple wires simultaneously.3 When one
qubit “controls” the application of a gate to another qubit, then the controlling wire is drawn witha dot linked vertically to the gate that is applied to the target qubit. This happens for instancewith the CNOT, where the applied single-qubit gate is X, usually drawn as ‘⊕’ in a circuit picture(similarly, the Toffoli gate is drawn in a circuit with a dot on the two control wires and an ‘⊕’ on
the target wire). Figure 2.1 gives a simple example on two qubits, initially in basis state |00i: first
apply H to the 1st qubit, then CNOT to both qubits (with the first qubit acting as the control),and then Z to the last qubit. The resulting state is √12 (|00i − |11i).
|0i

•

H

|0i

Z

Figure 2.1: Simple circuit for turning |00i into an entangled state
Note that if we have a circuit for unitary U , it is very easy to find a circuit for the inverse U −1
with the same complexity: just reverse the order of the gates, and take the inverse of each gate.
For example, if U = U1 U2 U3 , then U −1 = U3−1 U2−1 U1−1 .
3Note that the number of wires (qubits) going into a unitary must equal the number of wires going out becausea unitary is always invertible (reversible). This differs from the case of classical circuits, where non-reversible gateslike AND have more wires going in than out.

15

In analogy to the classical class BPP, we will define BQP (“Bounded-error Quantum Polynomial time”) as the class of languages that can efficiently be computed with success probability
at least 2/3 by (a family of) quantum circuits whose size grows at most polynomially with the
input length. We will study this quantum complexity class and its relation with various classicalcomplexity classes in more detail in Chapter 13.

2.2

Universality of various sets of elementary gates

Which set of elementary gates should we allow? There are several reasonable choices.
(1) The set of all 1-qubit operations together with the 2-qubit CNOT gate is universal,
meaning that any other unitary transformation can be built from these gates.
Allowing all 1-qubit gates is not very realistic from an implementational point of view, as there arecontinuously many of them, and we cannot expect experimentalists to implement gates to infinite
precision. However, the model is usually restricted, only allowing a small finite set of 1-qubit gatesfrom which all other 1-qubit gates can be efficiently approximated.
(2) The set consisting of CNOT, Hadamard, and the phase-gate T = Rπ/4 is universal
in the sense of approximation, meaning that any other unitary can be arbitrarily wellapproximated using circuits of only these gates. The Solovay-Kitaev theorem [196,Appendix 3] says that this approximation is quite efficient: we can approximate anygate on 1 or 2 qubits up to error ε using a number of gates (from our small set) thatis only polylog(1/ε), i.e., polynomial in the logarithm of 1/ε; in particular, simulating
arbitrary gates up to exponentially small error costs only a polynomial overhead.
It is often convenient to restrict to real numbers and use an even smaller set of gates:(3) The set of Hadamard and Toffoli (CCNOT) is universal for all unitaries with real
entries in the sense of approximation, meaning that any unitary with only real entries
can be arbitrarily well approximated using circuits of only these gates.

2.3

Quantum parallelism

One uniquely quantum-mechanical effect that we can use for building quantum algorithms is quantum parallelism. Suppose we have a classical algorithm that computes some function f : {0, 1}n →{0, 1}m . Then we can build a quantum circuit U (consisting only of Toffoli gates) that maps
|zi|0i → |zi|f (z)i for every z ∈ {0, 1}n . Now suppose we apply U to a superposition of all inputs z(which is easy to build using n Hadamard transforms):


X
X
1
1
U √
|zi|0i = √|zi|f (z)i.
2n z∈{0,1}n2n z∈{0,1}n
We applied U just once, but the final superposition contains f (z) for all 2n input values z! However,by itself this is not very useful and does not give more than classical randomization, since observing
the final superposition will give just one uniformly random |zi|f (z)i and all other information will
be lost. As we will see below, quantum parallelism needs to be combined with the effects ofinterference and entanglement in order to get something that is better than classical.
16

2.4

The early algorithms

The two best-known successes of quantum algorithms so far are Shor’s factoring algorithm from1994 [228] and Grover’s search algorithm from 1996 [125], which will be explained in later chapters.
Here we describe some of the earlier quantum algorithms that preceded Shor’s and Grover’s.
Virtually all quantum algorithms work with queries in some form or other. We will explain
this model here. It may look contrived at first, but eventually will lead smoothly to Shor’s andGrover’s algorithm. We should, however, emphasize that the query complexity model differs fromthe standard model described above, because the input is now given as a “black-box” (also sometimes called an “oracle”). This means that the exponential quantum-classical separations that we
describe below do not by themselves give exponential quantum-classical separations in the standard
circuit model (the same applies to Simon’s algorithm in the next chapter).
To explain the query setting, consider an N -bit input x = (x0 , . . . , xN −1 ) ∈ {0, 1}N . Usually wewill have N = 2n , so that we can address bit xi using an n-bit index i. One can think of the input
as an N -bit memory which we can access at any point of our choice (a “Random Access Memory”
or RAM). For example, a memory of N = 1024 bits can be indexed by addresses i ∈ {0, 1}10 ofn = 10 bits each. A memory access is via a so-called “black-box,” which is equipped to output thebit xi on input i. As a quantum operation, this is the following unitary mapping on n + 1 qubits:
Ox : |i, 0i → |i, xi i.
The first n qubits of the state are called the address bits (or address register), while the (n + 1)stqubit is called the target bit.4 Since this mapping must be unitary, we also have to specify what
happens if the initial value of the target bit is 1. Therefore we actually let Ox be the following
unitary transformation:
Ox : |i, bi → |i, b ⊕ xi i,here i ∈ {0, 1}n , b ∈ {0, 1}, and ⊕ denotes exclusive-or (addition modulo 2). In matrix representation, this Ox is now a permutation matrix and hence unitary. Note that a quantum computer canapply Ox on a superposition of various i, something a classical computer cannot do. One application of this black-box is called a query, and counting the required number of queries to compute
this or that function of x is something we will do a lot in the first half of these notes.
Given the ability to make a query of the above type, we can also make a query of the form|ii 7→ (−1)xi |ii by setting the target bit to the state |−i = √12 (|0i − |1i) = H|1i:
1
Ox (|ii|−i) = |ii √ (|xi i − |1 − xi i) = (−1)xi |ii|−i.
2This ±-kind of query puts the output variable in the phase of the state: if xi is 1 then we geta −1 in the phase of basis state |ii; if xi = 0 then nothing happens to |ii.5 This “phase-query”
or “phase-oracle” is sometimes more convenient than the standard type of query. We denote thecorresponding n-qubit unitary transformation by Ox,± .
4

It is a common rookie mistake to confuse the N bits of x with the n address bits; don’t fall for this!
This is sometimes called the “phase kick-back trick.” Note that for |+i = √12 (|0i + |1i), we have Ox (|ii|+i) =|ii|+i irrespective of what x is. This allows us to control on which part of the state a phase-query is applied: we put
the control qubit in state |−i for indices i where we want to apply the phase-query, and in state |+i for the indiceswhere we do to not want to apply a phase-query.
517

2.4.1

Deutsch-Jozsa

Deutsch-Jozsa problem [99]:
For N = 2n , we are given x ∈ {0, 1}N such that either(1) all xi have the same value (“constant”), or(2) N/2 of the xi are 0 and N/2 are 1 (“balanced”).
The goal is to find out whether x is constant or balanced.
The algorithm of Deutsch and Jozsa is as follows. We start in the n-qubit zero state |0n i, apply
a Hadamard transform to each qubit, apply a query (in its ±-form), apply another Hadamard toeach qubit, and then measure the final state. As a unitary transformation, the algorithm would be
H ⊗n Ox,± H ⊗n . We have drawn the corresponding quantum circuit in Figure 2.2 (where time again
progresses from left to right). Note that the number of wires going into the query is n, not N ; thebasis states on this sequence of wires specify an n-bit address.

|0i

H

|0i

H

|0i

H

H
Ox,±

H

measureH

Figure 2.2: The Deutsch-Jozsa algorithm for n = 3
Let us follow the state through these operations. Initially we have the state |0n i. By Equation (2.1) on page 14, after the first Hadamard transforms we have obtained the uniform superposition of all i:
X
1
√
|ii.
2n i∈{0,1}n
The Ox,± -query turns this intoX1√(−1)xi |ii.
n2 i∈{0,1}nApplying the second batch of Hadamards gives (again by Equation (2.1)) the final superposition
X
1 X
xi
(−1)
(−1)i·j |ji,2nnni∈{0,1}j∈{0,1}Pn

where i · j = k=1 ik jk as before. Since i · 0n = 0 for all i ∈ {0, 1}n , we see that the amplitude of
the |0n i-state in the final superposition is 1 if xi = 0 for all i,
X
1xi−1 if xi = 1 for all i,(−1) =
2n0 if x is balanced.
i∈{0,1}nHence the final observation will yield |0n i if x is constant and will yield some other state if x
is balanced. Accordingly, the Deutsch-Jozsa problem can be solved with certainty using only 1
18

quantum query and O(n) other operations (the original solution of Deutsch and Jozsa used 2
queries, the 1-query solution is from [91]).
In contrast, it is easy to see that any classical deterministic algorithm needs at least N/2 + 1
queries: if it has made only N/2 queries and seen only 0s, the correct output is still undetermined.
However, a classical algorithm can solve this problem efficiently if we allow a small error probability:
just query x at two random positions, output “constant” if those bits are the same and “balanced”
if they are different. This algorithm outputs the correct answer with probability 1 if x is constantand outputs the correct answer with probability 1/2 if x is balanced. Thus the quantum-classicalseparation of this problem only holds if we consider algorithms without error probability.

2.4.2

Bernstein-Vazirani

Bernstein-Vazirani problem [53]:
For N = 2n , we are given x ∈ {0, 1}N with the property that there is some unknown a ∈ {0, 1}nsuch that xi = (i · a) mod 2. The goal is to find a.
The Bernstein-Vazirani algorithm is exactly the same as the Deutsch-Jozsa algorithm, but now
the final observation miraculously yields a. Since (−1)xi = (−1)(i·a) mod 2 = (−1)i·a , we can write
the state obtained after the query as:
X
X
1
1
√
(−1)xi |ii = √(−1)i·a |ii.
nn
2 i∈{0,1}n2 i∈{0,1}nSince Hadamard is its own inverse, from Equation (2.1) we can see that applying a Hadamard toeach qubit of the above state will turn it into the classical state |ai. This solves the BernsteinVazirani problem with 1 query and O(n) other operations. In contrast, any classical algorithm(even a randomized one with small error probability) needs to ask n queries for information-theoretic
reasons: the final answer consists of n bits and one classical query gives at most 1 bit of information.
Bernstein and Vazirani also defined a recursive version of this problem, which can be solved
exactly by a quantum algorithm in poly(n) steps, but for which every classical randomized algorithm
needs nΩ(log n) steps.

Exercises
1. Is the controlled-NOT operation C Hermitian? Determine C −1 .
2. Construct a CNOT from two Hadamard gates and one controlled-Z (the controlled-Z gate
maps |11i 7→ −|11i and acts like the identity on the other basis states).
3. A SWAP-gate interchanges two qubits: it maps basis state |a, bi to |b, ai. Implement a SWAPgate using a few CNOTs (when using a CNOT, you’re allowed to use either of the 2 bits as
the control, but be explicit about this).
4. Show that every 1-qubit unitary with real entries can be written as a rotation matrix, possibly
preceded and followed by Z-gates. In other words, show that for every 2 × 2 real unitary U ,there exist signs s1 , s2 , s3 ∈ {1, −1} and angle θ ∈ [0, 2π) such that




1 0
cos(θ) − sin(θ)
1 0
U = s1.
0 s2sin(θ)
cos(θ)
0 s3
19

5. Let U be a 1-qubit unitary that we would like to implement in a controlled way, i.e., we want
to implement a map |ci|bi 7→ |ciU c |bi for all c, b ∈ {0, 1} (here U 0 = I and U 1 = U ). One canshow there exist 1-qubit unitaries A, B, and C, such that ABC = I and AXBXC = U (Xis the NOT-gate); you may assume this without proof. Give a circuit that acts on two qubits
and implements a controlled-U gate, using CNOTs and (uncontrolled) A, B, and C gates.
6. (H) Let C be a given quantum circuit consisting of T many gates, which may be CNOTs andsingle-qubit gates. Show that we can implement C in a controlled way using O(T ) Toffoli
gates, CNOTs and single-qubit gates, and no auxiliary qubits other than the controlling qubit.
7. (H) It is possible to avoid doing any intermediate measurements in a quantum circuit, using
one auxiliary qubit for each 1-qubit measurement that needs to be delayed until the end of
the computation. Show how.
8. (a) Give a circuit that maps |0n , bi 7→ |0n , 1 − bi for b ∈ {0, 1}, and that maps |i, bi 7→|i, bi whenever i ∈ {0, 1}n \{0n }. You are allowed to use every type of elementary gate
mentioned in the lecture notes (incl. Toffoli gates), as well as auxiliary qubits that are
initially |0i and that should be put back to |0i at the end of the computation.
(b) Suppose we can make queries of the type |i, bi 7→ |i, b ⊕ xi i to input x ∈ {0, 1}N , with
N = 2n . Let x0 be the input x with its first bit flipped (e.g., if x = 0110 then x0 = 1110).
Give a circuit that implements a query to x0 . Your circuit may use one query to x.
(c) Give a circuit that implements a query to an input x00 that is obtained from x (analogously to (b)) by setting its first bit to 0. Your circuit may use one query to x.
9. In Section 2.4 we showed that a standard query, which maps |i, bi 7→ |i, b ⊕ xi i (wherei ∈ {0, . . . , N − 1} and b ∈ {0, 1}), can be used to implement a phase-query to x, i.e., one of
the type |ii 7→ (−1)xi |ii (this is an uncontrolled phase-query).
(a) Show that a standard query can be implemented using one controlled phase-query to x
(which maps |c, ii 7→ (−1)cxi |c, ii, so the phase is added only if the control bit is c = 1),
and possibly some auxiliary qubits and other gates.
(b) Can you also implement a standard query using one or more uncontrolled phase-queries
to x, and possibly some auxiliary qubits and other gates? If yes, show how. If no, prove
why not.
10. Suppose we have a 2-bit input x = x0 x1 and a phase-query that maps
Ox,± : |bi 7→ (−1)xb |bi for b ∈ {0, 1}.
(a) Suppose we run the 1-qubit circuit HOx,± H on initial state |0i and then measure (inthe computational basis). What is the probability distribution on the output bit, as afunction of x?
(b) Now suppose the query leaves some workspace in a second qubit, which is initially |0i:0Ox,±
: |b, 0i 7→ (−1)xb |b, bi for b ∈ {0, 1}.

Suppose we just ignore the workspace and run the algorithm of (a) on the first qubit0with Ox,±
instead of Ox,± (and H ⊗ I instead of H, and initial state |00i). What is now
20

the probability distribution on the output bit (i.e., if we measure the first of the twobits)?
Comment: This exercise illustrates why it’s important to “clean up” (i.e., set back to |0i) workspace
qubits of some subroutine before running it on a superposition of inputs: the unintended entanglement
between the address and workspace registers can thwart the intended interference effects.

11. Give a randomized classical algorithm (i.e., one that can flip coins during its operation) thatmakes only two queries to x, and decides the Deutsch-Jozsa problem with success probability
at least 2/3 on every possible input. A high-level description is enough, no need to write out
the classical circuit.
12. Suppose our N -bit input x satisfies the following promise:either (1) the first N/2 bits of x are all 0 and the second N/2 bits are all 1; or (2) the numberof 1s in the first half of x plus the number of 0s in the second half, equals N/2. Modify theDeutsch-Jozsa algorithm to efficiently distinguish these two cases (1) and (2).
N corresponds to the (N + 1)-qubit
13. (H) Let N = 2n . A parity query to input x ∈ {0, 1}
PN −1
unitary map Qx : |y, bi 7→ |y, b ⊕ (x · y)i, where x · y = i=0 xi yi mod 2. For a fixed function
f : {0, 1}N → {0, 1}, give a quantum algorithm that computes f (x) using only one such query(i.e., one application of Qx ), and as many elementary gates as you want. You do not need togive the circuit in full detail, an informal description of the algorithm is good enough.

21

22

Chapter 3

Simon’s Algorithm
The Deutsch-Jozsa problem showed an exponential quantum improvement over the best deterministic classical algorithms; the Bernstein-Vazirani problem showed a polynomial improvement overthe best randomized classical algorithms that have error probability ≤ 1/3. In this chapter we will
combine these two features: we will see a computational problem due to Simon [230] where quantum
computers are provably exponentially more efficient (in terms of number of queries) than boundederror randomized algorithms. Simon’s problem may look rather contrived at first sight, but his
quantum algorithm to solve it was the main inspiration for Shor’s important quantum algorithm
for the very natural problem of integer factorization, which we will see in Chapter 5. More recently,
Simon’s algorithm itself was also used to break some classical cryptographic systems [147, 217].

3.1

The problem

Let N = 2n , and identify the set {0, . . . , N − 1} with {0, 1}n . Let j ⊕ s be the n-bit string obtainedby bitwise adding the n-bit strings j and s mod 2, so for example 00110 ⊕ 10101 = 10011.
Simon’s problem [230]:
For N = 2n , we are given x = (x0 , . . . , xN −1 ), with xi ∈ {0, 1}n , with the property that there issome unknown nonzero s ∈ {0, 1}n such that xi = xj iff (i = j or i = j ⊕ s). The goal is to find s.
Note that x, viewed as a function from {0, . . . , N − 1} to {0, . . . , N − 1}, is a 2-to-1 function,
where the 2-to-1-ness is determined by the unknown mask s. The queries to the input here areslightly different from before: the input x = (x0 , . . . , xN −1 ) now has variables xi that themselves
are n-bit strings, and one query gives such a string completely (|i, 0n i 7→ |i, xi i). However, we canalso view this problem as having n2n binary variables that we can query individually. Since we cansimulate one xi -query using only n binary queries (just query all n bits of xi ), this alternative view
will not affect the number of queries very much.

3.2

The quantum algorithm

Simon’s algorithm starts out very similar to Deutsch-Jozsa: start in a state of 2n zero qubits |0n i|0n i
and apply Hadamard transforms to the first n qubits to put them in a uniform superposition, giving
X1√|ii|0n i.
2n i∈{0,1}n23

At this point, the second n-qubit register still holds only zeroes. A query turns this intoX
1√
|ii|xi i.
2n i∈{0,1}n
Now the algorithm measures the second n-qubit register in the computational basis (see Exercise 1);
this measurement is actually not necessary, but it facilitates analysis. The measurement outcome
will be some value xi and the first register will collapse to the superposition of the two indiceshaving that xi -value:1√ (|ii + |i ⊕ si)|xi i.
2
We will now ignore the second register and apply Hadamard transforms to the first n qubits. Using
Equation (2.1) and the fact that (i ⊕ s) · j = (i · j) ⊕ (s · j), we can write the resulting state as


X
1  X
√
(−1)i·j |ji +(−1)(i⊕s)·j |ji =n+1
2
j∈{0,1}nj∈{0,1}n

√

1
2n+1

X


(−1)i·j
1 + (−1)s·j |ji .

j∈{0,1}nNote that |ji has nonzero amplitude iff s · j = 0 mod 2. Measuring the state gives a uniformly
random element from the set {j | s · j = 0 mod 2}. Accordingly, we get a linear equation that gives
information about s. We repeat this algorithm until we have obtained n − 1 independent linear
equations involving s. The solutions to these equations will be 0n and the correct s, which we cancompute efficiently by a classical algorithm (Gaussian elimination modulo 2). This can be done bymeans of a classical circuit of size roughly O(n3 ).
Note that if the j’s you have generated at some point span a space of size 2k , for some k < n−1,then the probability that your next run of the algorithm produces a j that is linearly independentof the earlier ones, is (2n−1 − 2k )/2n−1 ≥ 1/2. Hence an expected number of O(n) runs of thealgorithm suffices to find n − 1 linearly independent j’s. Simon’s algorithm thus finds s using an
expected number of O(n) xi -queries and polynomially many other operations.

3.3

Classical algorithms for Simon’s problem

3.3.1

Upper bound√Let us first sketch a classical randomized algorithm that solves Simon’s problem using O( 2n )queries. The algorithm is based on the so-called “birthday paradox,” which is the phenomenon
that in a group of only 23 people, there is already a large probability that two people share thesame birthday, despite the fact that the number of possible birthdays (365) is much larger than thenumber of people (23). The intuitive explanation is that the number of pairs of people is actuallyquadratic in the number of people, and each pair has a 1/365 probability to have the same birthday(assuming birthdays are distributed uniformly random among people). Of course, different pairs
may overlap and hence are not independent, but the idea still works.
Our algorithm will make T randomly chosen distinct queries i1 , . . . , iT , for some T to be
determined later. If there is a collision among those queries (i.e., xik = xi` for some k 6= `, so ik
24and i` happen to have the same “birthday”), then we are done, because then we know ik = i` ⊕ s,equivalently s = ik ⊕ i` . There won’t be any collisions if s = 0n , but how large should T be suchthat we are likely to see a collision in case s 6= 0n ? There are T2 = 12 T (T − 1) ≈ T 2 /2 pairs inour sequence that could be a collision, and since the indices are chosen randomly, the probability
for a fixed pair to form a collision is 1/(2n − 1). Hence by linearity of expectation,
the expected√
number of collisions in our sequence will be roughly T 2 /2n+1 . If we choose T = 2n+1 , we expect
to have roughly 1 collision in our sequence, which is good enough to find s. Of course, an expectedvalue of 1 collision does not mean that we will have at least one collision with high probability, buta slightly more involved calculation shows the latter statement as well.

3.3.2

Lower boundSimon [230]√proved that any classical randomized algorithm that finds s with high probability needs
to make Ω( 2n ) queries, so the above classical algorithm is essentially optimal. This was the firstproven exponential separation between quantum algorithms and classical bounded-error algorithms(let us stress again that this does not prove an exponential separation in the usual circuit model,
because we are counting queries rather than ordinary operations here). Simon’s algorithm inspired
Shor to his factoring algorithm, which we describe in Chapter 5.
We will prove the classical lower bound for a decision version of Simon’s problem:
Given: input x = (x0 , . . . , xN −1 ), where N = 2n and xi ∈ {0, 1}nPromise: ∃s ∈ {0, 1}n such that: xi = xj iff (i = j or i = j ⊕ s)
Task: decide whether s = 0n
Consider the input distribution µ that is defined as follows. With probability 1/2, x is a uniformly
random permutation of {0, 1}n ; this corresponds to the case s = 0n . With probability 1/2, we picka nonzero string s at random, and for each pair (i, i ⊕ s), we pick a unique value for xi = xi⊕s at
random. If there exists a randomized T -query algorithm that achieves success probability ≥ 2/3
under this input distribution µ, then there also is deterministic T -query algorithm that achieves
success probability ≥ 2/3 under µ (because the behavior of the randomized algorithm is an averageover a number of deterministic algorithms). Now consider a deterministic√ algorithm with error≤ 1/3 under µ, that makes T queries to x. We want to show that T = Ω( 2n ).
First consider the case s = 0n . We can assume the algorithm never queries the same point
twice. Then the T outcomes of the queries are T distinct n-bit strings, and each sequence of T
strings is equally likely.
Now consider the case s 6= 0n . Suppose the algorithm queries the indices i1 , . . . , iT (this sequence
depends on x) and gets outputs xi1 , . . . , xiT . Call a sequence of queries i1 , . . . , iT good if it showsa collision (i.e., xik = xi` for some k 6= `), and bad otherwise. If the sequence of queries of thealgorithm is good, then we can find s, since ik ⊕ i` = s. On the other hand, if the sequence is bad,then each sequence of T distinct outcomes is equally likely—just as in the s = 0n case! We will
now show that the probability of the bad case is very close to 1 for small T .
If i1 , . . . , ik−1 is bad, then we have excluded at most k−1
possible values of s (namely all values
2ij ⊕ ij 0 for all distinct j, j 0 ∈ [k − 1]), and all other values of s are equally likely. The probability
that the next query ik makes the sequence good, is the probability that xik = xij for some j < k,equivalently, that the set Sk = {ik ⊕ ij | j < k} happens to contain the string s. But Sk has onlyk − 1 members, while there are at least 2n − 1 − k−1equally likely remaining possibilities for s.
225This means that the probability that the sequence is still bad after query ik is made, is very close
to 1. In formulas:
Pr[i1 , . . . , iT is bad] =
≥

T
Y
k=2
T
Y

Pr[i1 , . . . , ik is bad | i1 , . . . , ik−1 is bad]
1−

k=2

≥ 1−

!

k−1

2n − 1 − k−1
2

T
X

k−1

.

2n − 1 − k−12
k=2PHere we used the fact that (1 − a)(1 − b) ≥ 1 − (a + b) if a, b ≥ 0. Note that Tk=2 (k − 1) =√T (T − 1)/2 ≈ T 2 /2, and 2n − 1 − k−1≈ 2n as long as k  2n . Hence we can approximate the2√last formula by 1 − T 2 /2n+1 . Accordingly, if T  2n then with probability nearly 1 (probability
taken over the input distribution µ) the algorithm’s sequence of queries is bad. If it gets a bad
sequence, it cannot “see” the difference between the s = 0n case and the s 6= 0n case, since bothcases result in a uniformly random√ sequence of T distinct n-bit strings as answers to the T queries.
This shows that T has to be Ω( 2n ) in order to enable the algorithm to get a good sequence ofqueries with high probability.

Exercises
1. Give the projectors of the 2n -outcome projective measurement that is applied to the whole2n-qubit state in Simon’s algorithm right after the query.
2. Analyze the different steps of Simon’s algorithm if s = 0n (so all xi -values are distinct), andshow that the final output j is uniformly distributed over {0, 1}n .
3. Suppose we run Simon’s algorithm on the following input x (with N = 8 and hence n = 3):x000 = x111 = 000
x001 = x110 = 001
x010 = x101 = 010
x011 = x100 = 011
Note that x is 2-to-1 and xi = xi⊕111 for all i ∈ {0, 1}3 , so s = 111.
(a) Give the starting state of Simon’s algorithm.
(b) Give the state after the first Hadamard transforms on the first 3 qubits.
(c) Give the state after applying the oracle query.
(d) Give the state after measuring the second register (suppose the measurement gave |001i).
P(e) Using H ⊗n |ii = √12n j∈{0,1}n (−1)i·j |ji, give the state after the final Hadamards.
(f) Why does a measurement of the first 3 qubits of the final state give information about s?
(g) Suppose the first run of the algorithm gives j = 011 and a second run gives j = 101.
Show that, assuming s 6= 000, those two runs of the algorithm already determine s.
26

4. Consider the following generalization of Simon’s problem: the input is x = (x0 , . . . , xN −1 ),with N = 2n and xi ∈ {0, 1}n , with the property that there is some unknown subspace V ⊆{0, 1}n (where {0, 1}n is the vector space of n-bit strings with entrywise addition modulo 2)
such that xi = xj iff there exists a v ∈ V such that i = j ⊕ v. The usual definition of Simon’s
problem corresponds to the case of 1-dimensional subspace V = {0, s}.
Show that one run of Simon’s algorithm now produces a j ∈ {0, 1}n that is orthogonal to thewhole subspace (i.e., j · v = 0 mod 2 for every v ∈ V ).
5. Let f : {0, 1}n → {0, 1}n−1 be a 2-to-1 function, meaning that every y ∈ {0, 1}n−1 has exactly
two distinct pre-images x, x0 ∈ {0, 1}n . Suppose there is an efficient quantum circuit (i.e.,with number of elementary gates that’s polynomial in n) to compute f , but no efficient circuitthat can produce from given x ∈ {0, 1}n an x0 6= x such that f (x) = f (x0 ).
Show how a quantum computer can efficiently generate a uniformly random y ∈ {0, 1}n−1
and an associated n-qubit state |φy i such that:(1) when asked, from |φy i you can efficiently generate an x such that f (x) = y;and(2) when asked, you can efficiently sample uniformly from the set{a ∈ {0, 1}n : a · (x ⊕ x0 ) = 0 mod 2}, where x and x0 are the two pre-images of y.
Comment: You’re not supposed to do both tasks (1) and (2) one after another, only either one of the two(whichever you’re asked to do). This problem may look arbitrary but was recently used to design an efficient protocol through which a classical computer can efficiently verify that a quantum computer works asintended [184].

6. (a) Suppose x is an N -bit string. What happens if we apply a Hadamard transform to eachX
1qubit of the N -qubit state √(−1)x·y |yi?
2N y∈{0,1}N(b) Give a quantum algorithm that uses T queries to N -bit string x, and that maps |yi 7→(−1)x·y |yi for every y ∈ {0, 1}N that contains at most T 1s (i.e., for every y of Hamming
weight ≤ T ). You can argue on a high level, no need to write out circuits in detail.
(c) (H) Give√ a quantum algorithm that with high probability outputs x, using at mostN/2 + 2 N queries to x.
(d) Argue that a classical algorithm needs at least N queries in order to have success probability > 1/2 of outputting the correct x.

27

28

Chapter 4

The Fourier Transform
4.1

The classical discrete Fourier transform

The Fourier transform occurs in many different versions throughout classical computing, in areas
ranging from signal-processing to data compression to complexity theory.
For our purposes, the Fourier transform is going to be an N × N unitary matrix, all of whose
entries have the same magnitude. For N = 2, it’s just our familiar Hadamard transform:


1
1
1
.
F2 = H = √2 1 −1
Doing something similar in 3 dimensions is impossible with real numbers: we can’t give threeorthogonal vectors in {+1, −1}3 . However, using complex numbers allows us to define the Fourier
k =1
transform for any N . Let ωN = e2πi/N be an N -th root of unity (“root of unity” means that ωNfor some integer k, in this case k = N ). The rows of the matrix will be indexed by j ∈ {0, . . . , N −1}
jk
and the columns by k ∈ {0, . . . , N − 1}. Define the (j, k)-entry of the matrix FN by √1N ωN, wherethe exponent jk is the usual product of two integers:


..
.

1 
jk
FN = √ 
·
·
·
ω
··· 
N


N
..
.
This FN is a unitary matrix, because each column has norm 1 and any two distinct columns (saythose indexed by k and k 0 ) are orthogonal:
N
−1
X


N −1
1
1 X j(k0 −k)
1 if k = k 0
jk ∗ 1jk0√ (ωN ) √ ωN =ωN=
0 otherwise
N
N
N
j=0
j=0

using the formula for geometric sums from Appendix B.1.
Since FN is unitary and symmetric, the inverse FN−1 = FN∗ only differs from FN by having minus
signs in the exponent of the entries. For a vector vP∈ RN , the vector vb = FN v is called the Fourier−1 jktransform of v.1 Its entries are given by vbj = √1N N
k=0 ωN vk .
1

The literature on Fourier analysis usually talks about the Fourier transform of a function rather than of a vector,

29

4.2

The Fast Fourier Transform

The naive way of computing the Fourier transform vb = FN v of v ∈ RN just does the matrixvector multiplication to compute all the entries of vb. This would take O(N ) steps (additions andmultiplications) per entry, and O(N 2 ) steps to compute the whole vector vb. However, there is amore efficient way of computing vb. This algorithm is called the Fast Fourier Transform (FFT, due
to Cooley and Tukey in 1965 [93]), and takes only O(N log N ) steps. This difference between thequadratic N 2 steps and the near-linear N log N is tremendously important in practice when N islarge, and is the main reason that Fourier transforms are so widely used.
We will assume N = 2n , which is usually fine because we can add zeroes to our vector to makeits dimension a power of 2 (but similar FFTs can be given also directly for most N that aren’t apower of 2). The key to the FFT is to rewrite the entries of vb as follows:
N −1

vbj

=

1 X jk
√
ωN vk
N k=0

=

1
√
N

=

1
√
2

!
X

j
jk
vk + ωNωN

j(k−1)
ωN
vk

odd k

even k1

XXp
N/2 even k

1
jk/2
j
p
ωN/2 vk + ωN!
X

N/2 odd kj(k−1)/2
ωN/2
vk

Note that we’ve rewritten the entries of the N -dimensional Fourier transform vb in terms of two
N/2-dimensional Fourier transforms, one of the even-numbered entries of v, and one of the oddnumbered entries of v.
This suggest a recursive procedure for computing vb: first separately compute the Fourier transform v[
even of the N/2-dimensional vector of even-numbered entries of v and the Fourier transformvd
odd of the N/2-dimensional vector of odd-numbered entries of v, and then compute the N entries
1jvbj = √ ([vd
vevenj + ωN
oddj ).
2
Strictly speaking this is not well-defined, because v[
even and vd
odd are just N/2-dimensional vectors.
However, if we take two copies of these N/2-dimensional vectors to get an N -dimensional vector,
defining v[[
even j+N/2 = v
evenj (and similarly for vdodd ), then it all works out.
The time T (N ) it takes to implement FN this way can be written recursively as T (N ) =2T (N/2) + O(N ), because we need to compute two N/2-dimensional Fourier transforms and doO(N ) additional operations to compute vb. This recursion works out to time T (N ) = O(N log N ),as promised. Similarly, we have an equally efficient algorithm for the inverse Fourier transform−jk
FN−1 = FN∗ , whose entries are √1N ωN.
but on finite domains that’s just a notational variant of what we do here: a vector v ∈ RN can also be viewed as afunction v : {0, . . . , N − 1} → R defined by v(i) = vi . Also, in the classical literature people sometimes use the term
“Fourier transform” for what we call the inverse Fourier transform.

30

4.3

Application: multiplying two polynomials

Suppose we are given two real-valued polynomials p and q, each of degree at most d:p(x) =dXj

aj x and q(x) =

j=0

d
X

bk xk

k=0

We would like to compute the product of these two polynomials, which is


!
d
d
2d X
2d
X
X
X
(p · q)(x) = 
aj xj bk xk =(
aj b`−j )x` ,
j=0

k=0

`=0 j=0

|

{z
c`

}

where implicitly we set aj = bj = 0 for j > d and b`−j = 0 if j > `. Clearly, each coefficient c` byitself takes O(d) steps (additions and multiplications) to compute, which suggests an algorithm forcomputing the coefficients of p · q that takes O(d2 ) steps. However, using the fast Fourier transform
we can do this in O(d log d) steps, as follows.
The convolutionof two vectors a, b ∈ RN is a vector a ∗ b ∈ RN whose `-th entry is definedPN−1by (a ∗ b)` = √1N j=0
aj b`−jmodN . Let us set N = 2d + 1 (the number of nonzero coefficientsof p · q) and make the above (d + 1)-dimensional vectors of coefficients a and b N -dimensional byadding d zeroes. Then
√ the coefficients of the polynomial p · q are proportional to the entries of the
convolution: c` = N (a ∗ b)` . It is easy to show that the Fourier coefficients of the convolution ofa and b are the products of the Fourier coefficients of a and b: for every ` ∈ {0, . . . , N − 1} we have

ad
∗b =b
a` ·bb` . This immediately suggests an algorithm for computing the vector of coefficients c` :`dapply the FFT to a and b to get ba and bb, multiply those two√ vectors entrywise to get a ∗ b, apply
the inverse FFT to get a ∗ b, and finally multiply a ∗ b with N to get the vector c of the coefficientsof p · q. Since the FFTs and their inverse take O(N log N ) steps, and pointwise multiplication of
two N -dimensional vectors takes O(N ) steps, this algorithm takes O(N log N ) = O(d log d) steps.
Note that if two numbers ad · · · a1 a0 and bd · · · b1 b0 are given in decimal notation, then we caninterpretPtheir digits as coefficients
P of single-variate degree-d polynomials p and q, respectively:p(x) = dj=0 aj xj and q(x) = dk=0 bk xk . The two numbers will now be p(10) and q(10). Theirproduct is the evaluation of the product-polynomial p · q at the point x = 10. This suggests that
we can use the above procedure (for fast multiplication of polynomials) to multiply two numbers inO(d log d) steps, which would be a lot faster than the standard O(d2 ) algorithm for multiplicationthat one learns in primary school. However, in this case we have to be careful since the steps of theabove algorithm are themselves multiplications between numbers, which we cannot count at unit
cost anymore if our goal is to implement a multiplication between numbers! Still, it turns out that
implementing this idea carefully allows one to multiply two d-digit numbers in O(d log d log log d)elementary operations. This is known as the Schönhage-Strassen algorithm [218] (slightly improved
further by Fürer [116] and Harvey and van der Hoeven [135]), and is one of the ingredients of Shor’salgorithm in the next chapter. We’ll skip the details.

4.4

The quantum Fourier transform

Since FN is an N × N unitary matrix, we can interpret it as a quantum operation, mapping an N dimensional vector of amplitudes to another N -dimensional vector of amplitudes. This is called the31quantum Fourier transform (QFT). In case N = 2n (which is the only case we will care about), thiswill be an n-qubit unitary. Notice carefully that this quantum operation does something different
from the classical Fourier transform: in the classical case we are given a vector v, written on a pieceof paper so to say, and we compute the vector vb = FN v, and also write the result on a piece of
paper. In the quantum case, we are working on quantum states; these are vectors of amplitudes, but
we don’t have those written down anywhere—they only exist as the amplitudes in a superposition.
We will see below that the QFT can be implemented by a quantum circuit using O(n2 ) elementarygates. This is exponentially faster than even the FFT (which takes O(N log N ) = O(2n n) steps),
but it achieves something different: computing the QFT won’t give us the entries of the Fouriertransform written down on a piece of paper, but only as the amplitudes of the resulting state.

4.5

An efficient quantum circuit

Here we will describe the efficient circuit for the n-qubit QFT. The elementary gates we will allow
ourselves are Hadamards and controlled-Rs gates, where


1
0
Rs =
.
s
0 e2πi/2




1 0
1
0
s
. For large s, e2πi/2 is close to 1 and hence, R2 =
Note that R1 = Z =0 i
0 −1
the Rs -gate is close to the identity-gate I. We could implement Rs -gates using Hadamards andcontrolled-R1/2/3 gates, but for simplicity we will just treat each Rs as an elementary gate.
Since the QFT is linear, it suffices if our circuit implements it correctly on all n-qubit basis
states |ki, i.e., it should map
N −1
1 X jk|ki 7→ FN |ki = √ωN |ji.
N j=0
The key to doing this efficiently is to rewrite FN |ki, which turns out to be a product state (so FN
does not introduce entanglement when applied to a basis state |ki), as follows. Let |ki =P|k1 . . . kn i,
k1 being the most significant bit. Note that for integer j = j1 . . . jn , we can write j/2n = n`=1 j` 2−` .
For example, binary 0.101 is 1 · 2−1 + 0 · 2−2 + 1 · 2−3 = 5/8. We have the following sequence ofequalities (which is probably most easily verified by working backwards from the last formula):
N −1

FN |ki ==1 X 2πijk/2n
√
e
|ji
N j=0
Pn
X
1
−`
√
e2πi( `=1 j` 2 )k |j1 . . . jn in2 j∈{0,1}n

=

n
X Y
1
`
√
e2πij` k/2 |j1 . . . jn in2 j∈{0,1}n `=1

=

n

O
1 
`
√ |0i + e2πik/2 |1i .
2
`=1

`

Note that e2πik/2 = e2πi k1 ...kn−` .kn−`+1 ...kn = e2πi 0.kn−`+1 ...kn : the n − ` most significant bits of k
don’t matter for this value, because e2πim = 1 if m is an integer.
32

As an example, for n = 3 we have the 3-qubit product state
1
1
1
F8 |k1 k2 k3 i = √ (|0i + e2πi0.k3 |1i) ⊗ √ (|0i + e2πi0.k2 k3 |1i) ⊗ √ (|0i + e2πi0.k1 k2 k3 |1i).
2
22This example suggests what the circuit should be. To prepare the first qubit of the desired state
F8 |k1 k2 k3 i, we can just apply a Hadamard to |k3 i, giving state √12 (|0i+(−1)k3 |1i) and observe that(−1)k3 = e2πi0.k3 . To prepare the second qubit of the desired state, apply a Hadamard to |k2 i, giving√1 (|0i + e2πi0.k2 |1i), and then conditioned on k3 (before we apply the Hadamard to |k3 i) apply R2 .
2This multiplies |1i with a phase e2πi0.0k3 , producing the correct qubit √12 (|0i+e2πi0.k2 k3 |1i). Finally,
to prepare the third qubit of the desired state, we apply a Hadamard to |k1 i, apply R2 conditioned
on k2 , and R3 conditioned on k3 . This produces the correct qubit √12 (|0i + e2πi0.k1 k2 k3 |1i). We have
now produced all three qubits of the desired state F8 |k1 k2 k3 i, but in the wrong order : the first
qubit should be the third and vice versa. So the final step is just to swap qubits 1 and 3. Figure 4.1
illustrates the circuit in the case n = 3. Here the black circles indicate the control-qubits for eachof the controlled-Rs operations, and the operation at the end of the circuit swaps qubits 1 and 3.
The general case works analogously: starting with ` = 1, we apply a Hadamard to |k` i and then“rotate in” the additional phases required, conditioned on the values of the later bits k`+1 . . . kn .
Some swap gates at the end then put the qubits in the right order.2

Figure 4.1: The circuit for the 3-qubit QFT
Since the circuit involves n qubits, and at most n gates are applied to each qubit, the overall
circuit uses at most n2 gates. In fact, many of those gates are phase gates Rs with s  log n, which
are very close to the identity and hence don’t do much anyway. As observed by Coppersmith [94],we can actually omit those from the circuit, keeping only O(log n) gates per qubit and O(n log n)gates overall. Intuitively, the overall error caused by these omissions will be small (Exercise 4 asks
you to make this precise). Finally, note that by inverting the circuit (i.e., reversing the order ofthe gates and taking the adjoint U ∗ of each gate U ) we obtain an equally efficient circuit for the
inverse Fourier transform FN−1 = FN∗ .

4.6

Application: phase estimation

An important applications of the QFT is in phase estimation. This was originally due to Kitaev [155], it was put in a broader context by Cleve et al. [91], and is now a very common subroutine
2

We can implement a SWAP-gate using CNOTs (Exercise 2.3); CNOTs and controlled-Rs gates can be constructedfrom Hadamard and controlled-R1 (= controlled-Z) gates, which are in the allowed set of elementary gates here.

33

in many quantum algorithms.
Suppose we can apply a unitary U and we are given an eigenvector |ψi of U with corresponding
unknown eigenvalue λ (i.e., U |ψi = λ|ψi), and we would like to compute or at least approximate
the λ. Since U is unitary, λ must have magnitude 1, so we can write it as λ = e2πiφ for some real
number φ ∈ [0, 1); the only thing that matters is this phase φ. Suppose for simplicity that we knowthat φ = 0.φ1 . . . φn can be written exactly with n bits of precision. Then here’s the algorithm forphase estimation:
1. Start with |0n i|ψi.
2. For N = 2n , apply FN to the first n qubits to get √12n
(in fact, H ⊗n ⊗ I would have the same effect).

PN −1
j=0

|ji|ψi

3. Apply the map |ji|ψi 7→ |jiU j |ψi = e2πiφj |ji|ψi. In other words, apply U to the second
register for a number of times given by the first register.
4. Apply the inverse Fourier transform FN−1 to the first n qubits and measure the result.
P −1 2πiφj
Note that after step 3, the first n qubits are in state √1N N|ji = FN |2n φi, hence (under
j=0 e
the assumption that φ can be written exactly with n bits) the inverse Fourier transform is goingto give us |2n φi = |φ1 . . . φn i with probability 1.
In case φ cannot be written exactly with n bits of precision, then one can show that thisprocedure still (with high probability) spits out a good n-bit approximation to φ. We’ll omit thecalculation.

Exercises


 

0
1
1 1
1
1. For ω = e2πi/3 and F3 = √13  1 ω ω 2 , calculate F3  1  and F3  ω 2 ω
1 ω2 ω
0

2. Prove that the Fourier coefficients of the convolution of vectors a and b are the product of
the Fourier coefficients of a and b. In other words, prove that for every a, b ∈ RN and every` ∈ {0, . . . , N − 1} we have ad∗b =ba` · bb` . Here the Fourier transform b
a is defined as the
`
PN −1
1
vector FN a, and the `-entry of the convolution-vector a∗b is (a∗b)` = √N j=0 aj b(`−j)modN .
3. (H) The total variation distance between
two probability distributions P and Q on the sameP
set, is defined as dT V D (P, Q) = 12 i |P (i) − Q(i)|. An equivalent alternative way to define
this: dT V D (P, Q) is the maximum, over all events E, of |P (E) − Q(E)|. Hence dT V D (P, Q)
is small iff all events have roughly the same probability under P and under Q.
PP
The Euclideanp
distance
between two states |φi = i αi |ii and |ψi = i βi |ii is defined asP
2
k|φi − |ψik =i |αi − βi | . Assume the two states are unit vectors with (for simplicity)
real amplitudes. Suppose the Euclidean distance is small: k|φi − |ψik = . If we measure |φiin the computational basis then the probability distribution over the outcomes is given by
the |αi |2 , and if we measure |ψi then thePprobabilities are |βi |2 . Show that these distributions
are close: the total variation distance 21 i αi2 − βi2 is ≤ .
34

4. (H) The operator norm of a matrix A is defined as kAk = max kAvk.
v:kvk=1

An equivalent definition is that kAk is the largest singular value of A (see Appendix A.5).
The distance between two matrices A and B is defined as kA − Bk.
(a) What is the distance between the 2 × 2 identity matrix and the phase-gate

1
0
0 eiφ


?

(b) What is the distance between the 4 × 4 identity matrix and the controlled version of thephase gate of (a)?
(c) What is the distance between the 2n × 2n identity matrix I2n and the controlled phasegate of (b) tensored with I2n−2 ?
(d) Suppose we have a product of n-qubit unitaries U = UT UT −1 · · · U1 (for instance, each Ui
could be an elementary gate on a few qubits, tensored with identity on the other qubits).
Suppose we drop the j-th gate from this sequence: U 0 = UT UT −1 · · · Uj+1 Uj−1 · · · U1 .
Show that kU 0 − U k = kI − Uj k.
(e) Now we also drop the k-th unitary: U 00 = UT UT −1 · · · Uj+1 Uj−1 · · · · · · Uk+1 Uk−1 · · · U1 .
Show that kU 00 − U k ≤ kI − Uj k + kI − Uk k.
(f) Give a quantum circuit with O(n log n) elementary gates that has distance less than 1/nfrom the Fourier transform F2n .
Comment: The above exercise shows the important fact that if we have a quantum circuit C that has various
subparts (“subroutines”), then a circuit C̃ where those subroutines are implemented with small operator-norm
error, rather than perfectly, still works well: if C − C̃ is small then (by definition of operator norm) for all
initial states |φi the states C|φi and C̃|φi are close in Euclidean distance. By Exercise 3 then also the final
output distributions are close (in total variation distance).

5. Suppose a ∈ RN is a vector (indexed by ` = 0, . . . , N − 1) which is r-periodic in the following
sense: there exists an integer r such that a` = 1 whenever ` is an integer multiple of r, anda` = 0 otherwise. Compute the Fourier transform FN a of this vector, i.e., write down aformula for the entries of the vector FN a. Assuming r divides N , write down a simple closed
form for the formula for the entries. Which are the nonzero entries in the vector FN a, andwhat is their magnitude?
6. (a) The squared Fourier transform, FN2 , turns out to map computational basis states tocomputational basis states. Describe this map, i.e., determine to which basis state abasis state |ki gets mapped for each k ∈ {0, 1}n .
(b) Show that FN4 = I. What can you conclude about the eigenvalues of FN ?

35

36

Chapter 5

Shor’s Factoring Algorithm
5.1

Factoring

Probably the most important quantum algorithm so far is Shor’s factoring algorithm [228]. It canfind a factor of a composite number N in roughly (log N )2 steps, which is polynomial in the lengthlog N of the input. On the other hand, there is no known classical (deterministic or randomized)
algorithm that can factor N in polynomial time. The best known classical randomized algorithms
run in time roughly
α2(log N ) ,where α = 1/3 for a heuristic upper bound [165] and α = 1/2 for a less-heuristic but still not fully
proven upper bound [166]. In fact, much of modern cryptography is based on the conjecture thatno fast classical factoring algorithm exists [211]. All this cryptography (for example RSA) would
be broken if Shor’s algorithm could be physically realized. In terms of complexity classes: factoring(rather, the decision problem equivalent to it) is provably in BQP but is not known to be in BPP.
If indeed factoring is not in BPP, then the quantum computer would be the first counterexample
to the “strong” Church-Turing thesis, which states that all “reasonable” models of computation
are polynomially equivalent (see [107] and [198, p.31,36]).

5.2

Reduction from factoring to period-finding

The crucial observation of Shor was that there is an efficient quantum algorithm for the problemof period-finding and that factoring can be reduced to this, in the sense that an efficient algorithm
for period-finding implies an efficient algorithm for factoring.
We first explain the reduction. Suppose we want to find factors of the composite number N > 1.
We may assume N is odd and not a prime power, since those cases can easily be filtered out by aclassical algorithm. Now randomly choose some integer x ∈ {2, . . . , N − 1} which is coprime1 to
N . If x is not coprime to N , then the greatest common divisor of x and N is a nontrivial factorof N , so then we are already done. From now on consider x and N are coprime, so x is an element
1

The greatest common divisor of two integers a and b is the largest positive integer c that divides both a and b.
If gcd(a, b) = 1, then a and b are called coprime. The gcd can be computed efficiently (in time roughly quadratic in
the number of bits of a and b) on a classical computer by Euclid’s algorithm.

37

of the multiplicative group Z∗N . Consider the sequence
1 = x0(mod N ),x1(mod N ),x2(mod N ), . . .

This sequence will cycle after a while: there is a least 0 < r ≤ N such that xr = 1 (mod N ). Thisr is called the period of the sequence (a.k.a. the order of the element x in the group Z∗N ). Assuming
N is odd and not a prime power (those cases are easy to factor anyway), it can be shown thatwith probability ≥ 1/2, the period r is even and xr/2 + 1 and xr/2 − 1 are not multiples of N [196,
Theorem A4.13]. In that case we have:xr ≡ 1
(x

r/2

(x

r/2

mod N

⇐⇒

(x

r/2 2

≡ 1

mod N

⇐⇒

+ 1)(xr/2− 1) ≡ 0

mod N

⇐⇒

+ 1)(xr/2− 1) = kN for some k.

)

Note that k > 0 because both xr/2 + 1 > 0 and xr/2 − 1 > 0 (x > 1). Hence xr/2 + 1 or xr/2 − 1will share a factor with N . Because xr/2 + 1 and xr/2 − 1 are not multiples of N this factor willbe < N , and in fact both these numbers will share a non-trivial factor with N . Accordingly, if wehave r then we can compute the greatest common divisors gcd(xr/2 + 1, N ) and gcd(xr/2 − 1, N ),and both of these two numbers will be non-trivial factors of N . If we are unlucky we might havechosen an x that does not give a factor (which we can detect efficiently), but trying a few different
random x gives a high probability of finding a factor.
Thus the problem of factoring reduces to finding the period r of the function given by modular
exponentiation f (a) = xa mod N . In general, the period-finding problem can be stated as follows:
The period-finding problem:
We are given some function f : N → {0, . . . , N − 1} with the property that there is some unknownr ∈ {0, . . . , N − 1} such that f (a) = f (b) iff a = b mod r. The goal is to find r.
One might think that if f itself is efficiently computable, then period-finding is an easy problem tosolve even on a classical computer: just compute f (0), f (1), f (2), . . . until we encounter the value
f (0) for the second time. The input at which this happens is the period r that we’re trying tofind. The problem with this approach is that r could be huge, for instance N 1/2 or N 1/100 , whichis exponentially large in the number of inputs bits. To be efficient, we would like a runtime thatis polynomial in log N , since that is the bitsize of the inputs to f . It is generally believed thatclassical computers cannot solve period-finding efficiently.
We will show below how we can solve this problem efficiently on a quantum computer, using
only O(log log N ) evaluations of f and O(log log N ) quantum Fourier transforms. An evaluationof f can be viewed as analogous to the application of a query in the algorithms of the previous
chapters. Even a somewhat more general kind of period-finding can be solved by Shor’s algorithmwith very few f -evaluations,whereas any classical bounded-error algorithm would need to evaluate√
1/3
the function Ω(N / log N ) times in order to find the period [88].
How many steps (elementary gates) does Shor’s algorithm take? For a = N O(1) , we can compute f (a) = xa mod N in O((log N )2 log log N log log log N ) steps by the “square-and-multiply”
method, using known algorithms for fast integer multiplication mod N , see Exercise 1.
Moreover, as explained in the previous chapter, the quantum Fourier transform can be implemented using O((log N )2 ) steps. Accordingly, Shor’s algorithm finds a factor of N using an
38

expected number of O((log N )2 (log log N )2 log log log N ) gates, which is only slightly worse thanquadratic in the input length.

5.3

Shor’s period-finding algorithm

Now we will show how Shor’s algorithm finds the period r of the function f , given a “black-box” thatmaps |ai|0n i 7→ |ai|f (a)i. We can always efficiently pick some q = 2` such that N 2 < q ≤ 2N 2 .
Then we can implement the Fourier transform Fq using O((log N )2 ) gates. Let Of denote theunitary that maps |ai|0n i 7→ |ai|f (a)i, where the first register consists of ` qubits, and the secondof n = dlog N e qubits.
|0i
..
.

Fq

Fq

.. measure
.

|0i
Of

|0i
..
.

..
.

measure|0i
Figure 5.1: Shor’s period-finding algorithm
Shor’s period-finding algorithm is illustrated in Figure 5.1.2 Start with |0` i|0n i. Apply the
QFT (or just ` Hadamard gates) to the first register to build the uniform superposition
q−1

1 X|ai|0n i.
√q
a=0

The second register still consists of zeroes. Now use the “black-box” to compute f (a) in quantum
parallel:q−1
1 X|ai|f (a)i.
√q
a=0

Observing the second register gives some value f (s), with s < r. Let m be the number of elementsof {0, . . . , q − 1} that map to the observed value f (s). Because f (a) = f (s) iff a = s mod r, thea of the form a = jr + s (0 ≤ j < m) are exactly the a for which f (a) = f (s). Thus the firstregister collapses to a superposition of |si, |r + si, |2r + si, |3r + si, . . .; this superposition runs until
the last number of the form jr + s that is < q, let’s define m to be the number of elements inthis superposition, i.e., the number of integers j such that jr + s ∈ {0, . . . , q − 1} (depending on s,
2
Notice the resemblance of the basic structure (Fourier, f -evaluation, Fourier) with the basic structure of Simon’salgorithm (Hadamard, query, Hadamard). This is not a coincidence, because Shor was inspired by reading Simon’s
paper. The number of qubits used is roughly 3 log N : log q ≈ 2 log N qubits for the first register, and dlog N e for thesecond register. This number can be reduced to slightly more than 2 log N qubits [38, 131]. Accordingly, to factor
for instance a 2048-bit integer N , slightly more than 4096 (perfect) qubits suffice.

39

this m will be dq/re or bq/rc). The second register collapses to the classical state |f (s)i. We can
now ignore the second register, and have in the first:
m−1

1 X
√
|jr + si.
m
j=0

Applying the QFT again gives


q−1
q−1
m−1
m−1
X
X
jrb
sb
1 X 1 X 2πi (jr+s)b12πi2πi q q√e|bi = √
e q 
e
|bi.
√
q
mq
m
j=0

b=0

j=0

b=0

We want to see which |bi have amplitudes withabsolute value—those are the b we are
P largej squared m
likely to see if we now measure. Using that m−1
z
=
(1
−
z
)/(1 − z) for z 6= 1 (see Appendix B),
j=0
we compute:
2πi rbm−1
if e q = 1
X  2πi rb j  m
X 2πi jrb m−1q =2πi mrb
e
=
(5.1)
e q
2πi rb 1−e rbq
if e q 6= 1
2πi
j=0
j=0
1−e

q

Easy case: r divides q. Let us do an easy case first. Suppose r divides q, so the whole period“fits” an integer number of times in the domain {0, . . . , q − 1} of f , and m = q/r. For the firstcase of Eq. (5.1), note that e2πirb/q = 1 iff rb/q is an integer iff b is a multiple of q/r. Such b will√
have squared amplitude equal to (m/ mq)2 = m/q = 1/r. Since there are exactly r such basis
states b, together they have all the amplitude: the sum of squares of those amplitudes is 1, so
the amplitudes of b that are not integer multiples of q/r must all be 0. Thus we are left with asuperposition where only the b that are integer multiples of q/r have nonzero amplitude. Observing
this final superposition gives some random multiple b = cq/r, with c a uniformly random numberin {0, . . . , r − 1}. Thus we get a b such that
b
c
= ,
q
r
where b and q are known to the algorithm, and c and r are not. There are φ(r) ∈ Ω(r/ log log r)
numbers smaller than r that are coprime to r [133, Theorem 328], so c will be coprime to r withprobability Ω(1/ log log r) ≥ Ω(1/ log log N ). Accordingly, an expected number of O(log log N )repetitions of the procedure of this section suffices to obtain a b = cq/r with c coprime to r.3 Once
we have such a b, we can obtain r as the denominator by writing b/q in lowest terms. Of course,
our algorithm doesn’t actually know whether c and r are coprime in some particular run of thealgorithm, but it can efficiently check if the purported factors gcd(xr/2 ± 1) are actual factors of N
by division (which, like multiplication, can be done classically with a near-linear number of gates).
Hard case: r does not divide q. Because our q is a power of 2, it is actually quite likely thatr does not divide q. However, the same algorithm will still yield with high probability a b which
is close to a multiple of q/r. Note that q/r is no longer an integer, and m = bq/rc, possibly +1.
3

The number of required f -evaluations for period-finding can actually be reduced from O(log log N ) to O(1).

40All calculations up to and including Eq. (5.1) are still valid. Using |1 − eiθ | = 2| sin(θ/2)|, we canrewrite the absolute value of the second case of Eq. (5.1) to|1 − e2πi mrbq|1 − e2πi rbq||=| sin(πmrb/q)|.
| sin(πrb/q)|

The right-hand side is the ratio of two sine-functions of b, where the numerator oscillates much
faster than the denominator because of the additional factor of m. Note that the denominator isclose to 0 (making the ratio large) iff b is close to an integer multiple of q/r. For most of those b,
the numerator won’t be close to 0. Hence, roughly speaking, the ratio will be small if b is far
from an integer multiple of q/r, and large for most b that are close to a multiple of q/r. Doingthe calculation precisely, one can show that with high probability (see [228, 196] for details) the
measurement yields a b such that
b c
1
−
≤ ,
q r
2q
for a random c ∈ {0, . . . , r − 1}. Equivalently, |b − cq/r| ≤ 1/2, so the measurement outcome b will
be an integer multiple of q/r rounded up or down to an integer. As in the easy case, b and q are
known to us while c and r are unknown.
Because the known ratio b/q is now not exactly equal to the unknown ratio q/r, we cannot justtry to find r by writing b/q in lowest terms like we did in the easy case. However, two distinct
fractions, each with denominator ≤ N , must be at least 1/N 2 > 1/q apart.4 Therefore c/r is the
only fraction with denominator ≤ N at distance ≤ 1/2q from the known ratio b/q. Applying aclassical method called “continued-fraction expansion” to b/q efficiently gives us the fraction withdenominator ≤ N that is closest to b/q (see next section). This fraction must be c/r. Again, c andr will be coprime with probability Ω(1/ log log r), in which case writing c/r in lowest terms gives r.

5.4

Continued fractions

Let [a0 , a1 , a2 , . . .] (finite or infinite) denote the real number
a0 +1
a1 + a +1 1
2...

This is called a continued fraction (CF). The ai are the partial quotients. We assume these to bepositive natural numbers ([133, p.131] calls such CF “simple”). [a0 , . . . , an ] is the n-th convergent of
the fraction. [133, Theorem 149 & 157] gives a simple way to compute numerator and denominatorof the n-th convergent from the partial quotients:
If
p0 = a0 , p1 = a1 a0 + 1, pn = an pn−1 + pn−2q0 = 1, q1 = a1 ,qn = an qn−1 + qn−2
then [a0 , . . . , an ] =pn. Moreover, this fraction is in lowest terms.
qnConsider two fractions c/r and c0 /r0 with integer c, c0 , r, r0 , and r, r0 ≤ N . If c/r 6= c0 /r0 then cr0 − c0 r is a nonzero
integer, and hence |c/r − c0 /r0 | = |(cr0 − c0 r)/rr0 | ≥ 1/|rr0 | ≥ 1/N 2 .
441Note that qn increases at least exponentially with n (qn ≥ 2qn−2 ). Given a real number x, thefollowing “algorithm” gives a continued fraction expansion of x [133, p.135]:
a0 := bxc, x1 := 1/(x − a0 )a1 := bx1 c, x2 := 1/(x1 − a1 )
a2 := bx2 c, x3 := 1/(x2 − a2 )...
Informally, we just take the integer part of the number as the partial quotient and continue with theinverse of the decimal part of the number. The convergents of the CF approximate x as follows [133,
Theorem 164 & 171]:
If x = [a0 , a1 , . . .] then x −

pn
1
< 2.
qn
qn

Recall that qn increases exponentially with n, so this convergence is quite fast. Moreover, pn /qn
provides the best approximation of x among all fractions with denominator ≤ qn [133, Theorem 181]:
If n > 1, q ≤ qn , p/q 6= pn /qn , then x −pnp< x− .
qn
q

Exercises
1. This exercise is about efficient classical implementation of modular exponentiation.
(a) (H) Given n-bit numbers x and N , compute the whole sequencen−1
x0 mod N , x1 mod N , x2 mod N , x4 mod N , x8 mod N , x16 mod N, . . . , x2
mod N ,
2
using O(n log(n) log log(n)) steps.
(b) Suppose n-bit number a can be written as a = an−1 . . . a1 a0 in binary. Express xa mod
N as a product of the numbers computed in part (a).
(c) Show that you can compute f (a) = xa mod N in O(n2 log(n) log log(n)) steps.
2. Consider the function f (a) = 7a mod 10.
(a) What is the period r of f ?
(b) Show how Shor’s algorithm finds the period of f , using a Fourier transform over q = 128
elements. Write down all intermediate superpositions of the algorithm for this case(don’t just copy the general expressions from the notes, but instantiate them with actual
numbers as much as possible, incl. with the value of the period found in (a)). You may
assume you’re lucky, meaning the first run of the algorithm already gives a measurement
outcome b = cq/r with c coprime to r.
3. (H) This exercise explains basic RSA encryption. Suppose Alice wants to allow other people
to send encrypted messages to her, such that she is the only one who can decrypt them.
She believes that factoring an n-bit number can’t be done efficiently (efficient = in timepolynomial in n). So in particular, she doesn’t believe in quantum computing.
Alice chooses two large random prime numbers, p and q, and computes their product N =p · q (a typical size is to have N a number of n = 1024 bits, which corresponds to both42

p and q being numbers of roughly 512 bits). She computes the so-called Euler φ-function:φ(N ) = (p − 1)(q − 1); she also chooses an encryption exponent e, which doesn’t share any
nontrivial factor with φ(N ) (i.e., e and φ(N ) are coprime). Group theory guarantees there isan efficiently computable decryption exponent d such that de = 1 mod φ(N ). The public key
consists of e and N (Alice puts this on her homepage), while the secret key consists of d and N .
Any number m ∈ {1, . . . , N − 1} that is coprime to N , can be used as a message. There areφ(N ) such m, and these numbers form a group under the operation of multiplication mod
N . The number of bits n = dlog N e of N is the maximal length (in bits) of a message m andalso the length (in bits) of the encryption. The encryption function is defined as C(m) = me
mod N , and the decryption function is D(c) = cd mod N .
(a) Give a randomized algorithm by which Alice can efficiently generate the secret and publickey.
(b) Show that Bob can efficiently compute the encoding C(m) of the message m that hewants to send to Alice, knowing the public key but not the private key.
(c) Show that D(C(m)) = m for all possible messages.
(d) Show that Alice can efficiently decrypt the encryption C(m) she receives from Bob.
(e) Show that if Charlie could factor N , then he could efficiently decrypt Bob’s message.

43

44

Chapter 6

Hidden Subgroup Problem
6.1

Hidden Subgroup Problem

6.1.1

Group theory reminder

A group G consists of a set of elements (which is usually denoted by G as well) and an operation◦ : G × G → G (often written as addition or multiplication), such that
1. the operation is associative: g ◦ (h ◦ k) = (g ◦ h) ◦ k for all g, h, k ∈ G;
2. there is an identity element e ∈ G satisfying e ◦ g = g ◦ e = g for every g ∈ G;
3. and every g ∈ G has an inverse g −1 ∈ G, such that g ◦ g −1 = g −1 ◦ g = e (if the group
operation is written as addition, then g −1 is written as −g).
We often abbreviate g ◦ h to gh. The group is Abelian (or commutative) if gh = hg for all g, h ∈ G.
Simple examples of finite additive Abelian groups are G = {0, 1}n with bitwise addition mod 2
as the group operation, and G = ZN , the “cyclic group” of integers mod N . The set G = Z∗N is
the multiplicative group consisting of all integers in {1, . . . , N − 1} that are coprime to N , withmultiplication mod N as the group operation.1 An important example of a non-Abelian group is
the “symmetric group” Sn , which is the group of n! permutations of n elements, using composition
as the group operation.
A subgroup H of G, denoted H ≤ G, is a subset of G that is itself a group, i.e., it contains e
and is closed under taking products and inverses. A (left) coset of H is a set gH = {gh | h ∈ H},
i.e., a translation of H by the element g. All cosets of H have size |H|, and it is easy to show that
two cosets gH and g 0 H are either equal or disjoint, so the set of cosets partitions G into equal-sizedparts.2 Note that g and g 0 are in the same coset of H iff g −1 g 0 ∈ H.
If T ⊆ G, then we use hT i to denote the set of elements of G that we can write as products ofelements from T and their inverses. This H = hT i is a subgroup of G, and T is called a generating
set of H. Note that adding one more element t 6∈ hT i to T at least doubles the size of the generated
subgroup, because H and tH are disjoint and H ∪ tH ⊆ hT ∪ {t}i. This implies that every H ≤ G
Euler’s φ-function counts the number of elements of {1, . . . , N − 1} that are coprime to N , so |Z∗N | = φ(N ).
Note that for prime p, the multiplicative Abelian group Z∗p is isomorphic to the additive group Zp−1 . However, forgeneral N , Z∗N need not be isomorphic to Zφ(N ) .
2
This also proves Lagrange’s theorem for finite groups: if H ≤ G then |H| divides |G|.
1

45

has a generating set of size ≤ log |H| ≤ log |G|. We abbreviate h{γ}i to hγi, which is the cyclic
group generated by γ; every cyclic group of size N is isomorphic to ZN .

6.1.2

Definition and some instances of the HSP

The Hidden Subgroup Problem is the following:
Given a known group G and a function f : G → S where S is some finite set.
Suppose f has the property that there exists a subgroup H ≤ G such that f is constantwithin each coset, and distinct on different cosets: f (g) = f (g 0 ) iff gH = g 0 H.
Goal: find H.
We assume f can be computed efficiently, meaning in time polynomial in log |G| (the latter is thenumber of bits needed to describe an input g ∈ G for f ). Since H may be large, “finding H”
typically means finding a generating set for H.
This looks like a rather abstract algebraic problem, but many important problems can be written
as an instance of the HSP. We will start with some examples where G is Abelian.
Simon’s problem. This is a very natural instance of HSP. Here G is the additive group Zn2 ={0, 1}n of size 2n , H = {0, s} for a “hidden” s ∈ {0, 1}n , and f satisfies f (x) = f (y) iff x − y ∈ H.
Clearly, finding the generator of H (i.e., finding s) solves Simon’s problem.
Period-finding. As we saw in Chapter 5, we can factor a large number N if we can solve thefollowing: given an x that is coprime to N and associated function f : Z → Z∗N by f (a) = xa mod N ,find the period r of f .3 Since hxi is a size-r subgroup of the group Z∗N , the period r divides|Z∗N | = φ(N ). Hence we can restrict the domain of f to Zφ(N ) .
Period-finding is an instance of the HSP as follows. Let G = Zφ(N ) and consider its subgroup
H = hri of all multiples of r up to φ(N ) (i.e., H = rZφ(N ) = {0, r, 2r, . . . , φ(N ) − r}). Note that
because of its periodicity, f is constant on each coset s + H of H, and distinct on different cosets.
Also, f is efficiently computable by repeated squaring. Since the hidden subgroup H is generated
by r, finding the generator of H solves the period-finding problem.
Discrete logarithm. Another problem often used in classical public-key cryptography is thediscrete logarithm problem: given a generator γ of a cyclic multiplicative group C of size N (soC = {γ a | a ∈ {0, . . . , N − 1}}), and A ∈ C, can we find the unique a ∈ {0, 1, . . . , N − 1} such that
γ a = A? This a is called the discrete logarithm of A (w.r.t. generator γ). It is generally believedthat classical computers need time roughly exponential in log N to compute a from A (and one
can actually prove this in a model where we can only implement group operations via some “blackbox” [229]). This assumption underlies for instance the security of Diffie-Hellman key exchange(where C = Z∗p for some large prime p, see Exercise 3), as well as elliptic-curve cryptography.
Discrete log is an instance of the HSP as follows. We take G = ZN × ZN and define function
f : G → C by f (x, y) = γ x A−y , which is efficiently computable by repeated squaring. For groupelements g1 = (x1 , y1 ), g2 = (x2 , y2 ) ∈ G we havef (g1 ) = f (g2 ) ⇐⇒ γ x1 −ay1 = γ x2 −ay2 ⇐⇒ (x1 − x2 ) = a(y1 − y2 ) mod N ⇐⇒ g1 − g2 ∈ h(a, 1)i.
3This r is also known as the order of the element x in the group Z∗N , so this problem is also known as order-finding.

46Let H be the subgroup of G generated by the element (a, 1), then we have an instance of the HSP.
Finding the generator of the hidden subgroup H gives us a, solving the discrete log problem.

6.2

An efficient quantum algorithm if G is Abelian

In this section we show that HSPs where G (and hence H) is Abelian, and where f is efficiently
computable, can be solved efficiently by a quantum algorithm. This generalizes Shor’s factoringalgorithm, and will also give an efficient quantum algorithm for computing discrete logarithms.

6.2.1

Representation theory and the quantum Fourier transform

We start by quickly explaining the basics of representation theory. The idea here is to replacegroup elements by matrices, so that linear algebra can be used as a tool in group theory. A ddimensional representation of a multiplicative group G is a map ρ : g 7→ ρ(g) from G to the set ofd × d invertible complex matrices, satisfying ρ(gh) = ρ(g)ρ(h) for all g, h ∈ G. The latter property
makes the map ρ a homomorphism. It need not be an isomorphism (i.e., bijective), for example
the constant-1 function is a trivial representation of any group. A representation of G is irreducible
if it cannot be decomposed further into the direct sum of lower-dimensional representations of G.
A 1-dimensional representation of G is called a character of G (sometimes linear character ). Notethat a character χ is irreducible, and the complex values χ(g) must have modulus 1 because|χ(g k )| = |χ(g)|k for all integers k. For example, the group Z2 = {0, 1} has two characters: the χthat maps both elements to 1, and the χ that maps 0 to 1 and 1 to −1.
In the remainder of this section we will restrict attention to the case where G is Abelian(and usually finite). In the Abelian case the characters are exactly the irreducible representations(irreps): there are no irreps of dimension > 1. The “Basis Theorem” of group theory says thatevery finite Abelian group G is isomorphic to a direct product ZN1 × · · · × ZN` of cyclic groups.
First consider just one cyclic group ZN , written additively. Consider the discrete√ Fourier transform(Chapter 4), which is an N × N matrix. Ignoring the normalizing factor of 1/ N , its k-th column
jk, where ωN = e2πi/N . Note that
may be viewed as a map χk : ZN → C defined by χk (j) = ωNχk (j+j 0 ) = χk (j)χk (j 0 ), so χk is actually a 1-dimensional representation (i.e., a character) of ZN . In
fact, the N characters corresponding to the N columns of the Fourier matrix are all the charactersof ZN . For Abelian groups G that are (isomorphic to) a product ZN1 × · · · × ZN` of cyclic groups,
the |G| = N1 · · · N` characters are just the products of the characters of the individual cyclic groups
ZNj . Note that the characters are pairwise orthogonal.
b with the operation of pointwise multiplication.
The set of all characters of G forms a group G
b of size |G|/|H|:This is called the dual group of G. If H ≤ G, then the following is a subgroup of G
H ⊥ = {χk | χk (h) = 1 for all h ∈ H}.
Let us interpret the quantum Fourier transform in terms of the characters. For k ∈ ZN , define thestate whose amplitudes are the (normalized) values of χk :
N −1
N −1
1 X
1 X jk|χk i = √χk (j)|ji = √ωN |ji.
N j=0
N j=0

47

With this notation, the QFT just maps the standard (computational) basis of CN to the orthonormal basis corresponding to the characters:
FN : |ki 7→ |χk i.
As we saw in Chapter 4, this map can be implemented by an efficient quantum circuit if N is a
power of 2. The QFT corresponding to a group G that is isomorphic to ZN1 × · · · × ZN` is just thetensor product of the QFTs for the individual cyclic groups. For example, the QFT corresponding
to Z2 is the Hadamard gate H, so the QFT corresponding to Zn2 is H ⊗n (which is of course very
different from the QFT corresponding to Z2n ).

6.2.2

A general algorithm for Abelian HSP

The following is an efficient quantum algorithm for solving the HSP for some Abelian group G(written additively) and function f : G → S. This algorithm, sometimes called the “standard
algorithm” for HSP, was first observed by Kitaev [155] (inspired by Shor’s algorithm) and worked
out further by many, for instance Mosca and Ekert [192].
1. Start with |0i|0i, where the two registers have dimension |G| and |S|, respectively.
1 X
2. Create a uniform superposition over G in the first register: p|gi|0i.
|G| g∈G
1 X
3. Compute f in superposition: p|gi|f (g)i.
|G| g∈G
4. Measure the second register. This yields some value f (s) for unknown s ∈ G. The firstregister collapses to a superposition over the g with the same f -value as s (i.e., the coset
1 X
s + H): p|s + hi.
|H| h∈H
1 X
5. Apply the QFT corresponding to G to this state, giving p|χs+h i.
|H| h∈H
6. Measure and output the resulting g.
The key to understanding this algorithm is to observe that step 5 maps the uniform superposition
over the coset s + H to a uniform superposition over the labels of H ⊥ :
XX
1 X
1
p
|χs+h i = p
χs+h (g)|gi|H| h∈H|H||G| h∈H g∈G1=pχs (g)
χh (g)|gi =|H||G| g∈G
h∈H
X

X

s

|H|
|G|

X
g:χg

χs (g)|gi,∈H ⊥where the last equality follows from the orthogonality of characters of the group H (note that χg
restricted to H is a character of H, and it’s the constant-1 character iff χg ∈ H ⊥ ):X
X
|H| if χg ∈ H ⊥χh (g) =χg (h) =0 if χg 6∈ H ⊥
h∈H

h∈H

48

The phases χs (g) do not affect the probabilities of the final measurement, since |χs (g)|2 = 1. The
above algorithm thus samples uniformly from the (labels of) elements of H ⊥ . Each such element
χg ∈ H ⊥ gives us a constraint on H because χg (h) = 1 for all h ∈ H.4 Generating a small numberof such elements will give sufficient information to find the generators of H itself. Consider ourearlier examples of Abelian HSP:
Simon’s problem. Recall that G = Zn2 = {0, 1}n and H = {0, s} for the HSP corresponding
to Simon’s problem. Setting up the uniform superposition over G can be done by applying H ⊗nto the initial state |0n i of the first register. The QFT corresponding to G is just H ⊗n . The 2ncharacters are χg (x) = (−1)x·g . The algorithm will uniformly sample from labels of elements of
H ⊥ = {χg | χg (h) = 1 for all h ∈ H} = {χg | g · s = 0}.
Accordingly, the algorithm samples uniformly from the g ∈ {0, 1}n such that g · s = 0 (mod 2).
Doing this an expected O(n) times gives n − 1 linearly independent equations about s, from which
we can find s using Gaussian elimination.
Period-finding.

For the HSP corresponding to period-finding, G = Zφ(N ) and H = hri, andH ⊥ = {χb | e2πibh/φ(N ) = 1 for all h ∈ H} = {χb | br/φ(N ) ∈ {0, . . . , r − 1}}.
Accordingly, the output of the algorithm is an integer multiple b = cφ(N )/r of φ(N )/r, for uniformly
random c ∈ {0, . . . , r − 1}.
Notice that the algorithm doesn’t actually know φ(N ), which creates two problems. First, of
the 4 numbers b, c, φ(N ), r involved in the equation b = cφ(N )/r we only know the measurement
outcome b, which is not enough to compute r. Second, step 5 of the algorithm wants to do a QFT
corresponding to the group Zφ(N ) but it doesn’t know φ(N ); and even if we knew φ(N ), we’ve
only seen how to efficiently implement a QFT over Zq when q is a power of 2. Fortunately, if we
actually use the QFT over Zq for q a power of 2 that is roughly N 2 (and in step 1 set up a uniform
superposition over Zq instead of over G), then one can show that the above algorithm still works:
the measurement yields an integer b that (with high probability) is close to an integer multiple ofq/r.5 This is basically just Shor’s algorithm as described in Chapter 5.
Discrete logarithm. For the HSP corresponding to the discrete log problem, where G = ZN ×ZN
and H = h(a, 1)i, a small calculation shows that H ⊥ = {χ(c,−ac) | c ∈ ZN } (see Exercise 2). Hencesampling from H ⊥ yields some label (c, −ac) ∈ G of an element of H ⊥ , from which we can computethe discrete logarithm a. The QFT corresponding to G is FN ⊗ FN , which we don’t know how to
implement efficiently for arbitrary N , but which we can replace by Fq ⊗ Fq for some power-of-2 q
chosen to be somewhat larger than N .
In the above algorithm we assumed G is a finite Abelian group. These techniques have been much
extended to the case of infinite groups such as G = Z and even Rd , to obtain efficient quantum
algorithms for problems like Pell’s equation [128], and computing properties in number fields [59].
4This is a linear constraint mod N . For example, say G = ZN1 × ZN2 , and g = (g1 , g2 ) is the label of an elementg 1 h1 g 2 h2
ωN2 for all h = (h1 , h2 ) ∈ H, equivalently g1 h1 N2 + g2 h2 N1 = 0 mod N .
of H ⊥ . Then 1 = χg (h) = ωN
1
5There is something to be proved here, but we will skip the details. In fact one can even use a Fourier transform
for q = O(N ) instead of O(N 2 ) [127]. Note that this also reduces the number of qubits used by Shor’s algorithm
from roughly 3 log N to roughly 2 log N .

49

6.3

General non-Abelian HSP

6.3.1

The symmetric group and the graph isomorphism problem

The Abelian HSP covers a number of interesting computational problems, including period-finding
and discrete log. However, there are also some interesting computational problems that can be castas an instance of HSP with a non-Abelian G. Unfortunately we do not have an efficient algorithm
for most non-Abelian HSPs.
A good example is the graph isomorphism (GI) problem: given two undirected n-vertex graphs
G1 and G2 , decide whether there exists a bijection taking the vertices of G1 to those of G2 thatmakes the two graphs equal. No efficient classical algorithm is known for GI, so it would be great
if we could solve this efficiently on a quantum computer.6
How can we try to solve this via the HSP? Let G be the 2n-vertex graph that is the disjoint
union of the two graphs G1 and G2 . Let G = S2n . Let f map π ∈ S2n to π(G), which means thatedge (i, j) becomes edge (π(i), π(j)). Let H be the automorphism group Aut(G) of G, which is theset of all π ∈ S2n that map G to itself. This gives an instance of the HSP, and solving it would give
us a generating set of H = Aut(G).
Assume for simplicity that each of G1 and G2 is connected. If G1 and G2 are not isomorphic,
then the only automorphisms of G are the ones that permute vertices inside G1 and inside G2 :Aut(G) = Aut(G1 ) × Aut(G2 ). However, if the two graphs are isomorphic, then Aut(G) will also
contain a permutation that swaps the first n with the second n vertices. Accordingly, if we wereable to find a generating set of the hidden subgroup H = Aut(G), then we can just check whether
all generators are in Aut(G1 ) × Aut(G2 ) and decide graph isomorphism.

6.3.2

Non-Abelian QFT on coset states

One can try to design a quantum algorithm for general, non-Abelian instances of the HSP along thelines of the earlier standard algorithm: set up a uniform superposition over a random coset of H,
apply the QFT corresponding to G, measure the final state, and hope that the result gives useful
information about H. QFTs corresponding to non-Abelian G are much more complicated than in
the Abelian case, because the irreducible representations ρ can now have dimension d > 1. Forb denote the set of irreducible representations
completeness, let’s write down the QFT anyway. Let G
b We can assume without loss of generalityof G, and dim(ρ) be the dimension of a particular ρ ∈ G.
that the dim(ρ) × dim(ρ) matrices ρ(g) are unitary. The QFT corresponding to G is defined asfollows:s
X dim(ρ) dim(ρ)
X|gi 7−→|ρi
ρ(g)ij |i, ji,
|G|
i,j=1

b
ρ∈G

where P
|ρi denotes a name or label of ρ. It can be shown that this map is unitary. In particular,|G| = ρ∈Gb dim(ρ)2 , which implies that the dimensions on the left and the right are the same,and that the right-hand state has norm 1. In many cases this QFT can still be implemented
with an efficient quantum circuit, including for the symmetric group G = S2n that is relevant forgraph isomorphism [36, 190]. However, that is not enough for an efficient algorithm: the standard
algorithm does not always yield much information about the hidden H ≤ S2n [124, 191, 129].
√

6

For a long time, the best algorithm for GI took time roughly 2 n [33], but in a recent breakthrough Babai gave aO(1)“quasi-polynomial” algorithm, which is 2(log n)time [32]. That’s not yet polynomial, but a lot faster than before.

50

There are some special cases of non-Abelian HSP that can be computed efficiently, for instancefor normal subgroups [130], solvable groups [244, 141], and nil-2 groups [142].

6.3.3

Query-efficient algorithm

While we do not have a general efficient quantum algorithm for the non-Abelian HSP, there does
exist an algorithm that needs to compute f only a few times, i.e., a query-efficient algorithm, due
to Ettinger et al. [108]. We will sketch this now.
Consider steps 1–3 of the standard algorithm for the Abelian case. Even in the general nonAbelian case, this produces a coset state, i.e., a two-register superposition where the second register
ranges over the values of f , and the first register will be a uniform superposition over the coset of
H that corresponds to that value of f . Suppose we do this m times, producing a state |ψH i whichis the tensor product of m coset states for the same unknown H (for simplicity, below we’ll ignore
the fact that this state also depends on the particular values f takes on the cosets of H). One canshow that the coset states corresponding to different possible H are pairwise almost orthogonal:|hψH |ψH 0 i| is exponentially small in m. How large should we take m to ensure that these states are“sufficiently orthogonal” to enable us to learn H from |ψH i? The hidden subgroup H is generated
by a set of ≤ log |G| elements. Hence the total number of possible H that we want to distinguish
2
is at most log|G||G| ≤ 2(log |G|) . This upper bound on the number of possible H allows us to define
a POVM measurement {EH } (see Section 1.2.2 for the definition of POVM), with one element foreach possible hidden subgroup H, such that if we measure |ψH i with this POVM, then we are likely
to get the correct outcome H. Choosing m = O((log |G|)2 ) make the states “sufficiently orthogonal”
for this idea to work (see Exercise 4). This POVM need not be efficiently implementable: circuits
to implement it (using only a computational-basis measurement at the end) may require a numberof elementary gates that’s polynomial in |G|. But at least the number of times we need to querythe function f is only polylogarithmic in |G|.
For those interested in more HSP results, a good source is Childs’s lecture notes [82, Chapter 4–14].

Exercises
1. Show that the Deutsch-Jozsa problem for n = 1 (i.e., where f : {0, 1} → {0, 1}) is an instanceof the HSP. Explicitly say what G, f , H, and H ⊥ are, and how sampling from H ⊥ allows you
to solve the problem.
2. Show that for the HSP corresponding to discrete log, we indeed have H ⊥ = {χ(c,−ac) | c ∈ ZN }as claimed near the end of Section 6.2.2.
3. This exercise explains Diffie-Hellman key exchange, which is secure under the assumptionthat the adversary cannot efficiently compute discrete logarithms. Alice and Bob choose apublic key consisting of a large prime p (say, of 1000 or 2000 bits) and generator γ of thegroup Z∗p , which has size φ(p) = p − 1. To agree on a shared secret key K, Alice chooses a
uniformly random a ∈ {0, . . . , p − 2} and sends Bob the group element A = γ a ; Bob chooses
a uniformly random b ∈ {0, . . . , p − 2} and sends Alice B = γ b . Alice and Bob use K = γ ab as
their secret key, which they can use for instance to encrypt messages using a one-time pad.
(a) Show that both Alice and Bob can efficiently compute K given the communication.
51

(b) Show that an adversary who can efficiently compute discrete logarithms, can compute
K from the public key and the communication tapped from the channel (i.e., A, B, pand γ, but not a and b).
4. Suppose we are given an unknown state |ψi i from a known set of K states {|ψj i | j ∈ [K]}.
(a) Suppose the states are pairwise orthogonal: hψj |ψk i = δjk . Give a projective measurement that determines i with probability 1.
(b) (H) Suppose the states are pairwise almost orthogonal: |hψj |ψk i|  1/K 2 for all distinctPj, k ∈ [K]. Define Ei = 23 |ψi ihψi |. Show that I − K
i=1 Ei is positive semidefinite.
(c) Under the same assumption as (b), give a POVM that determines i with success probability at least 2/3.
5. (H) Suppose we have an efficient algorithm to produce, from a given undirected n-vertex
graph G, the following n2 -qubit state:X|π(G)i,aG
π∈Snwhere the basis states correspond to n × n adjacency matrices. Here aG is a scalar that makes
the norm equal to 1. Use this procedure to efficiently decide (with high success probability)
whether two given graphs G1 and G2 are isomorphic or not.

52

Chapter 7

Grover’s Search Algorithm
The second-most important quantum algorithm after Shor’s is Grover’s search algorithm [125]. It
doesn’t provide an exponential speed-up, only a quadratic speed-up, but it is much more widely
applicable than Shor.

7.1

The problem

The search problem:
For N = 2n , we are given an arbitrary x ∈ {0, 1}N . The goal is to find an i such that xi = 1 (andto output ‘no solutions’ if there are no such i). We denote the number of solutions in x by t (i.e.,
t is the Hamming weight of x).
This problem may be viewed as a simplification of the problem of searching an N -slot unordered
database or search space, modeled by an N -bit string. Classically, a randomized algorithm
would√
need Θ(N√ ) queries to solve the search problem. Grover’s algorithm solves it in O( N ) queries,
and O( N log N ) other gates (the number of gates can be reduced a bit further, see Exercise 9).

7.2

Grover’s algorithm

Let Ox,± |ii = (−1)xi |ii denote the ±-type oracle for the input x (i.e., a phase-query), and R0 be
the unitary transformation that puts a −1 in front of all basis states |ii where i 6= 0n , and that
does nothing to the basis state |0n i.1 The Grover iterate is
G = H ⊗n R0 H ⊗n Ox,± .

(7.1)

Note that 1 Grover iterate makes 1 query, and uses O(log N ) other gates.
n i, applies a Hadamard transformation to each
Grover’s algorithm starts in the n-bit state |0P
qubit to get the uniform superposition |U i = √1N i |ii of all N indices, applies G to this state ktimes (for some k to be chosen later), and then measures the final state. Intuitively, what happens
is that in each iteration some amplitude is moved from the indices of the 0-bits to the indices of
the 1-bits. The algorithm stops when almost all of the amplitude is on the 1-bits, in which case ameasurement of the final state will probably give the index of a 1-bit. Figure 7.1 illustrates this.
1

This unitary R0 is independent of x, and can be implemented using O(n) elementary gates (Exercise 2.8.a).

53


|0i







n
|0i







|0i

...

H
G

H

...

G










G

...

H
|

measure









{z

}

k

Figure 7.1: Grover’s algorithm, with k Grover iterates
In order to analyze this, define the following “good” and “bad” states, corresponding to thesolutions and non-solutions, respectively:
X
1 X
1|Gi = √
|ii.
|ii and |Bi = √N − t i:x =0
t i:x =1iiThen the uniform state over all indices can be written as
N −1

1 X
|U i = √|ii = sin(θ)|Gi + cos(θ)|Bi,N i=0pfor θ = arcsin( t/N ).

The Grover iterate G is actually the product of two reflections.2 Firstly, Ox,± is a reflection throughthe subspace V spanned by the basis states that are not solutions; restricted to the 2-dimensional
space spanned by |Gi and |Bi this is in fact just a reflection through the state |Bi. Secondly,H ⊗n R0 H ⊗n = H ⊗n (2|0n ih0n | − I)H ⊗n = 2H ⊗n |0n ih0n |H ⊗n − H ⊗n IH ⊗n = 2|U ihU | − I
is a reflection through |U i.
Here is Grover’s algorithm restated, assuming we know the fraction of solutions is ε = t/N :1. Set up the starting state |U i = H ⊗n |0i√
2. Repeat the following k = O(1/ ε) times:(a) Reflect through |Bi (i.e., apply Ox,± )(b) Reflect through |U i (i.e., apply H ⊗n R0 H ⊗n )3. Measure the first register and check that the resulting i is a solution
2

A reflection through a subspace V is a unitary A such that Av = v for all vectors v ∈ V , and Aw = −w for
all w orthogonal to V . Note that we can write A = 2PV − I, where PV is the projector onto subspace V . If V is
1-dimensional, spanned by vector u, we also call this a reflection through u.

54

Geometric argument: There is a fairly simple geometric argument why the algorithm works.
The analysis is in the 2-dimensional real plane spanned by |Bi and |Gi. We start with
|U i = sin(θ)|Gi + cos(θ)|Bi.
The two reflections (a) and (b) increase the angle from θ to 3θ, moving us towards the good state
as illustrated in Figure 7.2.
|Gi

|Gi

|Gi

✻

✻

✻

|U i

θ

✣

G|U i
|U i

|U i

✿
✲ |Bi

θ
θ

✿
✲ |Bi
③

2θ
θ

✿
✲ |Bi

Ox,± |U i

Figure 7.2: The first iteration of Grover: (picture on the left) start with |U i; (middle) reflectthrough |Bi to get Ox,± |U i; (right) reflect through |U i to get G|U i
The next two reflections (a) and (b) increase the angle with another 2θ, etc. More generally,
after k applications of (a) and (b) our state has becomesin((2k + 1)θ)|Gi + cos((2k + 1)θ)|Bi.
If we now measure, the probability of seeing a solution is Pk = sin((2k + 1)θ)2 . We want Pk to beπ
as close to 1 as possible. Note that if we can choose k̃ = 4θ− 1/2, then (2k̃ + 1)θ = π/2 and hence2
Pk̃ = sin(π/2) = 1. An example where this works is if t = N/4, for then θ = π/6 and k̃ = 1.
π−1/2 will usually not be an integer, and we can only do an integer number
Unfortunately k̃ = 4θof Grover iterations. However, if we choose k to be the integer closest to k̃, then our final state will
still be close to |Gi and the failure probability will still be small (assuming t  N ):1 − Pk = cos((2k + 1)θ)2 = cos((2k̃ + 1)θ + 2(k − k̃)θ)2= cos(π/2 + 2(k − k̃)θ)2 = sin(2(k − k̃)θ)2 ≤ sin(θ)2 =

t
,
N

π
where we used |k − k̃| ≤ 1/2. Since arcsin(θ) ≥ θ, the number of queries is k ≤ 4θ
≤ π4

q

N
t .

Algebraic argument: For those who don’t like geometry, here’s an alternative (but equivalent)
algebraic argument. Let ak denote the amplitude of the indices of the t 1-bits after k Grover
iterates, and bk the amplitude
Initially, for the uniform superposition√ of the indices of⊗nthe 0-bits.
⊗n|U i we have a0 = b0 = 1/ N . Using that H R0 H
= N2 J − I, where J is the N × N all-1s
matrix, we find the following recursion:
ak+1 =
bk+1 =

N − 2t2(N − t)
ak +
bk
N
N
−2t
N − 2t
ak +
bk
N
N
55

The following formulas, due to Boyer et al. [62], provide a closed form
p for ak and bk (which may beverified by substituting them into the recursion). With θ = arcsin( t/N ) as before, define
ak =
bk =

1
√ sin((2k + 1)θ)t
1√
cos((2k + 1)θ)N −t

Accordingly, after k iterations the success probability (the sum of squares of the amplitudes of thelocations of the t 1-bits) is the same as in the geometric analysis
Pk = t · a2k = (sin((2k + 1)θ))2 .
p
Thus we have a bounded-error quantum search algorithm with O( N/t) queries, assuming weknow t. We now list (without full proofs) a number of useful variants of Grover:• If we know t exactly, then the algorithm can be tweaked to end up in exactly the good state.
Roughly speaking, you can make the angle θ slightly smaller, such that k̃ = π/4θ − 1/2
becomes an integer (see Exercise 5).
• If we do not know t, then there is a problem: we do not know which k to use, so we do
not know when to stop doing the Grover iterates. Note that if k gets too big, the successprobability Pk = (sin((2k + 1)θ))2 goes down again! However, a slightly more complicatedalgorithm due to [62] (basically running the above algorithmwith exponentially increasingpguesses for k) shows that an expected number of O( N/t) queries still suffices to find asolution if there are t solutions. If there is no solution (t = 0), then we can easily detect thatby checking xi for the i that the algorithm outputs.
• If we know a lower bound τ on the actual (possibly
p unknown) number of solutions t, then theabove algorithm uses an expected number of O( N/τ ) queries. If we run this algorithm for up
to three times its expected number of queries, then (by Markov’s inequality) with probability
at least 2/3 it will have found a solution. This way we can turn an expected runtime into aworst-case runtime.
• If we do not know t but would like to reducep the probability of not finding a solution to somesmall ε > 0, then we can do this using O( N log(1/ε)) queries (see Exercise 6).
NB: The important part here is that the log(1/ε) is inside the square-root; usual errorreductionby O(log(1/ε)) repetitions of basic Grover would give the worse upper bound of√O( N log(1/ε)) queries.

7.3

Amplitude amplification

The analysis that worked for Grover’s algorithm is actually much more generally applicable (wewill also see it again in the next chapter). In this section we describe a very similar procedure thatallows us to amplify the “good” part of the outcome of an algorithm. Quite abstractly, suppose wehave a quantum circuit A (without measurements) that acts on m qubits, such thatp√
A|0m i = p|ψ1 i + 1 − p|ψ0 i,56

where |ψ1 i and |ψ0 i are normalized m-qubit states that are orthogonal to each other (it could for
instance be that the last qubit of |ψ1 i is |1i and the last qubit of |ψ0 i is |0i). For some reason we√like the state |ψ1 i and we want to increase its “weight” p in the superposition. The following
procedure achieves this.
In analogy with the analysis of Grover, think of |ψ1 i as the “good state” and |ψ0 i as the “badstate,” and view these two states as the vertical and horizontal axes in a 2-dimensional picture. Ourstarting state will be |U i = A|0m i, which plays the role that the uniform state played in Grover,
and which is of course easy to obtain by applying A once to basis state |0m i. The angle between√|U i and the horizontal axis is θ = arcsin p. We would like to rotate this initial state towards thegood state, i.e., towards the vertical axis. As for Grover, we could implement the desired rotation
as a product of two reflections: a reflection through the bad state and a reflection through |U i.
For the first reflection, suppose we have a circuit RG that can somehow distinguish the goodstate from the bad state by putting a “−” in front of |ψ1 i and leaving |ψ0 i alone. For example, if
the last qubit of |ψ1 i is |1i and the last qubit of |ψ0 i is |0i, then RG would be extremely easy: it
would just apply a Z-gate to the last qubit. The second reflection can be implemented as
AR0 A−1 .
It is easy to check that this maps the state |U i = A|0m i to itself, while every state orthogonal to|U i gets a “−” in front of it, so indeed this reflects through |U i. Like before, the product of these
two reflections corresponds to a rotation by an angle of 2θ in the 2-dimensional picture.
The following amplitude amplification procedure from [66] increases the amplitude of the goodstate to be close to 1:
1. Setup the starting state |U i = A|0m i√
2. Repeat the following O(1/ p) times:(a) Reflect through the bad state |ψ0 i (i.e., apply RG )(b) Reflect through |U i (i.e., apply AR0 A−1 )The analysis is the same as for Grover: the initial angle between our algorithm’s state and thehorizontal axis is θ and every iteration increases this angle by 2θ, so after k iterations our state issin((2k + 1)θ)|ψ1 i + cos((2k + 1)θ)|ψ0 i.
We would like to end up with angle (2k + 1)θ ≈ π/2, because then the amplitude of the good stateπ|ψ1 i would be close to sin(π/2) = 1. Hence, like before, we choose k to be 4θ
− 1/2 rounded to the√nearest integer. This is O(1/ p). If we do not know in advance what p is, then we can try out
exponentially decreasing guesses for its value, similar to how we handle the case of Grover withunknown number of solutions.
Note that the Hadamard transform H ⊗n can be viewed as an algorithm with success probability
p = t/N for a search problem of size N with t solutions, because H ⊗n |0n i is the uniform superposition over all N locations. Hence Grover’s algorithm is a special case of amplitude amplification,
where m = n, A = A−1 = H ⊗n , and RG corresponds to a phase-query to x.
Amplitude amplification allows to speed up a very large class of classical algorithms: any
algorithm A that has some non-trivial probability p of finding a solution to whatever problem we’re√trying to solve, can be amplified to success probability nearly 1 by O(1/ p) runs of A and A−1
provided we can efficiently “recognize” solutions, i.e., implement RG . In contrast, classically wewould need to repeat A O(1/p) times before we have success probability close to 1.
57

7.4

Application: satisfiability

Grover’s algorithm has many applications: basically any classical algorithm that has some searchcomponent can be improved using Grover’s algorithm as a subroutine. This includes many basic
computer applications such as finding shortest paths and minimum spanning trees, various othergraph algorithms, etc.
We can also use it to speed up the computation of NP-complete problems (see Chapter 13 forthe complexity class NP), albeit only quadratically, not exponentially. As an example, consider
the satisfiability problem: we are given a Boolean formula φ(i1 , . . . , in ) and want to know if it hasa satisfying assignment, i.e., a setting of the bits i1 , . . . , in that makes φ(i1 , . . . , in ) = 1. A classicalbrute-force search along all 2n possible assignments takes time roughly 2n .
To find a satisfying assignment faster, define the N = 2n -bit input to Grover’s algorithm by
xi = φ(i), where i ∈ {0, 1}n . For a given assignment i = i1 . . . in it is easy to compute φ(i)classically in polynomial time. We can write that computation as a reversible circuit (using only
Toffoli gates), corresponding to a unitary Uφ that maps |i, 0, 0i 7→ |i, φ(i), wi i, where the third
register holds some classical workspace the computation may have needed. To apply Grover weneed an oracle that puts the answer in the phase and doesn’t leave workspace around (as that
could mess up the interference effects, see Exercise 2.10 for an example). Define Ox as the unitarythat first applies Uφ , then applies a Z-gate to the second register, and then applies Uφ−1 to “cleanup” the workspace again. This has the form we need for Grover: Ox,± |ii = (−1)xi |ii; here we did
not explicitly write the workspace qubits, which start and end in |0i. Now we can run Grover andfind a satisfying assignment
with high probability if there is one, using a number of elementary√noperations that is 2 times some polynomial factor.
If brute-force search is basically the best thing we can do classically to solve some particular NPhard problem, then that computation can be sped up quadratically on a quantum computer using
Grover search like above. However, there are also NP-hard problems where we know algorithms
that still run in exponential time, but that are much faster than brute-force search. For example,
consider the famous Traveling Salesman Problem (TSP): given an n-vertex graph with weights(distances) on the edges, find the shortest tour in this graph that visits every node exactly once.
Since there are (n − 1)! many different tours, classical brute-force search would take time (n − 1)!,times some polynomial in n. Grover’s algorithm could speed this up quadratically. However, there
are much more clever classical algorithms for TSP. In particular, the Bellman-Held-Karp dynamic
programming algorithm
solves TSP in time 2n , times a polynomial in n. This algorithm is much√
faster than O( n!) (which is roughly (n/e)n/2 ), and is not amenable to a straightforward speedup using Grover. Nevertheless, it turns out quantum computers can still solve TSP polynomiallyfaster than the best known classical algorithms, albeit in a much more complicated way than byjust applying Grover [16].

Exercises
1. (a) Suppose n = 2, and x = x00 x01 x10 x11 = 0001. Give the specific initial state, threeintermediate states, and final state in Grover’s algorithm, for k = 1 iterations (using
the decomposition of one Grover iterate into a product of four unitaries from Eq. (7.1)).
What is the success probability?
(b) Give the final state after k = 2 iterations. What is now the success probability?
58

2. (a) Suppose
you have a quantum algorithm for some computational problem that takes√
N operations on inputs of size N , each operation of constant cost C. And the bestpossible classical algorithm for the same computational problem takes N operations,each of constant cost c. Suppose C is much larger than c (which is certainly the case in
the current state of quantum technology: doing one elementary quantum gate is much
more expensive than one doing classical logic gate). How large does the input-size N
have to be before the quantum algorithm has lower cost than the best-possible classicalalgorithm?
√(b) Suppose you have a quantum algorithm of cost C 2n for satisfiability√ of n-variable
Boolean formulas, where the best-possible classical algorithm has cost c 2n , and again
C is much larger than c. How large does n have to be before the quantum algorithm has
lower cost than the best-possible classical algorithm?
3. Show that if the number of solutions is t = N/4, then Grover’s algorithm always finds asolution with certainty after just one query. How many queries would a classical algorithm
need to find a solution with certainty if t = N/4? And if we allow the classical algorithm
error probability 1/10?
4. Suppose we have a string of N = 2n bits, containing t ones (solutions) and N − t zeroes. You
may assume you know the number t.
(a) Show that we can use Grover’s
algorithm to find the positions of all t ones, using an√
expected number of O(t N ) queries. You can argue on a high level, no need to draw
actual quantum circuits.
√(b) (H) Show that this can be improved to an expected number of O( tN ) queries.
5. At the end of Section 7.2 we claimed without proof that Grover’s algorithm can be tweaked towork with probability 1 if we know the number of solutions exactly. For N = 2n , this question
asks you to provide such an exact algorithm for an x ∈ {0, 1}N with a unique solution (so weare promised that there is exactly one i ∈ {0, 1}n with xi = 1, and our goal is to find this i).
(a) Give the success probability of the basic version of Grover’s algorithm after k iterations.
π √(b) Suppose the optimal number of iterations k̃ = 4 arcsin(1/− 12 is not an integer. Show
N)

that if we round k̃ up to the nearest integer, doing dk̃e iterations, then the algorithm
will have success probability strictly less than 1.
(c) Define a new 2N -bit string y ∈ {0, 1}2N , indexed by (n + 1)-bit strings j = j1 . . . jn jn+1 ,by setting
1 if xj1 ...jn = 1 and jn+1 = 0,yj =0 otherwise.
Show how you can implement the following (n + 1)-qubit unitary
Sy : |ji 7→ (−1)yj |ji,using one query to x (of the usual form Ox : |i, bi 7→ |i, b ⊕ xi i) and a few elementarygates.
59
cos γ − sin γ(d) Let γ ∈ [0, 2π) and let Uγ =be the corresponding rotation matrix.
sin γ cos γ
Let A = H ⊗n ⊗ Uγ be an (n + 1)-qubit unitary. What is the probability (as a functionof γ) that measuring the state A|0n+1 i in the computational basis gives a solutionj ∈ {0, 1}n+1 for y (i.e., such that yj = 1)?
(e) (H) Give a quantum
algorithm that finds the unique solution in string x with probabil√ity 1 using O( N ) queries to x.
6. Given query access to x ∈ {0, 1}N , with unknown Hamming weight t = |x|, we want to finda solution, i.e., an index i ∈ {0, . . . , N − 1} such that xi = 1. If x = 0N then our searchalgorithm should output “no solution.”(a) (H) Suppose we know an integer s such that t ∈ √{1, . . . , s}. Give a quantum algorithm
that finds a solution with probability 1, using O( sN ) queries to x.
(b) Suppose we know that t ∈ {s + 1, . . . , N }. Give√a quantum algorithm that finds asolution with probability at least 1 − 2−s , using O( sN ) queries to x.
(c) For given ε > 2−N , give a pquantum algorithm that solves the search problem withprobability ≥ 1 − ε using O( N log(1/ε)) queries, without assuming anything about t.
7. (H) Here we will approximately count the number of 1s in a string x ∈ {0, 1}N . Let t = |x|denote that (unknown) number.
p(a) Given an integer m ∈ {1, . . . , N }, describe a quantum algorithm that makes O( N/m)queries to x and decides between the cases t ≤ m/2 and t ∈ [m, 2m] with probability
at least 2/3. That is, the algorithm has to output 0 with probability ≥ 2/3 whenevert ≤ m/2, has to output 1 with probability ≥ 2/3 whenever t ∈ [m, 2m], and can output
whatever it wants for other values of t.
√(b) Give a quantum algorithm that uses O( N log log N ) queries to x and that outputs an
integer m such that, with probability ≥ 2/3, the unknown t lies between m/2 and 2m.
8. Suppose we have a quantum circuit A acting on m qubits, such that√√
A|0m i = a|φ1 i|1i + 1 − a|φ0 i|0i,where |φ1 i and |φ0 i are arbitrary normalized (m − 1)-qubit states, and a ∈ [0, 1/4] is an
unknown number. Our goal is to estimate a (this is known as amplitude estimation). Let S
be the 2-dimensional subspace spanned by |φ1 i|1i and |φ0 i|0i.
(a) Show that in S, the unitary I ⊗ Z (where I is the identity on m − 1 qubits and Z is thephase-flip gate) is a reflection through |φ0 i|0i.
(b) Let R0 = 2|0m ih0m | − I be a reflection through |0m i. Show that in S, the unitary
AR0 A−1 is a reflection through A|0m i.
(c) Show that in S, the unitary U = AR0 A−1 · (I ⊗ Z) is a rotation over angle 2θ, where√θ = arcsin a.
(d) (H) Given some ε ∈ (0, 1/2), show how you can use phase estimation√(Section 4.6) with√
O(1/ε) applications of U to find an approximation ã of a such that | ã − a| ≤ ε.
60

(e) (H) Suppose we have query-access to a string x ∈ {0, 1}N of√unknown Hamming weightt = |x|. Use (d) √to compute an integer t̃ such that |t̃ − t| ≤ N with success probability≥ 2/3, using O( N ) queries to x.
(f) Suppose x ∈ {0,√1}N has |x| ∈ {0, 1}. Use (d) to compute |x| with success probability≥ 2/3, using O( N ) queries to x (you may not invoke Grover here).
9. Suppose you are given query access to x ∈ {0, 1}N , where |x| = 1 and N = 2n . You want tofind the unique index i = in−1 . . . i0 ∈ {0, 1}n such that xi = 1.
(a) Let k ∈ {1, . . . , n − 1}. Fix the first n − k bits of the n-bit index in−1 . . . i0 to specificvalues i∗n−1 . . . i∗k . Give a quantum algorithm to find a solution with success probability 1√(if one exists) among the 2k indices i ∈ {0, 1}n that start with i∗n−1 . . . i∗k , using O( 2k )√queries and O( 2k k) other gates.
√(b) Give a √quantum algorithm that solves the search problem on x using O( N ) queries
and O( N log log N ) other gates.

√√
Comment: The O( N log log N ) gates achieved here is better than standard Grover, which uses O( N log N )gates. The log log N can be reduced a bit further, to nearly-constant [28].

10. (H) Let x = x0 . . . xN −1 be a sequence of distinct real numbers, where N = 2n , and each xi
can be written exactly using b bits. We can query these in the usual way, i.e., we can apply(n + b)-qubit unitary Ox : |i, 0b i 7→ |i, xi i, as well as its inverse. The minimum of x is definedas min{xi | i ∈ {0, . . . , N − 1}}. Give a quantum algorithm√ that finds (with probability≥ 2/3) an index achieving the minimum, using at most O( N log N ) queries to the input,
and prove that this algorithm works.
√
Bonus: give a quantum algorithm that uses O( N ) queries.
11. Let x = x0 . . . xN −1 , where N = 2n and xi ∈ {0, 1}n , be an input that we can query in theusual way. We are promised that this input is 2-to-1: for each i there is exactly one other jsuch that xi = xj .3 Such an (i, j)-pair is called a collision.
(a) Suppose S is a uniformly randomly chosen set of s ≤ N/2 elements of {0, . . . , N − 1}.
What is the probability that there exists a collision in S?
(b) (H) Give√a classical randomized algorithm that finds a collision (with probability ≥ 2/3)
using O( N ) queries to x.
(c) (H) Give a quantum algorithm that finds a collision (with probability ≥ 2/3) using
O(N 1/3 ) queries.
12. Consider an undirected graph G = (V, E), with vertex set V = {1, . . . , n} and edge-set E.
We say G is connected if, for every pair of vertices i, j ∈ V , there is a path between i andj in the graph. The adjacency matrix of G is the n × n Boolean matrix M where Mij = 1
iff (i, j) ∈ E (note that M is a symmetric matrix because G is undirected). Suppose we are
given input graph G in the form of a unitary that allows us to query whether an edge (i, j)
is present in G or not:OM : |i, j, bi 7→ |i, j, b ⊕ Mij i.
3

The 2-to-1 inputs for Simon’s algorithm are a very special case of this, where the collisions are determined by asecret string s ∈ {0, 1}n : xi equals xj if i = j ⊕ s.

61

(a) Assume G is connected. Suppose we have a set A of edges which we already know to bein the graph (so A ⊆ E; you can think of A as given classically, you don’t have to queryit). Let GA = (V, A) be the subgraph induced by only these edges, and suppose GA is
not connected, so it consists of c > 1 connected components. Call an edge (i, j) ∈ E“good” if it connects two of these components.
√ Give a quantum algorithm that finds agood edge with an expected number of O(n/ c − 1) queries to M .
(b) Give a quantum algorithm that uses at most O(n3/2 ) queries to M and decides (withsuccess probability at least 2/3) whether G is connected or not.
(c) Show that classical algorithms for deciding (with success probability at least 2/3) whether
G is connected, need to make Ω(n2 ) queries to M .

62

Chapter 8

Quantum Walk Algorithms
8.1

Classical random walks

Consider an undirected graph G with N vertices. Suppose at least an ε-fraction of the vertices are“marked,” and we would like to find a marked vertex. One way to do this is with a random walk :Start at some specific vertex y of the graph.
Repeat the following a number of times: Check if y is marked, and if not then choose
one of its neighbors at random and set y to be that neighbor.
This may seem like a stupid algorithm, but it has certain advantages. For instance, it only needs
space O(log N ), because you only need to keep track of the current vertex y, and maybe a counterthat keeps track of how many steps you’ve already taken.1 Such an algorithm can for example
decide whether there is a path from a specific vertex y to a specific vertex x using O(log N ) space.
We’d start the walk at y and only x would be marked; one can show that if there exists a pathfrom y to x in G, then we will reach x in poly(N ) steps.
Let us restrict attention to d-regular graphs without self-loops, so each vertex has exactly dneighbors. A random walk on such a graph G corresponds to an N × N symmetric matrix P ,where Px,y = 1/d if (x, y) is an edge in G, and Px,y = 0 otherwise. This P is the normalizedadjacency matrix of G. If v ∈ RN is a vector with a 1 at position y and 0s elsewhere, then P v isa vector whose x-th entry is (P v)x = 1/d if (x, y) is an edge, and (P v)x = 0 otherwise. In otherwords, P v is the uniform probability distribution over the neighbors of y, which is what you get bytaking one step of the random walk starting at y. More generally, if v is a probability distribution
on the vertices, then P v is the new probability distribution on vertices after taking one step of therandom walk, and P k v is the probability distribution after taking k steps.
Suppose we start with some probability-distribution vector v (which may or may not be concentrated at one vertex y). We will assume G is connected and not bipartite. Then P k v will
converge to the uniform distribution over all vertices, and the speed of convergence is determinedby the “gap” between the first eigenvalue of P and all other eigenvalues. This can be seen as
follows. Let λ1 ≥ λ2 ≥ · · · ≥ λN be the eigenvalues of P , ordered by size, and v1 , . . . , vN be
corresponding orthogonal eigenvectors.2 The largest eigenvalue is λ1 = 1, and corresponds to the1Here we’re assuming the neighbors of a given vertex are efficiently computable, so you don’t actually need tokeep the whole graph in memory. This will be true for all graphs we consider here.
2
Analyzing graphs by looking at the eigenvalues and eigenvectors of their adjacency matrix is called “algebraic
graph theory” or “spectral graph theory,” see for instance [70].

63eigenvector v1 = u = (1/N ) which is the uniform distribution over all vertices. One can show that
our assumption that G is connected implies λ2 < 1, and our assumption that G is not bipartite
implies λN > −1. Hence all eigenvalues λi for i ∈ {2, . . . , N } will be in (−1, 1); the corresponding
eigenvector vi will be orthogonal to the uniform vector u, so the sum of its entries is 0. Let δ > 0
be the difference between λ1 = 1 and maxi≥2 |λi | (hence |λi | ≤ 1 − δ for all i ≥ 2). This δ is called
the “spectral gap” of the graph.
P
Now decompose the starting distribution v as v = N
i=1 αi vi . Since the sum of v’s entries is 1,
and the sum of v1 ’s entries is 1, while each other eigenvector vi (i ≥ 2) has entries summing to 0, it
follows that α1 = 1. Now let us see what happens if we apply the random walk for k steps, startingfrom v:!
X
X
X
kk
αi λki vi .
P v=Pαi λki vi = u +αi vi =
ii

i≥2

Consider the squared norm of the difference between P k v and u:
2

P kv − u

2

=

X
i≥2

αi λki vi=

X|αi |2 |λi |2k ≤ kvk2 (1 − δ)2k .

i≥2Since v is a probability distribution, we have kvk2 ≤ 1. By choosing k = ln(1/η)/δ, we get
P k v − u ≤ η. In particular, if δ is not too small, then we get quick convergence of the random
walk to the uniform distribution u, no matter which distribution v we started with.3 Once we areclose to the uniform distribution, we have probability roughly ε of hitting a marked vertex. Of
course, the same happens if we just pick a vertex uniformly at random, but that may not always
be an option if the graph is given implicitly.
Suppose it costs S to set up an initial state v; it costs U to update the current vertex, i.e., toperform one step of the random walk; and it costs C to check whether a given vertex is marked.
“Cost” is left undefined for now, but typically it will count number of queries to some input, or
number of elementary operations. Consider a classical search algorithm that starts at v, and thenrepeats the following until it finds a marked vertex: check if the current vertex is marked, and if
not run a random walk for roughly 1/δ steps to get close to the uniform distribution. Ignoring
constant factors, the expected cost before this procedure finds a marked item, is on the order of


1
1
S+
C+ U .
(8.1)
ε
δ

8.2

Quantum walks

We will now modify the classical random walk algorithm preceding Eq. (8.1) to a quantum algorithm, where the distribution-preserving matrix P is changed to a norm-preserving matrix W (P )(i.e., a unitary). This is due to Magniez et al. [182], inspired by Szegedy [233]; our presentation ismostly based on Santha’s survey paper [216], to which we refer for more details and references.
While the basis state of a classical random walk is the current vertex we are at, a basis stateof a quantum walk has two registers, the first corresponding to the current vertex and the second
3√
Convergence in total variation distance can be derived from this by Cauchy-Schwarz, choosing η  1/ N .

64

corresponding to the previous vertex. Equivalently, a basis state of a quantum walk corresponds
to an edge of the graph.
Our resulting quantum walk algorithm for search will actually be quite analogous to Grover’s
algorithm. We’ll
call a basis state |xi|yi “good” if x is a marked vertex, and “bad” otherwise.
P p
Define |px i = y Pxy |yi to be the uniform superposition over the neighbors of x. As for Grover,define “good” and “bad” states as the superpositions over good and bad basis states:
X
X
1
1|Gi = p|xi|px i and |Bi = p|xi|px i,|M | x∈M
N − |M | x6∈M
where M denotes the set of marked vertices. Note that |Gi is just the uniform superposition over
all edges (x, y) where the first coordinate is marked, and |Bi is just the uniform superposition over
all edges (x, y) where the first coordinate is not marked.
√
If ε = |M |/N and θ := arcsin( ε) then the uniform state over all edges can be written as
1 X|U i = √|xi|px i = sin(θ)|Gi + cos(θ)|Bi.
N x
Here is the algorithm for searching a marked vertex if an ε-fraction is marked4 :1. Setup the starting state |U i√
2. Repeat the following O(1/ ε) times:(a) Reflect through |Bi(b) Reflect through |U i
3. Measure the first register and check that the resulting vertex x is marked.
The description and analysis of this algorithm takes places in the 2-dimensional space spanned
by |Gi and |Bi. We’ll explain in a moment how to implement (a) and (b). Assuming we know
how to do that, the proof that this algorithm finds a marked vertex is the same as for Grover andfor amplitude amplification (Chapter 7). We start with |U i = sin(θ)|Gi + cos(θ)|Bi. The two
reflections (a) and (b) increase the angle from θ to 3θ, moving us towards the good state (similarly
to the analysis for Grover, you can draw a 2-dimensional picture with axes |Bi and |Gi to see this).
More generally, after k applications of (a) and (b) our state has becomesin((2k + 1)θ)|Gi + cos((2k + 1)θ)|Bi.
√π
Choosing k ≈ 4θ= O(1/ ε), we will have sin((2k + 1)θ) ≈ 1, at which point measuring the firstregister will probably yield a vertex x that is marked. We now look more closely how to implement
the two kinds of reflections.
(a) Reflect through |Bi. Reflecting through |Bi is relatively straightforward: we just haveto “recognize” whether the first register contains a marked x, and put a −1 if so (note that thisis really a reflection through the subspace spanned by the bad basis states, but restricted to the
2-dimensional subspace spanned by |Gi and |Bi that’s the same as a reflection through |Bi).
4

As in Grover, if we don’t know ε then we just run the algorithm repeatedly with exponentially decreasing guessesfor ε (1/2, 1/4, 1/8, . . . ). If at the end we still haven’t found a marked item, we’ll conclude that probably none exists.

65

(b) Reflect through |U i. This is where the quantum walk comes in. Let A be the subspacespan{|xi|px i} and B be span{|py i|yi}. Let ref(A) and ref(B) denote reflections through A and B,
respectively. Define W (P ) = ref(B)ref(A) to be the product of these two reflections. This is theunitary analogue of P . Suppose we are able to implement the following two operations (even in acontrolled manner):(1) |xi|0i 7→ |xi|px i(2) |0i|yi 7→ |py i|yi
Since (1) and (2) prepare a uniform superposition over the neighbors of x and y, respectively, one
can think of them as taking one classical walk step “in superposition.” Note that ref(A) can be
implemented by applying the inverse of (1), putting a minus if the second register is not |0i, andapplying (1). We can similarly implement ref(B) using (2) and its inverse. Hence we can think of
W (P ) = ref(B)ref(A) as corresponding to four steps of the classical walk in superposition.
To see how to implement the reflection through |U i, let us consider the eigenvalues and eigenvectors of W (P ). The eigenvalues of W (P ) can be related to the eigenvalues λ1 , λ2 , . . . of P as follows.
Let θj ∈ [0, π/2] be such that |λj | = cos(θj ). We won’t prove it here, but it turns out that the
eigenvalues of W (P ) are of the form e±2iθj . The state |U i is an eigenvalue-1 eigenvector of W (P ),corresponding to θ1 = 0. The spectral gap of P is√δ, so all eigenvectors of W (P ) that do not haveeigenvalue 1, have eigenvalue e±2iθj where θj ≥ 2δ, because 1 − δ ≥ |λj | = cos(θj ) ≥ 1 − θj2 /2.
We now want to implement a reflection R(P ) through the subspace spanned by the eigenvalue-1
eigenvectors of W (P ); restricted to the 2-dimensional subspace spanned by |Gi and |Bi this willbe the desired reflection through |U i.
√
We will implement R(P ) by using phase estimation (see Section 4.6) with precision δ/2 on
W (P ) to distinguishthe eigenvalue-1 eigenvectors from the other eigenvectors. This precision√
requires O(1/ δ) applications of W (P ), and O(log(1/δ)) auxiliary qubits that start in |0i and where
the estimate will be stored. Assume√ for5 simplicity that phase estimation always√ gives an estimateθ̃j of θj that is within precision
δ/2.
Becausethenonzero
θ
are
at
least
2δ, approximatingj√them within additive error δ/2 is good enough to determine whether the actual value θj itself is 0
or not. We then multiply the state with a −1 if the estimate is sufficiently far from 0, and finally
reverse the phase estimation to put the auxiliary qubits back to 0. Applied to some eigenvector|wi of W (P ) with corresponding eigenvalue e±2iθj , R(P ) maps
PE
PE−1
R(P ) : |wi|0i →7|wi|θ̃j i 7→ (−1)[θj 6=0] |wi|θ̃j i 7→ (−1)[θj 6=0] |wi|0i.
This has the desired effect: ignoring the auxiliary qubits (which start and end in 0), R(P ) maps
eigenvalue-1 eigenvectors of W (P ) to themselves, and puts a −1 in front of the other eigenvectors.
Now that we know how to implement the algorithm, let us look at its complexity. Consider thefollowing setup, update, and checking costs:• Setup cost S: the cost of constructing |U i
• Checking cost C: the cost of the unitary map |xi|yi 7→ mx |xi|yi, where mx = −1 if x ismarked, and mx = 1 otherwise
5

Phase estimation will actually give a superposition over estimates θ̃j , with small but nonzero amplitudes on bad
estimates, but we’ll skip the technical details that are needed to deal with this.

66• Update cost U : the cost of one step of the quantum walk, i.e., of W (P )√of W (P ), andThe cost of part (a) of the algorithm is C. Since R(P ) uses O(1/ δ) applications√a few other gates, the cost of part (b) of the algorithm is essentially O(U / δ). Ignoring constantfactors, the total cost of the algorithm is then1
1S+√ C+√ U .
(8.2)
ε
δ
Compare this with the classical cost of Eq. (8.1): quantum search square-roots both ε and δ.

8.3

Applications

There are a number of interesting quantum walk algorithms that beat the best classical algorithms.
We’ll give three examples here. More can be found in [216].

8.3.1

Grover search

Let us first derive a quantum algorithm for search. Suppose we have an N -bit string x of weight t,
and we know t/N ≥ ε. Consider the complete graph G on N vertices. Then the matrix P for the
random walk on G has 0s on its diagonal, and its off-diagonal entries are all equal to 1/(N −1). Thiscan be written as P = N 1−1 J − N 1−1 I, where J is the all-1 matrix and I is the identity. The only
nonzero eigenvalues of J is N , and adding a multiple of I just shifts the eigenvalues of a matrix,
hence the largest eigenvalue of P is λ1 = N/(N − 1) − 1/(N − 1) = 1 (corresponding to the uniform
vector) and all its other eigenvalues are −1/(N − 1). Note that the spectral gap δ is very large
here: δ = 1 − 1/(N − 1) ≈ 1. We’ll mark a vertex i iff xi = 1. Then, measuring cost by numberof queries, a quantum walk on G will have S = U = 0 and C = 1. Plugging this into Eq. (8.2),√
the quantum walk will find a marked vertex (with√high probability) using O(1/ ε) queries. The
worst case is ε = 1/N , in which case we’ll use O( N ) queries. Not surprisingly, we’ve essentiallyrederived Grover’s algorithm.

8.3.2

Collision problem

Consider the following collision problem:
Input: x = x0 , . . . , xn−1 , where each xi is an integer.6
Goal: find distinct i and j such that xi = xj if these exist, otherwise output “all elements
are distinct.”
The decision version of this problem (deciding if there exists at least one collision) is also known
as element distinctness.
Consider the graph whose vertices
 correspond to the sets R ⊆ {0, . . . , n − 1} of r elements. The
total number of vertices is N = nr . We’ll put an edge between the vertices for R and R0 iff these
two sets differ in exactly two elements; in other words, you can get from R to R0 by removing one
element i from R and replacing it by a new element j. The resulting graph J(n, r) is known as
the Johnson graph. It is r(n − r)-regular, since every R has r(n − r) different neighbors R0 . Its
6

Say, all xi ≤ n2 to avoid having to use too much space to store these numbers.

67

nspectral gap is known to be δ = r(n−r)[70, Sec. 12.3.2]; we won’t prove that here, just note that ifr  n, then δ ≈ 1/r. For each set R we also keep track of the corresponding sequence of x-values,
xR = (xi )i∈R . Hence the full “name” of a vertex is the pair (R, xR ).
We’ll call a vertex in J(n, r) marked if it contains a collision, i.e., the corresponding set R
contains distinct i, j such that xi = xj . In the worst case there is exactly one colliding pair i, j(more collisions only make the problem easier). The probability that i and j are both in a random
r−1
r-set R, is ε = nr n−1. Hence the fraction of marked vertices is at least ε ≈ (r/n)2 .
We will now determine the setup, checking, and update costs. The setup cost (measured interms of queries) is S = r + 1: we have to create a uniform superposition |U i over all edges R, R0 ,and for each such basis state query all r + 1 elements of R ∪ R0 to add the information xR and
xR0 . Checking whether a given vertex R, xR contains a collision doesn’t take any queries because
we already have xR , hence C = 0. To determine the update cost, note that mapping the second
register of |R, xR i|0i to a superposition of all neighbors R0 , xR0 requires querying (in superposition
for all neighbors R0 ) the value xj of the element j that was added to get R0 . Hence U = O(1).
Plugging this into Eq. (8.2), the cost of a quantum walk algorithm for collision-finding is


√
1
1
S + √ C + √ U = O(r + n/ r).
εδThis cost is O(n2/3 ) if we choose to set r = n2/3 (rounded to an integer). What the quantum walkproduces at the end is a superposition where, if we measure the first register, with high probability
we’ll see a marked vertex. That way we obtain a set R that contains a collision; and because R issmall, we can now cheaply find the colliding indices i, j ∈ R.
This query complexity O(n2/3 ) turns out to be the optimal quantum query complexity for thecollision problem [4]. By some more work involving efficient data structures, using a quantumaccessible classical RAM, the time complexity (= total number of elementary quantum gates plus
total number of queries) can be brought down to n2/3 (log n)O(1) [14].

8.3.3

Finding a triangle in a graphConsider the following triangle-finding problem:
Input: the adjacency matrix of a graph H on n vertices.
Goal: find vertices u, v, w that form a triangle (i.e., (u, v), (v, w), (w, u) are all edges in
the graph), if they exist.
We’ll assume we have query access to the entries
 of the adjacency matrix of H, which tells us
nwhether (u, v) is an edge or not. There are 2 bits in this oracle, one for each potential edgeof H. It is not hard to see that a classical algorithm needs Ω(n2 ) queries before it can decidewith good probability whether a graph contains a triangle or not. For example, take a bipartite
graph consisting of 2 sets of n/2 vertices each, such that any pair of vertices from different sets isconnected by an edge. Such a graph is triangle-free, but adding any one edge will create a triangle.
A classical algorithm would have to query all those edges separately.
Let us try a quantum walk approach. Again consider the Johnson graph J(n, r). Each vertex
will correspond to a set R ⊆ {0, . . . , n − 1} of r vertices, annotated with the result of queryingr
all possible 2 edges having both endpoints in R. We will call the vertex for set R marked if it
contains one edge of a triangle. If there is at least one triangle in the graph, then the fraction ofmarked vertices is at least ε ≈ (r/n)2 .
68



r+1
0
The setup cost will be S = r+1
2
2 : for an edge (R, R ) of the Johnson graph we query thepossible edges induced by the r + 1 H-vertices of R ∪ R0 . The update cost will be U = 2r − 2,
because if we remove one vertex i from R then we have to remove information about r − 1 edges
in H, and if we add a new j to R we have to query r − 1 new edges in H.
Getting a good upper bound for the checking cost C requires some more work—namely Groversearch plus another quantum walk! Suppose we are given a set R of r vertices. How do we decide
whether R contains an edge of a triangle? If we can efficiently decide, for a given u and R, whether
R contains vertices v, w such that u, v, w form a triangle in H, then we could combine this with aGrover search over all n possible vertices u of H. Given u and R, let us design a subroutine based onanother quantum walk, this time on the Johnson graph J(r, r2/3 ). Each vertex of this Johnson graphcorresponds to a subset R0 ⊆ R of r0 = r2/3 vertices. Its spectral gap is δ 0 = r/r0 (r − r0 ) ≈ 1/r2/3 .
We’ll mark R0 if it contains vertices v, w such that u, v, w form a triangle. If there is at least one
triangle involving u and some v, w ∈ R, then the fraction of marked vertices R0 in J(r, r2/3 ) is atleast ε0 ≈ (r0 /r)2 = 1/r2/3 . For this subroutine, the setup cost is O(r2/3 ) (for each v ∈ R, query
whether (u, v) is an edge in H); the update cost is O(1) (if we replace v in R by w, then we needto “unquery” edge (u, v) and query edge (u, w)); and the checking cost is 0. Plugging this into
Eq. (8.2), we can decide whether a fixed u forms a triangle with two vertices in R0 , using O(r2/3 )queries. Let’s ignore the small error probability of the latter subroutine (it can be dealt with, but
that’s technical). Then we can combine it with Grover search over all n vertices u to get checking√
cost C = O( nr2/3 ).
Plugging these S, U , and C into Eq. (8.2), the overall cost of a quantum walk algorithm fortriangle-finding is




1
1
n √
S + √ C + √ U = O r2 + ( nr2/3 + r3/2 ) .
rεδThis is O(n13/10 ) if we set r = n3/5 [183]. The quantum walk algorithm ends with a superposition
where most of the amplitude sits on sets R containing one edge of a triangle (i.e., two vertices of
H that are part of a triangle). Now a measurement of that final state gives us such a set R withhigh probability, and then it’s relatively cheap to find the third vertex of the triangle by another
Grover search over the n − r vertices of H that are not in R.
The exponent 13/10 can be slightly improved further [41, 163, 145], and the current best
exponent is 5/4 [162]. It is an open question what the optimal quantum query complexity fortriangle-finding is; the best lower bound is only Ω(n). Also, the optimal quantum time complexityof this problem is still wide open.

Exercises
1. Let d < n, and P be the projector on a d-dimensional subspace V ⊆ Rn that is spanned byorthonormal vectors v1 , . . . , vd . This means that P v = v for all v ∈ V , and P w = 0 for all w
that are orthogonal to V .
(a) Show that P can be written in Dirac notation as P =Pd

i=1 |vi ihvi |.

(b) Show that R = 2P − I is a reflection through the subspace corresponding to P , i.e.,
Rv = v for all v in the subspace, and Rw = −w for all w that are orthogonal to thesubspace.
69

2. Let G be a d-regular graph that is bipartite, so its vertex set V = [N ] can be partitioned
into disjoint sets A and B, and all its edges are in A × B. Give an eigenvector with eigenvalue 1 of the associated N × N normalized adjacency matrix P , and another eigenvector
with eigenvalue −1.
3. This exercise is about obtaining a quantum algorithm for the collision problem with a slightly
different quantum walk. Consider the problem of Section 8.3.2: we can query elements ofthe sequence of integers x0 , . . . , xn−1 , and want to find distinct i and j such that xi = xj
(or report that there are no collisions). Again consider the Johnson graph J(n, r), for somer to be optimized over later. Deviating from Section 8.3.2, now call a vertex R marked if
there exist i ∈ R and j ∈ [n] \ R such that xi = xj . Show that we can find a marked vertex
in this graph with high probability using O(n2/3 ) queries to x. You may ignore small error
probabilities, for example when using Grover’s algorithm. Be explicit about what data you
store about x at each vertex R.
4. (H) Let A, B, and C be n × n matrices with real entries. We’d like to decide whether or not
AB = C. Of course, you could multiply A and B and compare the result with C, but matrix
multiplication is expensive (the current best algorithm takes time roughly O(n2.38 )).
(a) Give a classical randomized algorithm that verifies whether AB = C (with success probability at least 2/3) using O(n2 ) steps, using the fact that matrix-vector multiplication
can be done in O(n2 ) steps.
(b) Show that if we have query-access to the entries of the matrices (i.e., oracles that map
i, j, 0 7→ i, j, Ai,j and similarly for B and C), then every classical algorithm needs at leastΩ(n2 ) queries to detect a difference between AB and C with error probability ≤ 1/3.
(c) Give a quantum walk algorithm that verifies whether AB = C (with success probability
at least 2/3) using O(n5/3 ) queries to matrix-entries.
5. A 3-SAT instance φ over n Boolean variables x1 , . . . , xn is a formula which is the AND of anumber of clauses, each of which is an OR of 3 variables or their negations. For example,
φ(x1 , . . . , x4 ) = (x1 ∨ x2 ∨ x3 ) ∧ (x2 ∨ x3 ∨ x4 ) is a 3-SAT formula with 2 clauses. A satisfying
assignment is a setting of the n variables such that φ(x1 , . . . , xn ) = 1 (i.e, TRUE). You may
assume the number of clauses is at most some polynomial in n. In general it is NP-hard tofind a satisfying assignment to such a formula. Brute force would try out all 2n possible truthassignments, but something much better is possible: consider the following simple algorithmof Schöning [219], which is a classical random walk on the set of all N = 2n truth assignments:
Start with a uniformly random x ∈ {0, 1}n .
Repeat the following at most 3n times: if φ(x) = 1 then STOP, else find the leftmost
clause that is false, randomly choose one of its 3 variables and flip its value.
√
One can show that this algorithm has probability at least (3/4)n / 5n of finding a satisfying
assignment (if φ is satisfiable). You may assume this without proof.
(a) Use the above to give a classical algorithm that finds a satisfying assignment with highprobability in time (4/3)n · p(n), where p(n) is some polynomial factor.
(b) (H) Givepa quantum algorithm that finds a satisfying assignment (with high probability)
in time (4/3)n · p(n).
70Chapter 9

Hamiltonian Simulation
9.1

Hamiltonians

Thus far, we have viewed the dynamics of quantum systems from the perspective of unitary transformations: apart from measurement, the only way a quantum state (i.e., a vector of amplitudes)
can change is by multiplication with a unitary matrix, for instance a 2-qubit gate tensored withidentities on the other qubits. But which unitary will actually occur in a given physical system?
This is determined by the Hamiltonian of the system, which is the observable H corresponding to
the total energy in the system. The expectation value hψ|H|ψi is called the energy of state |ψi.
Typically, this total energy is the sum of several different terms, corresponding to kinetic energy,
potential energy, etc. Also typically, it is the sum of many local terms that each act on only a few
of the particles (qubits) of the system, for example if all interactions are between pairs of particles.
One can think of the Hamiltonian H as describing the physical characteristics of the system.
These do not determine the initial state |ψ(0)i of the system, but they do determine the evolution of
the state in time, i.e., the state |ψ(t)i as a function of the time-parameter t, given initial state |ψ(0)i.
This is governed by the most important equation in quantum mechanics: the Schrödinger equation.
It is a linear differential equation that relates the time-derivative of the current state to that state
itself and to the Hamiltonian:d|ψ(t)ii~= H|ψ(t)i.
dtHere ~ is a very small (at least in standard units) yet very important physical constant: Planck’s
constant divided by 2π. We can set it to 1 by choosing appropriate units, and hence will ignore it
from now on. In general H may itself change with t, but for simplicity we will only consider here
the case where H is time-independent. Then, if we start in some state |ψ(0)i, the solution to thisdifferential equation is the following unitary evolution of the state:1
where U = e−iHt .

|ψ(t)i = U |ψ(0)i,

So t time-steps of evolution induced by Hamiltonian H, corresponds to applying the unitary matrix
e−iH t times. Note, however, that t need not be integer here: this evolution is continuous in time,in contrast to the discrete picture one gets from the circuit model with elementary quantum gates.
Applying a function, for instance f (x) = e−ix , to a normal matrix means applying f to its eigenvalues: if A has−1
diagonalization V DV −1 then f (A) = V f (D)Vby applying f to the
P , where f (D) is the diagonal matrix obtainedP
diagonal entries of D. For example, if A = j λj aj aTj and f (x) = e−ix , then f (A) = j e−iλj aj aTj . Note that if A
is Hermitian, then eiA is unitary.
171

In areas like quantum chemistry (i.e., the study of properties of molecules and their interaction)and material sciences, it is often important to figure out how a quantum system will evolve fromsome given initial state, for instance a basis state.2 This is typically hard to do on classicalcomputers, since the number of parameters (amplitudes) is exponential in the number of particles.
However, a quantum computer is like a universal quantum system, and should be able to efficiently
simulate every efficient quantum process, in the same way that a classical universal Turing machine
can efficiently simulate other (classical) physical processes.3 In fact, this was the main reason
why Feynman invented quantum computers: as a controllable quantum system that can be used
to simulate other quantum systems. In order to realize that idea, we need methods to efficiently
implement the unitary evolution that is induced by a given Hamiltonian. In other words, we needmethods to implement U = e−iHt as a quantum circuit of gates (say, up to some small error ε4 ), and to apply this to a given initial state |ψi. This is known as the problem of “Hamiltonian
simulation.”In this chapter we will cover several methods for Hamiltonian simulation. For simplicity we’ll
ignore the minus sign in Hamiltonian simulation, implementing U = eiHt rather than e−iHt . We
will also assume that our quantum system consists of n qubits. Some physical systems, for instanceelectron spins, naturally correspond to qubits. More complicated Hilbert spaces, for instance withbasis states labeled by the positions (x, y, z coordinates) of all particles involved, can be encoded(approximately) in binary to reduce them to the case of qubits. This encoding can be done in many
ways; much of the art in quantum chemistry is in how best to do this for specific systems, but wewon’t study that here (see for instance [77]).
Word of warning: this chapter is denser and more complicated than most of the other chapters inthese notes. On the other hand, unlike those chapters it explains some very recent, cutting-edge
results.

9.2

Method 1: Lie-Suzuki-Trotter methods

Note that an n-qubit Hamiltonian is a 2n ×2n matrix, which is huge even for moderate n. Typicallyin Hamiltonian simulation we are dealing with very structured Hamiltonians
P that have a much
shorter classical description. Suppose our Hamiltonian is of the form H = m
j=1 Hj , where m is
not too big (say, polynomial in n) and each Hj acts only on a few of the n qubits. For concreteness2

It is also very important in chemistry to be able to find out global properties of a given Hamiltonian like its
lowest energy, a.k.a. ground state energy. Unfortunately this problem seems to be hard to solve (in fact it is so-called
QMA-hard, see Chapter 14) even for a quantum computer, even for the special case of 2-local Hamiltonians [156, 149].
3
In Chapter 13 we will see that it is actually possible to classically simulate quantum computers (and hence
quantum systems more generally) with a polynomial amount of space, but our best methods still use an exponential
amount of time. If factoring a large integer is a hard problem for classical computers (which is widely believed),
then Shor’s efficient quantum factoring algorithm (Chapter 5) implies that it is impossible to simulate a quantum
computer in polynomial time on a classical computer.
4e (e.g., a quantum circuit with not too many gates) is meant to approximate n-qubit unitary U ,If n-qubit unitary U
e |ψi . However,e = maxψ U |ψi − Uthen we can measure the error by the operator norm of their difference U − U
we will also see simulation methods that allow some auxiliary qubits, say a of them, which start in state |0a i ande acts on more qubits than U , so we cannot use the operator
should end in something close to state |0a i. In this case U
norm of their difference; instead we can measure the error on the subspace of (n + a)-qubit states where the last ae (|ψi|0a i) . This way of measuring error still allows you to analyze a sequence
qubits are |0i: maxψ (U |ψi)|0a i − Uof approximate unitaries using triangle inequality (as in Ex 4.4) in a way that the errors add up at most linearly.

72

assume each Hj acts non-trivially on only two of the qubits.5 Such a Hamiltonian is called 2-local.
Note that, for fixed t, the unitary eiHj t is really just a 2-qubit gate, acting like identity on the othern − 2 qubits; this 2-qubit gate could in turn be
P constructed from CNOTs and single-qubit gates.
Our goal is to implement U = Q
eiHt = ei j Hj t . It is now tempting to view this exponential
iHj t , which is just a product of m 2-qubit gates. If allof a sum of matrices as a product m
j=1 e
terms Hj are diagonal, or if there is some basis in which all terms are diagonal (equivalently, if
all Hj commute), then this indeed works out. However, in general matrix exponentials do notwork that way: eA+B need not equal eA eB if A and B do not commute (see Exercise 1). The
Lie-Suzuki-Trotter decomposition gives us a way to handle this. It uses the fact that if A and B
have small operator norm, then eA+B and eA eB are approximately equal: eA+B = eA eB + E, where
the error-term E is a matrix whose operator norm is O(kAk · kBk).6
e of 2-qubit gates? Assume each of the terms
How can we use this to approximate U by a circuit U
Hj has operator norm ≤ 1 (see Exercise 2 for why such normalization matters). First consider thesimple case m = 2, so H = H1 + H2 . We can now implement U = eiHt by doing a little bit of H1 , alittle bit of H2 , a little bit of H1 , etc. More precisely, for every integer r ≥ 1 of our choice, we haveU = eiHt = (eiHt/r )r = (eiH1 t/r+iH2 t/r )r = (eiH1 t/r eiH2 t/r + E)r .

(9.1)

Here the error-term E has norm kEk = O(kiH1 t/rk · kiH2 t/rk) = O(kH1 k · kH2 kt2 /r2 ). Oure = (eiH1 t/r eiH2 t/r )r , which uses 2r = O(t2 /ε) 2-qubit gates. Since
approximating circuit will be U
errors in a product of unitaries add at most linearly (see Exercise 4.4), we have approximation error
e ≤ rkEk = O(kH1 k · kH2 kt2 /r) = O(t2 /r).
U −U
Choosing r = O(t2 /ε), we can make this error ≤ ε.
The same idea works for the general case where we have m > 2 Hamiltonian terms:
U = eiHt = (eiHt/r )r = (eiH1 t/r+···+iHm t/r )r = (eiH1 t/r · · · eiHm t/r + E)r ,(9.2)

where kEk = O(m2 t2 /r2 ) (Exercise 3). Choosing r = O(m2 t2 /ε), we have an approximating circuite = (eiH1 t/r · · · eiHm t/r )r with mr = O(m3 t2 /ε) 2-qubit gates, and error U − Ue ≤ rkEk ≤ ε.
UThis is the first-order Lie-Suzuki-Trotter approach to Hamiltonian simulation, due to Lloyd [172].
e depends quadratically on the time t for which we want to
The number of gates of the circuit U
simulate the evolution, which is not optimal. One can do fancier higher-order Lie-Suzuki-Trotter
decompositions that make the dependence on t nearly linear, but we won’t explain those here.
eInstead we will describe two methods below with linear t-dependence. The number of gates of U
7depends polynomially on ε; this can be very much improved as well, as we will see.
5This means H can be described efficiently by m 4 × 4 matrices, rather than by a 2n × 2n matrix. A different
assumption that is often made on Hamiltonians and that we will see later, is that H is s-sparse, meaning each of the
2n columns has
P at most s nonzero entries, and we have some efficient “sparse access” to these nonzero entries. Notethat if H = j Hj and each Hj acts on only 2 qubits, then H is 4m-sparse. Thus, roughly speaking, the locality
assumption implies the sparsity assumption.
6
A non-rigorous but reasonably convincing way to see this is to approximate term eM by its first-order Taylor
series I + M , which is a good approximation if M has small norm (the error of the approximation will be quadratic
in that norm). Then eA eB − eA+B ≈ (I + A)(I + B) − (I + A + B) = AB. In case you ever need it: the so-called
Baker-Campbell-Hausdorff formula gives a much more precise expression.
7
While the upper bounds on the number of gates for Trotter methods are theoretically worse (in their dependence
on t and ε) than the other two methods explained in this chapter, in practice Trotter is quite competitive [85]. Trotter
also has the advantages of being relatively simple and of not requiring any auxiliary qubits.

73

9.3

Method 2: Linear combination of unitaries (LCU)

Here we will describe a method for Hamiltonian simulation whose complexity depends linearly on
the time t for which we want to evolve the state, and only logarithmically on the desired error ε.
Let’s start with a more general problem. Suppose we have a 2n × 2n matrix M and an n-qubit
state |ψi, and we would like to prepare the state M |ψi/kM |ψik. Here M need not be unitary, but
suppose we can write M as a linear combination of unitaries:8M=mX

αj Vj ,

j=1

with thePαj being nonnegative reals (we can always absorb complex phases into the Vj ). Let
kαk1 = j αj , and let W be a unitary acting on dlog me qubits that maps
W : |0i 7→ pX√1
αj |ji.
kαk1 jSuppose each Vj is an “easy” unitary, for instance a 2-qubit gate tensored with identity on the othern − 2 qubits, or a small circuit. Also supposePwe can implement these unitaries in a controlled way:
we have access to a 2-register unitary V = m
j=1 |jihj| ⊗ Vj . This maps |ji|φi 7→ |jiVj |φi, and we
can think of the first register as “selecting” which unitary Vj to apply to the second register.9
We want to use V and W to implement M on a given state |ψi. Consider the following algorithm:
1. Start with two-register state |0i|ψi, where the first register has dlog me qubits.
2. Apply W to the first register.
3. Apply V to the whole state.
4. Apply W −1 to the first register.
A small calculation (see Exercise 6) shows that the resulting state can be written ass
1
kM |ψik2|0iM |ψi + 1 −
|φi,
kαk1
kαk21

(9.3)

where |φi is some other normalized state that we don’t care about, but that has no support on
basis states where the first register is |0i. Note that the state of (9.3) has norm 1, because thesquared norm of the first term is kM |ψik2 /kαk21 .
If we were to measure the first register, the probability of outcome 0 is p = kM |ψik2 /kαk21 .
In case of that measurement outcome, the second register would collapse to the normalized ver√sion of M |ψi, as desired. The success probability p may be small, but we could use O(1/ p) =8

In fact every M can be written in such a way, because the 4n n-qubit Pauli matrices (each of which is unitary)
form a basis for the linear space of all 2n × 2n matrices. See Appendix A.9.
9
In the literature, this V is often called “select-V .” One might expect the cost of V to be not much higher thanthe costliest Vj , just like the cost of a classical “if A then B, else C” statement is not much bigger than the largest of
the costs of B and C. However, if we measure circuit size, then the cost of V could be roughly the sum of the costsof the Vj s because circuits for each Vj should be “included” in the circuit for V .

74

O(kαk1 /kM |ψik) rounds of amplitude amplification to amplify the part of the state that starts
with |0i.10 Thus we would prepare (the normalized version of) M |ψi in the second register. Unfortunately this usage of amplitude amplification assumes the ability to implement a unitary (as wellas its inverse) to prepare |ψi from a known initial state, say |0i. Regular amplitude amplification
won’t work if instead of a unitary that prepares |ψi we just have one copy of the state |ψi available,
which is the typical situation in Hamiltonian simulation. However, Exercise 8 gives us a variant
called oblivious amplitude amplification, which circumvents this problem: it works even with justone copy of |ψi, as long as M is proportional to a unitary (or close to that). Fortunately, this is
the situation when we use LCU for Hamiltonian simulation, where M ≈ eiHt .

9.3.1

Hamiltonian simulation via LCU

Recall that our goal is to efficiently implement the unitary eiHt that is induced by a given Hamiltonian H, normalized so that kHk ≤ 1. The following approach is due to Berry et al. [54, 55, 56].
Suppose, somewhat paradoxically,that we can write out the Hermitian matrix H as a linear comP
bination of unitaries: H = j αj Vj . For example, if H is the sum of m 2-local terms like before,
then every 2-local term can be written as the sum of at most 16 n-qubit Pauli matrices (each ofwhich is unitary and acts non-trivially on only two qubits). Thus we would decompose H as asum of at most 16m unitaries, each acting non-trivially on only two of the n qubits. The sum ofcoefficients kαk1 will be O(m). P
kUsing the Taylor series ex = ∞k=0 x /k!, we write the unitary we want to implement as
e

iHt

=

∞
X
(iHt)k
k=0

k!

=

∞
X
(it)k



k!



k=0

k
X

αj Vj  =

∞
X
(it)k
k=0

j∈[m]

k!

X

αj1 · · · αjk Vj1 · · · Vjk .

(9.4)

j1 ,...,jk ∈[m]

Note that if each Vj is easy to implement and k is not too big, then the unitary Vj1 · · · Vjk isalso not too hard to implement. Exercise 9 shows that if we truncate the Taylor series at k =O(t + log(1/ε)), dropping the terms of higher order, then the induced error (i.e., the dropped part)has operator norm at most ε. Accordingly, we can take the part of the right-hand side of Eq. (9.4)
for k = O(t + log(1/ε)) and then use the linear combination of unitaries approach to approximately
implement
eiHt . The unitaries in this decomposition are of the form Vj1 ,...,jk = ik Vj1 · · · Vjk ; letP
V = j1 ,...,jk |j1 , . . . , jk ihj1 , . . . , jk |⊗Vj1 ,...,jk denote the controlled operation of the Vj1 ,...,jk unitaries,
each of which involves k Vj ’s. The corresponding nonnegative coefficients in this decomposition are
βj1 ,...,jk =tk
αj · · · αjk ,k! 1

for k ≤ O(t + log(1/ε)).

These β-coefficients add up to
kβk1 =

O(t+log(1/ε)) k
X
t
k=0

k!

X
j1 ,...,jk

αj1 · · · αjk ≤

∞ k X
X
t
k=0

k!

j1 ,...,jk

αj1 · · · αjk =∞X(tkαk )k
1

k=0

k!

= etkαk1 ,so straightforward application of the LCU method with oblivious amplitude amplification uses
O(kβk1 ) = O(etkαk1 ) applications of V and V −1 .
10

If we do not know the value of p in advance, then we can try out exponentially decreasing guesses for p, like we
do for Grover’s algorithm in Chapter 7 when we don’t know the number of solutions.

75

The logarithmic error-dependence of the complexity of the above method is excellent. The
exponential dependence on tkαk1 is quite terrible for large t, but not too bad for very small t. So
what we’ll do if we want to do a simulation for large t, is to divide that t into b = tkαk1 blocksof time τ = 1/kαk1 each, run the above algorithm for time τ with error ε0 = ε/b, and then glueb time-τ simulations together. This will simulate (eiHτ )b = eiHt , with error ≤ bε0 = ε. The costof each time-τ simulation is O(eτ kαk1 ) = O(1) applications of V and V −1 , each of which involves
O(τ + log(1/ε0 )) = O(log(tkαk1 /ε)) applications of the Vj ’s. The overall cost will be b times that,since we’ll run b subsequent time-τ simulations in order to implement a time-t simulation.
P
To give a more concrete example, consider again the special case where H = i Hi P
consists of
2-local terms, so the unitaries Vj in the induced linear combination of unitaries H = m
j=1 αj Vj
iHτ
only act nontrivially on 2 qubits each. Then we approximate the time-τ unitary e
by a linear
combination of unitaries
O(τ +log(1/ε0 ))

M=

X

X

k=0

j1 ,...,jk ∈[m]

βj1 ,...,jk Vj1 ,...,jk ,(9.5)

where each Vj1 ,...,jk is a product of k = O(τ + log(1/ε0 )) = O(log(tkαk1 /ε)) 2-qubit gates. We canimplement this using the linear combination of unitaries approach, and repeat this b = tkαk1 times.
The cost of the unitary W is typically relatively small (see Exercise 7), so we can ε-approximate
the unitary eiHt using a circuit of roughly O(tkαk1 log(tkαk1 /ε)) = O(mt log(mt/ε)) applicationsof V and V −1 , and slightly more other 2-qubit gates. Note the linear dependence of the cost on
the evolution-time t, and the logarithmic dependence on the error ε, both of which are better than
Lie-Suzuki-Trotter methods.

9.4

Method 3: Transforming block-encoded matrices

In this section we’ll describe a recent approach that is very general and flexible. Suppose A is ann-qubit matrix with operator norm kAk ≤ 1, and we can implement an (n + 1)-qubit unitary

U=

A ·
· ·


.

(9.6)

The ‘·’s are unspecified 2n × 2n -dimensional matrices, the only constraint on which is that U is
unitary. Such a U is called a unitary block-encoding of A. Note that
U : |0i|ψi 7→ |0iA|ψi + |1i|φi,where we can’t say much about the (subnormalized) state |φi. Written more technically, the defining
property of such a block-encoding is (h0| ⊗ I)U (|0i ⊗ I) = A, where the first register is one qubit.
More generally we can define an a-qubit block-encoding of A, which is an (a + n)-qubit unitary U
with the property that (h0a | ⊗ I)U (|0a i ⊗ I) = A.
Example 1: LCU does block-encoding. From Eq. (9.3) we can see that LCU (without the final
amplitude amplifcation) implements a dlog me-qubit block-encoding of the matrix A = M/kαk1 .
76

Example 2: Block-encoding a sparse Hermitian matrix. Let A be a 2n × 2n Hermitianmatrix of operator norm kAk ≤ 1 that is s-sparse, so each row and column of A have at most s
nonzero entries (for simplicity assume exactly s nonzero entries). Since this matrix A is still an
exponentially large object, we have to be careful how we can access such sparse matrices. First, we
assume we can query the entries of A in the usual way: we have an oracle
OA : |i, ji|0i 7→ |i, ji|Aij i,where we assume the last register has sufficiently many qubits to write down the complex entry Aijeither exactly or with sufficient precision. Of course, since A is sparse, Aij will actually be 0 for
most (i, j). Let ν(j, `) ∈ {0, . . . , N − 1} denote the location of the `-th nonzero entry of the j-thcolumn of A; so the s nonzero entries in the j-th column are at positions ν(j, 0), . . . , ν(j, s − 1). We
also assume we have another oracle that allows us to find these locations:
OA,loc : |j, `i 7→ |j, ν(j, `)i.
−1
−1
We also assume we can run OA
and OA,loc. Together these assumptions are called having “sparseaccess” to A.
We will now show how to implement a block-encoding of the matrix A/s. Exercise 10 shows
how we can implement two (2n + 1)-qubit unitaries that create superpositions over the locations of
the nonzero entries in the j-th column and i-th row of A, respectively:
X
1 X
1|0i|i, `i,|k, ji,W3 : |0i|0n i|ii 7→ √W1 : |0i|0n i|ji 7→ √ |0iss`:Ai` 6=0

k:Akj 6=0

using one OA,loc -query and a few other A-independent gates. We can also implement the following−1, and a few other A-independent gates (and someunitary using one query to each of OA and OA
auxiliary qubits that start and end in |0i):q
W2 : |0i|k, ji 7→ Akj |0i|k, ji + 1 − |Akj |2 |1i|k, ji.
By following the action on initial state |0n+1 ji step-by-step (Exercise 10), one can show that the(0n+1 i, 0n+1 j)-entry of U = W3−1 W2 W1 equals Aij /s. In other words, U is an (n + a)-qubit blockencoding of matrix A/s for some a (depending on how many auxiliary qubits are actually used).
How can we use a given block-encoding U of A? Suppose that for some function f : R → R wewant to implement a unitary V that looks like
f (A) ·V =,··using a small number of applications of the block-encoding of A. Here we don’t care what submatrices sit at the ‘·’ entries of U or V , as long as the upper-left block of V is f (A) and V as a wholeis unitary. For example, in Hamiltonian simulation A would be the Hamiltonian H and f (x) would
be eixt , so that we are effectively implementing f (H) = eiHt . In the HHL algorithm in the next
chapter, f (x) will be 1/x, so that we effectively implement A−1 .
It turns out that we can implement a good approximation of V efficiently if we have a low-degree
polynomial P approximating f . The idea is that we can let P act on the eigenvalues of A, thustransforming a block-encoding of A into one of P (A). We state without proof the following theorem
by Gilyén et al. [122, follows by applying their Theorem 56 to the real and to the imaginary partof the polynomial], which extends work of Low et al. [177, 178, 176, 179, 178].
77

Theorem 1 Let P : [−1, 1] → {c ∈ C | |c| ≤ 1/4} be a degree-d polynomial, and let U be aunitary a-qubit block-encoding of Hermitian matrix A. We can implement a unitary O(a)-qubit
block-encoding V of P (A) using d applications of U and U −1 , one controlled application of U , andO(ad) other 2-qubit gates.
This theorem can be generalized to a powerful technique called “singular-value transformation” [122], where A can be an arbitrary matrix, non-Hermitian and even non-square.

9.4.1

Hamiltonian simulation via transforming block-encoded matrices

Let’s see how we can use Theorem 1 for Hamiltonian simulation for a given sparse Hamiltonian H.
We again approximate the function f (x) = eixt using a polynomial P degree d = O(t + log(1/ε)),which is the first d terms of the Taylor series of f (see Exercise 9), divided by 4 to ensure thatits range satisfies the condition of Theorem 1. If H is s-sparse and we have sparse access to it,then Example 2 of Section 9.4 shows how to efficiently implement a block-encoding U of the scaled
Hamiltonian H/s, using O(1) queries to H and O(n) other gates. Note that evolving Hamiltonian H
for time t is the same as evolving H/s for time st. Theorem 1 now gives us a block-encoding V of
P (H) ≈ 41 eiHt . This V invokes U and U −1 O(st + log(1/ε)) times, and maps:
V : |0i|ψi 7→ |0iP (H)|ψi + |φi,where |φi has no support on basis states starting with |0i. Since P (H) ≈ 14 eiHt is essentially
proportional to a unitary, we can now apply O(1) rounds of oblivious amplitude amplification to
boost the factor 14 to essentially 1, using only one copy of |ψi.
This implements the desired unitary eiHt on one copy of |ψi, up to small error. The complexityof ε-precise Hamiltonian simulation of an s-sparse Hamiltonian H of operator norm ≤ 1 thenbecomes O(st + log(1/ε)) queries to H and O(n(st + log(1/ε))) 2-qubit gates.

Exercises
1. Compute the following five 2×2 unitaries: eiπZ , eiπX , eiπX eiπZ , eiπZ eiπX , and eiπ(X+Z) . HereX and Z are the usual Pauli matrices.
2. Suppose we want to implement a certain unitary U , and we can do that by switching on a
Hamiltonian H for some time t: U = e−iHt . Now suppose H 0 is another Hamiltonian, with
100 times as much energy as H: H 0 = 100H. Show that using H 0 we can implement U a 100
times faster than with H.
Comment: This exercise is about time in the physical sense of the word, not about “time complexity” in thesense of circuit size. It shows why some kind of normalization of H is needed if we want to talk about the time
it takes to implement something. We can always “speed up” a computation by a factor k if we can multiply
our Hamiltonian with a factor k.

3. (H) This exercise justifies the error bound of Eq. (9.2). Let δ > 0 be small (in Eq. (9.2) we’dset δ = t/r). Show that there is a constant c, independent of δ and H1 , . . . , Hm , such thateiH1 δ+···+iHm δ = eiH1 δ · · · eiHm δ + E,P
for some E of norm kEk ≤ cδ 2 m−1
j=1 j.
78

4. Consider the simple case of the linear-combination-of-unitaries trick where m = 2 and M =V1 + V2 . Describe the unitaries V and W , and track the initial state |0i|ψi through the 4-stepalgorithm in Section 9.3.


1
1 −i
as a linear combination of the Pauli matrices (see5. (a) Write the gate G = √i −1
2Appendix A.9).
(b) Suppose you want to implement G via LCU, using the linear combination of (a). What
are W |0i and V ?
(c) Consider the final state after the 4-step algorithm of Section 9.3. Calculate the part ofthat state that starts with |0i (without writing out that final state fully!)
6. (H) Give a calculation to justify that the 4-step algorithm in Section 9.3 indeed always
produces a state of the form of Eq. (9.3).
7. Let v ∈ [−1, 1]N be a vector with real entries, of dimension N = 2n , indexed by i ∈ {0, 1}n .
Suppose we can query the entries of this vector by a unitary that maps
Ov : |ii|0p i 7→ |ii|vi i,
so where the binary representation of the i-th entry of v is written into the second register.
We assume this second register has p qubits, and the numbers vi can all be written exactlywith p bits of precision (it doesn’t matter how, but for concreteness say that the first bit
indicates the sign of the number, followed by the p − 1 most significant bits after the decimalX
1dot). Our goal is to prepare the n-qubit quantum state |ψi =vi |ii.
kvk
ni∈{0,1}(a) Show how you can implement the following 3-register map (where the third register is
one qubit) using one application of Ov and one of Ov−1 , and some v-independent unitaries(you don’t need to draw detailed circuits for these unitaries, nor worry about how towrite those in terms of elementary gates).
q|ii|0p i|0i 7→ |ii|0p i(vi |0i + 1 − vi2 |1i).
(b) Suppose you apply the map of (a) to a uniform superposition over all i ∈ {0, 1}n . Write
the resulting state, and calculate the probability that measuring the last qubit in thecomputational basis gives outcome 0.
(c) What is the resulting 3-register state if the previous measurement gave outcome 0?
(d) Assume !
you know kvk exactly. Give an algorithm that prepares |ψi exactly, using√
NO
applications of Ov and Ov−1 , and some v-independent unitaries.
kvk
8. (H) This exercise explains oblivious amplitude amplification.
Let M be an n-qubit unitary. We start from |Ψi = |0a i|ψi for unknown n-qubit state |ψi.
Our goal is to prepare the state |Φi = |0a iM |ψi (this |Φi is the analogue of the “good state”
in amplitude amplification). Let U be an (a + n)-qubit unitary, independent of |ψi, such thatU |Ψi = sin(θ)|Φi + cos(θ)|Φ⊥ i,79

where θ is some angle that’s independent of |ψi, while |Φ⊥ i is some normalized state that
depends on |ψi and has no support on basis states starting with 0a (this |Φ⊥ i is the analogueof the “bad state”). If θ is close to π/2, then we can just apply U to our starting state |Ψiand measure the first register; we’ll see 0a with probability sin(θ)2 ≈ 1 and in that case end
up with the desired state |Φi. But suppose θ is quite small. Here we will see how we canamplify the angle θ to roughly π/2, without assuming a unitary to prepare |Ψi.
(a) Let S be the 2-dimensional space spanned by |Φi and |Φ⊥ i. Let R = (I − 2|0a ih0a |) ⊗ I
be a unitary that puts a ‘−’ in front of every basis state that starts with 0a . Show thatR, restricted to S, is a reflection through |Φ⊥ i.
(b) Define |Ψ⊥ i = U −1 cos(θ)|Φi − sin(θ)|Φ⊥ i . Show U |Ψi and U |Ψ⊥ i are orthogonal.
One can also show with a bit more work [54, Lemma 3.7] the stronger statement that|Ψ⊥ i has no support on basis states starting with 0a . You may assume this fact without
proof in the remainder of this exercise.
(c) Show that −U RU −1 , restricted to S, is a reflection through U |Ψi (note the minus sign!)(d) Show that (−U RU −1 R)k U |0a i|ψi = sin((2k + 1)θ)|Φi + cos((2k + 1)θ)|Φ⊥ i.
(e) How large should we take k in order to end up with (approximately) the state |Φi?
NB: If you know θ exactly, then you can even exactly prepare |Φi (along the lines of Exercise 7.5) but
you don’t need to show that.

9. (H) Let ε ∈ (0, 0.99). Show that you can choose a sufficiently large constant c (independentof t and ε) such that for all Hermitian H with operator norm kHk ≤ 1, we havec(t+log(1/ε))−1

eiHt −X
k=0(iHt)kk!

=∞X
k=c(t+log(1/ε))(iHt)kk!

≤ ε.

10. This exercise looks at the details of block-encoding an s-sparse matrix A with kAk ≤ 1 from
Section 9.4. Assume for simplicity that the entries of A are real.
(a) Show how to implement W1 using an OA,loc -query and a few other A-independent gates.
For simplicity you may assume s is a power of 2 here, and you can use arbitrary singlequbit gates, possibly controlled by another qubit.
(Note that the same method allows to implement W3 .)−1(b) (H) Show how to implement W2 using an OA -query, an OA-query, and a few other
A-independent gates (you may use auxiliary qubits as long as those start and end in|0i).

(c) Show that the (0n+1 i, 0n+1 j)-entry of W3−1 W1 is 1/s if Aij 6= 0, and is 0 if Aij = 0.
(d) Show that the (0n+1 i, 0n+1 j)-entry of W3−1 W2 W1 is exactly Aij /s.
11. (a) Give a quantum circuit on n + 1 qubits that uses O(n) gates, no auxiliary qubits, andcomputes the parity of the first n bits, in the sense that it maps
|xi|0i 7→ |xi|nX

xi mod 2i for all x ∈ {0, 1}n .

i=1

80

(b) Let P = Z ⊗ Z ⊗ · · · ⊗ Z be an n-qubit Hamiltonian, where Z is the usual phase-flip
Pauli matrix. What is the result of applying matrix P to an n-qubit basis state |xi?
(c) Fix some positive real number t. Let U = eiP t be the n-qubit unitary induced byapplying the above Hamiltonian for time t (via the Schrödinger equation, dropping theminus sign in the exponent like in Section 9.1). What is the result of applying U to an
n-qubit basis state |xi?
(d) (H) Give a quantum circuit with O(n) gates that implements U exactly using one auxiliary qubit that starts and ends in |0i. You may use arbitrary single-qubit gates, which
may be controlled by another qubit.
(e) (H) Now suppose P is a product of n arbitrary Pauli matrices, not ncessarily all-Z.
Show how to implement U = eiP t .
12. Suppose you have a classical description of an n-qubit Hamiltonian H that is the sum ofm = n2 2-local terms. Assume the eigenvalues of the Hermitian matrix H lie in [0, 1), andcan all be written exactly with 2 log n bits of precision. You would like to exactly determine thesmallest eigenvalue λmin of H, corresponding to unknown n-qubit eigenstate |ψmin i. You’re
given (as a quantum state) an n-qubit state |ψi that has a significant overlap with |ψmin i:|hψ|ψmin i|2 ≥ 0.7. Give a polynomial-size quantum circuit that, with probability ≥ 2/3,
outputs λmin exactly.
NB: You don’t need to write down the circuit to the last detail; a clear description of the different parts of thecircuit (possibly with some reference to details in the lecture notes) suffices.

81

82

Chapter 10

The HHL Algorithm
10.1

The linear-system problem

In this chapter we present the Harrow-Hassidim-Lloyd (HHL [134]) algorithm for solving large
systems of linear equations. Such a system is given by an N × N matrix A with real or complex
entries, and an N -dimensional nonzero vector b. Assume for simplicity that N = 2n . The linearsystem problem is
LSP: find an N -dimensional vector x such that Ax = b.
Solving large systems of linear equations is extremely important in many computational problems
in industry, in science, in optimization, in machine learning, etc. In many applications it suffices
to find a vector x̃ that is close to the actual solution x.
We will assume A is invertible (equivalently, has rank N ) in order to guarantee the existenceof a unique solution vector x, which is then just A−1 b. This assumption is just for simplicity: if
A does not have full rank, then the methods below would still allow to invert it on its support,
replacing A−1 by the “Moore-Penrose pseudoinverse.”
The HHL algorithm can solve “well-behaved” large linear systems very fast (under certain
assumptions), but in a rather weak sense: instead of outputting the N -dimensional solution vector
x itself, its goal is to output the n-qubit stateN −1|xi :=

1 X
xi |ii,kxk
i=0

or some other n-qubit state close to |xi. This state |xi has the solution vector as its vector of
amplitudes, up to normalization. This is called the quantum linear-system problem:
QLSP: find an n-qubit state |x̃i such that k|xi − |x̃ik ≤ ε and Ax = b.
Note that the QLSP is an inherently quantum problem, since the goal is to produce an n-qubit
state whose amplitude-vector (up to normalization and up to ε-error) is a solution to the linear
system. In general this is not as useful as just having the N -dimensional vector x written out ona piece of paper, but in some cases where we only want some partial information about x, it may
suffice to just (approximately) construct |xi.
We will assume without loss of generality that A is Hermitian (see Exercise 1). Let us state themore restrictive assumptions that will make the linear system “well-behaved” and suitable for the
HHL algorithm:
83

1
1. We have a unitary that can prepare the vector b as an n-qubit quantum state |bi = kbk
using a circuit of B 2-qubit gates. We also assume for simplicity that kbk = 1.

Pi bi |ii

2. The matrix A is s-sparse and we have sparse access to it, like in Section 9.4. Such sparsity
is not essential to the algorithm, and could be replaced by other properties that enable anefficient block-encoding of A.
3. The matrix A is well-conditioned : the ratio between its largest and smallest singular value
is at most some κ.1 For simplicity, assume the smallest singular value is ≥ 1/κ while thelargest is ≤ 1. In other words, all eigenvalues of A lie in the interval [−1, −1/κ] ∪ [1/κ, 1].
The smaller the “condition number” κ is, the better it will be for the algorithm. Let’s assume
our algorithm knows κ, or at least knows a reasonable upper bound on κ.

10.2

The basic HHL algorithm for linear systems

Let us start with some intuition. The solution vector x that we are looking for is A−1 b, so wewouldP
like to apply A−1 to b. Because A is assumed to be Hermitian, it has spectral decomposition
−1
∗
A = N
j=0 λj aj aj , where the vectors aj are an orthonormal basis of eigenvectors for the whole
N -dimensional space, and λj ∈ R are the corresponding eigenvalues. Then the map A−1 is thesame as the map aj 7→ λ1j aj : we just want to multiply the eigenvector aj with the scalar 1/λj .
P
The vector b can also be written as a linear combination of the eigenvectors aj : b = j βj aj (wedon’t need
the coefficients βj for what follows). We want to apply A−1 to b to obtain
P to know
1−1
A b = j βj λj aj , normalized, as an n-qubit quantum state.
Unfortunately the maps A and A−1 are not unitary (unless |λj | = 1 for all j), so weP
cannot justapply A−1 as a quantum operation to state |bi to get state |xi. Fortunately U = eiA = j eiλj aj aTj
is unitary, and has the same eigenvectors as A and A−1 . We can implement U and powers of U by
Hamiltonian simulation, and then use phase estimation (Section 4.6) to estimate the λj associatedwith eigenvector |aj i with some small approximation error (for this sketch, assume for simplicity
that the error
q is 0). Conditioned on our estimate of λj we can then rotate an auxiliary |0i-qubit

to κλ1 j |0i +

1 − (κλ1j )2 |1i (this is a valid state because |κλj | ≥ 1). Next we undo the phaseestimation to set the register that contained the estimate back to |0i. Suppressing the auxiliary
qubits containing the temporary results of the phase estimation (these qubits start and end in state|0i), we have now unitarily mappeds!
11|aj i|0i 7→ |aj i|0i + 1 −|1i .
κλj
(κλj )2
P
If we prepare a copy of |bi|0i = j βj |aj i|0i and apply the above unitary map to it, then we obtain
s
!
X
1
1
1X 1
βj |aj i|0i + 1 −|1i =βj |aj i |0i + |φi|1i,2
κλj(κλj )
κ
λj
j
j
|
{z
}
∝|xi

1

This ratio is called the condition number. Note that the assumption that A is invertible is equivalent to having
a finite condition number. The stronger assumption that the condition number is small, intuitively says that A isinvertible in a stable or robust way, so that small errors (say due to noise or to finite-precision rounding) don’t leadto massive errors in the solution vector x.

84

P
2
where we don’t care about the (subnormalized) state |φi. Note that because
j |βj /λj | ≥P2
j |βj | = 1, the norm of the part of the state ending in qubit |0i is at least 1/κ. Accordingly, we can now apply O(κ) rounds of amplitude amplification to amplify this part of the state
to have amplitude essentially 1. This prepares state |xi to good approximation, as intended.
This rough sketch (which Exercise 2 asks you to make more precise) is the basic idea of HHL.
It leads to an algorithm that produces a state |x̃i that is ε-close to |xi, using roughly κ2 s/ε queries
to A and roughly κs(κn/ε + B) other 2-qubit gates.

10.3

Improving the efficiency of the HHL algorithm

The complexity of the above basic HHL algorithm can be improved further. Gilyén et al. [122]used the singular-value transformation technique of Section 9.4 to implement A−1 , improving on
an LCU construction due to Childs et al. [83]. We would like to apply the function f (x) = 1/x toa block-encoding of A in order to get a block-encoding of A−1 (up to normalization) that we canthen apply to |bi|0i.
The function f (x) = 1/x is not itself a polynomial, so we need to approximate it by a low-degree
polynomial to be able to apply Theorem 1 of Chapter 9. Childs et al. [83, Lemmas 17-19] started
from the following polynomial of degree D = 2b − 1 for b = O(κ2 log(κ/ε)):1 − (1 − x2 )b.
xThis is indeed a polynomial because all terms in the numerator have degree ≥ 1, so we can divide
out the x of the denominator. Since (1 − x2 )b is close to 0 (unless |x| is small), this polynomial
is indeed close to 1/x (unless |x| is small, but we won’t care about that because we’ll apply thispolynomial to a matrix whose eigenvalues aren’t close to 0). More precisely, this polynomial is
ε/2-close to 1/x whenever x lies in the interval Eκ = [−1, −1/κ] ∪ [1/κ, 1]. Its range on this domainis [−κ, −1] ∪ [1, κ] (ignoring the small ε for simplicity). Like every degree-D polynomial, f can be
written exactly as a sum of the first D + 1 Chebyshev polynomials of the first kind.2 Childs etal. show that the coefficients in this sum decrease quickly for larger degree, and that dropping the
Chebyshev polynomials of degree higher than d = O(κ log(κ/ε)) incurs only small error ε/2. The
resulting degree-d polynomial p ε-approximates 1/x on the interval Eκ , and its largest value (inabsolute value) on this domain is κ. Now define the polynomial P = p/(4κ). This has the same
degree d as p, but a range [−1/4, 1/4] that fits the assumption of Theorem 1 of Chapter 9 (there’s
a trick to ensure the values of P are within that range even for x ≈ 0, which we’ll skip here).
As we saw in Section 9.4, we can implement a block-encoding of the s-sparse matrix A/s using
O(1) sparse-access queries to A and O(n) other gates. Using a factor O(s) more work, we canturn this into a block-encoding of A itself (alternatively, we could directly invert the matrix A/s,
whose singular values are ≥ 1/(κs)). We now apply Theorem 1 with this block-encoding of A,
and the polynomial P = p/(4κ), of degree d = O(κ log(κ/ε)). Note that all eigenvalues of A lie
1 −1
in the interval Eκ , where p(x) ≈ 1/x, hence p(A) ≈ A−1 and P (A) ≈ 4κA . Theorem 1 thengives us a block-encoding of P (A), at the expense of running the block-encoding of A O(d) times.
Using O(κ) rounds of amplitude amplification on top of this, we can get rid of the 1/(4κ) factor
2

These univariate polynomials are defined recursively as follows: T0 (x) = 1, T1 (x) = x, and Td+1 = 2xTd (x) −Td−1 (x). Note that Td has degree d, and maps [−1, 1] to [−1, 1]. The polynomials T0 , . . . , TD are linearly independent(even orthonormal in a certain way) and hence span the set of all univariate polynomials of degree ≤ D.

85

and end up with essentially the state A−1 |bi, normalized.3 This gives a quantum algorithm thatsolves the QLSP using O(dκs) = O(κ2 s log(κ/ε)) queries to A, and O(κs(κn log(κ/ε) + B)) 2-qubit
gates. Note that compared to basic HHL, the dependence on 1/ε has been improved from linear tologarithmic. The dependence on κ can also be improved from quadratic to linear, using a techniquecalled “variable-time amplitude amplification” [15, 83, 79, 169] that we won’t explain here.
The HHL algorithm can in some cases solve the QLSP exponentially faster than classical algorithms can solve the LSP. In particular, if the sparsity s, the condition number κ, and the cost B of
preparing |bi are all ≤ polylog(N ), and the allowed error is ε ≥ 2−polylog(N ) , then this improved
version of the HHL algorithm uses polylog(N ) queries and gates to solve (in a quantum way) an
N -dimensional linear system. It can also be used for other tasks, for instance approximately solving
differential equations and other applications in scientific computing, see the lecture notes of Lin
Lin [168] and references therein.

Exercises
1. Suppose we are given an arbitrary invertible N × N matrix A and an N -dimensional vector b.
(a) Give a Hermitian 2N ×2N matrix A0 (depending on A but not on b) and 2N -dimensional
vector b0 (depending on b but not on A), such that a solution x to the linear system
Ax = b can be read off from a solution to the system A0 x0 = b0 .
(b) How does the condition number of your A0 relate to that of A?
2. This exercise asks you to add more details to the sketch of the basic HHL algorithm given at
the start of Section 10.2. For simplicity we will only count queries, not gates.
(a) Use Hamiltonian simulation and phase estimation to implement the following unitarymap:|aj i|0i 7→ |aj i|λej i,where |λej i is a superposition over estimates of λj , which (if measured) gives with probability ≥ 0.99 an estimator ` ∈ [−1, 1] such that |λj − `| ≤ ε/κ. Your implementation isallowed to use O(κs/ε + log(κ/ε)) queries to the sparse matrix A. You may invoke thebest Hamiltonian simulator for sparse matrices from Section 9.4.
(b) Show that the basic HHL algorithm can be implemented using O(κ2 s/ε + κ log(κ/ε))sparse-access queries to A. To make your life easier, you may assume that |λej i is justone basis state, so one estimator which is close to λj rather than a superposition overestimators (and hence the success probability 0.99 is actually 1). You may also assume
for simplicity that the amplitude amplification at the end works perfectly.
3. Suppose A and B are sparse, well-conditioned N ×N matrices, and we can efficiently generate
vector b ∈ RN as a quantum state |bi. Here we will see how we can efficiently find the solution
to the linear system ABx = b as a quantum state |xi.
More precisely, assume N = 2n . Assume we have a unitary circuit to produce the n-qubit
state |bi with a number of elementary gates that’s polynomial in n. Let sA and sB be the3Note that we need to assume a unitary to prepare |bi here, having just one copy of |bi is not enough. We cannot
use oblivious amplitude amplification because that assumes we have a block-encoding of a matrix that is proportional
to a unitary (or close to that), which A−1 is not.

86

sparsities of the matrices A and B, respectively, and κA and κB be their condition numbers(ratio of largest over smallest singular value). Let x ∈ CN be B −1 A−1 b, which is the uniquesolution to the linear system ABx = b. Show how you can produce an n-qubit
state |x̃i that1 Pis ε-close (in the usual Euclidean distance) to the n-qubit state |xi = kxki∈{0,1}n xi |ii, using
a number of queries (to matrix entries) and elementary gates that is polynomial in sA , sB ,
κA , κB , 1/ε, and n.
Comment: Again, the point here is to avoid the polynomial dependence on the dimension N that classicallinear solvers would have, and replace that by a polynomial dependence on n = log N .

87

88

Chapter 11

Quantum Query Lower Bounds
11.1

Introduction

Most of the algorithms we have seen so far worked in the query model. Here the goal usually is
to compute some function f : {0, 1}N → {0, 1} on a given input x = x0 . . . xN −1 ∈ {0, 1}N . The
distinguishing feature of the query model is the way x is accessed: x is not given explicitly, but
is stored in a random access memory, and we’re being charged unit cost for each query that we
make to this memory. Informally, a query asks for and receives the i-th element xi of the input.
Formally, we model a query unitarily as the following 2-register quantum operation Ox , where thefirst register is N -dimensional and the second is 2-dimensional1 :Ox : |i, bi 7→ |i, b ⊕ xi i.
In particular, |i, 0i 7→ |i, xi i. This only states what Ox does on basis states, but by linearity thisdetermines the full unitary. Note that a quantum algorithm can apply Ox to a superposition ofbasis states, gaining some sort of access to several input bits xi at the same time.
A T -query quantum algorithm starts in a fixed state, say the all-0 state |0 . . . 0i, and then interleaves fixed unitary transformations U0 , U1 , . . . , UT with queries. The algorithm’s fixed unitaries
may act on a workspace-register, in addition to the two registers on which Ox acts. In this case we
implicitly extend Ox by tensoring it with the identity operation on this extra register, so it maps
Ox : |i, b, wi 7→ |i, b ⊕ xi , wi.
Hence the final state of the algorithm can be written as the following matrix-vector product:
UT Ox UT −1 Ox · · · Ox U1 Ox U0 |0 . . . 0i.
This state depends on the input x only via the T queries. The output of the algorithm is obtainedby a measurement of the final state. For instance, if the output is Boolean, the algorithm could
just measure the final state in the computational basis and output the first bit of the result.
The query complexity of some function f is now the minimal number of queries needed for analgorithm that outputs the correct value f (x) for every x in the domain of f (with error probability
1

If the input x consists of non-binary items xi (as is the case for instance with the input for Simon’s algorithm)
then those can be simulated by querying individual bits of each xi .

89

at most 1/3, say). Note that we just count queries to measure the complexity of the algorithm2 ,while the intermediate fixed unitaries are treated as costless.
In many cases, the overall computation time of quantum query algorithms (as measured by
the total number of elementary gates, say) is not much bigger than the query complexity. Thisjustifies analyzing the latter as a proxy for the former. This is the model in which essentially all
the quantum algorithm we’ve seen work: Deutsch-Jozsa, Simon, Grover, the various random walkalgorithms. Even the period-finding algorithm that is the quantum core of Shor’s algorithm works
because it needs only few queries to the periodic function.

11.2

The polynomial method

From quantum query algorithms to polynomials. An N -variate multilinear polynomial p
is a function p : CN → C that can be written asXp(x0 , . . . , xN −1 ) =S⊆{0,...,N −1}

aS

Y

xi ,

i∈S

for some complex numbers aS . The degree of p is deg(p) = max{|S| : aS 6= 0}. It is easy to showthat every function f : {0, 1}N → C has a unique representation as such a polynomial; deg(f ) isdefined as the degree of that polynomial (see Exercise 1). For example, the 2-bit AND function isp(x0 , x1 ) = x0 x1 , and the 2-bit Parity function is p(x0 , x1 ) = x0 + x1 − 2x0 x1 . Both polynomials
have degree 2. Sometimes a lower degree suffices for a polynomial to approximate the function.
For example, p(x0 , x1 ) = 31 (x0 + x1 ) approximates the 2-bit AND function up to error 1/3 for all
inputs, using degree 1.
A very useful property of T -query algorithms is that the amplitudes of their final state aredegree-T N -variate polynomials of x [113, 37]. More precisely: consider a T -query algorithm with
input x ∈ {0, 1}N acting on an m-qubit space. Then its final state can be writtenXαz (x)|zi,z∈{0,1}mwhere each αz is a multilinear complex-valued polynomial in x of degree at most T .
Proof. The proof is by induction on T . The base case (T = 0) trivially holds: the algorithm’s
state U0 |0 . . . 0i is independent of x, so its amplitudes are constants.
For the induction step, suppose we have already done T queries. Then by the induction hypothesis the state after UT can be written asXαz (x)|zi,z∈{0,1}mwhere each αz is a multilinear polynomial in x of degree at most T . Each basis state |zi = |i, b, wi
consists of 3 registers: the two registers |i, bi of the query, and a workspace register containing basis
state |wi. The algorithm now makes another query Ox followed by a unitary UT +1 . The query
2

Clearly, N queries always suffice since we can just query each of the N input bits separately, thus learning x
completely, and then look up and output whatever the correct value is for that input.

90

swaps basis states |i, 0, wi and |i, 1, wi if xi = 1, and doesn’t do anything to these basis states if
xi = 0. This changes amplitudes as follows:
αi,0,w (x)|i, 0, wi + αi,1,w (x)|i, 1, wi 7→((1 − xi )αi,0,w (x) + xi αi,1,w (x))|i, 0, wi + (xi αi,0,w (x) + (1 − xi )αi,1,w (x))|i, 1, wi.
Now the new amplitudes are of the form (1−xi )αi,0,w (x)+xi αi,1,w (x) or xi αi,0,w (x)+(1−xi )αi,1,w (x).
The new amplitudes are still polynomials in x0 , . . . , xN −1 . Their degree is at most 1 more thanthe degree of the old amplitudes, so at most T + 1. Finally, since UT +1 is a linear map that is
independent of x, it does not increase the degree of the amplitudes further (the amplitudes after
UT +1 are linear combinations of the amplitudes before UT +1 ). This concludes the induction step.
Note that this construction could introduce degrees higher than 1, e.g., terms of the form x2i .
However, our inputs xi are 0/1-valued, so we have xki = xi for all integers k ≥ 1. Accordingly, we
can reduce higher degrees to 1, making the polynomials multilinear without increasing degree. 2
Suppose our algorithm acts on an m-qubit state. If we measure the first qubit of the final stateand output the resulting bit, then the probability of output 1 is given byX
p(x) =|αz (x)|2 .
z∈{1}×{0,1}m−1This is a real-valued polynomial of x of degree at most 2T , because |αz (x)|2 is the sum of the squaresof the real and imaginary parts of the amplitude αz (x), and each of those two parts is a polynomialof degree ≤ T . Note that if the algorithm computes f with error ≤ 1/3, then p is an approximating
polynomial for f : if f (x) = 0 then p(x) ∈ [0, 1/3] and if f (x) = 1 then p(x) ∈ [2/3, 1]. This gives
a method to lower bound the minimal number of queries needed to compute f : if one can showthat every polynomial that approximates f has degree at least d, then every quantum algorithm
computing f with error ≤ 1/3 must use at least d/2 queries.
Applications of the polynomial method. For our examples we will restrict attention to symmetric functions.3 Those are the ones where the function value f (x) only depends on the Hamming
weight (number of 1s) in the input x. Examples are N -bit OR, AND, Parity, Majority, etc.
Suppose we have a polynomial p(x0 , . . . , xN −1 ) that approximates f with error ≤ 1/3. Then
it is easy to see that a polynomial that averages over all permutations π of the N input bits
x0 , . . . , xN −1 :1 X
q(x) =p(π(x)),
N!
π∈SN

still approximates f . As it turns out, we can define a single-variate polynomial r(z) of the same
degree as q, such that q(x) = r(|x|).4 This r is defined on all real numbers, and we know something3
One can also use the polynomial method for non-symmetric functions, for instance to prove a tight lower bound ofΩ(N 2/3 ) queries for the general problem of collision-finding; this matches the quantum walk algorithm of Section 8.3.2.
However, that lower bound proof is substantially more complicated and we won’t give it here (see [4]).
4To see why this is the case, note that for every degree i, all degree-i monomials in the symmetrized
polynomialq have the same coefficient ai . Moreover, on input x ∈ {0, 1}N of Hamming weight z, exactly zi of the degree-i


Pd
|x|
z
monomials are 1, while the others are 0. Hence q(x) == z(z − 1) · · · (z − d + 1)/d! is a
i=0 ai i . Sinced
Pdsingle-variate polynomial in z of degree d, we can define r(z) = i=0 ai zi . For example, if q(x0 , x1 ) = x0 x1 thenrwould be the unique univariate polynomials such that r(0) = 0, r(1) = 0 and r(2) = 1, i.e., r(z) = z(z − 1)/2 = z2 .

91

about its behavior on integer points {0, . . . , N }. Thus it suffices to lower bound the degree ofsingle-variate polynomials with the appropriate behavior.
For an important example, consider the N -bit OR function. Grover’s algorithm can find an isuch that xi = 1 (if such
√ an i exists) and hence can compute the OR function with error probability ≤ 1/3 using O( N ) queries. By the above reasoning, any T -query quantum algorithm thatcomputes the OR with error ≤ 1/3 induces a single-variate polynomial r satisfyingr(0) ∈ [0, 1/3], and r(t) ∈ [2/3, 1] for all integers t ∈ {1, . . . , N }.
This polynomial r(x) “jumps” between x = 0 and x = 1 (i.e., it has a derivative r0 (x) ≥ 1/3
for some x ∈ [0, 1]), while it remains fairly constant on the domain {1, . . . , N }. By a classicaltheorem from approximation theory (proved independently around the same time by Ehlich√andZeller [105], and√ by Rivlin and Cheney [212]), such polynomials must have degree d ≥ Ω( N ).
Hence T ≥ Ω( N ) as well. Accordingly, Grover’s algorithm is optimal (up to a constant factor) interms of number of queries.
What about exact algorithms for OR? Could we tweak√ Grover’s algorithm so that it always
finds a solution with probability 1 (if one exists), using O( N ) queries? This turns out not to be
the case: a T -query exact algorithm for OR induces a polynomial r of degree ≤ 2T that satisfiesr(0) = 0, and r(t) = 1 for all integers t ∈ {1, . . . , N }.
It is not hard to see that such a polynomial needs degree at least N : observe that r(x) − 1 is a
non-constant polynomial with at least N roots.5 Hence T ≥ N/2 (this can be improved to T ≥ N ,see Exercise 5). Accordingly, Grover cannot be made exact without losing the square-root speed-up!
Using the polynomial method, one can in fact show for every symmetric function f that isdefined on all 2N inputs, that quantum algorithms cannot provide a more-than-quadratic speed-up
over classical algorithms. More generally, for every function f (symmetric or non-symmetric) thatis defined on all inputs6 , quantum algorithms cannot provide a more-than-6th-root speed-up overclassical algorithms (see Exercise 11). The polynomial method has recently been strengthened by
Arunachalam et al. [26] to an optimal lower bound method, by imposing more constraints on thepolynomial (which can increase the required degree, while still giving a lower bound on quantum
query complexity).

11.3

The quantum adversary method

The polynomial method has a strength which is also a weakness: it applies even to a stronger (andless physically meaningful) model of computation where we allow any linear transformation on thestate space, not just unitary ones. As a result, it does not always provide the strongest possible
lower bound for quantum query algorithms.
Ambainis [12, 13] provided an alternative method for quantum lower bounds, the quantum
adversary. This exploits unitarity in a crucial way and in certain cases yields a provably betterbound than the polynomial method [13]. We will present a very simple version of the adversary
method here, a much stronger (in fact optimal!) version is given in Chapter 12.
5
A “root” is an x such that r(x) = 0. It is a well-known fact from algebra that every univariate non-constantpolynomial of degree d has at most d roots (over any field). Note that this is not true for multivariate polynomials;
for example the polynomial x0 · · · xN −1 has 2N − 1 roots in {0, 1}N but its degree is only N .
6Note that this doesn’t include functions where the input has to satisfy a certain promise, such as Deutsch-Jozsa
and Simon’s problem.

92

Recall that a quantum query algorithm is a sequence
UT Ox UT −1 Ox · · · Ox U1 Ox U0 ,applied to the fixed starting state |0 . . . 0i, where the basic “query transformation” Ox depends
on the input x, and U0 , U1 , . . . , UT are arbitrary unitaries that don’t depend on x. Consider theevolution of our quantum state under all possible choices of x. Let |ψxt i denote the state after
applying Ut when the input is x. In particular, |ψx0 i = U0 |0 . . . 0i for all x (and hence hψx0 |ψy0 i = 1
for each x, y), and |ψxT i is the final state of the algorithm on input x before the final measurement.
Now if the algorithm computes the Boolean function f with success probability 2/3 on every input,
then the final measurement must accept (i.e., output 1) every x ∈ f −1 (0) with probability ≤ 1/3,
and must accept every y ∈ f −1 (1) with probability ≥ 2/3. This means the two states |ψxT i and|ψyT i cannot be too close together, or equivalently their inner product cannot be too close to 1.
17 7
Specifically, we must have |hψxT |ψyT i| ≤ 18
. This suggests that we find a set R ⊆ f −1 (0) × f −1 (1)of hard-to-distinguish (x, y)-pairs, and consider the following progress measureXSt =|hψxt |ψyt i|(x,y)∈R

as a function of t. By our observations, initially we have S0 = |R|, and in the end we must haveST ≤ 17
18 |R|. Also, crucially, the progress measure is unaffected by each application of a unitary Ut ,since each Ut is independent of the input and unitary transformations preserve inner products.
If we can determine an upper bound ∆ on the change |St+1 − St | in the progress measure at|R|each step, we can conclude that the number T of queries is at least 18∆. Ambainis proved thefollowing. Suppose that(i) each x ∈ f −1 (0) appearing in R, appears at least m0 times in pairs (x, y) in R;(ii) each y ∈ f −1 (1) appearing in R, appears at least m1 times in pairs (x, y) in R;(iii) for each x ∈ f −1 (0) and i ∈ {0, . . . , N − 1}, there are at most `0 inputs y ∈ f −1 (1) such that(x, y) ∈ R and xi 6= yi ;(iv) for each y ∈ f −1 (1) and i ∈ {0, . . . , N − 1}, there are at most `1 inputs x ∈ f −1 (0) such that(x, y) ∈ R and xi 6= yi .

q
`0
`1
·
·
|R|
=: ∆. We will not prove this inequality
Then for all t ≥ 0, |St+1 − St | = O
m0 m1
here, though it is a reasonably straightforward generalization of the answer to Exercise 12, andwe will see a stronger result in the next chapter. This upper bound ∆ on the progress-per-query
immediately implies a lower bound on the number of queries:
r

m0 m1
T =Ω
·
.
(11.1)`0 `1
7

Remember Exercise 3 from Chapter 4 for states |φi and |ψi: if kφ − ψk = ε, then the total variation distance
between the probability distributions you get from measuring |φi and |ψi, respectively, is at most ε. Hence, if weknow there is a two-outcome measurement that accepts |φi with probability ≤ 1/3 and accepts |ψi with probability≥ 2/3, then we must have total variation distance at least 1/3 and hence ε ≥ 1/3. Assume for simplicity that the
inner product hφ|ψi is real. Via the equation ε2 = kφ − ψk2 = 2√− 2hφ|ψi, this translates into an upper bound|hφ|ψi| ≤ 1 − ε2 /2 ≤ 17/18 (this upper bound can be improved to 2 2/3 with more careful analysis).

93

Intuitively, conditions (i)-(iv) imply that |St+1 − St | is small relative to |R| by bounding the “distinguishing ability” of any query. The art in applying this technique lies in choosing the relation R
carefully to maximize this quantity, i.e., make m0 and/or m1 large, while keeping√ `0 and `1 small.
Note that for the N -bit OR function this method easily gives the optimal Ω( N ) lower bound,as follows. Choose R = {(x, y) : x = 0N , y has Hamming weight1}. Then m0 = N while m1 =√`0 = `1 = 1. Plugging this into Eq. (11.1) gives the right Ω( N ) bound.
Let us give another application, a lower bound that is much harder to prove using the polynomial
method. Suppose f : {0, 1}N → {0, 1} is a 2-level AND-OR tree, with N = k 2 input bits: f is the
AND of k ORs, each of which has its own set of k inputs bits. By carefully doing 2 levels of Grover
k one can construct a quantum algorithm that computes f
search (search for a subtree which is√ 0 ),√√
with small error probability and O( k · k) = O( N ) queries. It was long an open problem to givea matching lower bound on the approximate degree, and this was proved only in 2013 [226, 76]. In
contrast, the adversary method gives the optimal lower bound on the quantum query complexity
quite easily: choose the relation R as follows
R consists of those pairs (x, y) where
x has one subtree with input 0k and the other k − 1 subtrees have an arbitrary k-bit
input of Hamming weight 1 (note f (x) = 0)y is obtained from x by changing one of the bits of the 0k -subtree to 1 (note f (y) = 1).
q

√
m0 m1
Then m0 = m1 = k and `0 = `1 = 1, and we get a lower bound of Ω= Ω(k) = Ω( N ).
`0 `1Another lower bound one can prove fairly easily using a strengthened version of the adversary
method is for inverting a permutation, see Exercise 9.

Exercises
1. Consider a function f : {0, 1}N → R. Show that this function can be represented by an
N -variate multilinear polynomial of degree ≤ N , and that this representation is unique.
2. Consider a 2-bit input x = x0 x1 with phase-oracle Ox,± : |ii 7→ (−1)xi |ii. Write out the final
state of the following 1-query quantum algorithm: HOx,± H|0i. Give a degree-2 polynomialp(x0 , x1 ) that equals the probability that this algorithm outputs 1 on input x. What function
does this algorithm compute?
3. Consider polynomial p(x0 , x1 ) = 0.3 + 0.4x0 + 0.5x1 , which approximates the 2-bit OR function. Write down the symmetrized polynomial q(x0 , x1 ) = 21 (p(x0 , x1 ) + p(x1 , x0 )). Give asingle-variate polynomial r such that q(x) = r(|x|) for all x ∈ {0, 1}2 .
4. (H) Let f be the N -bit Parity function, which is 1 if its input x ∈ {0, 1}N has odd Hamming
weight, and 0 if the input has even Hamming weight (assume N is an even number).
(a) Give a quantum algorithm that computes Parity with success probability 1 on every
input x, using N/2 queries.
(b) Show that this is optimal, even for quantum algorithms that have error probability ≤ 1/3
on every input
94

5. Suppose we have a T -query quantum algorithm that computes the N -bit AND function withsuccess probability 1 on all inputs x ∈ {0, 1}N . In Section 11.2 we showed that such analgorithm has T ≥ N/2 (we showed it for OR, but the same argument works for AND).
Improve this lower bound to T ≥ N .
6. Consider the following 3-bit function f : {0, 1}3 → {0, 1}:
f (x0 , x1 , x2 ) = 1 if x0 = x1 = x2 , and f (x0 , x1 , x2 ) = 0 otherwise(a) How many queries does a classical deterministic algorithm need to compute f ? Explain
your answer.
(b) Give a quantum algorithm that computes f with success probability 1 using 2 queries.
(c) (H) Show that 2 queries is optimal: there is no quantum algorithm that computes fwith success probability 1 using only 1 query.
7. Let f be the N -bit Majority function, which is 1 if its input x ∈ {0, 1}N has Hamming weight> N/2, and 0 if the input has Hamming weight ≤ N/2 (assume N is even).
(a) Prove that deg(f ) ≥ N/2. What does this imply for the query complexity of exact
quantum algorithms that compute majority?
(b) (H) Use the adversary method to show that every bounded-error quantum algorithm
for computing Majority, needs Ω(N ) queries. Be explicit about what relation R you’reusing, and about the values of the parameters m0 , m1 , `0 , `1 .
8. Let k be an odd natural number, N = k 2 , and define the Boolean function f : {0, 1}N → {0, 1}
as the k-bit majority of k separate k-bit OR functions. In other words, the N -bit input isx = x(1) . . . x(k) with x(i) ∈ {0, 1}k for each i ∈ [k], and f (x) is the majority value of the kbits OR(x(1) ), . . . , OR(x(k) ). Use the adversary method to prove that computing this f witherror probability ≤ 1/3 requires Ω(N 3/4 ) quantum queries. Be explicit about what relation
R you’re using, and about the values of the parameters m0 , m1 , `0 , `1 .
9. This question is about the quantum complexity of inverting a permutation, which is an
important problem in cryptography. Let N be a power of 2 and S = {0, . . . , N − 1}. Letx ∈ S N correspond to a permutation on S, meaning that each j ∈ S occurs exactly once asan entry of x (so the map i 7→ xi is a permutation). Suppose we can query x, i.e., we have aunitary Ox that maps |i, ji → |i, xi + j mod N i for all i, j ∈ S, and we can also apply Ox−1 .
(a) Show how we can
S for which xi = 0, with success probability√ find the unique index i ∈−1≥ 2/3, using O( N ) queries to Ox and Ox .
(b) (H) The adversary lower bound of Section 11.3 still works with the following modifications:(1) the x’s and y’s are not binary strings, but strings over a larger alphabet, such as S,
and (2) let `x,i be the number of y ∈ Y such that (x, y) ∈ R and xi 6= yi ; `y,i be thenumber of x ∈ X such that (x, y) ∈ R and xi 6= yi ; and `max = max{`x,i · `y,i : (x, y) ∈R, i ∈ {0, . . . , N − 1}, xi 6= yi }.
p
In this case the quantum query lower bound is Ω( m0 m1 /`max ). You may assume thiswithout proof.
√
Use this strengthened adversary bound to show a lower bound of Ω( N ) quantum
queries for computing the task of part (a).
9510. (H) Consider the sorting problem: there are N numbers a1 , . . . , aN and we want to sort these.
We can only access the numbers by making comparisons. A comparison is similar to a blackbox query: it takes 2 indices i, j as input and outputs whether ai < aj or not. The output
of a sorting algorithm should be the list of N indices, sorted in increasing order. It is known
that for classical computers, N log(N ) + O(N ) comparisons are necessary and sufficient for
sorting. Prove that a quantum algorithm needs at least Ω(N ) comparisons for sorting, even
if it is allowed an error probability ≤ 1/3.
11. Consider a total Boolean function f : {0, 1}N → {0, 1}. Given an input x ∈ {0, 1}N andsubset B ⊆ {0, . . . , N − 1} of indices of variables, let xB denote the N -bit input obtained
from x by flipping all bits xi whose index i is in B. The block sensitivity bs(f, x) of f at
input x, is the maximal integer k such that there exist disjoint sets B1 , . . . , Bk satisfying
f (x) 6= f (xBi ) for all i ∈ [k]. The block sensitivity bs(f ) of f is maxx bs(f, x).
(a) (H) Show that the bounded-error quantum query complexity of f is Ω(pbs(f )).

(b) It is known that for every total Boolean function f , there is a classical deterministic
algorithm that computes it using O(bs(f )3 ) many queries. What can you conclude
from this and part (a) about the relation between deterministic and quantum querycomplexity for total functions?
12. (H) In this exercise we will derive the quantum lower bound for the search problem in a selfcontained way, without using the polynomial or adversary method (this exercise uses what iscalled the “hybrid method”).
Let N = 2n . Consider an input x ∈ {0, 1}N that we can query. Assume x has Hamming
weight 0 or 1, and suppose we would like to find the unique solution to the search problem (if a solution exists). Let A be any T -query quantum algorithm for this. Suppose forsimplicity that the algorithm acts on only n qubits (so there are no auxiliary qubits), andA = UT Ox,± UT −1 Ox,± · · · U1 Ox,± U0 , so A interleaves phase-queries to x and unitaries thatare independent of x. The initial state is |0n i. Let |ψxt i denote the n-qubit state right after
applying Ut , when we run A on input x, so the final state is |ψxT i. Let ei ∈ {0, 1}N be theinput that has a 1 only at position i. Assume the algorithm A is successful in finding the rightsolution i after T queries in the following sense: |ψeTi i − |ii ≤ 1/4 and |ψ0TN i − |ii ≥ 3/4
for all i ∈ {0, . . . , N − 1} (note that the basic Grover algorithm is an example of such an A).
(a) Consider the run of algorithm A on P
input x = 0N , and for t ∈ {0, . . . , T − 1} let the−1tamplitudes αt,i be such that |ψ0N i = N
i=0 αt,i |ii.
Prove that |ψ01N i − |ψe1i i ≤ 2|α0,i |, for all i ∈ {0, . . . , N − 1}.
P −1(b) Prove that |ψ0TN i − |ψeTi i ≤ 2 Tt=0|αt,i |, for all i ∈ {0, . . . , N − 1}.
(c) Prove that 1/2 ≤ |ψ0TN i − |ψeTi i , for all i ∈ {0, . . . , N − 1}.
√(d) Prove that T ≥ N /4.
13. Consider a standard quantum query algorithm: it makes T queries to a string x ∈ {0, 1}N ,with arbitrary unitaries U0 , U1 , . . . , UT (that are independent of x) around the queries, andthen measures a POVM {M, I − M } on the final m-qubit state |ψx i.
96

(a) Show that the probability P (x) of getting the first measurement outcome (on input x)
is hψx |M |ψx i, and that this can be written as an N -variate multilinear polynomial in
the bits of x of degree ≤ 2T .
(b) (H) A k-wise independent distribution D is a probability distribution over {0, 1}N , suchthat for each set S ⊆ [N ] of at most k coordinates, the distribution on the k-bit substringxS = (xi )i∈S is uniformly random (i.e, for each z ∈ {0, 1}k , the probability under
distribution D of the event that xS = z, is 1/2k ).
Show that a T -query quantum algorithm cannot distinguish the uniform distribution
U on its input x from a 2T -wise independent distribution D on x, in the sense thatno matter what binary measurement the algorithm does at the end, the probability ofoutput 1 is the same under U and under D.

97

98

Chapter 12

Quantum Algorithms from theGeneralized Adversary Bound
12.1

The generalized adversary boundIn the previous chapter we saw two different lower bound methods for the quantum query complexityof a given function f : the polynomial method and the adversary method. Neither is optimal forevery possible f . For example, the polynomial method doesn’t give optimal lower bounds for
iterations of some small functions [13] (see Exercise 1), while the adversary bound of Section 11.3
cannot prove optimal lower bounds for instance for distinguishing 2-to-1 from 1-to-1 inputs.
In this chapter we will look at a stronger version of the adversary bound, which turns out togive optimal quantum query complexity lower bounds for all Boolean functions. The beauty ofan optimal lower bound method is that it can also produce algorithms: if the best-possible lower
bound on the query complexity of f is T , then there must actually exist a T -query algorithm for f !
Suppose f : D → {0, 1}, with D ⊆ {0, 1}N , is a Boolean function whose quantum query complexity we’d like to determine.1 Consider a T -query quantum algorithm A = UT Ox UT −1 · · · U1 Ox U0 ,with initial state |0m i, that computes f with error probability ≤ ε < 1/2 for each x ∈ D. Let |ψxt idenote the algorithm’s state after Ut has been applied, given input x. Note that |ψx0 i = U0 |0m i isindependent of x. The crucial property, already used in the earlier version of the adversary bound,is that hψxt |ψyt i is 1 at the start (t = 0), but has to be small at the end (t = T ) for every (x, y)-pairwith different function values f (x) 6= f (y).
adversary matrix puts weights αx ∈ C on the inputs x ∈ D, with the constraint
P The generalized
2 for normalization. It also puts real (but possibly negative!) weights Γ|α|xxy on (x, y)-pairsx∈Dwith different function values. We impose the constraint that Γxy = Γyx , and Γxy = 0 wheneverf (x) = f (y). A |D| × |D| matrix Γ with these properties is called an adversary matrix.
Let us use these weights to define a progress measure:2
XSt =Γxy αx∗ αy hψxt |ψyt i.
x,y∈D

In the same spirit as Section 11.3, we will show that |S0 | is large, that |ST | is much smaller, and1

If the domain is D = {0, 1}N then f is called a total function, otherwise it’s a partial function.
We could have just absorbed the αx∗ αy into the Γxy and dispensed with the αx ’s altogether, but it will be cleaner
to have separate weights on the x’s and separate weights Γxy on the pairs.
299that St+1 can’t be too different from St (i.e., St can’t change very fast if we spend one more query).
This will give the lower bound on T .
At the start of the algorithm(t = 0), before any queries have been made, we have hψx0 |ψy0 i = 1
P
for all x, y and hence S0 = x,y Γxy αx∗ αy = α∗ Γα. Since α is restricted to a unit vector, the biggest
we can make |S0 | is|S0 | = kΓk,the operator norm (largest singular value) of Γ, by choosing α to be an eigenvector of Γ corresponding to the largest eigenvalue in absolute value.
At the end of the algorithm (t = T ), the final states |ψxT i and |ψyT i must be distinguishable
with success probability ≥ 1 − ε whenever f (x) 6= f (y). The following claim, proved in Exercise 2,
shows that this forces |ST | to be significantly smaller than |S0 |.
p
Claim 1 |ST | ≤ 2 ε(1 − ε) kΓk.
For example, if our algorithm has error probability ε = 1/3, then |ST | < 0.95 kΓk. Accordingly, theprogress measure has to change significantly in the course of the T -query algorithm. How much can
one more query change St ? This is upper bounded by the following claim, proved in Exercise 3.
Claim 2 Let Γi denote the |D| × |D| matrix obtained from Γ by setting Γxy to 0 if xi = yi . For allt ∈ {0, . . . , T − 1} we have |St − St+1 | ≤ 2 maxi∈[N ] kΓi k.
These two claims, together with our value for the initial |S0 |, imply


T
−1
T
−1

X
X
p
1 − 2 ε(1 − ε) kΓk ≤ |S0 | − |ST | ≤ |S0 − ST | = |St − St+1 | ≤|St − St+1 | ≤ 2T max kΓi k.
t=0

t=0

i∈[N ]

We get the following lower bound on quantum query complexity, due to Høyer, Lee, and Špalek [139]:
Theorem 2 (Generalized adversary bound) Let f : D → {0, 1}, with D ⊆ {0, 1}N , and Γ
be an adversary matrix for f . Every quantum
 algorithm that computes f with worst-case error
1 pkΓk
probability ≤ ε, needs at least− ε(1 − ε)queries.
2
maxi∈[N ] kΓi k√As an example, let us (again) prove the Ω( N ) lower bound for search. Consider the domain
D = {0N , e1 , . . . , eN } of inputs of weight 0 or 1 (ej is the N -bit string that has a 1 only at position j).
Define (N + 1) × (N + 1) adversary matrix
0 1 ··· 1
 1 0 ··· 0 
Γ= . . .
..  .
.
.
.
 . .
. . 
1 0 ···

0√
Then kΓk ≥ Γ(1, 0, . . . , 0)T = N . Each Γi is the 2 × 2 X-matrix padded with extra rows and√columns of 0s, so kΓi k = 1. Hence we obtain the familiar lower bound of Ω( N ).
More generally, we can recover the lower bound of Section 11.3 by constructing an appropriate
adversary matrix Γ based on the relation R. The rows and columns of Γ are indexed by D =100

pf −1 (0) ∪ f −1 (1). Define dx = |{y : (x, y) ∈ R}| and similarly define dy . Define Γxy √= 1/ dx dy if(x, y) ∈ R or (y, x) ∈ R, and Γxy = 0 otherwise. Let v be the vector with entries dx , andq note2
1 P
1Tthat kvk = |R|. We have kΓk ≥ kvk2 v Γv = |R| (x,y)∈R 1 = 1. We can also show kΓi k ≤ m`00 `m1 1
q

m0 m1
for all i.3 Now Theorem 2 gives the Ω
bound of Eq. (11.1).
`0 `1

12.2

The dual of the generalized adversary boundConsider the best-possible lower bound that we can obtain by optimizing over adversary matrix Γ:
max kΓks.t. kΓi k ≤ 1∀i ∈ [N ]Γ is symmetricΓxy = 0∀x, y ∈ D with f (x) = f (y)We will call the optimal value the generalized adversary bound for f (a.k.a. the negative-weights
adversary bound ), and denote it by ADV± (f ). Because the statement kΓi k ≤ 1 is equivalent to
the matrix inequality −I  Γi  I, the above maximization problem can be written in the formof a so-called semidefinite program: an optimization problem over real-valued variables, typicallyarranged in one or more matrices, with an objective function that’s linear in the variables, andpsd constraints that are linear in the variables as well. Every maximization-SDP has an associatedminimization-SDP which (under mild assumptions that hold in our case) has the same optimalvalue. The first SDP is called the primal SDP, the second is called the dual SDP.4 The equality ofthe optimal values of these two SDPs is called strong duality (see Exercise 4 for a proof of the easy
half of this equality). This generalizes the better-known strong duality of linear programs, whichcorrespond to SDPs with diagonal matrices.
With some effort that we will skip here, one can show that the dual of the above maximizationSDP can be written as the following minimization-SDP:X
X
min max max 
kuxj k2 ,kvxj k2 
x∈D

s.t.

X

j∈[N ]

j∈[N ]

huxj |vyj i = [f (x) 6= f (y)]∀x, y ∈ D

j:xj 6=yj

The truth-value [f (x) 6= f (y)] is 1 if f (x) 6= f (y), and 0 if f (x) = f (y). This SDP associates withevery x ∈ D and every j ∈ [N ] two vectors uxj and vxj (of some dimension d that will implicitly be
optimized over). We can write this more explicitly as an optimization problem over psd matrices√
Define two |D| × |D|pmatrices A, B by Axy = 1/ dx if xi 6= yi and ((x, y) ∈ R or (y, x) ∈ R), and Axy = 0
otherwise; and Bxy = 1/ dy if xi 6= yi and ((x, y) ∈ R or (y, x) ∈ R), and Bxy = 0 otherwise. Note that Γi = A ◦ B,
where ‘◦’ denotes the entrywise product. For matrices with nonnegativepentries, it is known [231, Appendix A] thatkA ◦ Bk is at most the largest norm among the rows of A (which is ≤ `0 /m0 , because each row of A has at most√
`0 nonzero entries, each of qwhich is at most 1/ m0 ) times the largest norm among the columns of B (which isp≤ `1 /m1 ). Hence kΓi k ≤ m`00 `m11 .
4
Strictly speaking the maximum in the primal should be a supremum and the minimum in the dual should be an
infimum, because the optimal value need not always be attained; it could be that there’s only an infinite sequence offeasible solutions whose objective values converge to the optimum without ever reaching it.
3101

by defining, for each j ∈ [N ], a 2|D| × 2|D| psd matrix Zj whose entries are given by the pairwise
inner products of the 2|D| vectors uxj , vxj (these vectors are the “Gram vectors” of Zj ). Then the
optimization isPover psd matrices Z1 , . . . , ZN , the objective function is the largest diagonal entryof the matrix j∈[N ] Zj , and the constraints are linear functions of the entries of the Zj ’s.
By strong duality, the optimal value of this minimization-SDP is ADV± (f ) as well. A feasible solution Γ to the primal gives a lower bound on ADV± (f ), while a feasible solution {uxj , vxj }x∈D,j∈[N ]for the dual gives an upper bound on ADV± (f ). The central result of this chapter is that ADV± (f )is not only a lower bound on the quantum query complexity of f (which follows from Theorem 2)
but also an upper bound, as we will see in the next section. This means that a feasible solution to
the dual SDP actually gives us an algorithm for f !

12.3

ADV± is an upper bound on quantum query complexity

In this section we will construct a bounded-error quantum algorithm for computing f , derived froma feasible solution {uxj , vxj }x∈D,j∈[N ] of the dual SDP for ADV± (f ).5 Let’s say the objective valueof this feasible solution is A; the query complexity of our algorithm will turn out to be O(A). Belowx, y always range over D, and j always ranges over [N ].
Our algorithm will act on 3 registers. The first register is spanned by |ji, j ∈ [N ], the second
is 1 qubit, and the third contains the states |vxj i ∈ span{|1i, . . . , |di} and the special state |0i (sothe third register has dlog(d + 1)e qubits). For each x, define the following two 3-register states:1|t+x i = √ (|0i|0i|0i + |1i|f (x)i|0i)2

1
and |t−x i = √ (|0i|0i|0i − |1i|f (x)i|0i).
2

The algorithm starts with the all-0 state1−|0i|0i|0i = √ (|t+x i + |tx i).
2−
The goal of the algorithm is to (approximately) multiply |t+
x i with +1 and |tx i with −1, whichrather magically gives a final state that tells us f (x):1−
√ (|t+
x i − |tx i) = |1i|f (x)i|0i.
2
The key will be to use phase estimation (Section 4.6) with a well-chosen unitary Ux that depends−
on x, to distinguish |t+
x i and |tx i. Define Ux = (2Πx − I)(2Λ − I) as the product of two reflections:X
0.02• Consider (unnormalized) states |ψy i = √ |t−i−|ji|yj i|vyj i, where yj = 1 − yj .
y
A
j
√
P
2
√ + A, using triangle inequality and the fact that
Note that k|ψy ik ≤ 0.02
j kvyj k ≤ A. LetAΛ be the projector on the subspace that is orthogonal to the span of these |ψy i’s, and 2Λ − I
be the reflection through this subspace. In other words, the unitary 2Λ − I puts a − in frontof all |ψy i’s and leaves states alone if they are orthogonal to all |ψy i’s. This reflection costs
no queries to implement, since it doesn’t depend on the actual input x.
5

Our presentation follows the approach of [164], modified and simplified for our special case of computing Booleanfunctions rather than their more general case of state-transformation. For other generalizations of the adversary boundto different scenarios, see [44]. Reichardt’s first proof of the optimality of the generalized adversary bound [205, 207]
went through so-called “span programs,” but we won’t need those here.

102

• Let Πx be the projector on the subspace spanned by states that have |ji|xj i in their first two
registers (with arbitrary states in the third register) and by states having |0i in their third
register. Then the reflection 2Πx −I through this subspace puts a − in front of states |ji|xj i|vi
if hv|0i = 0, and leaves the states alone that are in the subspace of Πx . This reflection canbe implemented with 1 query to x (Exercise 5).
−
We now relate |t+
x i and |tx i to the eigenstates of this unitary Ux . In the next two claims, theinformal “close” should be read as “within small constant Euclidean distance.”

Claim 3 |t+
x i is close to an eigenstate |φi of Ux that has eigenvalue 1 (i.e., phase 0).
Proof. Define

0.01 X|φi = |t+|ji|xj i|uxj i.
xi+ √
A j

P
The second term on the right-hand side has norm ≤ 0.01 because j kuxj k2 ≤ A, so |t+
x i is indeed
close to |φi (|φi’s norm is close to but not equal to 1, but this doesn’t matter).
1−
Note that hφ|ψy i = 0 for all y, because ht+
x |ty i = 2 [f (x) 6= f (y)] and

∗
X
X
X
X

huxj |vyj i = [f (x) 6= f (y)],|ji|xj i|uxj i
hxj |yj i · huxj |vyj i =|ji|yj i|vyj i =jj:xj 6=yjjj−and because |t+
x i, |tx i have |0i in the third register and so are orthogonal to all |ji|bi|uxj i, |ji|bi|vxj i,b ∈ {0, 1}. This shows that |φi lies in the subspace of Λ, so it is an eigenvalue-1 eigenvector of 2Λ−I.
Also, |φi is a linear combination of |t+x i (which has |0i in its third register) and states that have|ji|xj i in their first two registers, so |φi lies in the subspace of Πx and hence is also an eigenvalue-1
eigenvector of 2Πx − I. Hence |φi is an eigenvalue-1 eigenvector of Ux = (2Πx − I)(2Λ − I).
2iθClaim 4 |t−
x i is close to a superposition of eigenstates of Ux with eigenvalues of the form e withθ ∈ (−π, π] and |θ| > Θ = 1/(1000A).

Proof. Let {|βi} be a completePorthonormal set of eigenvectors of Ux , with respective eigenvalueseiθβ , θβ ∈ (−π, π]. Let PΘ =β:|θβ |≤Θ |βihβ| be the projector on the eigenvectors with small√
eigenphase. Define vectors w = 100 A|ψx i and v = PΘ Πx w = PΘ |t−
x i. Our goal is to show that v
has small norm.
To that end, define v 0 = (2Λ − I)v and v 00 = (2Πx − I)v 0 = Ux v, and note that
2

v−v

00 2

=

X
β:|θβ |≤Θ(1 − eiθβ)hβ|vi|βi=X|1−eiθβ |2 ·|hβ|vi|2 ≤ 2(1−cos Θ)kvk2 ≤ Θ2 kvk2 .

β:|θβ |≤Θ

Because v + v 0 = 2Λv, the vector√v + v 0 lies in the subspace corresponding to Λ and hence isorthogonal to |ψx i and to w = 100 A|ψx i. We then have
0 = hv + v 0 |wi = hv + v 0 |Πx |wi + hv + v 0 |(I − Πx )|wi = hv + v 00 |Πx |wi + hv − v 00 |(I − Πx )|wi,
103where the last equality used that v 0 + v 00 = 2Πx v 0 (hence Πx (v 0 + v 00 ) = 2Πx v 0 and so Πx v 0 = Πx v 00 )and v 0 − v 00 = 2(I − Πx )v 0 (hence (I − Πx )v 0 = −(I − Πx )v 00 ). We can now upper bound kvk by
kvk2 = |hv|PΘ Πx |wi| = |hv|Πx |wi|1
1
= |hv − v 00 |Πx |wi + hv + v 00 |Πx |wi| = |hv − v 00 |(2Πx − I)|wi|
2
2
√
1
1
v − v 00 · kwk ≤ Θkvk · 100 Akψx k
≤
2
2
 

√
0.02 √
1
1 1
1
kvk,
≤
kvk · 100 A √ + A =+2 1000A
20 1000A
A
where the first inequality is Cauchy-Schwarz. This implies kvk ≤ 1/20 + 1/(1000A), which is small(we may assume A ≥ 1).
2
Phase estimation with precision Θ/2 can distinguish between these two cases (eigenphase 0 vs−≥ Θ). This allows us to put a + in front of |t+
x i and a − in front of |tx i: run phase estimation,
multiply with −1 whenever the absolute value of the phase estimate is > Θ/2, and then invert
the phase estimation. Phase estimation uses O(1/Θ) = O(A) applications of Ux , and hence O(A)queries to x, as promised. There are small errors in this process due to the fact that Claims 3 and 4
say “close to” rather than “equal,” and due to the small approximation errors of phase estimation.
Accordingly, our final state will be close to |1i|f (x)i|0i but necessarily equal to it, and we end up
with an O(A)-query quantum algorithm for f that has a small error probability.
It should be noted that the upper bound is on the algorithm’s query complexity, not on its
gate complexity. The number of gates of the algorithm is O(A) times the number of gates needed
to implement the reflection 2Λ − I (the reflection 2Πx − I is relatively easy to implement, see
Exercise 5). In general this number of gates could be very large, though in some cases it can bemade quite small, for instance [17].

12.4

Applications√
Let us see how we can derive an O( N )-query quantum algorithm for the N -bit OR function fromthe dual adversary, for the special case where the N -bit input x is promised to have at most one
1-bit. Consider the set D = {0N , e1 , . . . , eN } of possible inputs. For the dual adversary bound
we need to choose vectors uxj , vxj for each x ∈ D and j ∈ [N ]. Here vectors of dimension 1 (i.e.,
numbers) already suffice: we define u0N j = v0N j = 1/N 1/4 for all j, and uek j = vek j P= N 1/4 if
j = k and uek j = vek j = 0 otherwise. For the objective function, note that for each x, j u2ek j =√√P 2
N ; for x = 0N this is because each of the N j’s contributes (1/N 1/4 )2 = 1/ N to thej vek j =√1/4 )2 =sum, while for x = ek there
is
only
one
nonzerocontribution,
namely(N
N for j = k. It
P
is also easy to verify that j:xj 6=yj uxj vyj = [f (x) 6= f (y)] for all x, y ∈ D.
A number of new quantum algorithms have been derived from the dual SDP for ADV± , forinstance for finding k-collisions [40], learning and testing “juntas” (functions that only depend on
few coordinates) [43, 17], st-connectivity in graphs [46], and formula evaluation [208, 18]. In general
it is often quite hard and non-intuitive to come up with a feasible solution {uxj , vxj } for the dual
SDP with a small objective value, but Belovs’s learning graphs [41] can sometimes help with moreintuitive constructions of feasible solutions.
104

12.5

Perfect composition and AND-OR trees

If we have two Boolean functions f : {0, 1}n → {0, 1} and g : {0, 1}m → {0, 1}, then we can define
the function F = f ◦ g n (on N = nm bits) which is their composition, as
F (x1 , . . . , xn ) = f (g(x1 ), . . . , g(xn ))where each xi ∈ {0, 1}m . One beautiful property of the adversary bound is perfect composition:
ADV± (F ) = ADV± (f )ADV± (g).
There are no hidden constant factors here! The upper bound ADV± (F ) ≤ ADV± (f )ADV± (g)of this composition property can be proved by combining feasible solutions for the dual SDPs forf and g to a feasible solution for the dual SDP for F . Similarly, the lower bound ADV± (F ) ≥ADV± (f )ADV± (g) can be proved by combining feasible solutions for the primal SDPs for f and g.
We will skip the rather technical details, see [45] for proof of a stronger and more general result.
Because of the optimality of the generalized adversary bound, it follows from the composition
property that the quantum query complexity of F equals the product of the query complexities of f
and g, up to a constant factor. For example, for the 2-level AND-OR
tree on N = k 2 bits mentioned√
at the end of Chapter 11, we immediately get an optimal O( N )-query quantum algorithm from thefact that the√k-bit AND and OR functions each have quantum query complexity (and hence ADV± )equal to Θ( k). Note that we are not directly composing bounded-error algorithms here (e.g.,trying to put Grover on top of another Grover to compute the AND-OR tree): reasoning about thecomposed function at the level of the adversary bound and then only translating to quantum queryalgorithms at the end, cleanly circumvents the problem of how the error probabilities of composedbounded-error algorithms for f and g affect the error probability of the resulting algorithm for F .
This composition result, used in a more subtle way, can also give a quantum speed-up forevaluating game trees. Imagine a two-player game, such as chess. First white chooses one of several
possible moves, then black chooses one of several moves, etc. We can picture this as a tree where
the root is the initial position and the leaves are the final positions (which are win, lose, or draw).
If we assign a binary value to each leaf indicating whether white wins, then the evaluation of thegame as a whole is a large, multilevel, unbalanced, AND-OR tree. If it’s white’s turn and at least
one subtree evaluates to 1, then the current position is a 1 as well: there is a winning move for white(this corresponds to an OR function). If it’s black’s turn and one of the subtrees from the current
position is labeled 0 then the current position is also labeled 0 because black has a non-losing move(this is an AND function). The value at the root of the tree indicates whether white has a sequenceof moves guaranteed to win or not. Using the adversary bound to do a more subtle
AND-OR√
composition, there is a quantum algorithm that evaluates this tree using roughly N queries tothe binary values at the leaves [18, 206]. In contrast, a classical algorithm has to evaluate nearly
all N leaves in the worst case unless the fan-out of the tree is very small [215].

Exercises
1. Consider the symmetric 4-bit Boolean function g(x0 , x1 , x2 , x3 ) which is 1 iff the 4-bit input x
is increasing or decreasing, i.e., if x ∈ {0000, 0001, 0011, 0111, 1111, 1110, 1100, 1000}. Let f
be the function on N = 4d input bits obtained by composing g with itself d times, in a treeof depth d, where the value of each internal node is obtained by applying g to the values of
its 4 children, and with the input bits at the N leaves.
105

(a) Show that deg(g) ≤ 2 and deg(f ) ≤ 2d .

√(b) Show that the polynomial method cannot prove a lower bound better than O( N ) on
the bounded-error quantum query complexity of f .
(c) It is known that ADV± (g) > 2.51 . . . (see [42, Example 3.3] for a proof, or you could
use an SDP-solver). Use this to show that ADV± (f ) ≥ N c for some c > 1/2.
Comment: This exercise shows that the generalized adversary bound can sometimes prove substantiallystronger lower bounds than the polynomial method. Incidentally, [42, Example 3.3] also shows that if we
restrict the adversary matrix to have nonnegative entries, then the best adversary lower bound we can provefor g is 2.5, and hence the best lower bound we can prove for the quantum query complexity f with such
restricted Γ, is at most Ω(2.5d ). So this example also shows that the “negative weights” ADV± can give
substantially better bounds than the “nonnegative weights” version of the adversary bound.

2. (H) This exercise justifies Claim 1. Below, the x, y always range over D.
(a) Let P1 , P0 denote the projectors on the subspaces corresponding to outputs 1 and 0,
respectively. Suppose inputs x, y have f (x) 6= f (y).
Show that hψxt |ψyt i = hψxt |Pf (x) · P1−f (y) |ψyt i + hψxt |P1−f (x) · Pf (y) |ψyt i for all t, x, y.
PP(b) Define unnormalized states |φi = x αx Pf (x) |ψxT i|xi and |φ⊥ i = x αx P1−f (x) |ψxT i|xi.
p2
2Show that k|φik2 + |φ⊥ i = 1, |φ⊥ i ≤ ε, and k|φik · |φ⊥ i ≤ ε(1 − ε).
(c) Show that |ST | ≤ 2|hφ|(I ⊗ Γ)|φ⊥ i|.
p(d) Show that |ST | ≤ 2 ε(1 − ε) kΓk.
3. (H) This exercise justifies Claim 2. It will be convenient for the proof to assume a phaseoracle, so the T -query algorithm will be of the form UT Ox,± UT −1 · · · U1 Ox,± U0 , applied toinitial state |0m i and followed by a measurement of the first qubit to produce the output bit.
Below, the x, y always range over D and the i ranges over [N ].
P(a) Show that St − St+1 = x,y Γxy αx∗ αy hψxt |(I − Ox,± Oy,± )|ψyt i.
(b) Let Pi = |iihi| ⊗ I be the projector on the space where the query register is |ii. DefinePP2|φti i = x αx Pi |ψxt i|xi. Show that i |φti i = 1.
P(c) Show that St − St+1 = 2 i hφi |(I ⊗ Γi )|φi i.
(d) Show that |St − St+1 | ≤ 2 maxi kΓi k.
4. (H) The following is a primal-dual pair of SDPs in so-called standard form:
min Tr(CX)s.t. Tr(Ai X) = bi ∀i ∈ [m]X0Ty
max bPms.t.
i=1 yi Ai  C

The input here consists of Hermitian n × n matrices C, A1 , . . . , Am and vector b ∈ Rm . Then × n matrix X is the variable of the primal, and the vector y ∈ Rm is the variable of thedual. Prove that “weak duality” always holds: for every feasible solution X for the primaland every feasible solution y for the dual, we have Tr(CX) ≥ bT y.
5. Show how the reflection 2Πx − I can be implemented with 1 phase-query to x, a Z-gate, anda circuit that decides if the third register is |0i.
106Chapter 13

Quantum Complexity Theory
13.1

Most functions need exponentially many gates

As we have seen, quantum computers seem to provide enormous speed-ups for problems like factoring, and square-root speed-ups for various search-related problems. Could they be used tosignificantly speed up all or almost all problems? Here we will show that this is not the case:quantum computers are not significantly better than classical computers for most problems.
Consider the problem of computing a Boolean function f : {0, 1}n → {0, 1} by means of aquantum circuit. Ideally, most such functions would be computable by efficient quantum circuits(i.e., using at most poly(n) elementary gates). Instead, we will show by means of a simple counting
argument that almost all such functions f have circuit complexity nearly 2n . This is a variant of awell-known counting argument for classical Boolean circuits due to Riordan and Shannon [209].
Let us fix some finite set of elementary gates, for instance the Shor basis {H, T, CNOT} or{H, Toffoli}. Suppose this set has k types of gates, of maximal fanout 3. Let us try to count the
number of distinct circuits that have at most C elementary gates. For simplicity we include theinitial qubits (the n input bits as well as workspace qubits, which are initially |0i) as a (k + 1)sttype among those C gates. First we need to choose which type of elementary gate each of the C
gates is; this can be done in (k + 1)C ways. Now every gate has at most 3 ingoing and 3 outgoingwires. For each of its 3 outgoing wires we can choose an ingoing wire into one of the gates in thefollowing level; this can be done in at most (3C)3 ways. Hence the total number of circuits withup to C elementary gates is at most (k + 1)C (3C)3C = C O(C) . We are clearly overcounting here,
but that’s OK because we want an upper bound on the number of circuits.
We’ll say that a specific circuit computes a Boolean function f : {0, 1}n → {0, 1} if for every
input x ∈ {0, 1}n , a measurement of the first qubit of the final state (obtained by applying the circuit
to initial state |x, 0i) gives value f (x) with probability at least 2/3. Each of our C O(C) circuits
can compute at most one f (in fact some of those circuits don’t compute any Boolean function
at all). Accordingly, with C gates we can compute at most C O(C) distinct Boolean functionsnf : {0, 1}n → {0, 1}. Hence even if we just want to be able to compute 1% of all 22 Booleanfunctions, then we already needC O(C) ≥1 2n
2 , which implies C ≥ Ω(2n /n).
100

Accordingly, very few computational problems will be efficiently solvable on a quantum computer.
Below we will try to classify those using the tools of complexity theory.
107

13.2

Classical and quantum complexity classes

A computational decision problem on binary strings corresponds to what is often called a “language”
in complexity theory: a language L ⊆ {0, 1}∗ is a set of binary strings of arbitrary lengths, and thecorresponding decision problem is to determine whether a given string is an element of L or not.
For example, L could be the set of prime numbers encoded in binary (corresponding to the problem
of deciding whether a given number is prime or not) or the set of satisfiable Boolean formulas. It
is often convenient to think of such a decision problem as corresponding to a sequence of Booleanfunctions fn : {0, 1}n → {0, 1}, one for each input length n, where fn takes value 1 exactly on the
n-bit strings that are in L.
A “complexity class” is a set of decision problems (i.e., languages) that all have similar complexity in some sense, for instance the ones that can be solved with polynomial time or polynomial
space. Let us first mention four of the most important classical complexity classes:• P. The class of problems that can be solved by classical deterministic computers using
polynomial time.
• BPP. The problems that can be solved by classical randomized computers using polynomial
time (and with error probability ≤ 1/3 on every input).
• NP. The problems where the ‘yes’-instances can be verified in polynomial time if someprover gives us a polynomial-length “witness.” More precisely, a language L is in NP iff
there exists a deterministic polynomial-time algorithm A, with two inputs x, y (where y is at
most polynomially longer than x), such that x ∈ L iff there is a y such that A(x, y) outputs 1.
Some problems L in this class are NP-complete, meaning that any other problem L0 ∈ NP
can be reduced to L in polynomial time: there exists a polynomial-time computable function
f such that x ∈ L0 iff f (x) ∈ L. Hence the NP-complete problems are the hardest problems in
NP. An example is the problem of satisfiability: we can verify that a given Boolean formula
is satisfiable if a prover gives us a satisfying assignment y, so the satisfiability-problem isin NP, but one can even show that it is NP-complete. Other examples of NP-complete
problems are integer linear programming, travelling salesman, graph-colorability, etc.
• PSPACE. The problems that can be solved by classical deterministic computers using
polynomial space.
We can consider quantum analogues of all such classes, an enterprise that was started by Bernsteinand Vazirani [53]:• EQP. The class of problems that can be solved exactly by quantum computers using polynomial time. This class depends on the set of elementary gates one allows, and therefore isnot so interesting.
• BQP. The class of problems that can be solved by quantum computers using polynomial time(and with error probability ≤ 1/3 on every input). This class is the accepted formalizationof “efficiently solvable by quantum computers.”• “quantum NP”. In analogy with the above definition of NP, one could define quantum NP
as the class of problems where the ‘yes’-instances can be verified efficiently if some prover
gives us a “quantum witness” of a polynomial number of qubits. For every ‘yes’-instance108

there should be a quantum witness that passes the verification with probability 1, while for‘no’-instances every quantum witness should be rejected with probability 1. This class isagain dependent on the elementary gates one allows, and not so interesting.
Allowing error probability ≤ 1/3 on every input, we get a class called QMA (“quantum
Merlin-Arthur”). This is a more robust and more interesting quantum version of NP. In
particular, like NP, QMA has complete problems: problems in QMA to which every other
QMA-problem can be efficiently reduced. The most famous example of such a problem is deciding whether the ground state energy (i.e., lowest eigenvalue) of a given k-local Hamiltonian(see Chapter 9) is at most some given number a or at least a + 1/poly(n). Determining the
ground state energy of a given physical system is extremely important in physics and chemistry. It is not hard to see that the problem is in QMA: we can just let the quantum witness
be the ground state (i.e., an eigenstate for the lowest eigenvalue) and measure its energy using
the Hamiltonian, which is the observable corresponding to total energy. The problem turns
out to be QMA-complete already for k = 2 [156, 149]. We will devote Chapter 14 to this.
• QPSPACE. The problems that can be solved by quantum computers using polynomial
space. This turns out to be the same as classical PSPACE.
As explained in Appendix B.2, in all the above cases the error probability 1/3 can be reduced
efficiently to much smaller constant ε > 0: just run the computation O(log(1/ε)) times and takethe majority of the answers given by these runs.
We should be a bit careful about what we mean by a “polynomial-time [or space] quantum
algorithm.” Our model for computation has been quantum circuits, and we need a separate quantum circuit for each new input length. So a quantum algorithm of time p(n) would correspond toa family of quantum circuits {Cn }, where Cn is the circuit that is used for inputs of length n; itshould have at most p(n) elementary gates.1
We have BPP ⊆ BQP, because a BPP-machine on a fixed input length n can be written
as a polynomial-size reversible circuit (i.e., consisting of Toffoli gates) that starts from a statethat involves some coin flips. Quantum computers can generate those coin flips using Hadamardtransforms, then run the reversible circuit, and measure the final answer bit. It is believed that
BQP contains problems that aren’t in BPP, for example factoring large integers: this problem(or rather the decision-version thereof) is in BQP because of Shor’s algorithm, and is generally
believed not to be in BPP. In the next section we will prove that BQP ⊆ PSPACE. Thus we
get the following sequence of inclusions:P ⊆ BPP ⊆ BQP ⊆ PSPACE.
It is generally believed that P = BPP [140], while the other inclusions are believed to be strict.
Note that a proof that BQP is strictly greater than BPP (for instance, a proof that factoringcannot be solved efficiently by classical randomized computers) would imply that P 6= PSPACE,
solving what has been one of the main open problems in computers science since the 1960s. Hencesuch a proof—if it exists at all—will probably be very hard.
1

To avoid smuggling loads of hard-to-compute information into this definition (e.g., Cn could contain information
about whether the n-th Turing machine halts or not), we will require this family to be efficiently describable: there
should be a classical Turing machine which, on input n and j, outputs (in time polynomial in n) the j-th elementarygate of Cn , with information about where its incoming and outcoming wires go.

109

What about the relation between BQP and NP? It’s generally believed that NP-complete
problems are probably not in BQP. The main evidence for this is the lower bound for Groversearch: a quantum brute-force search on all 2n possible assignments to an n-variable formula gives
a square-root speed-up, but not more. This is of course not a proof, since there might be somemore clever, non-brute-force methods that exploit the structure of the problem to solve satisfiability.
However, neither in the classical nor in the quantum case do we know clever methods that solve
the general satisfiability problem much faster than brute-force search.
Finally, there could also be problems in BQP that are not in NP, so it may well be that BQP
and NP are incomparable. Much more can be said about quantum complexity classes; see for
instance Watrous’s survey [246].

13.3

Classically simulating quantum computers in polynomial space

When Richard Feynman first came up with quantum computers [111], he motivated them by“the full description of quantum mechanics for a large system with R particles is given by
a function q(x1 , x2 , . . . , xR , t) which we call the amplitude to find the particles x1 , . . . , xR
[RdW: think of xi as one qubit], and therefore, because it has too many variables, itcannot be simulated with a normal computer with a number of elements proportional
to R or proportional to N.” [. . . ]“Can a quantum system be probabilistically simulated by a classical (probabilistic, I’dassume) universal computer? In other words, a computer which will give the sameprobabilities as the quantum system does. If you take the computer to be the classicalkind I’ve described so far (not the quantum kind described in the last section) and there
are no changes in any laws, and there’s no hocus-pocus, the answer is certainly, No!”The suggestion to devise a quantum computer to simulate quantum physics is of course a brilliant
one, but the main motivation is not quite accurate. As it turns out, it is not necessary to keep
track of all (exponentially many) amplitudes in the state to classically simulate a quantum system.
Here will prove the result of Bernstein and Vazirani [53] that quantum computers can actually besimulated efficiently in terms of space (though not necessarily in terms of time).
Consider a circuit with T = poly(n) gates that acts on S qubits, where the first n of thoseS qubits give the classical input string. Assume for simplicity that all gates are either the 1qubit Hadamard or the 3-qubit Toffoli gate (as mentioned in Section 2.2, these two gates together
suffice for universal quantum computation), and that the classical output (0 or 1) of the algorithm
is determined by a measurement of the first qubit of the final state. Without loss of generality
S ≤ 3T , because T Toffoli gates won’t affect more than 3T qubits. Let Uj be the unitary thatapplies the j-th gate to its (1 or 3) qubits,
identity to all other qubits. The entries of√ and applies√
this matrix are of a simple form (0, 1/ 2, or −1/ 2 for Hadamard; 0 or 1 for Toffoli) and easy tocompute. Let |i0 i = |xi|0S−n i be the starting state, where x ∈ {0, 1}n is the classical input, andthe second register contains the workspace qubits the algorithm uses. The final state will be|ψx i = UT UT −1 · · · U2 U1 |i0 i.
The amplitude of basis state |iT i in this final state is
hiT |ψx i = hiT |UT UT −1 UT −2 · · · U2 U1 |i0 i.
110Inserting an identity matrix I =2i∈{0,1}S |iihi| between the gates, we can rewrite this as

P




X

hiT |ψx i = hiT |UT |iT −1 ihiT −1 | UT −1 X|iT −2 ihiT −2 | UT −2 · · · U2

iT −2

iT −1 ∈{0,1}SX

TY

iT −1 ∈{0,1}S ,...,i1 ∈{0,1}S

j=1

=



!
X

|i1 ihi1 | U1 |x, 0i

i1

hij |Uj |ij−1 i.

The term hij |Uj |ij−1 i is just one entry of the matrix Uj and hence easy to calculate because Uj actsQ
non-trivially on only 1 or 3 qubits (see Exercise 2). Then Tj=1 hij |Uj |ij−1 i is also easy to compute,in polynomial space (and even√ in polynomial time). If ` of the T gates are Hadamards, then eachsuch term is either 0 or ±1/ 2` .
Q
Adding up Tj=1 hij |Uj |ij−1 i for all iT −1 , . . . , i1 is also easy to do in polynomial space if wereuse space for each new iT −1 , . . . , i1 . Hence the amplitude hiT |ψx i can be computed exactly using
polynomial space.3 We assume that the BQP machine’s answer is obtained by measuring the first
qubit of the final state. Then P
its acceptance probability is the sum of squares of all amplitudes ofbasis states starting with a 1: iT :(iT )1 =1 |hiT |ψx i|2 . Since we can compute each amplitude hiT |ψx i
in polynomial space, and we can loop over all iT ∈ {0, 1}S whose first bit is 1 to sum their squared
amplitudes, the acceptance probability of a BQP-circuit on classical input x can also be computedin polynomial space. This proves the inclusion BQP ⊆ PSPACE.

Exercises
1. (H) The following problem is a decision version of the factoring problem:
Given positive integers N and k, decide if N has a prime factor p ∈ {k, . . . , N − 1}.
Show that if you can solve this decision problem efficiently (i.e., in time polynomial in the
input length n = dlog N e), then you can also find the prime factors of N efficiently.
2. (a) Let U be an S-qubit unitary which applies a Hadamard gate to the k-th qubit, andidentity gates to the other S − 1 qubits. Let i, j ∈ {0, 1}S . Show an efficient way(i.e., using time polynomial in S) to classically calculate the matrix-entry Ui,j = hi|U |ji(note: even though U is a tensor product of 2 × 2 matrices, it’s still a 2S × 2S matrix,
so calculating U completely isn’t efficient).
(b) Let U be an S-qubit unitary which applies a CNOT gate to the k-th and `-th qubits,
and identity gates to the other S − 2 qubits. Let i, j ∈ {0, 1}S . Show an efficient way toclassically calculate the matrix-entry Ui,j = hi|U |ji. Here k and ` need not be adjacent,but you may assume that they are in order to simplify your notation.
3. This exercise shows how to use BQP-algorithms as subroutines in other BQP-algorithms.
2

For the physicists: this is very similar to a path integral.
Of course, the calculation will take exponential time, because there are 2S(T −1) different sequences iT −1 , . . . , i1that we need to go over sequentially.
3111

(a) (H) Suppose L is a language in BQP. Let f be the corresponding Boolean function, so
f (x) = 1 iff x ∈ L. Show that there is a w ≤ poly(n) and a polynomial-size quantum
circuit U that implements the following map for all x ∈ {0, 1}n :p√|x, 0w+1 i 7→ p|x, f (x)i|φ(x)i + 1 − p|x, 1 − f (x)i|ψ(x)i,where p ≥ 1 − exp(−n), and |φ(x)i and |ψ(x)i are states of the w-qubit workspace.
(b) Show that there is a polynomial-size quantum circuit V that (when restricted to thesubspace where the workspace qubits are |0i) is exp(−n)-close in operator norm to thefollowing unitary:
Of : |x, b, 0w i 7→ |x, b ⊕ f (x), 0w i,
for all x ∈ {0, 1}n and b ∈ {0, 1}.
(c) (H) Suppose L is a language in BQP, and you have a polynomial-size quantum circuit
for another language L0 that uses queries to the language L (i.e., applications of theunitary Of ). Show that the language L0 is also in BQP: there is a polynomial-size
quantum circuit for L0 that doesn’t need queries to L.
4. (H) Consider a circuit C with T = poly(n) elementary gates (only Hadamards and Toffolis)
acting on S = poly(n) qubits. Suppose this circuit computes f : {0, 1}n → {0, 1} withbounded error probability: for every x ∈ {0, 1}n , when we start with basis state |x, 0S−n i,run the circuit and measure the first qubit, then the result equals f (x) with probability atleast 2/3.
(a) Consider the following quantum algorithm: start with basis state |x, 0S−n i, run theabove circuit C without the final measurement, apply a Z gate to the first qubit, andreverse the circuit C. Denote the resulting final state by |ψx i. Show that if f (x) = 0
then the amplitude of basis state |x, 0S−n i in |ψx i is in the interval [1/3, 1], while if
f (x) = 1 then the amplitude of |x, 0S−n i in |ψx i is in [−1, −1/3].
(b) PP is the class of computational decision problems that can be solved by classicalrandomized polynomial-time computers with success probability > 1/2 (however, thesuccess probability could be exponentially close to 1/2, i.e., PP is BPP without the ‘B’for bounded-error). Show that BQP ⊆ PP.

112

Chapter 14

QMA and the Local Hamiltonian
Problem
14.1

Quantum Merlin-Arthur (QMA)

One can think of the complexity class NP as formalizing the standard notion of an efficientlyverifiable proof. For example, to prove that a given formula φ is satisfiable we give a satisfying
assignment: this is easy to verify but hard to find (unless P=NP). The theory of NP-completenessshows that many very different computational problems (satisfiability, TSP, integer linear programming, etc.) are essentially the same computational problem, in the sense that instances from one
can easily be translated to instances of another in deterministic polynomial time.
We can relax the notion of proof slightly by allowing the prover and verifier the use of randomness, and allowing them some error probability, say 1/3. For every x ∈ L the prover should be able
to provide a polynomial-size proof or “witness” that convinces the randomized verifier (with probability ≥ 2/3) that x ∈ L; while for x 6∈ L, no matter what purported “witness” the prover sends,
the verifier should only accept with probability ≤ 1/3. For historical reasons [34] the the complexity class corresponding to such L is called Merlin-Arthur (MA), with Merlin referring to theomniscient prover and Arthur referring to the mere mortal (i.e., randomized and polynomial-time)
king who is supposed to verify Merlin’s proofs.
Quantum Merlin-Arthur (QMA) is the proper quantum analogue of NP. We already mentioned
it in the previous chapter, but let us formally define QMA here. In contrast to NP, which consistsof languages L where every string x is either in or out of L, QMA is a class of promise problems. A
promise problem L partitions the set {0, 1}∗ of all binary strings into L1 , L0 , and L∗ . An algorithm
is “promised” that it never receives inputs from L∗ ; if it gets an input from Lb for b ∈ {0, 1}, thenit has to determine b. The usual languages are promise problems where L∗ = ∅.
Definition 1 A promise problem L = (L1 , L0 , L∗ ) is in the class QMA, if there exists a uniform
family {Cn } of polynomial-size quantum circuits with two input registers and one output qubit, anda polynomial w (for “witness length”), such that for all x ∈ {0, 1}∗ :• Completeness: If x ∈ L1 ∩ {0, 1}n , then there exists a w(n)-qubit state |ψi (a “proof ” or“witness” state) such that the circuit Cn outputs 1 with probability ≥ 2/3 when run on x, |ψi.
• Soundness: If x ∈ L0 ∩ {0, 1}n , then for every w(n)-qubit state |ψi, the circuit Cn outputs 1
with probability ≤ 1/3 when run on x, |ψi.
113

If we force |ψi to be classical, then we get a class called QCMA. If we additionally force the verifier
to be classical, then we get MA. And if we additionally replace success probability 2/3 by 1, thenwe get NP.1 Hence NP ⊆ MA ⊆ QCMA ⊆ QMA follows immediately from the definitions. It
is believed that MA=NP [158], for similar reasons as why we believe BPP=P [140]. However,
QMA is strongly believed to be a larger class than NP, meaning that “quantum proofs” canprove more than classical proofs can. Moreover, as we will see later, we can identify important
QMA-complete problems, none of which is in NP (unless NP=QMA).
We have fixed the error probability here to 1/3 rather arbitrarily. We can easily reduce this to amuch smaller δ like we would for a randomized algorithm (see Appendix B.2): repeat the protocol
O(log(1/δ)) times and output the majority output bit of those runs. If done naively, we’d need a
new witness state |ψi in each run, because the measurement that produces the verifier’s output bitin each run can collapse the state. One has to be careful about soundness here, since the prover cansend a large entangled state instead of a tensor product of witness states for the individual runs;
however, it is not too hard to show that this cannot help the prover. This approach increases theverifier’s runtime but also the required witness-size w(n) by a factor O(log(1/δ)). However, there
is a beautiful and quite surprising technique (which we will not explain here) due to Marriott andWatrous [187] that achieves the same error reduction using the same witness state! The verifier’s
runtime in that amplified protocol will still go up by a factor O(log(1/δ)), but the witness-size
remains w(n).

14.2

The local Hamiltonian problem

The quintessential NP-complete problem is satisfiability (SAT): given a formula φ(x1 , . . . , xn ) ofn Boolean variables x1 , . . . , xn 2 , decide if there is an assignment of truth values to x1 , . . . , xn thatmakes the formula true. The famous Cook-Levin theorem [92, 167] says this is NP-complete.
A special case of this is k-SAT, where we restrict the formula φ to be the conjunction of clauses,
each of which is the disjunction of k literals (a literal is a variable xi or its negation). For example,
the following is a 3-SAT instance with 4 clauses on n = 5 Boolean variables:(x1 ∨ ¬x2 ∨ x3 ) ∧ (¬x1 ∨ x2 ∨ x5 ) ∧ (¬x2 ∨ ¬x3 ∨ ¬x5 ) ∧ (x3 ∨ x4 ∨ ¬x5 ).

(14.1)

It is well-known that k-SAT is still NP-complete if k ≥ 3, while 2-SAT is actually in P.
Let us try to reformula k-SAT in a way that looks “more quantum,” by relating it to the minimal
eigenvalue of a particular Hamiltonian (recall from Section 9.1 that the Hamiltonian for a physicalsystem is the observable corresponding to total energy) that is diagonal in the computational basis.
For concreteness we will fix k = 3. Consider a clause C = x1 ∨ ¬x2 ∨ x3 . This has one non-satisfying
assignment, namely x1 = 0, x2 = 1, x3 = 0. With this clause let us associate the following diagonal
1
As mentioned in the previous chapter, requiring success probability 1 instead of 2/3 in QMA itself (like in NP)
leads to an unsatisfactory complexity class because it depends on what set of elementary gates one uses.
2
To remain consistent with the literature we now use n for the number of Boolean variables, not for the actual
length of the input, i.e., the number of bits needed to describe the instance φ. However, the latter should be at mostpolynomial in n.

114

Hamiltonian:






HC = 








0
0













1
0
0
0
0
0

Note that the 1 sits at the location indexed by x1 x2 x3 = 010, the unique non-satisfying assignment
for C. Think of HC as giving a “penalty” of 1 to x if x doesn’t satisfy clause C. We will implicitly
treat HC as an n-qubit Hamiltonian, by tensoring it with identity for the other n − 3 qubits. Thatway, we have hx|HC |xi = 0 if clause C is satisfied by assignment x, and hx|HC |xi = 1 if not.
Now suppose we have a 3-SAT formula φ = C1 ∧ · · · ∧ Cm that is the conjunction of m clauses,
each with 3 literals. To this we associate the following Hamiltonian:
Hφ =

m
X

HCj .

j=1

Note that the eigenvalues of Hφ lie in the interval [0, m], and that Hφ is a 3-local Hamiltonian: eachterm involves only 3 of the qubits non-trivially (more generally, if we start with a k-SAT instance,then Hφ is k-local). Also note that the “energy” of assignment x ∈ {0, 1}n ismXhx|Hφ |xi =hx|HCj |xi,
j=1

which exactly counts the number of unsatisfied clauses under assignment x. The “minimal energy”(lowest eigenvalue λmin ) of Hφ is equal to the minimal number of unsatisfied clauses (= m−themaximal number of satisfied clauses). In particular, φ is satisfiable iff λmin = 0.
The above Hamiltonian is diagonal, and hence rather “classical,” because it is the sum of
diagonal 3-local terms. If instead we allow the terms to be arbitrary 3-local (or even k-local)
Hamiltonians, we arrive at the central problem of this chapter.
Definition 2 The k-local Hamiltonian problem is the following: given a classical description of
an n-qubit Hamiltonian
m
X
H=
Hj
(14.2)
j=1

where each Hj is k-local (i.e., it acts nontrivially on only k of the n qubits) and 0  Hj  I, andgiven parameters a, b ∈ [0, m] with b − a ≥ 1/poly(n), promised that H’s minimal eigenvalue λmin
is either ≤ a or ≥ b, decide which is the case.
Note that this is a promise problem: some H of the form of Eq. (14.2) will have λmin in (a, b)
and hence won’t satisfy the promise. Such instances will form the set L∗ of this promise problem,
while the “≤ a” instances will form L1 and the “≥ b” instances will form L0 . The input H isa 2n × 2n matrix, but because it is k-local we do not need to describe it literally. Instead the115description of H that is given as input will
just consist of each of the m terms as a 2k × 2k matrixn(m · 22k complex numbers) and mdlog k e bits telling us for each of the m terms on which k qubitsthat term acts non-trivially. Accordingly, if m = poly(n), k = O(log n), and each complex entry isrepresented with poly(n) bits, then the actual input length is poly(n) bits.
The assumption that each Hj (and therefore H as well) is positive semidefinite, is not essential.
If we were instead to start with the weaker condition −I  Hj  I, then by defining psd matrices
Hj0 = (Hj + I)/2 we obtain an instance
where 0  Hj0  P
I with a simple relation between thePminimal eigenvalues λmin of H = j Hj and λ0min of H 0 = j Hj0 (namely λ0min = (λmin + m)/2).
This allows us to also model negative energies.
The minimal eigenvalue λmin is known as the “ground state energy” of the Hamiltonian: it isthe energy of the state(s) we get if we cool an n-qubit system governed by H to temperature 0.
Distinguishing λmin ≤ a or λmin ≥ b is essentially equivalent to approximating λmin up to an additive error O(b − a) (see Exercise 3). Finding information about λmin , and more generally about
the lowest eigenvalues of H and about the structure of the “ground states” (the eigenstates foreigenvalue λmin ) is important for many problems in physics and chemistry, for instance in determining the properties of materials at low temperatures (including poorly-understood phenomena
such as superconductivity) and the reaction speeds of chemical reactions. Much work in computational science is expended on solving such problems for particular Hamiltonians corresponding tophysical systems of interest. Such Hamiltonians are typically indeed k-local for small k, at least
approximately, since particles tend to significantly influence only the particles close to them.
Unfortunately the local Hamiltonian problem is NP-hard already for k ≥ 2 and very large
gap between a and b. This follows from our above translation from SAT: we can convert a 2-SAT
instance φ to 2-local Hamiltonian Hφ where λmin = m−the maximal number of satisfied clauses.
Computing the maximal number of satisfied clauses is known as the MAX-2-SAT problem, anddistinguishing between different values that are Ω(m) apart for its value is already known to be
an NP-hard problem [136]. Since it is generally believed that NP 6⊆ BQP, it is unlikely thata quantum computer can solve local Hamiltonian efficiently in general. Even worse, as we will
see next, k-local Hamiltonian turns out to be complete for the complexity class QMA (which ispresumably larger than NP), already for k ≥ 2, but with polynomially small gap between a and b.

14.3

Local Hamiltonian is QMA-complete

In this section we will show that k-local Hamiltonian is QMA-complete, proving a quantum analogue of the Cook-Levin theorem.
First, it is not too hard to see that the problem is in QMA. The witness |ψi for the instancesx ∈ L1 would be a ground state, and there are several efficient ways to approximate its energy inorder to verify that it is indeed ≤ a and not ≥ b (see Exercise 4).
Second, we need to show that k-local Hamiltonian is QMA-hard, meaning that any otherproblem in QMA can be reduced to it. So consider an arbitrary L = (L1 , L0 , L∗ ) ∈ QMA as in
Definition 1, and fix an n-bit input x ∈ L1 ∪ L0 . We would like to convert the circuit Cn into a
Hamiltonian H, such that H has a small eigenvalue iff Cn has high acceptance probability on somestates |ψi. We will assume the error probability is ≤ 1/4T rather than 1/3.
The circuit Cn acts on n + s + w(n) qubits, where the first n qubits contain the fixed classicalinput x (which we will omit below for simplicity), the circuit uses s workspace qubits (which startout as |0i), and the third register contains the purported w(n)-qubit witness state. Since Cn
116consists of some T = poly(n) gates, we can write it as a product Cn = UT · · · U1 where each Ut
is an elementary gate on 1 or 2 qubits, tensored with identity on the other qubits. For a given
w(n)-qubit state |ψi, let |ψ0 i = |0s i|ψi and |ψt i = Ut |ψt−1 i for t ∈ [T ] be the initial, intermediate,and final states of the algorithm. The output qubit of the circuit is obtained by measuring the first
qubit of the final state |ψT i in the computational basis.
We will now describe a Hamiltonian H that “follows” the state and gives “penalties” for every
deviation from the proper sequence of states |ψ0 i, . . . , |ψT i, as well as penalizing a 0-output inthe final measurement. In addition to the register that U acts on, we will add another registerof dlog(T + 1)e qubits that acts like a “clock,” ranging from 0 to T . We will subscript the firsts + w(n) qubits by integers in {1, . . . , s + w(n)}, and subscript the clock register by ‘C’. Define
Hinit

=

Ht

=

s
X

|1ih1|i ⊗ |0ih0|C
i=1
1∗
2 (I ⊗ (|t − 1iht − 1|C + |tiht|C ) − Ut ⊗ |tiht − 1|C − Ut ⊗ |t − 1iht|C ) , for t ∈ [T ]Hfinal = |0ih0|1 ⊗ |T ihT |C
TX
H= Hinit +Ht + Hfinal .
t=1

The number of terms in H is m = s + T + 1. The idea behind this Hamiltonian H is that Hinit
checks that the s workspace qubits are all 0 in the initial state, where the clock register is 0 (giving
an “energy penalty” if some of those workspace qubits are 1); Ht checks that Ut is applied properlyin the t-th step (the factor 1/2 is to ensure Ht  1); and Hfinal checks that the output qubit in the
final state is 1 (giving a penalty if it’s 0). Because the clock register uses dlog(T + 1)e bits, andeach gate Ut acts on at most 2 qubits, the locality of H is k = dlog(T + 1)e + 2 = O(log n). We
will reduce this to a constant later.

14.3.1

Completeness and soundness

We now want to show that we can distinguish x ∈ L1 and x ∈ L0 by considering the smallest
eigenvalue λmin of the above Hamiltonian H. First, for completeness we want to show that if
x ∈ L1 then there is a state with small eigenvalue. Since x ∈ L1 , there is a w(n)-qubit witness
state |ψi that leads U with initial state |ψ0 i = |0s i|ψi to accept (i.e., output 1) with probability≥ 1 − 1/4T . Consider the following state:|ψ 0 i = √TX1|ψt i|ti.
T + 1 t=0This state is sometimes called the “history state” of the circuit U , and you can think of it as thequantum analogue of a satisfying assignment in classical SAT. It faithfully “follows” the intermediate states of the computation. This means |ψ 0 i gets penalty 0 from Hinit and from each Ht . Since
the probability of getting (the incorrect) measurement outcome 0 is ≤ 1/4T , we haveλmin ≤ hψ 0 |H|ψ 0 i =111hψT |hT | Hfinal |ψT i|T i =hψT | (|0ih0|1 ⊗ I) |ψT i ≤
:= a.
T +1
T +1
4T (T + 1)
117

Second, to prove soundness we’ll show that if x ∈ L0 , then λmin is at least b := 2a. Consider any
purported witness state |ψ 0 i. We can write this as|ψ 0 i =TX

αt |φt i|ti

t=0

for some nonnegative reals αt and normalized states |φt i. Note thathψ 0 |Ht |ψ 0 i = (αt−1 hφt−1 |ht − 1| + αt hφt |ht|) Ht (αt−1 |φt−1 i|t − 1i + αt |φt i|ti)1 2
αt−1 + αt2 − αt−1 αt hφt |Ut |φt−1 i − αt−1 αt hφt−1 |Ut∗ |φt i=2
1= kαt |φt i − αt−1 Ut |φt−1 ik2 .
(14.3)
2
So intuitively, assuming αt ≈ αt−1 , the Hamiltonian term Ht gives a penalty proportional to howmuch |φt i deviates from Ut |φt−1 i, i.e., from a correct application of the t-th gate of Cn .
For ease of presentation we will now make the following three simplifying assumptions.3√• All αt are equal to 1/ T + 1, as they would be in the history state. This assumption isreasonable because |φt i and Ut |φt−1 i both have norm 1, so differences between αt and αt−1
will only make the penalty of Eq. (14.3) bigger.
• |φ0 i starts with s 0s, so |φ0 i = |0s i|ψi for some w(n)-qubit state |ψi. This is reasonablebecause if |φ0 i deviates significantly from this form, then Hinit will give a large energy penalty.
• |φT i has acceptance probability close to 1. This is reasonable because if |φT i has low acceptance probability, then Hfinal will give a large energy penalty.
Because of the second item and the fact that x ∈ L0 , the state Cn |φ0 i must have acceptanceprobability close to 0. Comparing with the third√ item, it follows that |φT i and Cn |φ0 i must be
nearly orthogonal, so their distance is close to 2, and in particular at least 1. This implies
TX

1 ≤ k|φT i − Cn |φ0 ik =UT · · · Ut+1 |φt i − UT · · · Ut |φt−1 i

t=1

≤

T
X

kUT · · · Ut+1 |φt i − UT · · · Ut |φt−1 ik =

t=1

T
X

k|φt i − Ut |φt−1 ik.

t=1Here the first equality uses a telescoping sum, the second inequality is the triangle inequality, andthe last equality is because the operator norm
is unitarily invariant (kU v − U wk = kv − wk).
√
Using Eq. (14.3) with αt = αt−1 = 1/ T + 1, and Cauchy-Schwarz, we now have:
T
X

T

X
1
hψ |H|ψ i ≥hψ |Ht |ψ i =k|φt i − Ut |φt−1 ik2
2(T + 1)
t=1
t=1
!2
T
X
1
1
≥
k|φt i − Ut |φt−1 ik≥= b.
2T (T + 1)
2T (T + 1)
0

0

0

0

t=1

Accordingly, if x ∈ L0 then λmin = min|ψ0 i hψ 0 |H|ψ 0 i ≥ b. If x ∈ L1 then the history state shows
λmin ≤ a = 1/(4T (T + 1)). We also have b − a = 1/(4T (T + 1)) ≥ 1/poly(n), as required.
3

Exercise 5 shows this is without loss of generality, though the lower bound on b − a becomes a worse polynomial(1/T 6 instead of 1/T 2 ) if we drop these three assumptions and take the unary clock of the next section into account.

118

14.3.2

Reducing the locality

The above construction of H, with the history state as witness for x ∈ L1 , is due to Kitaev [156],
who was inspired by an earlier clock construction in [112]. Our proof of soundness is a bit different
from Kitaev’s. He also showed that the locality can be reduced from O(log n) to 5 by representing
the clock in unary: t = 0 would now be represented by |0T iC , t = 1 by |10T −1 iC , t = 2 by |110T −2 iC ,etc. This now requires T qubits to represent the clock instead of dlog(T + 1)e. Denoting the t-th
qubit of the clock by ‘Ct ’, for t ∈ [T ], the previous terms in H now become
Hinit

=

Ht

=

s
X

|1ih1|i ⊗ |0ih0|C1i=1
1
2 I ⊗ |100ih100|Ct−1 ,Ct ,Ct+1 + I ⊗ |110ih110|Ct−1 ,Ct ,Ct+1 + − Ut ⊗ |110ih100|Ct−1 ,Ct ,Ct+1 − Ut∗ ⊗ |100ih110|Ct−1 ,Ct ,Ct+1

Hfinal = |0ih0|1 ⊗ |1ih1|CT(H1 and HT have a slightly different form than the Ht written above, because the clock register
starts resp. ends there.) We also add the following to penalize a T -bit clock register that doesn’t
conform to the proper 1s-followed-by-0s format of a unary number:
Hclock =T−1
X|01ih01|Ct ,Ct+1 .

t=1Note that the terms in the Hamiltonian now only “touch” at most 5 qubits: in particular, each Ht
touches 1 or 2 qubits for the gate Ut , and 3 qubits of the clock. This shows k-local Hamiltonianis QMA-complete for k ≥ 5. Subsequently, Kempe, Kitaev, and Regev [149] showed that k-local
Hamiltonian is QMA-complete already for k = 2 (in contrast to 2-SAT, which is in P).
All of these results assume a polynomially small gap b − a. Intuitively, the local Hamiltonian
problem becomes easier if the gap between a and b becomes bigger, since the 1-instances and0-instances are further apart and should be easier to distinguish. One may ask whether k-local
Hamiltonian is still QMA-complete if b − a ≥ Ω(m) instead of ≥ 1/poly(n). We know that it is
at least NP-hard for all k ≥ 2 because of the connection with MAX-2-SAT mentioned at the endof Section 14.2, but whether it is also QMA-hard is a longstanding open problem in the field ofHamiltonian complexity [119], known as the “quantum PCP conjecture” [6].

14.4

Other interesting problems in QMA

The main reason NP-completeness is a prominent notion in computer science, is that very many interesting and practically important computational problems are NP-complete: satisfiability, Traveling Salesman, scheduling problems, integer linear programming, protein folding, and many more.
See [117] for an already very extensive list from the late-70s. Similarly (though not yet as extensively) there is a growing list of QMA-complete problems, often from physics or chemistry. Below
we list a few without proof of their QMA-hardness; the fact that these problems are in QMA isusually easy to show. See [8, 61] for more.
• The local Hamiltonian problem for Hamiltonians corresponding to actual physicalsystems, such as 2-local Ising model with 1-local transverse field and a tunable 2-local
transverse coupling [58], the 2D Heisenberg Hamiltonian with local magnetic fields [220], the2D Hubbard Hamiltonian with local magnetic fields [220], and the Bose-Hubbard model [84].
119• Non-Identity check [144]. Given a polynomial-size quantum circuit U on n qubits, determine whether U is not close to the identity up to some global phase:(1) for all φ ∈ [0, 2π) we have U − eiφ I ≥ b or(0) there is a φ ∈ [0, 2π) such that U − eiφ I ≤ a,promised one of these is the case, and b − a ≥ 1/poly(n).
• k-local density matrix consistency [170, 171, 68].4 Given m = poly(n) density matrices
ρ1 , . . . , ρm where the state of ρi is only on qubits Ci ⊆ [n] with |Ci | ≤ k, determine whether:(1) there is an n-qubit density matrix ρ such that for all i ∈ [m], Tr[n]\Ci (ρ) = ρi , or(0) for all n-qubit density matrices ρ there is an i ∈ [m] such that Tr[n]\Ci (ρ) − ρi tr ≥ b,promised one of these is the case, and b ≥ 1/poly(n).
The following problem is in QMA, is not known to be QMA-complete, but also not known to be
in NP (in contrast, group member ship is known to be in NP).
• Group non-membership [243]. Given a finite group G, subgroup H ≤ G, and an elementg ∈ G, determine whether:(1) g 6∈ H, or(0) g ∈ H.
Here the groups H, G could be given as multiplication tables for a set of generating elements, or bymeans of an oracle (black-box) for the multiplication. The witness state for case (1) is the uniform
superposition over H. Exercise 9 asks you to show completeness; proving soundness is a bit harder.

14.5

Quantum interactive proofs

The prover-verifier protocols in QMA, just like NP and MA, only allow one message from theprover to the verifier. This is akin to submitting a proof to a journal, where the referee thenverifies the correctness of the proof without further interaction with the prover. One can also allow
multiple rounds of interaction, formalizing the back-and-forth situation that often occurs when amathematician (the prover) proves a complicated theorem in front of a colleague (the verifier): theverifier can raise objections or ask questions about steps of the proof, which the prover answers(hopefully to the verifier’s satisfaction) before proceeding with the next steps. A “proof” here is avery general notion: it’s any polynomial interaction that convinces the verifier of true statements
and cannot convince the verifier about any false statements.
The complexity class IP consists of those languages that can be decided by a polynomialinteraction between an unbounded prover and a polynomial-time classical verifier. Again, if x ∈ L1
then the prover should succeed in convincing the verifier to accept (with probability ≥ 2/3), and if
x ∈ L0 then no matter what the prover does, the verifier should reject with probability ≥ 2/3. A
fundamental classical complexity theory result says that IP=PSPACE [181, 224, 225].
One can define quantum IP (QIP) analogously. The two main results known about QIP are:1. Every QIP protocol can be implemented with only 3 messages, with the prover starting [245,154]. Roughly speaking, the 3-message protocol starts from a poly(n)-message protocol for
an L ∈ QIP, using the 3 messages to check one randomly chosen one among the poly(n)messages. This results in a 3-message protocol with 1/poly(n) gap between completeness and4

A density matrix is a generalization of a pure state. See Chapters 15 and 18 for the notation used here.

120soundness parameters for the same L. This small gap can then be amplified to a constant
gap by repeating the protocol in parallel; this repetition increases the communication permessage but not the number of messages, which remains 3. In contrast, it is widely believedthat IP restricted to 3-message protocols is a much smaller class than the full class IP.
2. QIP=IP [143]. Roughly speaking, this is proved by showing that the acceptance probabilityof the optimal strategy of the prover in a QIP-protocol can be described implicitly by an
exponential-size semidefinite program. Its optimal value (which is either ≥ 2/3 or ≤ 1/3) canthen be approximated by an exponential-size but polynomial-depth circuit. Such circuits canbe implemented in PSPACE, and we already knew that IP=PSPACE.
Accordingly, adding quantum to the model of interactive proofs does not change the class of languages that can be decided, but does reduce the required number of messages between prover andverifier from polynomial to constant. See [242] for much more about quantum proof systems.

Exercises
1. Give a satisfying assignment for the 3-SAT instance of Eq. (14.1).
2. Show that 1-local Hamiltonian is in P.
3. (H) Suppose you had an efficient quantum algorithm for the k-local Hamiltonian problem forevery a, b that satisfy b − a ≥ 1/n. Give an efficient quantum algorithm that approximates
λmin to within additive error ±2/n.
4. Show that k-local Hamiltonian is in QMA in two different ways, by providing details for thefollowing two sketches:(a) Choose a j ∈ [m] uniformly at random and measure the observable Hj on the witness
state. Repeat this a few times (using new witness states each time) to approximate theexpected value.
(b) Apply phase estimation (Section 4.6) to the unitary U = eiH with the given witness
state; U can be implemented using Hamiltonian simulation (Chapter 9).
5. This long exercise completes the proof of the soundness for the Hamiltonian of Section 14.3.2,
with the unary clock and without the three simplifying assumptions of Section 14.3.1. The
gap b − a between completeness and soundness will now be Ω(1/T 6 ) instead of Ω(1/T 2 ).
(a) Assume the error probability of the QMA-protocol for L is  1/T 5 . Let |ψ 000 i be an
arbitrary ground state (with energy λmin ) for the Hamiltonian of Section 14.3.2. Show
that if x ∈ L1 , then λmin  1/T 6 .
(b) (H) For the remainder of the exercise assume x ∈ L0 . Let Pbc be the projector on thesubspace of bad (i.e., non-unary) clock states. Show that kPbc |ψ 000 ik2 ≤ λmin .
(c) Show that kHk ≤ O(T ).
(d) (H) Let |ψ 00 i be the state obtained from |ψ 000 i by removing Pbc |ψ 000 i and renormalizing.
Show that its energy λ00 cannot be much larger than λmin : λ00 ≤ O(T λmin ).
121PT(e) (H) Write |ψ 00 i =t=0 αt |φt i|ti for nonnegative reals αt and normalized states |φt i.
PT
Show that t=1 |αt − αt−1 |2 ≤ 2λ00 .
(f) (H) Show that for all t, t0 we have |αt0 − αt |2 ≤ 2λ00 T .
P(g) (H) Let |ψ 0 i = √T1+1 Tt=0 |φt i|ti be the state after making all amplitudes equal in |ψ 00 i.
Show that k|ψ 00 i − |ψ 0 ik2 ≤ O(T 2 λ00 ).
(h) Modify |φ0 i and |φT i to satisfy the second and third simplifying assumptions.
(i) Show that the energy λ0 of |ψ 0 i cannot be much larger than λ00 : λ0 ≤ O(T 3 λ00 ).
(j) (H) Show that λmin ≥ Ω(1/T 6 ).
6. Consider a promise problem L = (L1 , L0 , L∗ ) ∈ QMA and a protocol as in Definition 1 withwitness states of w(n) qubits.
(a) (H) Show that there is a QMA protocol for L with witness states of w(n) qubits anderror probability ≤ 31 2−w(n) .
(b) Suppose we now replace the w(n) qubits of the protocol of (a) with a uniformly randomw(n)-bit basis state. Show that if x ∈ L1 , then the acceptance probability (i.e., theprobability of output 1) is ≥ 23 2−w(n) , while if x ∈ L0 then it is ≤ 13 2−w(n) .
(c) Use (b) to show that QMA with witness states restricted to w(n) = O(log n) qubits
equals BQP.
7. (H) Let PP be the class of promise problems L = (L1 , L0 , L∗ ) that can be decided by apolynomial-time classical algorithm with success probability > 1/2 (meaning that for inputs x ∈ L1 the algorithm accepts with probability > 1/2, and for x ∈ L0 it accepts withprobability < 1/2). Show that QMA ⊆ PP.
8. Consider the following computational decision problem. We are given a Hamiltonian H of
the form of page 117, with the additional property that w(n) = 0. We are promised that thesmallest eigenvalue λmin of H is either ≤ 1/(4T (T + 1)) (“yes-instance”) or ≥ 1/(2T (T + 1))(“no-instance”), and the problem is to decide which case we are in.
(a) (H) Show that this problem is in BQP.
(b) Show that this problem is BQP-hard, meaning that for every promise problem L =(L1 , L0 , L∗ ) in BQP there exists a classical deterministic polynomial-time algorithm
that maps every x ∈ L1 to a yes-instance of the above problem and every x ∈ L0 to ano-instance.
9. Suppose we are given (in some form) a finite group G, a subgroup H ≤ G, and an elementg ∈ G, and we can efficiently implement the unitary map V corresponding to multiplication
with g (i.e., the map V : |hi 7→ |h ◦ gi). Let
1 X|ψi = p|hi
|H| h∈H
be the uniform superposition over H. The prover for the non-membership problem canconstruct this state, though not necessarily efficiently.
122

(a) Show that if g ∈ H, then V |ψi = |ψi.
(b) Show that if g 6∈ H, then V |ψi is orthogonal to |ψi.
(c) Consider the following procedure that the verifier can use to test if g ∈ H or not:(1) prepare an auxiliary qubit in state H|0i,(2) conditioned on that qubit apply V to |ψi,(3) apply H to the auxiliary qubit and measure it.
Show that the probability of measurement outcome 0 is 1 if g ∈ H, and is 1/2 if g 6∈ H.

123

124

Chapter 15

Quantum Encodings, with a
Non-Quantum Application
15.1

Mixed states and general measurements

So far, we have restricted our states to so-called pure states: unit vectors of amplitudes. In theclassical world we often have uncertainty about the state of a system, which can be expressed byviewing the state as a random variable that has a certain probability distribution over the setof basis states. Similarly we can define a mixed quantum state as a probability distribution (or“mixture”) over pure states. While pure states are written as vectors, it is most convenient to write
mixed states as density matrices. A pure state |φi corresponds to the density matrix |φihφ|, whichis the outer product of the vector |φi with itself. For example, the pure state |φi = α|0i + β|1i
corresponds to the density matrix|φihφ| =

α
β


· (α

∗

∗

β )=



|α|2 αβ ∗α∗ β |β|2


.

A mixed state that is in pure states
1 i, . . . , |φ` i with probabilities p1 , . . . , p` , respectively, correP|φ`sponds to the density matrix ρ = i=1 pi |φi ihφi |. This ρ is sometimes called a “mixture” of thestates |φ1 i, . . . , |φ` i.1 The set of density matrices is exactly the set of positive semidefinite (psd)matrices of trace 1. A mixed state is pure if, and only if, it has rank 1.
You can always write a mixed state ρ as a probability distribution over orthogonal pure states,
using the diagonalization of ρ (see Appendix A.5) plus the observations that (1) the eigenvalues ofa trace-1 psd matrix form a probability distribution, and (2) that the eigenvectors of a Hermitianmatrix can be assumed to form an orthonormal set without loss of generality. But you can also
write ρ as a convex combination of non-orthogonal states (see Exercise 1.c).
Applying a unitary U to a pure state |φi gives pure state U |φi. Written in terms of rank-1
density matrices, this corresponds to the map|φihφ| 7→ U |φihφ|U ∗ .
1Note that applying the
P probabilities pi to the vectors |φi i (rather than to the matrices |φi ihφi |) does not makesense in general, because `i=1 pi |φi i need not be a unit vector. Using square roots of the probabilities also doesn’t
P√
work, because `i=1 pi |φi i need not be a unit vector either if the |φi i are not pairwise orthogonal.

125

By linearity, this actually tells us that a unitary acts on an arbitrary mixed state by conjugation:ρ 7→ U ρU ∗ .
What about measurements? Recall from Section 1.2.2 that an m-outcome
projective measurement
P
corresponds to m orthogonal projectors P1 , . . . , Pm that satisfy m
P=
I. When applying thisii=1
measurement to a mixed state ρ, the probability to see outcome i is given by pi = Tr(Pi ρ). If we
get outcome i, then the state collapses to Pi ρPi /pi (the division by pi renormalizes the state to havetrace 1). This may look weird, but let’s recover our familiar
Pd measurement in the computational
basis in thisPframework. Suppose we measure a state |φi = j=1 αj |ji using d projectors Pi = |iihi|(note that i Pi is the identity on the d-dimensional space). The probability to get outcome i isgiven by pi = Tr(Pi |φihφ|) = |hi|φi|2 = |αi |2 . If we get outcome i then the state collapses to
Pi |φihφ|Pi /pi = αi |iihi|αi∗ /pi = |iihi|. This is exactly the measurement in the computational basis
as we have used it until now. Similarly, a measurement of the first register of a two-register statecorresponds to projectors Pi = |iihi| ⊗ I, where i goes over all basis states of the first register.
If we only care about the final probability distribution on the m outcomes, not about theresulting state, then the most general thingPwe can do is a POVM. This is specified by m positive
semidefinite matrices E1 , . . . , Em satisfying m
i=1 Ei = I. When measuring a state ρ, the probabilityof outcome i is given by Tr(Ei ρ).

15.2

Quantum encodings and their limits

Quantum information theory studies the quantum generalizations of familiar notions from classicalinformation theory such as Shannon entropy, mutual information, channel capacities, etc. Here wewill discuss a few quantum information-theoretic results that all have the same flavor: they saythat a low-dimensional quantum state (i.e., a small number of qubits) cannot contain too muchaccessible information.
Holevo’s Theorem: The mother of all such results is Holevo’s theorem from 1973 [138], which
predates the area of quantum computing by several decades. Its proper technical statement isin terms of a quantum generalization of mutual information, but the following consequence of it(derived by Cleve et al. [90]) about two communicating parties, suffices for our purposes.
Theorem 3 (Holevo, CDNT) Suppose Alice wants to communicate some classical string x toBob.
• If Alice sends Bob m qubits, and they did not share any prior entanglement, then Bob receives
at most m bits of information about x.
• If Alice sends Bob m qubits, and they did share some prior entangled state, then Bob receives
at most 2m bits of information about x.
• If Alice sends Bob m classical bits, and they did share some prior entangled state, then Bob
receives at most m bits of information about x.
This theorem is slightly imprecisely stated here, but the intuition should be clear: if Bob makes
any measurement on his state after the communication, then the mutual information between his
126classical outcome and Alice’s x, is bounded by m or 2m. In particular, the first part of the theorem
says that if we encode some classical random variable X in an m-qubit state2 , then no measurementon the quantum state can give more than m bits of information about X. If we encoded the classicalinformation in an m-bit system instead of an m-qubit system this would be a trivial statement,
but the proof of Holevo’s theorem is quite non-trivial. Thus we see that an m-qubit state, despite
somehow “containing” 2m complex amplitudes, is no better than m classical bits for the purpose ofstoring or transmitting information. Prior entanglement can improve this by a factor of 2 becauseof superdense coding (see Exercise 1.12), but no more than that.
Low-dimensional encodings: Here we provide a “poor man’s version” of Holevo’s theorem due
to Nayak [193, Theorem 2.4.2], which has a simple proof and often suffices for applications. Suppose
we have a classical random variable X, uniformly distributed over [N ] = {1, . . . , N }.3 Let x 7→ ρx
be some encoding of [N ], where ρx is a mixed state in a d-dimensional space. Let E1 , . . . , EN be
the POVM operators applied for decoding; these sum to the d-dimensional identity operator. Thenthe probability of correct decoding in case X = x, is
px = Tr(Ex ρx ) ≤ Tr(Ex ).
The sum of these success probabilities is at most
N
X
x=1

px ≤

N
X

Tr(Ex ) = Tr

x=1

N
X

!
Ex

= Tr(I) = d.

(15.1)

x=1

In other words, if we are encoding one of N classical values in a d-dimensional quantum state, thenany measurement to decode the encoded classical value has average success probability at most d/N(uniformly averaged over all N values that we can encode). For example, if we encode n uniformly
random bits into m qubits, we will have N = 2n , d = 2m , and the average success probability of
decoding is at most 2m /2n , which is very small unless m is nearly n.
Random access codes: The previous two results dealt with the situation where we encoded aclassical random variable X in some quantum system, and would like to recover the original value
X by an appropriate measurement on that quantum system. However, suppose X = X1 . . . Xn isa string of n bits, uniformly distributed and encoded by a map x 7→ ρx , and it suffices for us if
we are able to decode individual bits Xi from this with some probability p > 1/2. More precisely,for each i ∈ [n] there should exist a measurement {Mi , I − Mi } allowing us to recover xi . Mi
would correspond to output 1 and I − Mi to output 0. Hence for each x ∈ {0, 1}n we should have
Tr(Mi ρx ) ≥ p if xi = 1 and Tr(Mi ρx ) ≤ 1 − p if xi = 0. An encoding satisfying this is called aquantum random access code, since it allows us to choose which bit of X we would like to access.
Note that the measurement to recover xi can change the state ρx , so generally we may not be able
to decode more than one bit of x (also, we cannot copy ρx because of the no-cloning theorem, see
Exercise 1.10).
An encoding that allows us to recover (with high success probability) an n-bit string requires
about n qubits by Holevo. Random access codes only allow us to recover each of the n bits. Can2

Via an encoding map x 7→ ρx ; we generally use upper-case letters like X to denote random variables, lower-caseletters like x to denote specific values.
3
NB: unlike in most of these lecture notes, N need not equal 2n in this chapter!

127

they be much shorter? In small cases they can be: for instance, one can encode two classical bits
into one qubit, in such a way that each of the two bits can be recovered with success probability
85% from that qubit (see Exercise 2). However, Nayak [193] proved that asymptotically quantum
random access codes cannot be much shorter than classical.
Theorem 4 (Nayak) Let x 7→ ρx be a quantum random access encoding of n-bit strings intom-qubit states such that, for each i ∈ [n], we can decode Xi from |φX i with success probability p(averaged over a uniform choice of x and the measurement randomness). Then m ≥ (1 − H(p))n,where H(p) = −p log p − (1 − p) log(1 − p) is the binary entropy function.
The intuition of the proof is quite simple: since the quantum state allows us to predict the bit
Xi with probability pi , it reduces the “uncertainty” about Xi from 1 bit to H(pi ) bits. Hence it
contains at least 1 − H(pPi )n bits of information about Xi . Since all n Xi ’s are independent, the state
has to contain at least i=1 (1 − H(pi )) bits of information about X in total.

15.3

Lower bounds on locally decodable codes

Here we will give an application of quantum information theory to a classical problem.4
The development of error-correcting codes is one of the success stories of science in the second
half of the 20th century. Such codes are eminently practical, and are widely used to protect
information stored on discs, communication over channels, etc. From a theoretical perspective,
there exist codes that are nearly optimal in a number of different respects simultaneously: they
have constant rate, can protect against a constant noise-rate, and have linear-time encoding anddecoding procedures. We refer to Trevisan’s survey [236] for a complexity-oriented discussion ofcodes and their applications.
One drawback of ordinary error-correcting codes is that we cannot efficiently decode small
parts of the encoded information. If we want to learn, say, the first bit of the encoded message
then we usually still need to decode the whole encoded string. This is relevant in situations where
we have encoded a very large string (say, a library of books, or a large database), but are onlyinterested in recovering small pieces of it at any given time. Dividing the data into small blocks
and encoding each block separately will not work: small chunks will be efficiently decodable but
not error-correcting, since a tiny fraction of well-placed noise could wipe out the encoding of one
chunk completely. There exist, however, error-correcting codes that are locally decodable, in thesense that we can efficiently recover individual bits of the encoded string.
Definition 3 C : {0, 1}n → {0, 1}N is a (q, δ, ε)-locally decodable code (LDC) if there is a classicalrandomized decoding algorithm A such that
1. A makes at most q queries to an N -bit string y.
2. For all x ∈ {0, 1}n and i ∈ [n], and all y ∈ {0, 1}N with Hamming distance d(C(x), y) ≤ δN
we have Pr[Ay (i) = xi ] ≥ 1/2 + ε.
Here δ is an upper bound on the fraction of bits of the codeword that may have been corrupted(by some noise process, or by our worst enemy), and ε is a lower bound on the advantage we have
4

There is a growing number of such applications of quantum tools to non-quantum problems. See [100] for asurvey.

128

compared to just randomly guessing the value of the bit xi . The notation Ay (i) reflects that the
decoder A has two different types of input. On the one hand there is the (possibly corrupted)
codeword y, to which the decoder has oracle access and from which it can read at most q bits of
its choice. On the other hand there is the index i of the bit that needs to be recovered, and which
is known fully to the decoder.
The main question about LDCs is the tradeoff between the codelength N and the number ofqueries q (which is a proxy for the decoding-time). This tradeoff is still not very well understood.
The only case where we know the answer is the case of q = 2 queries.5 For q = 2 there is the
Hadamard code: given x ∈ {0, 1}n , define a codeword of length N = 2n by writing down the bitsx · z mod 2, for all z ∈ {0, 1}n , with the z’s ordered in lexicographic order. For example for n = 2
and x = 10, the codeword would be
C(x) = (x · 00, x · 01, x · 10, x · 11) = 0011.
One can decode xi with 2 queries as follows: choose z ∈ {0, 1}n uniformly at random, query the(possibly corrupted) codeword at indices z and z ⊕ ei (where the latter denotes the string obtained
from z by flipping its i-th bit), and output the sum of the two returned bits modulo 2. Individually,each of these two indices z and z ⊕ ei is uniformly distributed. Hence for each of them, theprobability that the returned bit is corrupted is at most δ. By the union bound, with probability
at least 1 − 2δ, both queries return the uncorrupted values. Adding these two bits mod 2 gives thecorrect answer:
C(x)z ⊕ C(x)z⊕ei = (x · z) ⊕ (x · (z ⊕ ei )) = x · ei = xi .
Thus the Hadamard code is a (2, δ, 1/2 − 2δ)-LDC of exponential length.
The only superpolynomial lower bound known on the length of LDCs is for the case of 2 queries:
there one needs an exponential codelength and hence the Hadamard code is essentially optimal.
This is shown via a quantum argument [152]—despite the fact that the result is a purely classicalresult, about classical codes and classical decoders. The easiest way to present this argument is to
assume the following fact, which states a kind of “normal form” for the decoder.
Fact 1 (Katz & Trevisan [148] + folklore) For every (q, δ, ε)-LDC C : {0, 1}n → {0, 1}N ,and for each i ∈ [n], there exists a set Mi of Ω(δεN/q 2 ) disjoint tuples, each of at most q indicesfrom [N ], and a bit ai,t for each tuple t ∈ Mi , such that the following holds:
Prx∈{0,1}nxi = ai,t ⊕X

C(x)j  ≥ 1/2 + Ω(ε/2q ),(15.2)

j∈t

where the probability is taken uniformly over x. Hence to decode xi from C(x), the decoder can justquery the indices in a randomly chosen tuple t from Mi , outputting the sum of those q bits andai,t .
Note that the above decoder for the Hadamard code is already of this form, with Mi consisting of
the 2n−1 pairs {z, z ⊕ ei }. We omit the fairly easy proof of Fact 1, which uses purely classical ideas.
5

For q = 1, LDCs don’t√exist once n is sufficiently large [148]. For q = 3, the best upper bound known on thecodelength N is roughly 22

log n[252, 104], while the best lower bound is roughly n3 [10].

129Now suppose C : {0, 1}n → {0, 1}N is a (2, δ, ε)-LDC. We want to show that the codelength
N must be exponentially large in n. Our strategy is to show that the following N -dimensional
quantum encoding is a quantum random access code for x (with some success probability p > 1/2):N

1 X(−1)C(x)j |ji.
x 7→ |φx i = √N j=1
Theorem 4 then implies that the number of qubits of this state (which is dlog N e) is at least(1 − H(p))n = Ω(n), and we are done.
Suppose we want to recover xi from |φx i. We’ll do this by a sequence of two measurements, as
follows. We turn each Mi from Fact 1 into a projective P
measurement: for each pair (j, k) ∈ Mi
form the projector Pjk = |jihj| + |kihk|, and let Prest = j6∈∪t∈M t |jihj| be the projector on theiremaining indices. These |Mi | + 1 projectors sum to the N -dimensional identity matrix, so they
form a valid projective measurement. Applying this to |φx i gives outcome (j, k) with probability
kPjk |φx ik2 = 2/N for each (j, k) ∈ Mi . There are |Mi | = Ω(δεN ) different (j, k)-pairs in Mi , so
the probability to see one of those as outcome of the measurement, is |Mi | · 2/N = Ω(δε). With
the remaining probability r = 1 − Ω(δε), we’ll get “rest” as outcome of the measurement. In thelatter case we didn’t get anything useful from the measurement, so we’ll just output a fair coin flipas our guess for xi (then the output will equal xi with probability exactly 1/2). In case we got oneof the (j, k) as measurement outcome, the state has collapsed to the following useful superposition: (−1)C(x)j 1 √ (−1)C(x)j |ji + (−1)C(x)k |ki =√|ji + (−1)C(x)j ⊕C(x)k |ki2
2
We know what j and k are, because it is the outcome of the measurement on |φx i. Now do a
2-outcome projective measurement with projectors P0 and P1 corresponding to the two vectors√1 (|ji + |ki) and √1 (|ji − |ki), respectively. The measurement outcome equals the value C(x)j ⊕2
2
C(x)k with probability 1. By Eq. (15.2), if we add the bit ai,(j,k) to this, we get xi with probability
at least 1/2 + Ω(ε). The success probability of recovering xi , averaged over all x, is


1
1
1
p≥ r+
+ Ω(ε) (1 − r) = + Ω(δε2 ).
222
Thus we have constructed a random access code that encodes n bits into log N qubits, and has
success probability at least p. Applying Theorem 4 and using that
1 − H(1/2 + η) = Θ(η 2 ) for η ∈ [0, 1/2],(15.3)

we obtain the following:
2 4

Theorem 5 If C : {0, 1}n → {0, 1}N is a (2, δ, ε)-locally decodable code, then N ≥ 2Ω(δ ε n) .

Exercises
1. Suppose we have a qubit whose density matrix is ρ.
(a) Show that there exist real numbers r0 , r1 , r2 , r3 such that ρ = r20 I + r21 X + r22 Y + r23 Z,
where I, X, Y, Z are the Pauli matrices (see Appendix A.9).
130(b) Show that r0 = 1.
(c) Show that Tr(ρ2 ) = 12 (r02 + r12 + r22 + r32 ).
(d) Show that r12 + r22 + r32 ≤ 1.
(e) Show that r12 + r22 + r32 = 1 iff ρ is a pure state.
Comment: One can represent a qubit by the corresponding vector (r1 , r2 , r3 ) ∈ R3 . By part (e) the pure states
are exactly the ones that are on the boundary of the 3-dimensional sphere of radius 1. The mixed states arein the interior of the sphere, and the maximally mixed state ρ = I/2 is at the origin (0, 0, 0). This geometricpicture is called the Bloch-sphere representation of a qubit, and is very useful in physics. For example, singlequbit gates correspond to rotations on this sphere. Unfortunately this picture does not generalize cleanly tomore than one qubit.

2. (a) (H) Give a quantum random access code that encodes 2 classical bits into 1 qubit, suchthat each of the two classical bits can be recovered from the quantum encoding withsuccess probability p ≥ 0.85.
√(b) Prove an upper bound of 1/2+O(1/ n) on the success probability p for a random accesscode that encodes n classical bits into 1 qubit.
3. (H) Teleportation transfers an arbitrary unknown qubit from Alice to Bob, using 1 EPR-pairand 2 classical bits of communication from Alice to Bob (see Section 1.5). Prove that these2 bits of communication are necessary, i.e., you cannot teleport an arbitrary unknown qubit
using 1 EPR-pair and only 1 classical bit of communication.
4. Suppose n + 1 = 2k for some integer k. For ` ∈ {0, . . . , n} define n-qubit state1|ψ` i = q 
n
`

X

|xi,

x∈{0,1}n :|x|=`where |x| denotes the Hamming weight (number of 1s) in x.
(a) Show that hψ` |ψ`0 i equals 1 if ` = `0 , and equals 0 otherwise.
(b) Consider a qubit |φi = α|0i + β|1i. Show that the n-qubit state |φi⊗n can be written asa linear combination of the states |ψ` i. Say explicitly what the coefficients of this linear
combination are.
(c) Give a unitary V , independent of α, β, that encodes |φi⊗n into a k-qubit state |ψi inthe sense that
V : |φi⊗n 7→ |ψi ⊗ |0n−k i.
Say explicitly what your state |ψi is and how it depends on α and β (you’re not required
to write out circuits).
5. Consider the Hadamard code C that encodes n = 2 bits x1 x2 into a codeword of N = 4 bits.
(a) Give the 4-bit codeword C(11).
(b) What are the states |φx i that arise as quantum random access code when we apply the
LDC lower bound proof of Section 15.3 to C? Give the 4 states, not one general formula.
131

(c) What is the measurement used for recovering x2 from |φx i at the end of that proof?
You may either describe this as a sequence of two projective measurements, or as one(combined) projective measurement.
6. (a) Let x ∈ {0, 1}n . Suppose we apply the 2n-qubit Fourier transform F22n on the 2n-bit
basis state |xi|0n i, followed by F2−1
n on the last n qubits (and identity on the first n
qubits). Show that we end up with the 2n-qubit state |+i⊗n |xi.
(b) (H) Consider a circuit C that implements F22n in some way using arbitrary 1-qubit and2-qubit gates (C can do anything, it need not be one of the specific QFT circuits fromthe lecture notes). Show that there must be Ω(n) two-qubit gates in C where the control
bit lies in the first n qubits of the state and the target qubit lies in the second n qubits(or vice versa).
7. Suppose there are two classically-known mixed states ρ0 and ρ1 , and we are given one copy ofquantum state ρb for a uniformly random b ∈ {0, 1}. We want to learn b using some 2-outcome
projective measurement with operators P0 and P1 , which we can choose ourselves dependingon what ρ0 and ρ1 are. The success probability of such a measurement is 12 (Tr(P0 ρ0 ) +Tr(P1 ρ1 )).
(a) (H) Give a projective measurement with success probability ≥ 12 + 14 kρ0 − ρ1 k1 , where
the norm kAk1 of a matrix A is defined as the sum of A’s singular values.
(b) Show that every 2-outcome projective measurement P0 , P1 has a success probability thatis ≤ 21 + 14 kρ0 − ρ1 k1 .

132

Chapter 16

Quantum Communication Complexity
Communication complexity was first introduced by Yao [250], and has been studied extensively inthe area of theoretical computer science and has deep connections with seemingly unrelated areas,such as VLSI design, circuit lower bounds, lower bounds on branching programs, sizes of data
structures, and bounds on the length of logical proof systems, to name just a few.

16.1

Classical communication complexity

First we sketch the setting for classical communication complexity. Alice and Bob want to compute
some function f : D → {0, 1}, where D ⊆ X × Y .1 Alice receives input x ∈ X, Bob receives inputy ∈ Y , with (x, y) ∈ D. A typical situation, illustrated in Fig. 16.1, is where X = Y = {0, 1}n ,so both Alice and Bob receive an n-bit input string. As the value f (x, y) will generally depend on
both x and y, some communication between Alice and Bob is required in order for them to be able
to compute f (x, y). We are interested in the minimal amount of communication they need.
Inputs:x ∈ {0, 1}ny ∈ {0, 1}n

❄

❄

Alice

✛

✲
✲

Bob

communication❄

Output:f (x, y)Figure 16.1: Alice and Bob solving a communication complexity problem
A communication protocol is a distributed algorithm where first Alice does some individualcomputation, and then sends a message (of one or more bits) to Bob, then Bob does some computation and sends a message to Alice, etc. Each message is called a round. After one or more rounds
the protocol terminates and one of the parties (let’s say Bob) outputs some value that should be
f (x, y). The cost of a protocol is the total number of bits communicated on the worst-case input.
1

If the domain D equals X × Y then f is called a total function, otherwise it is called a partial or promise function.

133

A deterministic protocol for f always has to output the right value f (x, y) for all (x, y) ∈ D. In abounded-error protocol, Alice and Bob may flip coins and the protocol has to output the right valuef (x, y) with probability ≥ 2/3 for all (x, y) ∈ D. We could either allow Alice and Bob to toss coinsindividually (local randomness, or “private coin”) or jointly (shared randomness, or “public coin”).
A public coin can simulate a private coin and is potentially more powerful. However, Newman’s
theorem [194] says that having a public coin can save at most O(log n) bits of communication,compared to a protocol with a private coin.
To illustrate the power of randomness, let us give a simple yet efficient bounded-error protocol
for the equality problem, where the goal for Alice is to determine whether her n-bit input is thesame as Bob’s or not: f (x, y) = 1 if x = y, and f (x, y) = 0 otherwise. Alice and Bob jointly
toss a random string r ∈ {0, 1}n . Alice sends the bit a = x · r to Bob (where ‘·’ is inner productmod 2). Bob computes b = y · r and compares this with a. If x = y then a = b, but if x 6= y thena 6= b with probability 1/2. Repeating this a few times, Alice and Bob can decide equality withsmall error probability using O(n) public coin flips and a constant amount of communication. This
protocol uses public coins, but note that Newman’s theorem implies that there exists an O(log n)bit protocol that uses a private coin (see Exercise 9 for an explicit protocol). Note that the correct
output of the equality function depends on all n bits of x, but Bob does not need to learn all n bitsof x in order to be able to decide equality with high success probability. In contrast, one can showthat deterministic protocols for the equality problem need n bits of communication, so then Alicemight as well just send x to Bob.

16.2

The quantum question

Now what happens if we give Alice and Bob a quantum computer and allow them to send eachother qubits and/or to make use of EPR-pairs that they share at the start of the protocol?
Formally speaking, we can model a quantum protocol as follows. The total state consistsof 3 parts: Alice’s private space, the channel, and Bob’s private space. The starting state is|xi|0i|yi: Alice gets x, the channel is initialized to 0, and Bob gets y. Now Alice applies a unitarytransformation to her space and the channel. This corresponds to her private computation as wellas to putting a message on the channel (the length of this message is the number of channel-qubits
affected by Alice’s operation). Then Bob applies a unitary transformation to his space and thechannel, etc. At the end of the protocol Alice or Bob makes a measurement to determine theoutput of the protocol. This model was introduced by Yao [251].
In the second model, introduced by Cleve and Buhrman [89], Alice and Bob share an unlimited
number of EPR-pairs at the start of the protocol, but now they communicate via a classical channel:
the channel has to be in a classical state throughout the protocol. We only count the communication,
not the number of EPR-pairs used. Protocols of this kind can simulate protocols of the first kindwith only a factor 2 overhead: using teleportation, the parties can send each other a qubit using
an EPR-pair and two classical bits of communication. Hence the qubit-protocols that we describe
below also immediately yield protocols that work with entanglement and a classical channel. Notethat an EPR-pair can simulate a public coin toss: if Alice and Bob each measure their half of thepair of qubits, they get the same random bit.
The third variant combines the strengths of the other two: here Alice and Bob start out withan unlimited number of EPR-pairs and they are allowed to communicate qubits. This third kindof communication complexity is in fact equivalent to the second, up to a factor of 2, again by134

teleportation.
Before continuing to study this model, we first have to face an important question: is there
anything to be gained here? At first sight, the following argument seems to rule out any significant
gain. Suppose that in the classical world k bits have to be communicated in order to compute f .
Since Holevo’s theorem says that k qubits cannot contain more information than k classical bits, it
seems that the quantum communication complexity should be roughly k qubits as well (maybe k/2
to account for superdense coding, but not less). Surprisingly (and fortunately for us), this argument
is false, and quantum communication can sometimes be much less than classical communication
complexity. The information-theoretic argument via Holevo’s theorem fails, because Alice andBob do not need to communicate the information in the k bits of the classical protocol; they are
only interested in the value f (x, y), which is just 1 bit. Below we will go over four of the main
examples that have so far been found of differences between quantum and classical communication
complexity.

16.3

Example 1: Distributed Deutsch-Jozsa

The first impressively large gaps between quantum and classical communication complexity were
exhibited by Buhrman, Cleve, and Wigderson [74]. Their protocols are distributed versions ofknown quantum query algorithms, like the Deutsch-Jozsa and Grover algorithms. Let us startwith the first one. It is actually explained most easily in a direct way, without reference to theDeutsch-Jozsa algorithm (though that is where the idea came from). The problem is a promise
version of the equality problem. Suppose the n-bit inputs x and y are restricted to the following
case:Distributed Deutsch-Jozsa: either x = y, or x and y differ in exactly n/2 positions
Note that this promise only makes sense if n is an even number, otherwise n/2 would not be integer.
In fact it will be convenient to assume n is a power of 2. Here is a simple quantum protocol tosolve this promise version of equality using only log n qubits of communication:
P
1. Alice sends Bob the log n-qubit state √1n ni=1 (−1)xi |ii, which she can prepare unitarily fromx and log n |0i-qubits.
2. Bob applies the unitary map |ii 7→ (−1)yi |ii to the state, applies a Hadamard transform toeach qubit (for this it is convenient to view i as a log n-bit string), and measures the resulting
log n-qubit state.
3. Bob outputs 1 if the measurement gave |0log n i and outputs 0 otherwise.
It is clear that this protocol only communicates log n qubits, but why does it work? Note that thestate that Bob measures is
!
n
n
X
1 X
1X
⊗ log nxi +yi
√
H
(−1)
|ii =
(−1)xi +yi(−1)i·j |ji
n
n
log n
i=1

i=1

j∈{0,1}

ThisP
superposition looks rather unwieldy, but consider the amplitude of the |0log n i basis state. It
1
is n ni=1 (−1)xi +yi , which is 1 if x = y and 0 otherwise because the promise now guarantees thatx and y differ in exactly n/2 of the bits! Hence Bob will always give the correct answer.
135

What about efficient classical protocols (without entanglement) for this problem? Proving
lower bounds on communication complexity often requires a very technical combinatorial analysis.
Buhrman, Cleve, and Wigderson used a deep combinatorial result from [114] to prove that everyclassical errorless protocol for this problem needs to send at least 0.007n bits.
This log n-qubits-vs-0.007n-bits example was the first exponentially large separation of quantum
and classical communication complexity. Notice, however, that the difference disappears if we moveto the bounded-error setting, allowing the protocol to have some small error probability. We canuse the randomized protocol for equality discussed above or even simpler: Alice can just send a few(i, xi ) pairs to Bob, who then compares the xi ’s with his yi ’s. If x = y he will not see a difference,but if x and y differ in n/2 positions, then Bob will probably detect this. Hence O(log n) classicalbits of communication suffice in the bounded-error setting, in sharp contrast to the errorless setting.

16.4

Example 2: The Intersection problem

Now consider the Intersection function, which is 1 if xi = yi = 1 for at least one i. Buhrman, Cleve,and Wigderson [74] also presented an efficient quantum protocol for this, based on Grover’s searchalgorithm (Chapter 7). We can solve Intersection if we can solve the following search problem: findsome i such that xi = yi = 1, if such an i exists.2 We want to find a solution to the search problem
on the string z = x ∧ y (which is the bit-wise AND of x and y), since zi = 1 whenever both xi = 1
and yi = 1. The idea is now to let Alice run Grover’s algorithm to search for such a solution.
Clearly, she can prepare the uniform starting state herself. She can also apply the unitaries H andR herself. The only thing where she needs Bob’s help, is in implementing the phase-query Oz,±√
(which she needs to do O( n) times, because that’s how many queries Grover makes). Alice andBob can together implement a phase-query as follows. Whenever Alice wants to apply Oz,± to a
state
n
X
|φi =
αi |ii,i=1

she tags on her xi ’s in an extra qubit (which she can do by the unitary map |ii|0i 7→ |ii|xi i) andsends Bob the statenX
αi |ii|xi i.
i=1

Bob applies the unitary map|ii|xi i 7→ (−1)xi ∧yi |ii|xi i
and sends back the result. Alice sets the last qubit back to |0i (which she can do unitarily because
she has x), and now she has the state Oz,± |φi! Thus we can simulate Oz,± using 2 messages oflog(n) + 1 qubits each. Thus Alice and Bob can run Grover’s algorithm to find an intersection,√√using O( n) messages of O(log n) qubits each, for total communication of O( n log n) qubits.
√
Later Aaronson and Ambainis [3] gave a more complicated protocol that uses O( n) qubits ofcommunication.
What about lower bounds? It is a well-known result of classical communication complexity thatclassical bounded-error protocols for the Intersection problem need about n bits of communication.
2

This is sometimes called the appointment-scheduling problem: view x and y as Alice’s and Bob’s agendas, respectively, with a 1 at the i-th bit indicating that timeslot i is available. Then the goal is to find a timeslot where Aliceand Bob are both available, so they can schedule an appointment.

136

Thus we have a quadratic quantum-classical separation for this problem. Could there be a quantum√
protocol that uses much less than n qubits of communication? This question was open for quite afew years after [74] appeared, until finally Razborov [202] showed that any bounded-error quantum√
protocol for Intersection needs to communicate about n qubits.

16.5

Example 3: The vector-in-subspace problem

Notice the contrast between the examples of the last two sections. For the Distributed DeutschJozsa problem we get an exponential quantum-classical separation, but the separation only holds
if we require the classical protocol to be errorless. On the other hand, the gap for the disjointness
function is only quadratic, but it holds even if we allow classical protocols to have some error
probability.
Here is a function where the quantum-classical separation has both features: the quantum
protocol is exponentially better than the classical protocol, even if the latter is allowed some error:
Alice receives a unit vector v ∈ Rm
Bob receives two m-dimensional projectors P0 and P1 such that P0 + P1 = I
Promise: either P0 v = v or P1 v = v.
Question: which of the two?
As stated, this is a problem with continuous input, but it can be discretized in a natural way byapproximating each real number by O(log m) bits. Alice and Bob’s input is now n = O(m2 log m)
bits long. There is a simple yet efficient 1-round quantum protocol for this problem: Alice views v
as a log m-qubit state and sends this to Bob; Bob measures with operators P0 and P1 , and outputs
the measurement result (0 or 1). this takes only log m = O(log n) qubits of communication, andBob’s output is correct with probability 1 thanks to the promise on the inputs.
The efficiency of this protocol comes from the fact that an m-dimensional unit vector can be“compressed” or “represented” as a log m-qubit state. Similar compression is not possible withclassical bits, which suggests that any classical protocol will have to send the vector v more or less
literally and hence will require a lot of communication. This turns out to be true, but the proof isquite hard [157]. It shows that any bounded-error protocol needs to send Ω(m1/3 ) bits.

16.6

Example 4: Quantum fingerprinting

The examples of the previous section were either exponential quantum improvements for promise
problems (Deutsch-Jozsa and vector-in-subspace) or polynomial improvements for total problems(disjointness). We will now give an exponential improvement for the total problem of equalitytesting, but in a restricted setting called the simultaneous message passing (SMP) model. Aliceand Bob receive n-bit input x and y, respectively. They do not have any shared resources like sharedrandomness or an entangled state, but they do have local randomness. They don’t communicate
with each other directly, but instead send a single message to a third party, called the Referee. The
Referee, upon receiving message mA from Alice and mB from Bob, should output the value f (x, y).
The goal is to compute f (x, y) with a minimal amount of communication from Alice and Bob to
the Referee.
We will see that for the equality problem there is an exponential savings in communication
when qubits are used instead of classical bits. Classically, the problem of the bounded-error com137

munication complexity of equality in the SMP model was first raised by Yao [250], and was open√
for almost twenty years until Newman and Szegedy [195] exhibited a lower bound of Ω( n) bits.
This is tight, since Ambainis [11] constructed a bounded-error protocol for this problem where the√messages are O( n) bits long (see Exercise 8). In contrast, in the quantum setting this problem
can be solved with very little communication: only O(log n) qubits suffice [73].
The quantum trick is to associate each x ∈ {0, 1}n with a short quantum state |φx i, called
the quantum fingerprint of x. Just like with physical fingerprints, the idea is that a quantum
fingerprint is a small object that doesn’t contain very much information about the object x, butthat suffices for testing if the fingerprinted object equals some other fingerprinted object. As wewill see below, we can do such testing if the fingerprints are pairwise almost orthogonal. Moreprecisely, an (n, m, ε)-quantum fingerprinting scheme maps n-bit string x to m-qubit state |φx iwith the property that for all distinct x, y ∈ {0, 1}n , we have |hφx |φy i| ≤ ε.
We will now show how to obtain a specific (n, m, 0.02)-quantum fingerprinting scheme froman error-correcting code C : {0, 1}n → {0, 1}N where m = log N ≈ log n. There exist codes
where N = O(n) and any two codewords C(x) and C(y) have Hamming distance close to N/2, sayd(C(x), C(y)) ∈ [0.49N, 0.51N ] (we won’t prove this here, but for instance a random linear code
will work). Define the quantum fingerprint of x as follows:N

1 X|φx i = √(−1)C(x)j |ji.
N j=1
This is a unit vector in an N -dimensional space, so it corresponds to only dlog N e = log n + O(1)qubits. For distinct x and y, the corresponding fingerprints will have small inner product:Nhφx |φy i =1 X
N − 2d(C(x), C(y))∈ [−0.02, 0.02].
(−1)C(x)j +C(y)j =NN
j=1

Bob: yAlice: x|φx i ❥✙

|φy i

Referee❄?

x=yFigure 16.2: Quantum fingerprinting protocol for the equality problem
The quantum protocol is very simple (see Figure 16.2): Alice and Bob send quantum fingerprintsof x and y to the Referee, respectively. The referee now has to determine whether x = y (whichcorresponds to hφx |φy i = 1) or x 6= y (which corresponds to hφx |φy i ∈ [−0.02, 0.02]). The following
test (Figure 16.3), sometimes called the SWAP-test, accomplishes this with small error probability.
This circuit first applies a Hadamard transform to a qubit that is initially |0i, then SWAPs
the other two registers conditioned on the value of the first qubit being |1i, then applies another
Hadamard transform to the first qubit and measures it. Here SWAP is the operation that swaps the
138

|0i

H

H

measure

|φx i
SWAP

|φy i
Figure 16.3: Quantum circuit to test if |φx i = |φy i or |hφx |φy i| is small
two registers: |φx i|φy i 7→ |φy i|φx i. The Referee receives |φx i from Alice and |φy i from Bob and applies the test to these two states. An easy calculation reveals that the outcome of the measurementis 1 with probability (1 − |hφx |φy i|2 )/2. Hence if |φx i = |φy i then we observe a 1 with probability 0,
but if |hφx |φy i| is close to 0 then we observe a 1 with probability close to 1/2. Repeating thisprocedure with several individual fingerprints can make the error probability arbitrarily close to 0.

Exercises
1. (H) Prove that classical deterministic protocols with one message (from Alice to Bob), needto send n bits to solve the equality problem.
2. (a) (H) Show that if |φi and |ψi are non-orthogonal states (i.e., hφ|ψi 6= 0), then there isno two-outcome projective measurement that perfectly distinguishes these two states, inthe sense that applying the measurement on |φi always gives a different outcome fromapplying the same measurement to |ψi.
(b) Prove that quantum protocols with one message (from Alice to Bob), need to send at
least n qubits to solve the equality problem (on n-bit inputs) with success probability 1
on every input. Assume for simplicity that Bob does a projective measurement rather
than a general POVM.
(c) (H) Prove that quantum protocols with one message (from Alice to Bob), need to send at
least log n qubits to solve the distributed Deutsch-Jozsa problem with success probability 1 on every input. Again assume for simplicity that Bob does a projective measurement
rather than a general POVM.
3. (H) Consider one-round quantum communication complexity. Alice gets input x ∈ {0, 1}n ,Bob gets input y ∈ {0, 1}n , and they want to compute some Boolean function f (x, y) of their
inputs. Assume that all rows of the communication matrix are different, i.e., for all x and x0
there is a y such that f (x, y) 6= f (x0 , y). They are allowed only one round of communication:
Alice sends a quantum message to Bob and Bob must then be able to give the right answer
with probability 1. Prove that Alice needs to send n qubits to Bob for this. You may assume
that Alice’s messages are pure states (this is without loss of generality).
4. Suppose Alice and Bob each have n-bit agendas, and they know that for exactly 25% of
the timeslots they are both free. Give a quantum protocol that finds such a timeslot withprobability 1, using only O(log n) qubits of communication.
139

5. (H) The disjointness problem of communication complexity is the following decision versionof the intersection problem: Alice receives an x ∈ {0, 1}n , Bob receives y ∈ {0, 1}n , andf (x, y) = 0 if there is an i such that xi = yi = 1, and f (x, y) = 1 otherwise (i.e., f says
whether x and y represent disjoint subsets of [n]). Suppose there exists an m-qubit one-way
protocol that solves this problem, so where Alice sends Bob m qubits and then Bob outputs
f (x, y) with probability at least 2/3. Prove the lower bound m = Ω(n) on the number of
qubits sent.
6. (H) Consider the intersection problem: Alice has input x ∈ {0, 1}n , Bob has input y ∈ {0, 1}n ,and they want to find (with success probability ≥ 2/3) an i such that xi = yi = 1, if such√an i exists. We know that using r = O( n) messages between Alice and Bob, they can√solve the intersection problem with O( n log n) qubits of communication (see Section 16.4).
We also know that with only r = 1 message (i.e., one-way communication) Θ(n) qubits ofcommunication are necessary and sufficient (see Exercise 5). Now suppose we limit them to√some r ∈ {1, . . . , n} messages. This r is known to Alice and Bob. Describe a communication
protocol by means of which Alice and Bob can solve the intersection problem with at most r
messages, and O((n/r) log n) qubits of communication in total.
7. (a) Consider the following variant of the search problem: we are given query access to astring x ∈ {0, 1}n , and we know a set S ⊆ [n] of k < n elements such that xi = 0 for alli 6∈ S. Show that there is a quantum algorithm that can find a solution for this search
problem(i.e., an i such that xi = 1, if there is one) with success probability ≥ 2/3, using√O( k) queries to x.
(b) Consider the following variant of the intersection problem of communication complexity:
Alice holds a string x ∈ {0, 1}n of Hamming weight k, and Bob holds a string y ∈ {0, 1}nof Hamming weight k. Give a quantum communication protocol that finds an√ i suchthat xi = yi = 1 (if such an i exists) with success probability ≥ 2/3, using O( k log n)qubits of communication.
8. Consider an error-correcting code C : {0, 1}n → {0, 1}N where N = O(n), N is a square, andany two distinct codewords are at Hamming distance d(C(x), C(y)) ∈ [0.49N, 0.51N ] (suchcodes exist, but you don’t have to prove that).
√√(a) View the codeword C(x) as a N × N matrix. Show that if you choose a row index uniformly at random and choose a column index uniformly at random, then the unique index i where these row and column intersect, is uniformly distributed over i ∈ {1, . . . , N }.
(b) (H) Give a classical bounded-error SMP-protocol for the equality problem where Alice√and Bob each send O( n) bits to the Referee.
9. Alice and Bob want to solve the equality problem on n-bit inputs x and y (i.e., decide
whether x = y). They do not share randomness or entanglement but can use local (private)randomness.
(a) (H) Fix a prime number p ∈ [3n, 6n], then the set Fp of integers modulo p is a finite fieldn(i.e., it has a well-defined addition and multiplication). For x = (x0 , . . . , xn−1 ) ∈ {0, 1} ,Pn−1idefine the univariate polynomial Px : Fp → Fp of degree < n as Px (t) = i=0 xi t (notethat the n bits of x are used as coefficients here, not as the argument of the polynomial).
140

Show that for distinct n-bit strings x and y, we have Prt∈Fp [Px (t) = Py (t)] ≤ 1/3, where
the probability is taken over a uniformly random t ∈ Fp .
(b) Use (a) to give a classical communication protocol where Alice sends an O(log n)-bit
message to Bob, and Bob can decide whether x = y with success probability ≥ 2/3.
(c) Use (a) to give a quantum fingerprinting scheme x 7→ |φx i, where quantum state |φx i
has O(log n) qubits, and |hφx |φy i| ∈ [0, 1/3] for all distinct n-bit strings x and y (prove
the latter property explicitly, it’s not enough to write down only the states).
10. The inner product problem in communication
complexity is the function f : {0, 1}n ×Pnn{0, 1} → {0, 1} defined by f (x, y) =i=1 xi yi mod 2. Suppose there exists a quantum
protocol P for Alice and Bob that uses q qubits of communication (possibly using multiple
messages between Alice and Bob) and computes the inner product function with success probability 1 (on every possible inputs x, y). The protocol does not assume any shared entangledstate at the start.
(a) Give a quantum protocol that uses 2q qubits of communication and implements the 2nqubit map |xiA |yiB 7→ (−1)x·y |xiA |yiB (possibly with some auxiliary qubits for each of
Alice and Bob; these should start and end in state |0i).
(b) (H) Give a protocol where Alice transmits x to Bob using 2q qubits of communication.
(c) Derive a lower bound on q from (b) and Holevo’s theorem (Theorem 3 of Chapter 15;
be specific about which part of the theorem you invoke).
11. Consider the following problem in communication complexity. Alice’s input has two parts:
a unit vector v ∈ Rm and two orthogonal projectors P0 and P1 . Bob’s input is an m × m
unitary U . They are promised that the vector U v either lies in the subspace corresponding to
P0 (i.e., P0 U v = v) or in the subspace corresponding to P1 (i.e., P1 U v = v), and the problem
for Alice and Bob is to find out which of these two cases holds.
(a) Give a quantum protocol that uses two messages of O(log m) qubits (one message from
Alice to Bob and one from Bob to Alice) to solve this problem with success probability 1.
(b) (H) Show that there exists a constant c > 0 such that classical protocols need to sendΩ(mc ) bits of communication to solve this problem with error probability ≤ 1/3, evenwhen they are allowed to send many messages.
12. (H) Consider the following communication complexity problem, called the “Hidden Matching
Problem.” Alice’s input is some x ∈ {0, 1}n . Bob’s input is a matching M , i.e., a partition of{1, . . . , n} into n/2 disjoint unordered pairs (assume n is a power of 2 for simplicity). Theirgoal is that Bob outputs a pair {i, j} ∈ M together with the parity xi ⊕ xj of the two bits
indexed by that pair. It doesn’t matter which pair {i, j} ∈ M Bob outputs, as long as the
additional bit of output equals the parity of the two indexed bits of x. Show that they cansolve this problem with success probability 1 using only a message of log n qubits from Aliceto Bob (and no communication from Bob to Alice).
√
Comment: One can show that classical one-way protocols need Ω( n) bits of communication to solve thisproblem with small error probability.

13. (a) Suppose you have a state √12 (|0i|φi + |1i|ψi), where |φi and |ψi are quantum states withreal amplitudes. Suppose you apply a Hadamard gate to its first qubit and then measurethat first qubit. Show that the probability of measurement outcome 0 is 12 (1 + hφ|ψi).
141

(b) Suppose H is a subgroup of a finite group G, and g ∈ G some element. Show (1) if
g ∈ H then the cosets g ◦ H and H are equaland (2) if g 6∈ H then the cosets g ◦ H and H are disjoint.
P(c) Suppose you are given quantum state |ψH i = √1H h∈H |hi (for an unknown H ≤ G),
and an element g ∈ G. You may assume you have a unitary A available that implements
the group operation, A : |g, hi 7→ |g, g ◦ hi, and you may also apply a controlled versionof A. Give an algorithm that acts on |ψH i and possibly some auxiliary qubits, and that
outputs 0 with probability 1 if g ∈ H, and outputs 0 with probability ≤ 1/2 if g 6∈ H.
(d) (H) Consider the following communication complexity problem. Alice and Bob bothknow a finite group G, Alice gets as input some subgroup H ≤ G (for instance in theform of a generating set for H) and Bob gets input g ∈ G. Give a one-way quantum
protocol where Alice sends to Bob a message of O(log |G|) qubits, and then Bob decides
with success probability ≥ 2/3 whether g ∈ H.

142

Chapter 17

Entanglement and Non-Locality
17.1

Quantum non-locality

Entangled states are those that cannot be written as a tensor product of separate states. The most
famous one is the EPR-pair:1√ (|00i + |11i).
2
Suppose Alice has the first qubit of the pair, and Bob has the second. If Alice measures her qubit
in the computational basis and gets outcome b ∈ {0, 1}, then the state collapses to |bbi. Similarly,
if Alice measures her qubit in some other basis, this will collapse the joint state (including Bob’s
qubit) to some state that depends on her measurement basis as well as its outcome. Somehow
Alice’s action seems to have an instantaneous effect on Bob’s side—even if the two qubits arelight-years apart! This was a great bother to Einstein, whose theory of relativity posits that
information and causation cannot travel faster than the speed of light. Einstein called such effects
of entanglement “spooky action at a distance” (in German: “spukhafte Fernwirkungen”), andviewed it as a fundamental problem for quantum mechanics [106]. In his view, quantum mechanics
should be replaced by some “local realist” physical theory that would still have the same predictive
power as quantum mechanics. Here “local” means that information and causation act locally, notfaster than light, and “realistic” means that physical systems have definite, well-defined properties(even if those properties may be unknown to us).
Note that the above experiment where Alice measures her half of the EPR-pair doesn’t actually
violate locality: no information is transfered from Alice and Bob. From Bob’s perspective there
is no difference between the situation where Alice measured and the situation where she didn’t.1
For this experiment, a shared coin flip between Alice and Bob is a local realist physical modelthat has exactly the same observable consequences as measuring the qubits of the EPR-pair in thecomputational basis: a 50-50 distribution on outcomes |00i and |11i. This shared-coin-flip model
is local because no information is transfered between Alice and Bob, and it’s realist because thecoin flip has a definite outcome (even if that outcome is unknown to Alice and Bob before theymeasure).
Given this example, one might hope (and Einstein expected) that any kind of behavior thatcomes from entangled states can be replaced by some local realist physical model. This way,quantum mechanics could be replaced by an alternative physical theory with less counter-intuitive1

In fact, one can show that entanglement cannot replace communication, see for example Exercise 18.7.

143behavior. Surprisingly, in the 1960s, John Bell [39] devised entanglement-based experiments whose
behavior cannot be reproduced by any local realist theory. In other words, we can let Alice and Bob
do certain measurements on an entangled state, and the resulting distributions on their outputs predicted by quantum mechanics, cannot be obtained from any local realist theory. This phenomenon
is known as “quantum non-locality.” It could of course be that the quantum mechanical predictionsof the resulting correlations are just wrong. However, in the early 1980s, such experiments wereactually done by Aspect and others [31], and they gave the outcomes that quantum mechanics
predicted.2 Note that such experiments don’t prove quantum mechanics, but they disprove any
local realist physical theory.3
Such experiments, which realize correlations that are provably impossible to realize with local
realist models, are among the deepest and most philosophical results of 20th century physics: thecommonsense idea of local realism is most probably false! Since Bell’s seminal work, the concept ofquantum non-locality has been extensively studied, by physicists, philosophers, and more recently
by computer scientists.
In the next sections we review some interesting examples. The two-party setting of theseexamples is illustrated in Fig. 17.1: Alice receives input x and Bob receives input y, and they
produce outputs a and b, respectively, that have to be correlated in a certain way (which depends
on the game). They are not allowed to communicate. In physics language, we could assume they
are “space-like separated,” which means that they are so far apart that they cannot influence eachother during the course of the experiment (assuming information doesn’t travel faster than the
speed of light). In the classical scenario they are allowed to share a random variable. Physicists
would call this the “local hidden variable” that gives properties their definite value (that value may
be unknown to the experimenter). This setting captures all local realist models. In the quantum
model Alice and Bob are allowed to share entangled states, such as EPR-pairs. The goal is to showthat entanglement-based strategies can do things that local realist strategies cannot.
Inputs:

Outputs:

x

y

❄

❄

Alice

Bob

❄

❄

a

b

Figure 17.1: The non-locality scenario involving two parties: Alice and Bob receive inputs x and y,
respectively, and are required to produce outputs a and b that satisfy certain conditions. Once theinputs are received, no communication is permitted between the parties.

2

Modulo some technical “loopholes” due to imperfect photon sources, measurement devices, Alice and Bob not
being sufficiently far apart etc. These are still hotly debated, but most people accept that Aspect’s and later
experiments are convincing, and kill any hope of a complete local-realist explanation of nature. Recently [137] anexperiment was done that simultaneously closed the two most important loopholes.
3
Despite its name, non-locality doesn’t disprove locality, but rather disproves the conjunction of locality andrealism—at least one of the two assumptions has to fail.

144

17.2

CHSH: Clauser-Horne-Shimony-Holt

In the CHSH game [87] Alice and Bob receive input bits x and y, and their goal is to output bitsa and b, respectively, such thata ⊕ b = x ∧ y,(17.1)(‘∧’ is logical AND; ‘⊕’ is parity, i.e. addition mod 2) or, failing that, to satisfy this condition withas high a probability as possible.
First consider the case of classical deterministic strategies, so without any randomness. For
these, Alice’s output bit depends solely on her input bit x, and similarly for Bob. Let a0 be thebit that Alice outputs if her input is x = 0, and a1 the bit she outputs if x = 1. Let b0 , b1 be theoutputs Bob gives on inputs y = 0 and y = 1, respectively. These four bits completely characterize
any deterministic strategy. Condition (17.1) becomesa0 ⊕ b0 = 0,a0 ⊕ b1 = 0,a1 ⊕ b0 = 0,a1 ⊕ b1 = 1.

(17.2)

It is impossible to satisfy all four equations simultaneously, since summing them modulo 2 yields
0 = 1. Therefore it is impossible to satisfy Condition (17.1) perfectly. Since a probabilistic strategy(where Alice and Bob share randomness) is a probability distribution over deterministic strategies,
it follows that no probabilistic strategy can have success probability better than 3/4 on every
possible input (the 3/4 can be achieved simultaneously for every input, see Exercise 4).4
Now consider the same problem but where Alice and Bob are supplied with a shared 2-qubit
system initialized to the entangled state√1 (|00i − |11i).
2

Such a state can easily be obtained from an EPR-pair by local operations, for instance if Aliceapplies a Z-gate to her qubit. Now the parties can produce outputs that satisfy Condition (17.1)
with probability cos(π/8)2 ≈ 0.85 (higher than what is possible in the classical case), as follows.
cos θ − sin θ. If x = 0
Recall the unitary operation that rotates the qubit by angle θ: R(θ) =
sin θ
cos θ
then Alice applies R(−π/16) to her qubit; and if x = 1 she applies R(3π/16). Then Alice measures
her qubit in the computational basis and outputs the resulting bit a. Bob’s procedure is the same,depending on his input bit y. It is straightforward to calculate that if Alice rotates by θA and Bob
rotates by θB , the state becomes1√ (cos(θA + θB )(|00i − |11i) + sin(θA + θB )(|01i + |10i)) .
2
After the measurements, the probability that a ⊕ b = 0 is cos(θA + θB )2 . Note that if x ∧ y = 0
then θA + θB = ±π/8, while if x ∧ y = 1 then θA + θB = 3π/8. Hence Condition 17.1 is satisfied
with probability cos(π/8)2 for all four input possibilities, showing that quantum entanglement
4

Such statements, upper bounding the optimal success probability of classical strategies for a specific game, are
known as Bell inequalities. This specific one is called the CHSH inequality.

145

allows Alice and Bob to win the game with a probability that’s higher than what the best classicalstrategy can achieve. Tsirelson [86] showed that cos(π/8)2 is the best that quantum strategies cando for CHSH, even if they are allowed to use much more entanglement than one EPR-pair (seeExercise 6).

17.3

Magic square gameIs there a game where the quantum protocol always succeeds, while the best classical successprobability is bounded below 1? A particularly elegant example is the following magic squaregame [25]. Consider the problem of labeling the entries of a 3 × 3 matrix with bits so that theparity of each row is even, whereas the parity of each column is odd. This is clearly impossible:
if the parity of each row is even then the sum of the 9 bits is 0 mod 2, but if the parity of eachcolumn is odd then the sum of the 9 bits is 1 mod 2. The two matrices
0
0
1

0
0
1

0
0
0

0
0
1

0
0
1

0
0
1

each satisfy five out of the six constraints. For the first matrix, all rows have even parity, but only
the first two columns have odd parity. For the second matrix, the first two rows have even parity,
and all columns have odd parity.
Consider the game where Alice receives x ∈ {1, 2, 3} as input (specifying the number of a row),and Bob receives y ∈ {1, 2, 3} as input (specifying the number of a column). Their goal is to eachproduce 3-bit outputs, a1 a2 a3 for Alice and b1 b2 b3 for Bob, such that
1. They satisfy the row/column parity constraints: a1 ⊕ a2 ⊕ a3 = 0 and b1 ⊕ b2 ⊕ b3 = 1.
2. They are consistent where the row intersects the column: ay = bx .
As usual, Alice and Bob are forbidden from communicating once the game starts, so Alice does notknow y and Bob does not know x. We shall show the best classical strategy has success probability
8/9, while there is a quantum strategy that always succeeds.
An example of a deterministic strategy that attains success probability 8/9 (when the input xy
is uniformly distributed) is where Alice plays according to the rows of the first matrix above andBob plays according the columns of the second matrix above. This succeeds in all cases, except
where x = y = 3. To see why this is optimal, note that for any other classical strategy, it is possible
to represent it as two matrices as above but with different entries. Alice plays according to therows of the first matrix and Bob plays according to the columns of the second matrix. We canassume that the rows of Alice’s matrix all have even parity; if she outputs a row with odd parity
then they immediately lose, regardless of Bob’s output. Similarly, we can assume that all columnsof Bob’s matrix have odd parity.5 Considering such a pair of matrices, the players lose at eachentry where they differ. There must be such an entry, since otherwise it would be possible to have
all rows even and all columns odd with one matrix. Thus, when the input xy is chosen uniformly
from {1, 2, 3} × {1, 2, 3}, the success probability of any classical strategy is at most 8/9.
5

In fact, the game can be simplified so that Alice and Bob each output just two bits, since the parity constraint
determines the third bit.

146

We now give the quantum strategy for this game. Let I, X, Y , Z be the 2 × 2 Pauli matrices
from Appendix A.9. Each is a 1-qubit observable with eigenvalues in {+1, −1}.6 That is, each canbe written as P+ − P− where P+ and P− are orthogonal projectors that sum to identity, and hence
define a two-outcome measurement with outcomes +1 and −1. For example, Z = |0ih0| − |1ih1|,
corresponding to a measurement in the computational basis (with |bi corresponding to outcome(−1)b ). And X = |+ih+| − |−ih−|, corresponding to a measurement in the Hadamard basis. The
Pauli matrices are self-inverse, they anti-commute unless one of them is I (e.g., XY = −Y X), and
X = iZY , Y = iXZ, and Z = iY X. Consider the following table, where each entry is a tensor
product of two Paulis:
X ⊗X
Y ⊗Y
Z ⊗Z

Y ⊗Z
Z ⊗X
X ⊗Y

Z ⊗Y
X ⊗Z
Y ⊗X

Because (P+ − P− ) ⊗ (Q+ − Q− ) = (P+ ⊗ Q+ + P− ⊗ Q− ) − (P+ ⊗ Q− + P− ⊗ Q+ ), each suchproduct is itself a {+1, −1}-valued observable. Hence each product of Pauli matrices corresponds
to a measurement on a 2-qubit space, with outcomes +1 and −1.
Note that the observables along each row commute and their product is I ⊗ I, and the observables along each column commute and their product is −I ⊗ I. This implies that for any
2-qubit state, performing the three measurements along any row results in three {+1, −1}-valued
bits whose product is +1. Also, performing the three measurements along any column results inthree {+1, −1}-valued bits whose product is −1.
We can now describe the quantum protocol. It uses two pairs of entangled qubits, each of whichis in initial state1√ (|01i − |10i)
2(again, such states can be obtained from EPR-pairs by local operations). Alice, on input x, applies
three 2-qubit measurements corresponding to the observables in row x of the above table. For eachmeasurement, if the result is +1 then she outputs 0, and if the result is −1 then she outputs 1.
Similarly, Bob, on input y, applies the measurements corresponding to the observables in column y,and converts the ±1-outcomes into bits.
We have already established that Alice and Bob’s output bits satisfy the required parity constraints. It remains to show that Alice and Bob’s output bits agree at the point where the row
meets the column. For that measurement, Alice and Bob are measuring with respect to the sameobservable in the above table. Because all the observables in each row and in each column commute, we may assume that the place where they intersect is the first observable applied. Those
bits are obtained by Alice and Bob each measuring 12 (|01i − |10i)(|01i − |10i) with respect to theobservable in entry (x, y) of the table. To show that their measurements will agree for all cases ofxy, we consider the individual Pauli measurements on the individual entangled pairs of the form
√1 (|01i − |10i). Let a0 and b0 denote the 0/1-valued outcomes of the first measurement, and a00
2
and b00 denote the outcomes of the second. The measurement associated with the tensor product of
two observables gives the same distribution over outcomes as measuring each individual observableand then taking the product of the two results. Hence we have ay = a0 ⊕ a00 and bx = b0 ⊕ b00 . It is
6

See Section 1.2.2. In particular, a ±1-valued observable A can be written as A = P − Q, where P and Q are
projectors on two orthogonal subspaces such that P + Q = I. This corresponds to a two-outcome measurement
specified by projectors P and Q with outcomes +1 and −1, respectively.

147

straightforward to verify that if the same measurement from {I, X, Y, Z} is applied to each qubitof √12 (|01i − |10i) then the outcomes will be distinct: a0 ⊕ b0 = 1 and a00 ⊕ b00 = 1. We now haveay = bx , because
ay ⊕ bx = (a0 ⊕ a00 ) ⊕ (b0 ⊕ b00 ) = (a0 ⊕ b0 ) ⊕ (a00 ⊕ b00 ) = 1 ⊕ 1 = 0.

17.4

(17.3)

A non-local version of distributed Deutsch-Jozsa

The previous two examples used small amounts of entanglement: one EPR-pair for CHSH, two
EPR-pairs for magic square. In both cases we could show that classical protocols need at least
some communication if they want to achieve the same as what entanglement-based protocols canachieve without any communication. We will now give a non-locality game that’s parametrized by anumber n, and where Alice and Bob’s quantum strategy uses log n EPR-pairs [65]. The advantage
is that we can show that classical protocols for this game need just some but actually much classicalcommunication rather than at least some nonzero amount.
Non-local DJ problem: Alice and Bob receive n-bit inputs x and y that satisfy the
DJ promise: either x = y, or x and y differ in exactly n/2 positions. The task is for
Alice and Bob to provide outputs a, b ∈ {0, 1}log n such that if x = y then a = b, and if
x and y differ in exactly n/2 positions then a 6= b.
They achieve this as follows
1. Alice and Bob share log n EPR-pairs, i.e., the maximally entangled state √1n
2. They both apply locally a conditional phase to obtain: √1nPn−1

i=0 |ii|ii.

7

Pn−1

xi
yi
i=0 (−1) |ii(−1) |ii.

3. They both apply a Hadamard transform, obtaining
n−1
1 X
√
(−1)xi +yi
n n
i=0

1
= √
n n

X

(−1)i·a |ai

X(−1)i·b |bib∈{0,1}log na∈{0,1}log n

X

n−1
X

a,b∈{0,1}log ni=0!
xi +yi +i·(a⊕b)(−1)|ai|bi.

4. They measure in the computational basis and output the results a and b, respectively.
For every a, the probability that both Alice and Bob obtain the same result a is:
n−1
1 X
√
(−1)xi +yi
n n

2

,

i=0

7

Note that k EPR-pairs⊗k√1 (|0iA |0iB + |1iA |1iB )2

X
1|iiA |iiB if we reorder
can also be written as √k
2 i∈{0,1}k

the qubits, putting Alice’s k qubits on the left and Bob’s on the right. While these two ways of writing the state
strictly speaking correspond to two different vectors of amplitudes, they still represent the same bipartite physicalstate, and we will typically view them as equal.

148

which is 1/n if x = y, and 0 otherwise. This solves the problem perfectly using prior entanglement.
What about classical protocols? Suppose there is a classical protocol that uses C bits of communication, and that wins the non-local Deutsch-Jozsa problem with success probability 1. If
Alice and Bob ran this protocol, and then Alice communicated her output a to Bob (using an
additional log n bits), then they could solve the distributed Deutsch-Jozsa problem since Bob could
then check whether a = b or a 6= b. But we know from Section 16.3 that solving the distributed
Deutsch-Jozsa problem requires at least 0.007n bits of communication. Hence C + log n ≥ 0.007n,
so C ≥ 0.007n − log n = Ω(n). Thus we have a non-locality problem that can be solved perfectly if
Alice and Bob share log n EPR-pairs, while classically it needs not just some communication, but
actually a lot of communication if we want to solve it perfectly.

Exercises
1. Suppose Alice and Bob share an EPR-pair √12 (|00i + |11i).
(a) Let U be a 1-qubit unitary. Show that the following two states are the same: (1) thestate obtained if Alice applies U to her qubit of the EPR-pair;(2) the state obtained if Bob applies the transpose U T to his qubit of the EPR-pair.
(b) (H) What state do you get if each of Alice and Bob applies a Hadamard transform totheir qubit of the EPR-pair?
2. Alice and Bob share an EPR-pair, √12 (|00i+|11i). Suppose they each measure their qubit with
an X-observable (which corresponds to a particular projective measurement with possible
outcomes +1, −1).
(a) Show that Alice’s measurement outcome is uniformly distributed, so 50% probability ofoutcome +1 and 50% probability of outcome −1.
(b) (H) Show that Alice’s and Bob’s measurement outcomes are always equal.
(c) Suppose we view X ⊗ X as one 2-qubit observable (with possible outcomes +1, −1)
instead of two 1-qubit observables. What is the probability distribution on the two
possible outcomes?
3. Alice and Bob share n EPR-pairs. Call their shared 2n-qubit state |ψiAB .
(a) Let U be an arbitrary n-qubit unitary and Ū be U after conjugating its entries (withouttransposing). Prove that (U ⊗ Ū )|ψiAB = |ψiAB .
(b) Suppose Alice receives some input x, and she does an n-qubit unitary Ux on her part ofthe state and then measures in the computational basis, obtaining a classical outcomea ∈ {0, 1}n . What is the probability distribution over Alice’s measurement outcomes,
and why?
(c) Suppose Bob receives the same input x as Alice already received. How can he learn
Alice’s measurement outcome a from part (b) without communication? (you may assume
Bob knows the map x 7→ Ux )4. (H) Give a classical strategy using shared randomness for the CHSH game, such that Aliceand Bob win the game with probability at least 3/4 for every possible input x, y (note theorder of quantification: the same strategy has to work for every x, y).
149

5. “Mermin’s game” is the following. Consider three space-like separated players: Alice, Bob,
and Charlie. Alice receives input bit x, Bob receives input bit y, and Charlie receives input
bit z. The input satisfies the promise that x ⊕ y ⊕ z = 0. The goal of the players is to output
bits a, b, c, respectively, such that a ⊕ b ⊕ c = OR(x, y, z). In other words, the outputs should
sum to 0 (mod 2) if x = y = z = 0, and should sum to 1 (mod 2) if x + y + z = 2.
(a) Show that every classical deterministic strategy will fail on at least one of the 4 allowed
inputs.
(b) Show that every classical randomized strategy has success probability at most 3/4 under
the uniform distribution on the four allowed inputs xyz.
(c) Suppose the players share the following entangled 3-qubit state:
1(|000i − |011i − |101i − |110i).
2
Suppose each player does the following: if his/her input bit is 1, apply H to his/her
qubit, otherwise do nothing. Describe the resulting 3-qubit superposition.
(d) Using (c), give a quantum strategy that wins the above game with probability 1 on every
input that satisfies the promise.
6. (H) This question examines how well the best quantum protocol can do for CHSH (resulting
in the so-called “Tsirelson bound”). Consider a protocol where Alice and Bob share a 2kqubit state |ψi = |ψiAB with k qubits for Alice and k for Bob (the state can be arbitrary andneed not consist of EPR-pairs). Alice has two possible ±1-valued observables A0 and A1 , andBob has two possible ±1-valued observables B0 and B1 . Each of these observables acts on k
qubits. On inputs x ∈ {0, 1} and y ∈ {0, 1}, respectively, Alice measures her half of |ψi with
Ax and outputs the resulting sign a ∈ {+1, −1}, and Bob measures his half of |ψi with By
and outputs the resulting sign b. Note that we treat the output bits as signs instead of 0/1
now. However, the winning condition is the same: the AND of the input bits should equal
the parity (XOR) of the output bits. So Alice and Bob win the game if (−1)xy = ab.
(a) Show that the expected value of the product ab on inputs x, y is hψ|Ax ⊗ By |ψi (this is
the same as Tr [(Ax ⊗ By )|ψihψ|]).
(b) Define 2k-qubit operator C = A0 ⊗ B0 + A0 ⊗ B1 + A1 ⊗ B0 − A1 ⊗ B1 . Show that thewinning probability of the protocol (averaged over all 4 inputs pairs x, y) is 12 + 18 hψ|C|ψi.
(c) Show that C 2 = 4I + (A0 A1 − A1 A0 ) ⊗ (B1 B0 − B0 B1 ), where I is the 2k-qubit identity
matrix.
√(d) Show that hψ|C|ψi ≤ 8.
(e) What can you conclude about the best-possible winning probability among all possible
quantum protocols for CHSH?

150

Chapter 18

Quantum Cryptography
18.1

Saving cryptography from Shor

Most classical public-key cryptography in use today can be broken by a large quantum computer.
In particular, the RSA system relies on the hardness of factoring integers and hence is broken
by Shor’s factoring algorithm (see Exercise 5.3); and Diffie-Helman relies on the hardness of thediscrete logarithm problem which was also broken by Shor (see Exercise 6.3). This could clearly
become a huge problem for society if and when a large quantum computer is realized: if we cannot
securely send messages, make payments or sign transactions online anymore, then much of oureconomy and society breaks down, or will at least need to be heavily reconfigured.
There are two ways to address this problem. On the one hand we can try to design otherclassical cryptographic systems, based on the assumed hardness (even for quantum computers) ofcomputational problems other than factoring or discrete log. This part of classical cryptography is(slightly confusingly) called post-quantum cryptography [52]. Its most famous cryptosystem to dateis “learning with errors” (LWE) [204], which relies on the assumed hardness of certain computational
problems in integer lattices.
On the other hand, we can also try to design cryptographic systems that explicitly rely on quantum effects. This area is called quantum cryptography and is the topic of this chapter. Comparedto post-quantum cryptography, this has the disadvantage that even the honest users of the scheme
need to have a (simple) quantum computer at their disposal, but it has the advantage that the
security against adversaries in some cases is information-theoretic, not predicated on the assumed
but unproven hardness of some computational problems.

18.2

Quantum key distribution

One of the most basic tasks of cryptography is to allow Alice to send a message to Bob (whomshe trusts) over a public channel, without allowing a third party Eve (for “eavesdropper”) to
get any information about M from tapping the channel. Suppose Alice wants to send message
M ∈ {0, 1}n to Bob. The goal here is not minimal communication, but secrecy. This is often doneby public-key cryptography such as RSA. Such schemes, however, are only computationally secure,not information-theoretically secure: all the information about the private key can be computedfrom the public key, it just appears to take a lot of time to compute it—assuming of course thatproblems like factoring are classically hard, and that nobody builds a quantum computer. . .
151

In contrast, the following “one-time pad” scheme is information-theoretically secure. If Aliceand Bob share a secret key K ∈ {0, 1}n then Alice can send C = M ⊕K over the channel. By adding
K to what he received, Bob learns M . On the other hand, if Eve didn’t know anything about Kthen she learns nothing about M from tapping the message M ⊕ K that goes over the channel.
How can we make Alice and Bob share a secret key? In the classical world this is impossible, butwith quantum communication it can be done!
Below we describe the famous BB84 quantum key distribution (QKD) protocol of Bennett andBrassard [51]. Consider two possible bases: basis 0 is the computational basis {|0i, |1i}, and basis 1
is the Hadamard basis {|+i, |−i}. The main property of quantum mechanics that we’ll use, isthat if a bit b is encoded in an unknown basis, then Eve cannot get information about b without
disturbing the state, and the latter can be detected by Alice and Bob.1
1. Alice chooses n random bits a1 , . . . , an and n random bases b1 , . . . , bn . She sends ai to Bob
in basis bi over the public quantum channel. For example, if ai = 0 and bi = 1 then the i-th
qubit that she sends is in state |+i.
2. Bob chooses random bases b01 , . . . , b0n and measures the qubits he received in those bases,
yielding bits a01 , . . . , a0n .
3. Bob sends Alice all b0i (this also signals to Alice that Bob has measured the qubits he received),
and Alice sends Bob all bi . Note that for roughly n/2 of the is, Alice and Bob used the same
basis bi = b0i . For those i Bob should have a0i = ai (if there was no noise and Eve didn’t
tamper with the i-th qubit on the channel). Both Alice and Bob know for which is this holds.
Let’s call these roughly n/2 positions the “shared string.”
4. Alice randomly selects n/4 locations in the shared string, and sends Bob those locations aswell as the values ai at those locations. Bob then checks whether they have the same bitsin those positions. If the fraction of errors is bigger than some number p, then they suspectsome eavesdropper was tampering with the channel, and they abort.2
5. If the test is passed, then they discard the n/4 test-bits, and have roughly n/4 bits left in theirshared string. This is called the “raw key.” Now they do some classical postprocessing on theraw key: “information reconciliation” to ensure they end up with exactly the same sharedstring, and “privacy amplification” to ensure that Eve has negligible information about thatshared string.3
The communication is n qubits in step 1, 2n bits in step 3, O(n) bits in step 4, and O(n) bits instep 5. So the required amount of communication is linear in the length of the shared secret key
that Alice and Bob end up with.
1

Quantum key distribution might in fact better be called “quantum eavesdropper detection.” There is anotherassumption underlying BB84 that should be made explicit: we assume that the classical channel used in steps 3–5
is “authenticated,” meaning that Alice and Bob know they are talking to each other, and Eve can listen but notchange the bits sent over the classical channel (in contrast to the qubits sent during step 1 of the protocol, which Eve
is allowed to manipulate in any way she wants). One can authenticate a classical communication channel by using
some shared secret key; if this is used, then one may think of QKD as something that allows to grow an initial sharedsecret key, rather than as something that conjures up a shared random key out of nothing.
2
The number p can for instance be set to the natural error-rate that the quantum channel would have if there
were no eavesdropper.
3This can be done for instance by something called the “leftover hash lemma.”152

It’s quite hard to formally prove that this protocol yields (with high probability) a shared key
about which Eve has negligible information. In fact it took more than 12 years before BB84 was
finally proven secure [188, 175]. The main reason it works is that when the qubits that encode
a1 , . . . , an are going over the public channel, Eve doesn’t know yet in which bases b1 , . . . , bn theseare encoded (she will learn the bi later from tapping the classical communication in step 3, but
at that point this information is not of much use to her anymore). She could try to get as muchinformation as she can about a1 , . . . , an by some measurement, but there’s an information-vsdisturbance tradeoff : the more information Eve learns about a1 , . . . , an by measuring the qubits,
the more she will disturb the state, and the more likely it is that Alice and Bob will detect her
presence in step 4.
We won’t go into the full proof details here, just illustrate the information-disturbance tradeoff
for the case where Eve individually attacks the qubits encoding each bit in step 1 of the protocol.4
In Fig. 18.1 we give the four possible states for one BB84-qubit. If Alice wants to send ai = 0,then she sends a uniform mixture of |0i and |+i across the channel; if Alice wants to send ai = 1
she sends a uniform mixture of |1i and |−i. Suppose Eve tries to learn ai from the qubit on thechannel. The best way for her to do this is to measure in the orthonormal basis corresponding tostate cos(π/8)|0i + sin(π/8)|1i and − sin(π/8)|0i + cos(π/8)|1i. Note that the first state is halfway
between the two encodings of 0, and the second state is halfway between the two encodings of 1
(remember that |−i and −|−i are physically indistinguishable because they only differ by a global
phase). This will give her the value of ai with probability cos(π/8)2 ≈ 0.85 (remember the 2-to-1
quantum random access code from Exercise 2 of Chapter 15). However, this measurement willchange the state of the qubit by an angle of at least π/8, so if Bob now measures the qubit hereceives in the same basis as Alice, then his probability of recovering the incorrect value of ai is
at least sin(π/8)2 ≈ 0.15 (if Bob measured in a different basis than Alice, then the result will bediscarded anyway). If this i is among the test-bits Alice and Bob use in step 4 of the protocol(which happens with probability 1/2), then they will detect an error. Eve can of course try a lessdisturbing measurement to reduce the probability of being detected, but such a measurement will
also have lower probability of telling her ai .
|1i
✻

|+i
✒
✲ |0i
❘

|−i

Figure 18.1: The four possible states in BB84 encoding: |0i and |+i are two different encodingsof 0, and |1i and |−i are two different encodings of 1.

4

The more complicated situation where Eve does an n-qubit measurement on all qubits of step 1 simultaneously
can be reduced to the case of individual-qubit measurements by something called the quantum De Finetti theorem,
but we won’t go into the details here.

153

18.3

Reduced density matrices and the Schmidt decomposition

Suppose Alice and Bob share some pure state |φi. If this state is entangled, it cannot be written
as a tensor product |φA i ⊗ |φB i of separate pure states for Alice and Bob. Still, there is a way todescribe Alice’s local state as a mixed state, by tracing out Bob’s part. Formally, if C ⊗ D is atensor product matrix then TrB (C ⊗D) = C ·Tr(D). By extending this linearly to matrices that are
not of product form, the operation TrB is well-defined on all mixed states. Note that TrB removes
Bob’s part of the state, leaving just Alice’s part of the state. If ρAB is some bipartite state (mixed
or pure, entangled or not), then ρA = TrB (ρAB ) is Alice’s local density matrix. This describes all
the information she has. For example, for an EPR-pair |φi = √12 (|00i + |11i), the corresponding
density matrix is
ρAB =
=

1
(|00ih00| + |00ih11| + |11ih00| + |11ih11|)21(|0ih0| ⊗ |0ih0| + |0ih1| ⊗ |0ih1| + |1ih0| ⊗ |1ih0| + |1ih1| ⊗ |1ih1|),2

and since Tr(|aihb|) = 1 if a = b and Tr(|aihb|) = 0 if |ai and |bi are orthogonal, we have1ρA = TrB (ρAB ) = (|0ih0| + |1ih1|).
2
In other words, Alice’s local state is the same as a random coin flip! Similarly we can compute Bob’s
local state by tracing out Alice’s part of the space: ρB = TrA (ρAB ). Note that the original 2-qubit
density matrix ρAB is not equal to ρA ⊗ ρB , because the tracing-out operation has “removed” theentanglement between the two qubits.
The Schmidt decomposition is a very useful way to write bipartite pure states, and allows us toeasily calculate the local density matrices of Alice and Bob. It says the following: for every bipartite
pure state |φi there is a unique integer d (called the Schmidt rank of |φi), an orthonormal set ofstates |a1 i, . . . , |ad i for Alice’s space, an orthonormal set of states |b1 i, . . . , |bd i for Bob’s space, andpositive reals λ1 , . . . , λd whose squares sum to 1, such that
|φi =

d
X

λi |ai i|bi i.

(18.1)

i=1√
For example, an EPR-pair has Schmidt coefficients λ1 = λ2 = 1/ 2 and hence has Schmidt rank 2.
The Schmidt rank and the Schmidt coefficients of a state |φi are unique, but there is some freedom
in the choice of bases if the λj are not all distinct. For example
1
1√ (|00i + |11i) = √ (| + +i + | − −i)22
are two distinct Schmidt decompositions of the EPR-pair.
The existence of the Schmidt decomposition is shown as follows. Let ρA = TrB (|φihφ|)
P be Alice’s
local density matrix. This is Hermitian, so it has a spectral decomposition ρA = di=1 µi |ai ihai |withPorthonormal eigenvectors |ai i and positive real eigenvalues µi . Note that d is the rank of ρA ,and i µi = Tr(ρA ) = 1. Then there are cij such that
|φi =

d
X
√

µi cij |ai i|ji,

i,j=1

154

√
where
the |ji are the computational basis states for Bob’s space. Define λi = µi and |bi i =Pj cij |ji. This gives the decomposition of |φi of Eq. (18.1). It only remains to show that {|bi i} isan orthonormal set, which we do as follows. The density matrix version of Eq. (18.1) is|φihφ| =dXλi λj |ai ihaj | ⊗ |bi ihbj |.

i,j=1

P
We know that if we trace out the B-part from |φihφ|, then we should get ρA = i λ2i |ai ihai |, butthat can only happen if hbj |bi i = Tr(|bi ihbj |) = 1 for i = j and hbj |bi i = 0 for i 6= j. Hence the|bi i form an orthonormal
set. Note that from Eq. (18.1) it easily follows that Bob’s local densityPmatrix is ρB = i λ2i |bi ihbi |.

18.4

The impossibility of perfect bit commitment

Key distribution is just one of the many tasks cryptographers would like to solve. Another importantprimitive is bit commitment. In this scenario there is no eavesdropper, but Alice and Bob don’t
trust each other. Suppose Alice has a bit b which for the time being she doesn’t want to reveal
to Bob, though she would like to somehow convince Bob that she has already made up her mind
about b and won’t change its value later. A protocol for bit commitment comes in two stages, eachof which may involve several rounds of communication:
1. In the “commit” phase Alice gives Bob a state which is supposed to commit her to the valueof b (without informing Bob about the value of b).
2. In the “reveal” phase Alice sends b to Bob, and possibly some other information to allow him
to check that this is indeed the same value b that Alice committed to before.
A protocol is binding if Alice can’t change her mind, meaning she can’t get Bob to “open” 1 − b.
A protocol is concealing if Bob cannot get any information about b before the “reveal phase.”5
A good protocol for bit commitment would be a very useful building block for many othercryptographic applications. For instance, it would allow Alice and Bob (who still don’t trust eachother) to jointly flip a fair coin. Maybe they’re going through a divorce, and need to decide whogets to keep their joint car. Alice can’t just flip the coin by herself because Bob doesn’t trust her
to do this honestly, and vice versa. Instead, Alice would pick a random coin b and commit to it.
Bob would then pick a random coin c and send it to Alice. Alice then reveals b, and the outcome of
the coin flip is defined to be b ⊕ c. As long as at least one of the two parties follows this protocol,
the result will be a fair coin flip.
Perfect coin flipping (and hence also perfect bit commitment) are known to be impossible inthe classical world. After BB84 there was some hope that perfect bit commitment (and hence also
perfect coin flipping) would be possible in the quantum world, and there were some seeminglysecure proposals for quantum protocols to achieve this. Unfortunately it turns out that there is noquantum protocol for bit commitment that is both perfectly binding and perfectly concealing.
To show that a protocol for perfect bit commitment is impossible, consider the joint purestate |φb i that Alice and Bob would have if Alice wants to commit to bit-value b, and they both
5

A good metaphor to think about this: in the commit phase Alice locks b inside a safe which she sends to Bob.
This commits her to the value of b, since the safe is no longer in her hands. During the reveal phase she sends Bob
the key to the safe, who can then open it and learn b.

155

honestly followed the protocol.6 If the protocol is perfectly concealing, then the reduced density
matrix on Bob’s side should be independent of b, i.e., TrA (|φ0 ihφ0 |) = TrA (|φ1 ihφ1 |). The way weconstructed the Schmidt decomposition in the previous section now implies that there exist Schmidt
decompositions of |φ0 i and |φ1 i with the same λi ’s and the same bi ’s: there exist orthonormal bases{ai } and {a0i } such that
|φ0 i =dX

λi |ai i|bi i and |φ1 i =

i=1

d
X

λi |a0i i|bi i

i=1

Now Alice can locally switch from |φ0 i to |φ1 i by just applying on her part of the state the map|ai i 7→ |a0i i. Alice’s map is unitary because it takes one orthonormal basis to another orthonormal
basis. But then the protocol is not binding at all: Alice can still freely change her mind about thevalue of b after the “commit” phase is over! Accordingly, if a quantum protocol for bit commitment
is perfectly concealing, it cannot be binding at all.

18.5

More quantum cryptography

Quantum cryptography is by now a pretty large subset of the area of quantum information andcomputation. Here we just briefly mention a few other topics in quantum crypto (see [69]):• There are quantum protocols for bit commitment that are partially concealing and partiallybinding—something which is still impossible in the classical world. A primitive called “weakcoin flipping” can be implemented almost perfectly in the quantum world, and cannot be
implemented at all in the classical world.
• Under assumptions on the fraction of dishonest players among a set of k parties, it is possible
to implement secure multi-party quantum computation. This is a primitive that allows theplayers to compute any function of their k inputs, without revealing more information to
player i than can be inferred from i’s input plus the function value.
• One can actually do nearly perfect bit commitment, coin flipping, etc., assuming the dishonest
party has bounded quantum storage, meaning that it can’t keep large quantum states coherent
for longer times. At the present state of quantum technology this is a very reasonable assumption (though a breakthrough in physical realization of quantum computers would wipeout this approach).
• In device-independent cryptography, Alice and Bob want to solve certain cryptographic tasks
like key distribution or randomness generation without trusting their own devices (for instancebecause they don’t trust the vendor of their apparatuses). Roughly speaking, the idea here
is to use Bell-inequality violations to prove the presence of entanglement, and then use thisentanglement for cryptographic purposes. Even if Alice or Bob’s apparatuses have been
tampered with, they can still only violate things like the CHSH inequality if they actuallyshare an entangled state.
• Experimentally it is much easier to realize quantum key distribution than general quantum
computation, because you basically just need to prepare qubits (usually photons) in either the
6

The assumption that the state is pure rather than mixed is without loss of generality.

156

computational or the Hadamard basis, send them across a channel (usually an optical fibre,
but sometimes free space), and measure them in either the computational or the Hadamard
basis. Many sophisticated experiments have already been done. Somewhat surprisingly, you
can already commercially buy quantum key distribution machinery. Unfortunately the implementations are typically not perfect (for instance, we don’t have perfect photon sources orperfect photon detectors), and once in a while another loophole is exposed in the implementation, which the vendor then tries to patch, etc.

Exercises
1. Here we will consider in more detail the information-disturbance tradeoff for measuring aqubit in one of the four BB84 states (each of which occurs with probability 25%).
(a) Suppose Eve measures the qubit in the orthonormal basis given by cos(θ)|0i + sin(θ)|1i
and sin(θ)|0i − cos(θ)|1i, for some parameter θ ∈ [0, π/4]. The first basis vector corresponds to output 0, the second to output 1. For each of the four possible BB84 states,
give the probabilities of outcome 0 and outcome 1 (so your answer should consist of
8 numbers, each of which is a function of θ).
(b) What is the average probability that Eve’s measurement outcome equals the encoded
bit ai , as a function of θ? (average taken both over the uniform distribution over thefour BB84 states, and over the probabilities calculated in part (a))(c) By what angle does the state change in each of the 8 cases of (a)?
2. (a) What is the Schmidt rank of the state 12 (|00i + |01i + |10i + |11i)?
(b) Suppose Alice and Bob share k EPR-pairs. What is the Schmidt rank of their jointstate?
(c) Prove that a pure state |φi is entangled if, and only if, its Schmidt rank is greater than 1.
3. Give the Schmidt decomposition of the state 12 (|0iA |0iB + |0iA |1iB + |1iA |1iB + |1iA |2iB ).
Here Alice’s space has dimension 2, and Bob’s space has dimension 3. It suffices if you write
down your Schmidt decomposition, being explicit about the values of the λi ’s and what are
the states |ai i and |bi i. You can add your calculation (involving local density matrices etc.)
as a justification, but you don’t have to.
4. Consider a density matrix ρ on Alice’s Hilbert space. A bipartite pure state |ψiAB is called apurification of ρ, if ρ = TrB (|ψihψ|). The B-register in |ψiAB is called the purifying register.
(a) Show that an EPR-pair is a purification of the 1-qubit mixed state ρ = I/2.
(b) Show that if ρ is a density matrix of rank r, then there exists a purification of ρ where
the purifying register has at most dlog re qubits.
(c) Show that if |ψiAB and |ψ 0 iAB are purifications of the same ρ, then there exists a unitary
U on Bob’s space such that |ψ 0 iAB = (I ⊗ U )|ψiAB .
5. Suppose Alice has a 1-qubit state ρ.
(a) Suppose Alice chooses a uniformly random Pauli matrix (see Appendix A.9) and applies
it to ρ. What is the resulting density matrix, averaged over the four cases?
157

(b) Suppose Alice and Bob shared a uniformly distributed secret 2-bit string ab, which is
unknown to Eve. How can Alice send ρ to Bob over a public quantum channel, without
leaking any information to Eve (i.e., the quantum state sent over the channel should byitself be independent of ρ), in such a way that Bob can recover ρ?
6. (H) Suppose we have a qubit in mixed state ρ that we want to hide from Alice and Bob
individually, but in such a way that if Alice and Bob cooperate, then they can recover ρ.
Describe how we can change ρ into some other 1-qubit state ρ0 , what secret keys we give to
Alice and Bob, why individually they can get no information about ρ from the qubit ρ0 , andwhy jointly they can fully recover the qubit in state ρ from ρ0 . The keys should be classical.
7. (H) Prove that Alice cannot give information to Bob by doing a unitary operation on herpart of an entangled pure state.
8. Suppose Alice sends two n-bit messages M1 and M2 with the one-time pad scheme, reusing
the same n-bit key K. Show that Eve can now get some information about M1 , M2 fromtapping the classical channel.
9. (a) (H) Consider a bipartite pure state shared between Alice and Bob, where Alice andBob’s local spaces have dimension d each:X
αij |iiA |jiB .
i,j∈{1,...,d}The state is given to you classically, as a list of d2 amplitudes, each described by O(d)bits. Give a classical polynomial-time algorithm to find the Schmidt coefficients and tofind Alice and Bob’s basis for a Schmidt decomposition.
(b) Give a classical polynomial-time algorithm that decides whether a given bipartite purestate (given as in (a)) is entangled or not.
Comment: If the given state were mixed instead of pure, this decision problem is known to be NP-hardand hence probably not polynomial-time solvable.

158

Chapter 19

Quantum Machine Learning
19.1

Introduction

Machine learning tries to extract patterns and regularities from given data for the purposes ofprediction and understanding. In a slogan, one could say: ML = data + optimization. The data iswhat you learn from; the optimization finds a good model or hypothesis for the given data, which
hopefully has some generalization power. ML has gone through several ups and downs over theyears, but currently is booming thanks to the success of so-called “deep learning,” based on neuralnetworks.1 ML is often subdivided into three subareas, depending on the data one has:
1. In supervised learning we are given labelled data, for instance pictures of animals annotatedwith the kind of animal that’s on the picture, and we want to learn how to predict the label.
2. In unsupervised learning we are just given unlabeled data, and need to find patterns in it. The
canonical example is the clustering problem, where we are given unlabelled data items that
we want to group into “similar” subsets. For example, it could be that our data consists ofpictures of different kinds of animals (not labeled with the type of animal), and we somehow
want to cluster the cat-pictures together, the wolf-pictures together, etc. We may or may notknow in advance what the number of clusters should be.
3. In reinforcement learning the learner actually interacts with the environment, receiving rewards or penalties for desirable or undesirable behavior, and tries to learn from this interactive
data to behave more successfully in the environment. This is roughly how a child learns.2
It is a very interesting question to see how quantum computing changes and helps machine learning. Here the learner would be a quantum computer, and the data may be classical or quantum.
Quantum ML is by now a rather large area, and in this chapter we will go over a few representative results and methods for supervised and unsupervised learning, mostly with classical output.
See [101] for quantum applications to reinforcement learning, and [57, 27, 222] for much more.
1

Machine learning based on neural networks has been studied for decades but quite suddenly became much more
successful starting around 2012, due to the availability of more data, stronger computing hardware (incl. specialpurpose GPUs for fast parallel matrix-vector calculations), and better software to do the training.
2
It’s also how a computer can learn to play games. One of the big breakthroughs of machine learning was in 2016
when the AlphaGo program learned to play the game of Go so well that it beat one of the world’s best human Go
players. Computers have been better than humans at chess already since the late 1990s (the IBM program “DeepBlue” beat Kasparov in 1997), but Go was viewed as a much more complicated game than chess.

159

19.2

Supervised learning from quantum data

19.2.1The PAC model of learning

Let us first describe a mathematical model of what it means to learn from labeled data. This is
Valiant’s PAC model [238], for “probably approximately correct” learning (see [223, 189] for more).
Assume for simplicity that the labels are just binary: 0 or 1. Our goal is to learn a Booleanfunction f : X → {0, 1} from examples of the form (x, f (x)), where x ∈ X . A typical case would
be X = {0, 1}n . The last bit f (x) of the example is called the label. Think for instance about thecase where we are given 1000 × 1000-pixel black-and-white pictures (n = 1000, 000) whose labels
f (x) indicate whether x is the picture of a wolf or not. We would like to learn f , or some good
approximation of it, to be able to recognize pictures of wolves in the future. Some x’s are more
important and more likely to appear as examples than others: many 1000 × 1000-grids don’t depict
anything. The assumption in PAC learning is that the examples are generated (independent andidentically distributed) according to some distribution D on X . The idea is that this D represents“the world” or “Nature,” which provides us with examples. We assume f cannot be completely
arbitrary (in that case there would be an f consistent with every possible sequence of labeled
examples) but comes from some known “concept class” C of Boolean functions. For instance, C
could be a set of small logical formulas f on n Boolean variables, or a set of small-depth or small-size
decision trees on n input bits, or neural networks with a restricted number of nodes or depth.
A learning algorithm should generate a “hypothesis” h : X → {0, 1} that has small error
compared to the unknown f that we’re trying to learn, measured under the same distribution D
that generated the data.3 The generalization error of h w.r.t. the target function f is defined as
errD (f, h) = Pr [f (x) 6= h(x)].
x∼DThis error measures how well we’ve generalized the examples, and how well we can predict the labelsof future examples. We say that h is “approximately correct” if this error is small, at most somespecified ε. The goal in PAC learning is to output an h that is probably approximately correct:
Definition 4 An (ε, δ)-PAC learner for a concept class C w.r.t. distribution D on X , is an algorithm that receives m labeled examples (x1 , f (x1 )), . . . , (xm , f (xm )) for a target function f ∈ C,
where each xi ∼ D, and that outputs a hypothesis h such thatPr[errD (f, h) ≤ ε] ≥ 1 − δ.
The learning algorithm has to satisfy the above for every possible target function f ∈ C, and theprobability is over both the choice of the examples and over the internal randomness of the algorithm.
An (ε, δ)-PAC learner for a concept class C is an algorithm that is an (ε, δ)-PAC learner for C
w.r.t. every possible distribution D.
Note that the first part of the definition is about learners that are only required to work correctlyfor one specific distribution D (for instance, the uniform distribution over X ), while the second
part is “distribution-independent”: here we want a learner that works well irrespective of what3

It is important to be taught and tested according to the same distribution D. Imagine a quantum-computing
course whose lectures focused on the mathematics of quantum algorithms, but with an exam that focuses on physics
questions about how to implement qubits and gates—that would clearly be very unreasonable.

160

(unknown) distribution D generates the data. This is in keeping with the usual attitude towards
algorithms in computer science: these should work well even for a worst-case input. We don’t
require the class H of possible hypotheses h to equal the class C of possible target functions f (ifwe add this requirement, then it’s called proper PAC learning). This allows us for instance to use
neural networks to learn target functions that come from some other class C, say logical formulas.
The number of examples m that a particular learning algorithm uses is called its “sample
complexity,” and the overall time or number of elementary operations it takes to output h is its“time complexity.” Clearly the latter upper bounds the former, since we need at least one operation
to process one example. The sample complexity of a concept class C (as a function of ε, δ) is theminimal sample complexity among all PAC learners for C. Ideally, a good learner for C has both
small sample complexity and small time complexity (say, polynomial in n). For some concept classes
C efficient distribution-independent PAC learners exist, for example the class of logical formulas
in k-Conjunctive Normal Form (i.e., each f would be the AND of several ORs, each of at most kvariables or negated variables) or the class of regular languages (with the added help of so-called“membership queries”), but there are also many C that are not efficiently learnable.

19.2.2

Learning from quantum examples under the uniform distribution

There are different ways to define learning from quantum data. One natural way, due to Bshouty andJackson [71], is to replace each classical random example (x, f (x)), with x ∼ D, by a superposition.
Focusing on the typical case X = {0, 1}n , a quantum example would be the (n + 1)-qubit stateXp
D(x)|x, f (x)i.

x∈{0,1}nOf course, the world doesn’t usually present us with quantum examples, in contrast to the abundance of classical data for machine learning. So this model is only relevant in special cases, forexample if we have a physical experiment producing such states.
One thing we could do with a quantum example is measure it in the computational basis, butthat would just give us back a classical example (x, f (x)) with x ∼ D. A more clever thing we cando is Fourier sampling. Suppose D is the uniform distribution. Exercise 1 shows how to convert aquantum example (with probability 1/2) into an n-qubit state where the labels are ±1-phases:X1√(−1)f (x) |xi.
2n x∈{0,1}nIf we apply n Hadamard gates to this state, then we get
X

1
2n
n

s∈{0,1}X(−1)x·s (−1)f (x) |si =x∈{0,1}nX

αs |si.

s∈{0,1}nIf we measure this state, then we’ll see outcome s ∈ {0, 1}n with probability αs2 . The amplitudes αs
are called the Fourier coefficients of the function (−1)f (x) , whence the name “Fourier sampling.”
In some cases Fourier sampling gives a lot of information about the f we’re trying to learn.
161

Learning linear functions. A perfect illustration of Fourier sampling is for the following class:
C = {fa | a ∈ {0, 1}n , ∀x : fa (x) = a · x mod 2 =nXai xi mod 2},

i=1

these are the linear functions modulo 2. It is easy to calculate that if we do Fourier sampling
on a quantum example for function fa , then αa = 1 and αs = 0 for all s 6= a. So one Fourier
sample already tells us what a is! Hence we can learn fa exactly (i.e., with ε = 0), with highprobability, using O(1) examples and O(n) elementary gates. In contrast, learning linear functions
from classical examples under the uniform distribution requires Θ(n) examples (see Exercise 2).
Learning DNF. A richer concept class that can be learned efficiently from uniform quantum
examples is the class of s-term Disjunctive Normal Form (DNF) formulas on n Boolean variables.
These are formulas of the form f (x) = (x1 ∧ ¬x3 ) ∨ (x2 ∧ x3 ∧ x5 ), i.e., an OR of up to s different
ANDs of variables or negations of variables. The concept class C of s-term DNF is not known tobe efficiently PAC learnable w.r.t. the uniform distribution D classically. However, Bshouty andJackson [71] showed that s-term DNF can be learned in polynomial time (in s and n) from uniform
quantum examples. Roughly speaking, they use Fourier sampling to produce a linear function thatis weakly correlated with the target DNF function f , and then use a classical “boosting” algorithm
to combine multiple such weak hypotheses into one good hypothesis h. We’ll skip the details here.

19.2.3

Learning from quantum examples under all distributions

We saw a few cases where quantum examples reduce the sample and/or time complexity of learningalgorithms w.r.t. a fixed data-generating distribution D, namely uniform D. But in the PAC model
we ideally want a distribution-independent learner that works well for every possible distribution D.
Can allowing quantum instead of classical examples significantly reduce the sample complexity oflearning a class C in the distribution-independent setting? It turns out the answer is ‘no’.
Classically, the number of examples that is necessary and sufficient for (ε, δ)-PAC learning a
concept class C is known to be [60, 132]


V Cdim(C) log(1/δ)
m=Θ
+,(19.1)
εε
where V Cdim(C) is the so-called VC-dimension of C, named after Vapnik and Chervonenkis [241]and defined as follows. We say that a set S ⊆ {0, 1}n is shattered by C if for each of the 2|S|
possible labelings ` : S → {0, 1}, there is a function f ∈ C that has the same labeling of S (i.e.,
f|S = `). V Cdim(C) is the size of a largest S shattered by C. Intuitively, larger VC-dimension
corresponds to a more complex or “richer” (and hence harder to learn) concept class. We won’t
prove the characterization of Eq. (19.1) here, but Exercises 4 and 5 go most of the way towards theclaimed upper and lower bounds on m, respectively.
It was proven in [29] that in fact the same formula Eq. (19.1) determines the number of quantum
examples that are necessary and sufficient for learning C. The sufficiency is trivial: just measure thequantum examples and run the best classical PAC learner. The necessity was proved by reducing
a quantum measurement problem to the problem of PAC learning C from quantum examples, andshowing that the number of copies of the example-state required to solve that measurement problem
is at least the expression of Eq. (19.1). So, up to constant factors, quantum examples are not more
useful than classical examples for distribution-independent PAC learning.
162

19.2.4

Learning quantum states from classical data

One can generalize PAC learning from Boolean-valued to real-valued target functions f : X → [0, 1],
and then consider a hypothesis h : X → [0, 1] to be approximately correct (for some small γ) if
errD,γ (f, h) = Pr [|f (x) − h(x)| > γ] ≤ ε.
x∼D

So now a good hypothesis h is supposed to be close to f (rather than equal) for most x.
An interesting example is the problem of learning an unknown n-qubit quantum state ρ frommeasurement data. Let X be the set of measurement elements, i.e., psd matrices M with kM k ≤ 1.
If we measure ρ with some POVM of which M is one element, then the probability to get theoutcome corresponding to M , is Tr(M ρ). Accordingly, we can define f : X → [0, 1] as f (M ) =Tr(M ρ) and consider the class C of all such functions (one f for each possible ρ, so this class is
uncountable). Aaronson [1] showed that this C is classically PAC learnable from O(n) examplesof the form (x, f (x)) (with some polynomial dependence of the sample complexity on γ, ε, andexponential time complexity). Note that we are not really learning ρ itself, but rather learn topredict the measurement probabilities. In contrast, learning a good approximation of ρ itself (withsmall error in trace distance) requires a number of copies of ρ that is exponential in n [126, 197].
Some positive results for learning specific classes of quantum states can be found in [180, 20, 161].

19.3

Unsupervised learning from quantum data

In this section we will look at an example of unsupervised learning from quantum data: dimensionreduction via Principal Component Analysis. Suppose we are given m vectors v1 , . . . , vm ∈ Rd , sayunit vectors for simplicity. Let’s say the dimension d of the data-vectors is very large, and we would
like to reduce it to some much smaller k, say at most k = polylog(d). Many machine learning tasks,
for example clustering, become much easier if we can significantly reduce this dimension.
One way to achieve this dimension-reduction is to find k suitable unit vectors c1 , . . . , ck ∈ Rd
(which may or may not be in the set {vi } themselves), such that the projection PS vi of the vi ’s
on the k-dimensional space S = span{c1 , . . . , ck } typically doesn’t lose much, i.e., PS viP
is close tovi for most i ∈ [m]. Then we can replace each vi by the k-dimensional vector PS vi = kj=1 αj cj ,expressed as the vector of coefficients (αj ) ∈ Rk (note that αj = hcj |vi i). How to find those k“directions”? One method that often (though not always) works well is to find the k eigenvectors
corresponding to the k largest eigenvalues of the following d × d “correlation matrix”:A=mX

vi viT .

i=1

Those k eigenvectors are called the k “principal components” of A. They intuitively correspond to
the k most important directions in the data, and we can choose them for dimension-reduction.
Classically, we can find those k eigenvectors by diagonalizing A, which takes times polynomial
in d. In the quantum case we can do something very different, under the (very strong) assumptionthat we can efficiently, say in time polylog(d), prepare the dlog(d)e-qubit quantum states |vi icorresponding to the vectors vi . By choosing i ∈ [m] uniformly at random and preparing |vi i, we
prepare the following dlog(d)e-qubit mixed state, which is proportional to the correlation matrix:
m

ρ=

1 X
1
|vi ihvi | = A.
m
m
i=1

163

P
Let’s say this has (unknown) spectral decomposition ρ = dj=1 λj |cj ihcj | with λ1 ≥ · · · ≥ λd ≥ 0,
where the first k eigenvalues sum to something close to 1, and are not too close together, at least
1/poly(k) apart.4 We would now like to find the top-k eigenstates |c1 i, . . . , |ck i of this ρ.
Note that the unitary U = eiρ has the same eigenstates as ρ itself, with every eigenvalue λj ofρ translating into eigenvalue eiλj of U . Lloyd et al. [174] (with more precise analysis and matching
lower bound in [153]) showed that we can actually implement the power U t up to error ε usingO(t2 /ε) copies of the state ρ (see Exercise 7). We now use phase estimation with the unitary U
on a copy of ρ itself, with additive error δ = 1/poly(k). By Section 4.6, phase estimation withadditive error δ corresponds to running controlled versions of U t for t up to O(1/δ). Under ourearlier assumptions, this only takes poly(k) = polylog(d) time. Ignoring for simplicity the small
errors (≤ δ) that phase estimation makes in estimating the values λj , phase estimation transforms
the copy of ρ and a few auxiliary |0i-qubits into the statemX

λj |cj ihcj | ⊗ |λj ihλj |.

j=1

If we measure the second register, then we obtain state |cj i ⊗ |λj i with probability λj .5 Doing thispoly(k) many times, we learn the k largest values λ1 , . . . , λk , and for each of those λj ’s we’ll have anumber of copies of the eigenstate |cj i. This is a quantum form of Principal Component Analysis.
This collection of eigenstates determines a k-dimensional subspace on which we could re-express
the vi ’s (approximately), but it is not very explicit: we only have the k basis vectors of this spaceas quantum states! Suppose we want to express some unit vector v (which again we assume we canprepare efficiently as a state |vi) as a linear combination of the cj ’s. One thing we can do is use a
few copies of each |cj i to approximate |hcj |vi|2 for each i using the SWAP-test, which gives us atleast partial information about the coefficients hcj |vi (see Exercise 8).
“Quantum PCA” has a lot of drawbacks, but at least it shows some genuinely quantum tricks
that we can use under the assumption that our input vectors can be efficiently prepared as quantum
states. There have also been some quantum approaches for the prominent unsupervised learning
problem of clustering, but we will not describe those here (see for instance [173, 150]).

19.4

Optimization

In the previous two sections we assumed quantum data: either the data is already given as asuperposition, or we can efficiently put given classical data in superposition. However, in mostreal-world applications of machine learning we have classical data without the means to efficiently
make this quantum. Remembering the slogan ML = data + optimization, if there’s any room
left for quantum improvements when data is classical, it would be in the optimization to find awell-fitting model for the data. We’ll look at some examples where quantum computing might help.
4

All these assumptions make this principal-component analysis a heuristic method for clustering, not somethingthat provably always works. It is anyway not clear in this case what a correct or optimal output would be: because
this is unlabeled data, we do not have a clear standard for correctness.
5
Actually, in the second register we will see (with high probability) a δ-close approximation of λj rather thanλj itself, but if we assume δ is much smaller than the spacing between the eigenvalues λ1 , . . . , λk , then such aδ-approximation is good enough to “recognize” the state in the first register as the jth principal component.

16419.4.1

Variational quantum algorithms

One approach that has received a lot of attention is to optimize over parametrized circuits. Suppose
we have a quantum circuit U (θ) with a vector θ of parameters. This could for instance be a circuit
where CNOTs and single-qubit rotations are already in place, but the angles of the single-qubit
gates are parameters that we can tweak. This U (θ) is then applied to a fixed starting state, say |0i,yielding a final state |ψ(θ)i = U (θ)|0i. The goal is now to minimize the expected value of someobservable M , i.e., to find a θ to mimimize the function f (θ) = hψ(θ)|M |ψ(θ)i. In the case of
supervised learning applications, U (θ) could for instance represent some hypothesis (i.e., a way to
predict labels of x’s), M could incorporate the given labeled examples (x, f (x)), and f (θ) could be
the “empirical error”: the fraction of mis-predicted labels among the given examples.
Note that f (θ) can be computed approximately (for classically given θ) on a quantum computer
by repeatedly preparing |ψ(θ)i and measuring the observable M . If the circuits U (θ) are relatively
simple (say, few qubits, few gates, low depth) and M is relatively easy to measure (say, a sumof a few n-qubit Pauli matrices with few non-identity terms) then this could already be doneon a relatively small and simple quantum computer. Variational quantum algorithms (VQAs)
are typically hybrid classical-quantum algorithms: the minimization over θ is usually done by aclassical outer loop that iteratively improves θ. Using the ability to approximately compute f we
can for instance try to do approximate gradient descent (move θ by some step-size in the directionof steepest descent of f ) or some other method. This is analogous to the iterative way the weights
in neural networks are optimized, and these variational quantum approaches are sometimes (witha keen sense for marketing) called “quantum neural networks” or “quantum deep learning.” Forcombinatorial optimization, a very structured version of the variational approach is the Quantum
Approximate Optimization Algorithm (QAOA) [109]. See [78] for a general overview of VQAs.
One interesting application of this variational idea is in trying to find the smallest eigenvalue of agiven Hamiltonian H. For example, H could describe the energy of a chemical system as a functionof the locations of the particles (nuclei and electrons) of the system; the smallest eigenvalue of H
would be the “ground-state energy” of the system, which is an important quantity in chemistry. We
know from Chapter 14 that in general this problem of determining or even well-approximating thisground state energy is QMA-hard, even in the special case where H is a sum of 2-local terms, so in
general this shouldn’t be efficiently solvable on a quantum computer. However, suppose that fromsome general physics or chemistry intuition we have a rough idea of what the ground state of ourparticular Hamiltonian H should look like, something we can prepare using a simple parametrizedcircuit U (θ). The set of states |ψ(θ)i = U (θ)|0i that we are limiting ourselves to, is called an“Ansatz” (German for “approach” or “attempt”). We can now try to optimize the parameters θin order to minimize the expected value f (θ) = hψ(θ)|H|ψ(θ)i, i.e., the energy of the state |ψ(θ)i.
This approach is called the “variational quantum eigensolver” (VQE) [199], and is one of the best
hopes for applying smallish, near-term quantum computers to problems in chemistry.

19.4.2

Some provable quantum speed-ups for optimization

The variational approach is rather heuristic: it very much depends on how good the “Ansatz” (thechoice of the class of parametrized circuits U (θ)) happens to be for the particular problem at hand.
Here we mention some other approaches, which yield provable (albeit usually only polynomial)
quantum speed-ups under some assumptions on how the input is given.
• There are many quantum speed-ups for optimization problems on graphs, typically using165

Grover search (Section 7.2), Grover-based minimum-finding (Exercise 7.10), amplitude amplification (Section 7.3), or amplitude estimation (Exercise 7.8) as a subroutine. Examples
are finding shortest paths [102] and approximating minimum cuts or graph sparsification [24].
• Solving linear systems and other basic linear algebra is ubiquitous in classical optimization
algorithms. Since quantum states are vectors and quantum operations are matrices, one
can try to improve such classical algorithms using quantum algorithms. Examples are phaseestimation (Section 4.6), the block-encoding approach (Section 9.4 and [120, Section 3.2.4]),
and HHL (Chapter 10). The trouble with this approach is that it often assumes the input
is a quantum state (which is not always practical) and/or that it produces the output as aquantum state (which is not always useful). For example, HHL and quantum PCA have bothfeatures. See [2] for more discussion.
One interesting application of “quantum linear algebra” (with classical inputs and outputs!)
is the quantum recommendation system of Kerenidis and Prakash [151], which can generate
recommendations of type “you might also like” to a user of systems like Amazon or Netflix,
based on the user’s and other users’ earlier behavior. Initially [151] was believed to givean exponential speed-up over classical recommendation systems, until Tang showed how to“dequantize” their quantum algorithm under similar classical access assumptions [234, 81].
• In convex optimization we minimize a convex function f : Rn → R, either over all x ∈ Rn
or over all x that are constrained to lie in some convex domain X ⊂ Rn . This covers a big
part of continuous optimization. Convexity ensures that the only local minima are also global
minima, but such methods often still work to find good local minima for non-convex problems(such as training neural networks). Iterative first-order methods like gradient descent use
the gradient of f at a given point, which in some cases can be computed more efficiently by
quantum algorithms [146, 121, 95] (see Exercise 6). Second-order methods often solve a linear
system involving the Hessian (the n × n matrix of partial second derivatives at a given point),
and we can try to use quantum linear algebra. If the matrix is symmetric and diagonallydominant and the output needs to be classical, then we could use the linear solver of [24].
Quantum algorithms are known for the specific cases of linear programming (LPs) andsemidefinite programming (SDPs) [64, 22, 63, 23, 21], for learning support vector machines(SVMs) [203, 221, 213, 9, 214], and for least-squares linear regression with an `1 -regularizer [80].

Exercises
1. Suppose that for some unknown Boolean function f : {0, 1}n → {0, 1} and amplitude-vector(αx )x∈{0,1}n , you are given one copy of the (n + 1)-qubit stateX
αx |xi|f (x)i.
x∈{0,1}nShow how you can convert this into stateXαx (−1)f (x) |xi|1ix∈{0,1}nwith success probability 1/2, in such a way that you know when you succeeded.
166

2. Consider again the concept class C of linear functions mod 2.
(a) Give a classical learning algorithm to learn a linear function exactly with high successprobability (ε = 0, δ = 1/3) using O(n) uniform random examples and O(n3 ) time.
(b) Argue that every classical PAC learner for C under uniform D, with ε < 1/4, needs Ω(n)examples.
3. In the model of exact learning with membership queries, the goal is to exactly learn a targetfunction f ∈ C from queries to f (so there are no examples in this setting, or rather thelearner can choose their own examples).
Show that if C is the concept class of linear functions, then a target function f ∈ C can belearned with 1 quantum membership query, but requires Ω(n) classical membership queries.
4. Consider a concept class C of functions f : X → {0, 1}, with |X | = N and V Cdim(C) = d.
(a) Consider the following simple (and probably not very time-efficient) learning algorithm:
Draw m examples for target function f ; output a h ∈ C consistent with these examples.
Let h ∈ C be a function with errD (f, h) > ε. Show that at the end of this algorithm,
the probability that h is still consistent with the m examples is < (1 − ε)m .
(b) Set m = dlog(3|C|)/ log(1/(1 − ε))e. Show that with probability ≥ 2/3, the only h thatare consistent with the m examples have errD (f, h) ≤ ε.
(c) Derive an upper bound m = O(d log(N )/ε) on the classical sample complexityof (ε, 1/3)PPAC learning the class C using Sauer’s lemma, which says that |C| ≤ di=0 Ni .
5. Suppose the set S = {x1 , . . . , xd } ⊆ X is shattered by concept class C. Consider a distribution
D that puts 1 − 4ε probability on x1 and 4ε/(d − 1) probability on each of x2 , . . . , xd .
(a) Let f ∈ C be the target function. Show that you need Ω((d − 1)/ε) examples ∼ D to see(with probability ≥ 2/3) (xi , f (xi )) for at least 50% of the i ∈ {2, . . . , d}.
(b) Show that the sample complexity of every (ε, 1/3)-PAC learner for the class C is at leastΩ((d − 1)/ε).
6. This exercise is about efficiently finding the gradient ∇f (z) of a function f : Rd → R ata point z ∈ Rd . The gradient is the d-dimensional real vector of the d partial derivatives∂f /∂xi , evaluated at the point z.
(a) (H) Let f (x) = a + bx be a linear function from R to R, where the real number b ∈ [0, 1)
can be written with n bits of precision. Suppose we have a unitary Of that maps
|x, 0i → |x, f (x)i (assume we have enough qubits to write down x and f (x)). Give aquantum algorithm to compute b using one application of Of and one application of
Of−1 , and some unitaries that do not depend on f .
(b) Let f (x1 , . . . , xd ) = a + b1 x1 + · · · + bd xd be a linear function from Rd to R, wherea, b1 , . . . , bd ∈ R. Show that the gradient ∇f (z) is equal to (b1 , . . . , bd ) for every z ∈ Rd .
(c) Assume that for the function f in (b), each coefficient bk is ∈ [0, 1) and can be writtenwith n bits of precision. Suppose we have a unitary Of that maps |x1 , . . . , xd , 0i →|x1 , . . . , xd , f (x1 , . . . , xd )i. Give a quantum algorithm that computes the gradient ∇f (z)using one application of Of and Of−1 , and some unitaries that do not depend on f .
167

Comment: The quantum algorithm of (c) is somewhat reminiscent of the Bernstein-Vazirani algorithm (Section 2.4.2), though that one is for functions over Fd2 rather than Rd . Variants of the algorithm of (c) can also
be applied to efficiently approximate the gradient of a sufficiently smooth non-linear function f : Rd → R,since a smooth f can be well-approximated at a given point z ∈ Rd by a linear function whose coefficients are
the entries of the gradient ∇f (z).

7. (H) Let σ and ρ be k-qubit mixed states, ε > 0 small, t ≥ 0, and U = eiρ be a unitary. Our
goal in this exercise is to apply U t to σ (with error ≤ ε in trace norm) at the expense of using
some copies of the state ρ.
(a) Let V be the 2-qubit SWAP-gate (which maps |ai|bi → |bi|ai for all a, b ∈ {0, 1}). Show
that V −2η/π = e−iη eiV η for all η ≥ 0.
(b) Let W be the 2k-qubit unitary that swaps the first k qubits with the last k qubits,i.e., it maps |ai|bi → |bi|ai for all a, b ∈ {0, 1}k . Show that for all η ≥ 0, eiW η can be
implemented with k 2-qubit gates.
(c) Show that for small η ≥ 0, U η σU −η = σ + iη(σρ − ρσ) + E, where kEk1 = O(η 2 ).
(d) Let σ 0 be the k-qubit local state of the first register after applying the unitary eiW η tothe 2k-qubit state σ ⊗ ρ. Show that σ 0 = σ + iη(σρ − ρσ) + E 0 , where kE 0 k1 = O(η 2 ).
(e) Show that kσ 0 − U η σU −η k1 = O(η 2 ).
(f) Show that you can implement U t on σ with error ε in trace norm, using O(t2 /ε) copiesof ρ and O(kt2 /ε) elementary gates.
8. Suppose |φi and |ψi are unknown n-qubit pure states.
(a) (H) Show how a quantum computer can estimate the overlap |hφ|ψi| (in absolute value)
up to additive error 1/100 using O(1) given copies of |φi and |ψi, and O(n) elementarygates.
(b) Assume the inner product hφ|ψi is a real number. Show that k|φi − |ψik2 = 2 − 2hφ|ψi.
(c) Assume hφ|ψi is real and positive. Show how a quantum computer can estimate thedistance k|φi − |ψik up to additive error 1/100 using O(1) copies of |φi and |ψi, andO(n) gates.
(d) Can a quantum computer detect the difference between the two cases |ψi = |φi and|ψi = −|φi, given arbitrarily many copies of these two states? Explain your answer.

168

Chapter 20

Error-Correction and Fault-Tolerance
20.1

Introduction

When Shor’s algorithm had just appeared in 1994, most people (especially experimental physicists,
who were very aware of the difficulties in manipulating subatomic particles) were extremely skeptical
about the prospects of actually building a quantum computer. In their view, it would be impossible
to avoid errors when manipulating small quantum systems, and such errors would very quickly
overwhelm the computation, rendering it no more useful than classical computation. However, inthe few years that followed, the theory of quantum error-correction and fault-tolerant computation
was developed. This shows, roughly speaking, that if the error-rate per operation can be brought
down to something reasonably small (say 1%), and the errors between different qubits are notvery correlated, then we can actually do near-perfect quantum computing for as long as we want.
Below we give a succinct and somewhat sketchy introduction to this important but complex area,
just explaining the main ideas. See the surveys by Gottesman [123] and Terhal [235] for more (inparticular the latter for the important “surface code,” which we won’t cover here).

20.2

Classical error-correction

In the early days of classical computing, errors were all over the place: memory-errors, errors inbits sent over a channel, incorrectly applied instructions, etc.1 Nowadays hardware is much morereliable, but we also have much better “software solutions” for errors, in particular error-correcting
codes. Such codes take a string of data and encode it in a larger string (the “codeword”), adding
a lot of redundancy so that a small fraction of errors on the codeword won’t be able to reduce theinformation about the encoded data.
The simplest example is of course the repetition code. If we want to protect a bit b, we could
repeat it three times:
b 7→ bbb.
If we want to decode the encoded bit b from the (possibly corrupted) 3-bit codeword, we just takethe majority value of the 3 bits.
Consider a very simple noise model: every bit is flipped (independently of the other bits) withprobability p. Then initially, before applying the code, b has probability p to be flipped. But if
1

The name “bugs” actually comes from insects getting stuck inside the computer and causing errors.

169we apply the repetition code, the probability that the majority-value of the three bits is different
from b, is the probability of 2 or 3 bitflips, which is 3p2 (1 − p) + p3 < 3p2 . Hence the error-rate
has been reduced from p to less than 3p2 . If the initial error-rate p0 was < 1/3, then the newerror-rate p1 < 3p20 is less than p0 and we have made progress: the error-rate on the encoded bit
is smaller than the error-rate on the unencoded bits. If we’d like it to be even smaller, we could
concatenate the code with itself, i.e., repeat each of the three bits in the code three times, so thecodelength becomes 9. This would give error-rate p2 = 3p21 (1 − p1 ) + p31 < 3p21 < 27p40 , giving afurther improvement. As we can see, as long as the initial error-rate p was at most 1/3, we canreduce the error-rate to whatever we want: k levels of concatenation encode one “logical bit” intok
3k “physical bits,” but the error-rate for each logical bit has been reduced to 31 (3p0 )2 .2 This is avery good thing: if the initial error is below 1/3, then k levels of concatenation increase the numberof bits exponentially (in k) but reduce the error-rate double-exponentially fast!
Typically, already a small choice of k gets the error-rate down to negligible levels. For example,
suppose we want to protect some polynomial (in some n) number of bits for some polynomial
number of time-steps, and our physical error-rate is some fixed p0 < 1/3. Choosing k = 2 log log nk2levels of concatenation already suffices for this, because then pk ≤ 13 (3p0 )2 ∼ 2−(log n) = n− log ngoes to 0 faster than any polynomial. In that case, by the union bound, even the probability that
there exists an error anywhere among our polynomially many logical bits in polynomially manytime-steps, will be negligibly small. With this choice of k, each logical bit would be encoded in
3k = (log n)2 log(3) physical bits, so we only increase the number of bits by a polylogarithmic factor.

20.3

Quantum errors

The need for error-correction is far greater for quantum computers than for classical computers,
because “quantum hardware” is much more fragile than classical hardware. Unfortunately, errorcorrection is also substantially more difficult in the quantum world, for several reasons:• The classical solution of just repeating a state is not available in general in the quantum
world, because of the no-cloning theorem.
• The classical world has basically only bitflip-errors, while the quantum world is continuousand hence has infinitely many different possible errors.
• Measurements that test whether a state is correct can collapse the state, losing information.
Depending on the specific model of errors that one adopts, it is possible to deal with all of theseissues. We will consider the following simple error model. Consider quantum circuits with S
qubits, and T time-steps; in each time-step, several gates on disjoint sets of qubits may be appliedin parallel. After each time-step, at each qubit, independently from the other qubits, some unitaryerror hits that qubit with probability p. Note that we assume the gates themselves to operate
perfectly; this is just a convenient technical assumption, since a perfect gate followed by errors on
its outgoing qubits is the same as an imperfect gate.
2

With a bit more work we can show that this even works if the initial error-rate p is only strictly less than 1/2
rather than ≤ 1/3. See Exercise 9.

170

Let’s investigate what kind of (unitary) errors we could get on one qubit. Consider the fourPauli matrices from Appendix A.9:








1 0
0 1
0 −i
1 0
I=
, X=
, Y =
, Z=
.
0 1
1 0
i 0
0 −1
These have an interpretation as possible errors: I corresponds to no-error, X is a bitflip-error, Z isa phaseflip-error, and Y = iXZ is a phaseflip-error followed by a bitflip-error (and a global phaseof i, which doesn’t matter). These four matrices span the space of all possible 2 × 2 matrices, soevery possible error-operation E on a qubit is some linear combination E = α0 I +α1 X +α2 Y +α3 Z
of the 4 Pauli matrices. More generally, every 2k × 2k matrix can be written uniquely as a linear
combinations of matrices that each are the tensor product of k Pauli matrices.
Consider for example the error which puts a small phase φ on |1i:


1 0
E=
= eiφ/2 cos(φ/2)I − ieiφ/2 sin(φ/2)Z.
0 eiφ
Note that for small φ most of the weight in this linear combination sits on I, which corresponds tothe fact that E is close to I. The sum of squared moduli of the two coefficients is 1 in this case.
That’s not a coincidence: whenever we write a unitary as a linear combination of Pauli matrices,
the sum of squares of the coefficients will be 1 (see Exercise 1).
The fact that all 1-qubit errors are linear combinations of I, X, Y, Z, together with the linearityof quantum mechanics, implies that if we can correct bitflip-errors (X), phaseflip-errors (Z), andtheir product (Y ), then we can correct all possible unitary errors on a qubit.3 So typically, quantum
error-correcting codes are designed to correct bitflip and phaseflip-errors (their product is thentypically also correctable), and all other possible errors are then also handled without further work.
Our noise model does not explicitly consider errors on multiple qubits that are not a productof errors on individual qubits. However, even such a joint error on, say, k qubits simultaneously
can still be written as a linear combination of products of k Pauli matrices. So also here the main
observation applies: if we can just correct bitflip and phaseflip-errors on individual qubits, then wecan correct all possible errors!

20.4

Quantum error-correcting codes

Quantum error-correcting codes encode a number of “logical qubits” into a larger number of “physical qubits,” in such a way that errors on some number of its qubits can be corrected. The first andsimplest is Peter Shor’s 9-qubit code [227], which encodes 1 logical qubit into 9 physical qubits,
and can correct an error on any one of the 9 physical qubits. Here are the codewords for the twological basis states:1|0i 7→ |0i = √ (|000i + |111i)(|000i + |111i)(|000i + |111i)
8
1|1i 7→ |1i = √ (|000i − |111i)(|000i − |111i)(|000i − |111i)
8
3

We can even correct the non-unitary errors that arise from undesired interaction between qubits of our circuitwith the environment, but we won’t talk about such errors here.

171

These two quantum codewords |0i and |1i span a 2-dimensional space {α|0i + β|1i}. This 2dimensional subspace of the overall 29 -dimensional space is called the “codespace.”
Suppose an error happens on one of these 9 qubits. We would like to have a procedure thatmaps the resulting state back to the codespace. By linearity, it suffices if we can do this for thebasis states |0i and |1i. First consider bitflip and phaseflip-errors.
Detecting a bitflip-error. If a bitflip-error occurs on one the first 3 qubits, we can detect its
location by noting which of the 3 positions is the minority bit. We can do this for each of thethree 3-qubit blocks. Hence there is a unitary that writes down in 4 auxiliary qubits (which are all
initially |0i) a number eb ∈ {0, 1, . . . , 9}. Here eb = 0 means that no bitflip-error was detected, andeb ∈ {1, . . . , 9} means that a bitflip-error was detected on qubit number eb . Note that we don’t
specify what should happen if more than one bitflip-error occurred.
Detecting a phaseflip-error. To detect a phaseflip-error, we can consider the relative phasefor each of the three blocks |000i ± |111i, and if they are not all the same, unitarily write downin 2 more auxiliary qubits (again, initially |0i) a number ep ∈ {0, 1, 2, 3}. Here ep = 0 means thatno phaseflip-error was detected, and ep ∈ {1, 2, 3} means that a phaseflip-error was detected in the
ep -th block.4
Together the above two procedures form one unitary U (i.e., one circuit) that acts on 9 + 4 + 2 = 15
qubits, and that “writes down” eb in 4 auxiliary qubits and ep in 2 auxiliary qubits. For example,
suppose we have the state |0i. If Xi denotes a bitflip-error on the i-th qubit (i ∈ [9]) and Zj denotesa phaseflip-error on the j-th qubit (let j 0 ∈ [3] denote the number of the block in which qubit jlies). Then after these errors our state is Xi Zj |0i. After fresh auxiliary qubits |04 i|02 i are added,
U mapsXi Zj |0i|04 i|02 i 7→ Xi Zj |0i|ii|j 0 i.
Together, eb = i and ep = j 0 form the “error syndrome”; this tells us which error occurred where.
The error-correction procedure can now measure this syndrome in the computational basis, andtake corrective action depending on the classical outcomes eb and ep : apply an X to qubit eb (orno X if eb = 0), and apply a Z to one qubit in the ep -th block (or no Z if ep = 0). The case of a
Y -error on the i-th qubit corresponds to the case where i = j (i.e., the i-th qubit is hit by both aphaseflip and a bitflip); our procedure still works in this case. Hence we can perfectly correct one
Pauli-error on any one of the 9 codeword qubits.
As we argued before, the ability to correct Pauli-errors suffices to correct all possible errors.
Let’s see in more detail how this works. Consider for instance some 9-qubit unitary error E. Assume
it can be decomposed as a linear combination of 9-qubit products of Paulis, each having at mostone bitflip-error and one phaseflip-error:

E = (α0 I +9X

αi Xi )(β0 I +

i=1

9
X

βj Zj ).

j=1

4

Note that we are not discovering exactly on which of the 9 qubits the phaseflip-error happened (in contrast to
the case of bitflips), but that’s OK: we can correct the phaseflip-error by applying a Z-gate to any one of the 3 qubits
in the block where the affected qubit sits.

172

Suppose this error occurs on |0i:

E|0i = (α0 I +

9
X
i=1

αi Xi )(β0 I +9X

βj Zj )|0i =9X

αi βj Xi Zj |0i,

i,j=0

j=1

where we denote X0 = Y0 = I.
If we now add auxiliary qubits |04 i|02 i and apply the above unitary U , then we go into asuperposition of error syndromes:
U (E ⊗ I ⊗6 )|0i|04 i|02 i =9X

αi βj Xi Zj |0i|ii|j 0 i.

i,j=0Measuring the 6 auxiliary qubits will now probabilistically give us one of the syndromes |ii|j 0 i, withi ∈ {0, 1, . . . , 9} and j 0 ∈ {0, 1, 2, 3}, and it will collapse the state toXi Zj |0i|ii|j 0 i.
In a way, this measurement of the syndrome “discretizes” the continuously many possible errors to
the finite set of Pauli-errors. Once the syndrome has been measured, we can apply a corrective X
and/or Z to the first 9 qubits to undo the specific error corresponding to the specific syndrome wegot as outcome of our measurement. It is also possible that the measurement outcome is 04 , 02 ; inthat case the state has collapsed to |0i|04 i|02 i, so the syndrome measurement itself already removed
the error!
So now we can correct an error on one qubit. To achieve this, however, we have substantially
increased the number of locations where such an error could occur: the number of qubits has gonefrom 1 to 9 (even to 15 if we also count the 6 auxiliary qubits used for the syndrome measurements),
and we need a number of time-steps to compute and measure the syndrome, and to correct a
detected error. Hence this procedure only gains us something if the error-rate p is so small thatthe probability of 2 or more errors on the larger encoded system is smaller than the probabilityof 1 error in the unencoded qubit. We will get back to this issue below, when talking about thethreshold theorem. Note also that each new application of the correction-procedure need a new,fresh 6-qubit register initialized to |04 i|02 i. After one run of the error-correction procedure theseauxiliary qubits will contain the measured error syndrome, and we can just discard this. In a way,error correction acts like a refrigerator: a fridge pumps heat out of its system and dumps it into theenvironment, and error-correction pumps noise out of its system and dumps it in the environment
in the form of the discarded auxiliary qubits.
The above 9-qubit code is just one example of a quantum error-correcting code. Better codes
exist, and a lot of work has gone into simultaneously optimizing the different parameters: we wantto encode a large number of logical qubits into a not-much-larger number of physical qubits, while
being able to correct as many errors as possible. The shortest code that encodes one logical qubit
and protects against one error, has five physical qubits. There are also “asymptotically good”
quantum error-correcting codes; these encode k logical qubits into O(k) physical qubits and cancorrect errors on a constant fraction of the physical qubits (rather than just an error on one of thequbits).
173

20.5

Fault-tolerant quantum computation

Encoding a quantum state in a quantum error-correcting code to protect it against noise is good,
but not enough: we also need to be able to do operations on the encoded qubits (Hadamards,
CNOTs, etc.). One way is to decode the logical qubits, do the operation on them, and then reencode them. This, however, is a recipe for disaster: if an error occurs in the interval between
the decoding and subsequent encoding, then we’re unprotected and we cannot detect (let aloneundo) errors happening during that interval. Accordingly, we need to be able to do operations on
the logical qubits while they are encoded. Additionally, we need operations for regular stages oferror-correction, i.e., measuring the syndrome and then correcting errors based on the outcomesof those measurements. These operations may also introduce errors, and the big worry is thaterror-correction steps may themselves introduce more errors than they correct.5
There is a 7-qubit code due to Steane [232] which is used often because it has some niceproperties: a Hadamard on the logical qubit corresponds to H ⊗7 on the physical qubits, and a
CNOT between two logical qubits corresponds to applying CNOTs between the 7 pairs of the two
blocks of physical qubits (i.e., between the 1st qubit of one block and the 1st qubit of the otherblock, etc.). Such implementations are called transversal. Adding the T -gate (|bi 7→ eibπ/4 |bi) to H
and CNOT would yield a gate-set that suffices for universal quantum computation. Unfortunately,
implementing the T -gate fault-tolerantly takes a lot more work, and we won’t go into that here
(see Exercise 7, though).
When designing schemes for fault-tolerant computing, it is very important to ensure that errors
do not spread too quickly. Consider for instance a logical CNOT: if its control-bit is erroneous but
its target bit is not, then after doing the CNOT both bits will be erroneous. The trick is to keep
the errors on the physical qubits under control in such a way that regular stages of error-correction
don’t get overwhelmed by the errors. For example, suppose we have a code that is able to correct
up to one error in each encoded block (logical qubit); then the implementation of a logical CNOT
may convert two encoded blocks where only one physical qubit has an error, into two blocks eachof which has a single error, but not to multiple errors within one block, because our code will beable to handle two blocks with one error each but not one block with two errors (this is why thetransversal implementation of the CNOT for Steane’s code is nice). In addition, we need to be able
to fault-tolerantly prepare states, and measure logical qubits in the computational basis. We won’t
go into the many further details of fault-tolerant quantum computing here.

20.6

Concatenated codes and the threshold theorem

The idea to concatenate a code with itself, described at the end of Section 20.2 for classical codes,
also applies to quantum codes as we will sketch now. Suppose we have some code that encodes
one qubit into C qubits, suppose that it can correct one error on any one of its C qubits, anduses D time-steps per stage of error-correcting (each time-step may involve a number of elementarygates in parallel). Instead of only 1, we now have CD locations where an error could occur!
Assuming error-rate p per-qubit-per-time-step, the probability for the code to fail on a specificlogicaltime (i.e., to have more than 1 physical error on its CD locations) is
PqubitCDat ai specificCD−i . If p is a sufficiently small constant, then this sum is dominated by
p0 = CD
p
(1
−
p)
i=2
i
5

It’s like being inside a leaky boat on the open seas, using a leaky bucket to scoop out water all the time to preventthe boat from filling up with water and sinking. It’s doable, but not easy.

174the term for i = 2, and we have p0 ≈ (CD)2 p2 . Accordingly, if the initial error-rate p is below
some magical constant ≈ 1/(CD)2 , then p0 < p and hence each level of error-correction reduces theerror-rate by a constant factor.
More generally, suppose we concatenate this code k times with itself. Then every “logicalqubit” gets encoded into C k qubits, but (by the same calculation as in Section 20.2) the errork
rate for each logical qubit gets reduced to O((CDp)2 ). Suppose we want to be able to “survive”
T = poly(n) time-steps without any error on the logical qubits; that is what we would need torun an efficient quantum algorithm on faulty quantum hardware. Then it suffices if we reduce theerror rate to  1/T , for which k = O(log log T ) levels of concatenation are enough. These layersof error-correction increase the number of qubits and the computation time by a factor which isexponential in k, but that is still only a polylogarithmic overhead, since 2O(log log T ) = (log T )O(1) .6
The above sketch (when implemented precisely) gives us the famous “threshold theorem” [7,159]: if the initial error-rate of the quantum hardware can be brought down below some magicalconstant (known as the “fault-tolerance threshold”), then we can use software-solutions like quantum error-correcting codes and fault-tolerant computing to ensure that we can quantum computefor long periods of time without serious errors. Much research has gone into finding the best value
for this fault-tolerance threshold. The more efficient our basic quantum error-correcting codes are(i.e., the smaller C and D), the higher (= better) the value of the threshold is. Currently thebest rigorous estimates for the threshold are around 0.1%, but there is numerical evidence thateven a few percent might be tolerable. This is actually one of the most important results in thearea of quantum computing, and is the main answer to the skeptics mentioned at the start of thechapter: as long as experimentalists manage to implement basic operations within a few percent oferror in a scalable way, then we should be able to build large-scale quantum computers.7 Currently
there seems to be no fundamental reason why we cannot do this; it is, however, an extremely hardengineering problem.

Exercises
1. (H) Let E be an arbitrary 1-qubit unitary. We know that it can be written as
E = α0 I + α1 X + α2 Y + α3 Z,
P
for some complex coefficients αi . Show that 3i=0 |αi |2 = 1.
2. (a) Write the 1-qubit Hadamard transform H as a linear combination of the four Paulimatrices.
(b) Suppose an H-error happens on the first qubit of α|0i + β|1i using the 9-qubit code.
Give the various steps in the error-correction procedure that corrects this error.
3. Give a quantum circuit for the encoding of Shor’s 9-qubit code, i.e., a circuit that maps
|008 i 7→ |0i and |108 i 7→ |1i. Explain why the circuit works.
4. Shor’s 9-qubit code allows to correct a bit flip and/or a phase flip on one of its 9 qubits.
Below we give a 4-qubit code which allows to detect a bitflip and/or a phaseflip. By this we
6

Recently it was shown that one can even bring the overhead down to O(1) [110].
This is of course assuming our simple model of independent noise on each physical qubit is not too far off; if thenoise can be correlated in devious ways it becomes much harder (though often still possible) to protect against.
7

175

mean that after the detection procedure we either have the original uncorrupted state back,or we know that an error occurred (though we do not know which one). The logical 0 and 1
are encoded as:|0i = 12 (|00i + |11i) ⊗ (|00i + |11i)|1i = 12 (|00i − |11i) ⊗ (|00i − |11i)(a) Give a procedure (either as a circuit or as sufficiently-detailed pseudo-code) that detects
a bitflip error on one of the 4 qubits of α|0i + β|1i.
(b) Give a procedure (either as a circuit or as sufficiently-detailed pseudo-code) that detects
a phaseflip error on one of the 4 qubits of α|0i + β|1i.
(c) Does that mean that we can now detect any unitary 1-qubit error on one of the 4 qubits?
Explain your answer.
5. (H) Show that there cannot be a quantum code that encodes one logical qubit into 2k physicalqubits while being able to correct errors on up to k of the physical qubits.
6. Suppose we have a qubit whose density matrix is ρ = α0 I + α1 X + α2 Y + α3 Z, where
α0 , α1 , α2 , α3 are real coefficients and I, X, Y, Z are the Pauli matrices.
(a) Show that α0 = 1/2.
(b) Depolarizing noise (of strength p ∈ [0, 1]) acts on a qubit as follows: with probability
1 − p nothing happens to the qubit, and with probability p the qubit is replaced by the“completely mixed state” of a qubit, whose density matrix is I/2.
Show that depolarizing noise on the above qubit doesn’t change the coefficient α0 , butshrinks each of α1 , α2 , α3 by a factor of 1 − p.
10
7. Suppose we have a qubit |φi = α|0i+β|1i to which we would like to apply a T =0 eiπ/4
gate, but for some reason we cannot. However, we have a second
 qubit available in state10
1√ (|0i + eiπ/4 |1i), and we can apply a CNOT gate and an S =
gate.
2
0 i
(a) What state do we get if we apply a CNOT to the first and second qubit?
(b) Suppose we measure the second qubit in the computational basis. What are the probabilities of outcomes 0 and 1, respectively?
(c) Suppose the measurement yields 0. Show how we can get T |φi in the first qubit.
(d) Suppose the measurement yields 1. Show how we can get T |φi in the first qubit, up toan (irrelevant) global phase.
Comment: This way of implementing the T -gate is very helpful in fault-tolerant computing, where often
CNOT and S are easy to do on encoded states but T is not. What this exercise shows is that we can prepare(encodings of) the so-called “magic state” √12 (|0i + eiπ/4 |1i) beforehand (offline, assuming we can store them
until we need them), and use those to indirectly implement a T -gate using only CNOT and S-gates.

176

8. Consider a quantum-error correcting code that encodes k qubits (and n − k |0is) into an
n-qubit codeword state, via the unitary encoding map
U : |x, 0n−k i 7→ |C(x)i, where x ∈ {0, 1}k , and |C(x)i need not be a basis state.
A “weight-w Pauli error” is the tensor product of n Pauli matrices, of which at most w are
not identity (e.g., something like X ⊗ I ⊗ Z ⊗ I ⊗ I if w = 2 and n = 5). Suppose that there isa unitary map S on 3n qubits that can identify every weight-w Pauli error E on a codeword,by writing the name of E (the “error syndrome,” which we can think of as a 2n-bit string”E”, for example writing 00 for I, 10 for X, 01 for Z, 11 for Y ) in a second register that’s
initially 02n . In other words, for every x ∈ {0, 1}k and weight-w Pauli error E, this S maps
S : (E|C(x)i)|02n i 7→ (E|C(x)i)|”E”i.
(a) Show that if x and y are k-bit strings, and E and F are weight-w Pauli errors, then then-qubit states E|C(x)i and F |C(y)i are orthogonal unless both x = y and E = F .
w  
X
n i
k
(b) Prove the inequality 2
3 ≤ 2n .
ii=0Comment: This inequality implies a lower bound on the required number of qubits n, in terms of thenumber of encoded qubits k and the weight w of errors that you can correct, but you don’t need toderive that consequence.

9. In this exercise we will see that the argument about concatenating the classical 3-bit code at
the end of Section 20.2 still works if the initial error rate is p ≤ 1/2 − ε for some ε > 0.
(a) Define the function f as f (p) = 3p2 (1 − p) + p3 . Show that if p = 1/2 − ε for someε ∈ [0, 1/6], then f (p) ≤ 1/2 − (13/9)ε.
(b) Show that there is an m = O(log(1/ε)) such that m levels of concatenation reduce theerror to pm < 1/3.
(c) Show that m + k levels of concatenation reduce the error to something exponentiallysmall in 2k .
(d) How many bits are used to encode one logical bit in the scheme from (c)?

177

178

Appendix A

Some Useful Linear Algebra
In this appendix we quickly introduce the basic elements of linear algebra, most of which will be
used somewhere or other in these notes.

A.1

Vector spaces

A vector space V over a field F is a set of objects (called vectors) satisfying that if v, w ∈ V , thencv + dw ∈ V for all c, d ∈ F. In other words, V is closed under addition and scalar multiplication.
A (linear) subspace W is a subset W ⊆ V which is itself a vector space (i.e., closed under additionand scalar multiplication). For example, V = Cd is the d-dimensional complex vector space, whichis the set of all column vectors of d complex numbers. The set W ⊆ V of vectors whose first two
entries are 0 is a subspace of V . As another example, the set V = {0, 1}d of d-bit vectors, withentrywise addition modulo 2, is a linear space. The field here is F2 = {0, 1}. The set W ⊆ V ofvectors whose first two entries are equal is a subspace of V .
P
A set of vectors v1 , . . . , vm ∈ V is linearly independent if the only way to get m
i=1 ai vi equal
to the zero-vector 0, is to set a1 = · · · = am = 0. The span (over field F) of a set of vectors
S
Pd= {v1 , . . . , vm } ⊆ V is the set span(S) of vectors that can be written as a linear combination
i=1 ai vi (with coefficients a1 , . . . , am ∈ F). A basis for V is a linearly independent set S of vectors
such that span(S) = V . One can show that all bases of V have the same size; this size is called
the dimension of V . If we fix anPordered basis S = (v1 , . . . , vm ), then every w ∈ V can be written
uniquely as a linear combination m
i=1 wi vi , and can also be written (in that basis) as (w1 , . . . , wm ).
The support of such a w is the set {i | wi 6= 0} of locations where w is nonzero. For example, thesupport of w = (1, 5, 0, 4) is {1, 2, 4}.

A.2

Matrices

Matrices represent linear maps between two vector spaces with particular bases. We assume familiarity with the basic rules of matrix addition and multiplication. We use Aij for the (i, j)-entry ofa matrix A and AT for its transpose, which has ATij = Aji . We use Id to denote the d × d identity
matrix, which has 1s on its diagonal and 0s elsewhere; we usually omit the subscript d when thedimension is clear from context. If A is square and there is a matrix B such that AB = BA = I,then we use A−1 to denote this B, which is called the inverse of A (and is unique if it exists). Notethat (AB)−1 = B −1 A−1 .
179

In the remainder of this appendix we will mostly consider the complex field. If A is a matrix(not necessarily square), then A∗ denotes its conjugate transpose (or adjoint): the matrix obtainedby transposing A and taking the complex conjugates of all entries. Note that (AB)∗ = B ∗ A∗ .
Physicists usually write A† (pronounced “A-dagger”) instead of A∗ , but in these notes we will stickwith the A∗ notation that is common in mathematics.

A.3

Inner productP
For vectors v, w, we use hv|wi = v ∗ w = i vi∗ wi for their inner product.1 The combination of thevector space V with this inner product is called a Hilbert space. Two vectors v, w are orthogonal
if hv|wi = 0. A set {vi } of vectors is called orthogonal if all vectors are pairwise orthogonal:
hvi |vj i = 0 if i 6= j. If additionally the vectors all have norm
the set is called orthonormal.
p 1, thenpP
2
The inner product induces a vector norm kvk =hv|vi =
i |vi | . This is the usual
Euclidean norm (or “length”). The norm in turn induces a distance kv − wk between vectors v
and w. Note that distance and inner product are closely related:kv − wk2 = hv − w|v − wi = kvk2 + kwk2 − hv|wi − hw|vi.
In particular, for unit vectors v and w the real part of their inner product equals 1 − 12 kv − wk2 .
Hence unit vectors that are close together have an inner product close to 1, and vice versa. The
Cauchy-Schwarz inequality gives |hv|wi| ≤ kvk · kwk (see also Appendix B).
The outer product of v and w is the matrix vw∗ .

A.4

Unitary matrices

Below we will restrict attention to square matrices, unless explicitly mentioned otherwise.
A matrix A is unitary if A−1 = A∗ . The following conditions are equivalent:
1. A is unitary
2. A preserves inner product: hAv|Awi = hv|wi for all v, w
3. A preserves norm: kAvk = kvk for all v
4. kAvk = 1 if kvk = 1(1) implies (2) because if A is unitary then A∗ A = I, and hence hAv|Awi = (v ∗ A∗ )Aw = hv|wi. (2)implies (1) as follows: if A is not unitary then A∗ A 6= I, so then there is a w such that A∗ Aw 6= w
and, hence, a v such that hv|wi =6 hv|A∗ Awi = hAv|Awi, contradicting (2). Clearly (2) implies (3).
Moreover, it is easy to show that (3) implies (2) using the following identity:
kv + wk2 = kvk2 + kwk2 + hv|wi + hw|vi.
The equivalence of (3) and (4) is obvious. Note that by (4), the eigenvalues of a unitary matrix
have absolute value 1.
1

Here we follow a physics convention: mathematicians usually define hv|wi = vw∗ .

180

A.5

Diagonalization and singular values

The complex number λ is an eigenvalue of (square) matrix A if there is some nonzero vector v(called an eigenvector ) such that Av = λv.
Matrices A and B are similar if there is an invertible matrix S such that A = SBS −1 . Note that
if Av = λv, then BS −1 v = λS −1 v, so similar matrices have the same eigenvalues. Schur’s lemma
states that every matrix A is similar to an upper triangular matrix: A = U T U −1 for some unitary
U and upper triangular T . Since similar matrices have the same eigenvalues and the eigenvalues ofan upper triangular matrix are exactly its diagonal entries, the eigenvalues of A form the diagonalof T .
A matrix D is diagonal if Dij = 0 whenever i 6= j. Let S be some matrix satisfying AS = SD
for some diagonal matrix D. Let vi be the i-th column of S and λi be the i-th entry on the diagonalof D, then

 

..
..
..
..
.   .
.  .
 Av1 · · · Avd  =  λ1 v1 · · · λd vd ,

 

..
..
..
..
.
.
.
.
|
{z
} |
{z
}
AS

SD

and we see that vi is an eigenvector of A associated with eigenvalue λi . Conversely, if v1 , . . . , vd are
eigenvectors of A with eigenvalues λ1 , . . . , λd , then we have AS = SD, where S has the vi as columns
and D is the diagonal matrix of λi . We call a square matrix A diagonalizable if it is similar to somediagonal matrix D: A = SDS −1 . This D then has A’s eigenvalues λi on its diagonal, some of which
may be zero. Note that A is diagonalizable iff it has a linearly independent set of d eigenvectors.
These eigenvectors will form the columns of S, giving AS = SD, and linear independence ensuresthat S has an inverse, giving A = SDS −1 . A matrix A is unitarily diagonalizable iff it can be
diagonalized via a unitary matrix U : A = U DU −1 . If the columnsof U are the vectors ui , and thePdiagonal entries of D are λi , then we can also write A = i λi ui u∗i ; this is sometimes called thespectral decomposition of A. By the same argument as before, A will be unitarily diagonalizable iff
it has an orthonormal set of d eigenvectors.
A matrix A is normal if it commutes with its conjugate transpose (A∗ A = AA∗ ). For example,
unitary matrices are normal. If A is normal and A = U T U −1 for some upper triangular T (whichmust exist because of Schur’s lemma), then T = U −1 AU and T ∗ = U −1 A∗ U , so T T ∗ = U −1 AA∗ U =U −1 A∗ AU = T ∗ T . Hence T is normal and upper triangular, which implies (with a little work) that
T is diagonal. This shows that normal matrices are unitarily diagonalizable. Conversely, if A is
diagonalizable as U DU −1 , then AA∗ = U DD∗ U ∗ = U D∗ DU −1 = A∗ A, so then A is normal. Thusa matrix is normal iff it is unitarily diagonalizable. If A is not normal, it may still be diagonalizable
via a non-unitary S, for example:

 
 
 

1 1
1 1
1 0
1 −1
=
·
·
.
0 2
0 1
0 2
0
1
| {z } | {z } | {z } |
{z
}
A

S

D

S −1

If A = U DU −1 then A∗ = U D∗ U −1 , so the eigenvalues of A∗ are the complex conjugates of theeigenvalues of A.
An important class of normal (and hence unitarily diagonalizable) matrices are the Hermitianmatrices, which are the ones satisfying A = A∗ . Note that the last line of the previous paragraphimplies that the eigenvalues of Hermitian matrices are real.
181

A Hermitian matrix A is called positive semidefinite (resp. positive definite), if all its eigenvalues
are nonnegative (resp. positive). An equivalent definition is that A is positive semidefinite (psd) iff
there exists a matrix C such that A = C ∗ C (in other words, there exist vectors ci such that for alli, j, we have Aij = hci |cj i). A useful and easy to prove property is that A is psd iff Tr(AB) ≥ 0 for
all psd matrices B. By defining A  B iff A−B is positive semidefinite, we obtain a partial orderingon the set of all Hermitian matrices. If all eigenvalues are 0 or 1, then A is called a projection (orprojection matrix or projector ). This is equivalent to requiring
A2= A.

0 1
Not all matrices are diagonalizable, for instance A =is not. However, every matrix
0 0
has a singular value decomposition (SVD), which is almost as useful as a diagonalization. We
will derive this below for an invertible square matrix A. Since A∗ A is psd, we can write A∗ A =V DV −1 for some unitary V whose columns vi are the orthonormal eigenvectors of A∗ A, and somenonnegative
diagonal matrix D with the corresponding eigenvalues. The entries σi of the matrix Σ =√D are called the singular values of A (some of which may be zero). Define vectors ui = Avi /σi .
Note that the ui form an orthonormal system because u∗i uj = vi∗ (A∗ Avj )/σi σj = vi∗ (σj2 vj )/σi σj ,which is 1 if i = j and 0 if i 6= j. Hence the matrix U that has these ui ’s as columns is unitary.
We have UP= AV Σ−1 , so we can write A = U ΣV −1 , which is the SVD of A. Equivalently, we canwrite A = i σi ui vi∗ . This derivation of the SVD A = U ΣV −1 can easily be extended to arbitrarym × n matrices A; U will be an m × m unitary, Σ will be m × n (padded with 0s if the rank of A
is < m, n), and V will be an n × n unitary.

A.6

Tensor products

If A = (Aij ) is an m×n matrix and B an m0 ×n0 matrix, then their tensor product (a.k.a. Kronecker
product) is the mm0 × nn0 matrix
A11 B · · · A1n B
 A21 B · · · A2n B A⊗B =
.
..

.
Am1 B · · ·Amn BFor example:

√1
2
√1
2

√1
2
− √12

!


⊗

0 1
−1 0



0

 − √1

2
=
0

− √12

√1
2

0

√1
2



0 − √12
0 

1 .
√1
√
0 − 2 
2
1
√
0
0
2

Note that the tensor product of two numbers (i.e., 1 × 1 matrices) is itself just a number, and thetensor product of two column vectors is itself a column vector.
The following properties of the tensor product are easily verified:• c(A ⊗ B) = (cA) ⊗ B = A ⊗ (cB) for all scalars c• (A ⊗ B)∗ = A∗ ⊗ B ∗ , and similarly for inverse and transpose (note that the order of the tensor
factors doesn’t change).
• A ⊗ (B + C) = (A ⊗ B) + (A ⊗ C)
182

• A ⊗ (B ⊗ C) = (A ⊗ B) ⊗ C• (A ⊗ B)(C ⊗ D) = (AC) ⊗ (BD)
Different vector spaces can also be combined using tensor products. If V and V 0 are vector spaces ofdimension d and d0 with basis {v1 , . . . , vd } and {v10 , . . . , vd0 0 }, respectively, then their tensor productspace is the d · d0 -dimensional space W = V ⊗ V 0 spanned by {vi ⊗ vj0 | 1 ≤ i ≤ d, 1 ≤ j ≤ d0 }.
Applying a linear operation A to V and B to V 0 corresponds to applying the tensor product A ⊗ B
to the tensor product space W .

A.7

Trace

The trace of a matrix A is the sum of its diagonal entries: Tr(A) =easily verified properties of Tr(A) are:P

i Aii .

Some important and• Tr(A + B) = Tr(A) + Tr(B)• Tr(AB) = Tr(BA), which is known as the “cyclic property” of the trace.
For example, Tr(Avv ∗ ) = v ∗ Av.
• Tr(A) is the sum of the eigenvalues of A.
−1−1(This follows
P from Schur and the previous item: Tr(A) = Tr(U T U ) = Tr(U U T ) =Tr(T ) = i λi )• Tr(A ⊗ B) = Tr(A)Tr(B)

A.8

Rank

The rank of a matrix A (over a field F) is the size of a largest linearly independent set of rowsof A (linear independence taken over F). Unless mentioned otherwise, we take F to be the fieldof complex numbers. We say that A has full rank if its rank equals its dimension. The following
properties are all easy to show:• rank(A) = rank(A∗ )• rank(A) equals the number of nonzero eigenvalues of A (counting multiplicity)• rank(A + B) ≤ rank(A) + rank(B)• rank(AB) ≤ min{rank(A), rank(B)}• rank(A ⊗ B) = rank(A) · rank(B)• A has an inverse iff A has full rank
183

A.9

The Pauli matrices

The four Pauli matrices are:








1 0
0 1
0 −i
1
0
I=
, X=
, Y =
, and Z =
.
0 1
1 0
i
0
0 −1
Note that each Pauli matrix P is both unitary and Hermitian, and hence self-inverse: P −1 = P .
This implies that their eigenvalues are in {−1, 1}. Non-identity Paulis anti-commute: if P, Q ∈{X, Y, Z} are distinct then P Q = −QP . Note that Y = iXZ. Also, products of two distinct Paulimatrices have trace 0.
Define the Hilbert-Schmidt inner product on the space of d × d matrices as hA, Bi = d1 Tr(A∗ B).
With respect to this inner product (for d = 2), the four Pauli matrices form an orthonormal set.
This implies that every complex 2 × 2 matrix A can be written as a linear combination of the Paulimatrices:
A = α0 I + α1 X + α2 Y + α3 Z,with complex coefficients αi . If A is Hermitian, then these coefficients will be real.
We can also consider the n-qubit Paulis, which are n-fold tensor products of the above 2 × 2
Paulis. For example X ⊗ Z ⊗ I ⊗ Y ⊗ Z is a 5-qubit Pauli. There are 4n n-qubit Paulis, since wehave 4 possibilities for each of the n tensor factors, and these 4n matrices form an orthonormal set
w.r.t. Hilbert-Schmidt inner product. Accordingly, every 2n × 2n matrix A can be written uniquely
as a linear combination of the 4n n-qubit Paulis. Again, if A is Hermitian, then the 4n coefficients
will be real.

A.10

Dirac notation

Physicists often write their linear algebra in Dirac notation, and we will follow that custom fordenoting quantum states. In this notation we write |vi = v and hv| = v ∗ . The first is called a ket,the second a bra. Some points about this notation:• hv|wi = hv||wi: inner products are bra-ket (“bracket”) products.
P• If matrix A is unitarily diagonalizable, then A = i λi |vi ihvi | for some orthonormal set of
eigenvectors {vi }.
• |vihv| ⊗ |wihw| = (|vi ⊗ |wi)(hv| ⊗ hw|), the latter is often abbreviated to |vi ⊗ |wihv| ⊗ hw|.
Abbreviating the latter further by omitting the tensor product leads to dangerous ambiguity,
though sometimes it’s still clear from context.
• (U |vi)∗ = hv|U ∗ and (|ui ⊗ |vi)∗ = hu| ⊗ hv| (the ordering of tensor factors doesn’t change).
• Don’t write kets inside of other kets or bras: the notation hu|(α|vi + β|wi)i doesn’t reallymake sense.

184

Appendix B

Some other Useful Math and CS
Here we collect various basic but useful facts and definitions needed in parts of the lecture notes.

B.1

Some notation, equalities and inequalities• We use [n] to denote the set {1, . . . , n}, and δa,b ∈ {0, 1} to indicate whether a = b or not.
If P is a statement which can be true or false, then [P ] ∈ {0, 1} denotes its truth value.
Logarithms will always be to base 2 unless stated otherwise.
• A complex number is of the form c = a + bi, where a, b ∈ R, and i is the imaginary√ unit,2iφwhich satisfies i = −1. Such a c can also be written as c = re where r = |c| = a2 + b2
is the magnitude (a.k.a. modulus or norm) of c, and φ ∈ [0, 2π) is the angle that c makeswith the positive horizontal axis when we view it as a point (a, b) in the plane. Note thatcomplex numbers of magnitude 1 lie on the unit circle in this plane. We can also write thoseas eiφ = cos(φ) + i sin(φ). The complex conjugate c∗ is a − ib, equivalently c∗ = re−iφ .
• The Cauchy-Schwarz inequality: for a = (a1 , . . . , an ) ∈ Cn and b = (b1 , . . . , bn ) ∈ Cn
v
v
u n
u n
n
X
X
uX
u
∗
2
t
|ai | t|bi |2 .
ai bi ≤
i=1

i=1

i=1

Equivalently, written in terms of inner products and norms of vectors: |ha|bi| ≤ kak · kbk.
Proof for the case with real entries: for every real λ we have 0 ≤ ha − λb|a − λbi = kak2 + λ2 kbk2 − 2λha|bi.
Now set λ = kak/kbk and rearrange (a slightly more complicated proof works if a, b ∈ Cn ).

• Geometric sum:

m−1
X
j=0

j

z =



m
1−z m
1−z

if z = 1
if z 6= 1

Proof: The case z = 1 is obvious; for the case z 6= 1, observe (1 − z)(

Pm−1
j=0

zj ) =

Pm−1
j=0

zj −

Pm

j=1 z

j

= 1 − zm.

For example, if z = e2πir/N is a root of unity, with r an integer in {1, . . . , N − 1}, thenPN −1 j1−e2πir
j=0 z = 1−e2πir/N = 0.
• The ratio in the previous line can be rewritten using the identity |1 − eiθ | = 2| sin(θ/2)|;
this identity can be seen by drawing the numbers 1 and eiθ as vectors from the origin in the185complex plane, and dividing their angle θ in two. Some other useful trigonometric identities:cos(θ)2 + sin(θ)2 = 1, sin(2θ) = 2 sin(θ) cos(θ).
• 1 + x ≤ ex for all real numbers x (positive as well as negative).
• If εj ∈ [0, 1] then 1 −

k
X
j=1

εj ≤

k
Y

(1 − εj ) ≤ e−Pk

j=1 εj.

j=1

Proof: The upper bound comes from the preceding item. The lower bound follows easily by induction on k,
using the fact that (1 − ε1 )(1 − ε2 ) = 1 − ε1 − ε2 + ε1 ε2 ≥ 1 − ε1 − ε2 .

B.2

Algorithms and probabilities• When we do not care about constant factors, we’ll often use big-Oh notation: T (n) = O(f (n))
means there exist constants c, n0 ≥ 0 such that for all integers n ≥ n0 , we have T (n) ≤ cf (n).
Similarly, big-Omega notation is used for lower bounds: T (n) = Ω(f (n)) means there exist
constants c, n0 ≥ 0 such that T (n) ≥ cf (n) for all n ≥ n0 . T (n) = Θ(f (n)) means thatsimultaneously T (n) = O(f (n)) and T (n) = Ω(f (n)). Such notation is often used to write
upper and/or lower bounds on the running time of algorithms as a function of their input
length n.
• For N = 2n , we can identify the integers {0, . . . , N −1} with their n-bit binary representationsPi
as follows: the bitstring x = xn−1 . . . x1 x0 ∈ {0, 1}n corresponds to the integer n−1
i=0 xi 2 .
The leftmost bit xn−1 is called the most significant bit of x (since it corresponds to the largest
power of two, 2n−1 ), and the rightmost bit x0 is its least significant bit (it corresponds to
20 = 1, so determines whether x is an even or odd integer). For example, if n = 3 then the
bitstring x = x2 x1 x0 = 101 corresponds to the integer x2 · 4 + x1 · 2 + x0 · 1 = 4 + 1 = 5.
The integer 0 corresponds to the bitstring 0n (if we use 0 to denote a bitstring of 0s, then thevalue of n should be clear from context).
We can also use binary notation for non-integral numbers, with the bits to the right of thedecimal dot corresponding to negative powers of two (1/2, 1/4, 1/8, etc.). For example,
0.1 denotes 1/2 and 10.101 denotes 2 + 1/2 + 1/8 = 21/8. Note that multiplying by twocorresponds to shifting the dot to the right, and dividing corresponds to shifting to the left.
• The union bound says that the probability of the union (or logical “or”) of two events is at
most the sum of their probabilities: Pr[A ∨ B] ≤ Pr[A] + Pr[B]. This inequality should be
obvious from drawing
PaT Venn diagram. More generally, if we have T events A1 , . . . , AT , thenPr[A1 ∨ · · · ∨ AT ] ≤ i=1 Pr[Ai ].
• A (discrete) random variable X is an object thatpi . Its
P takes value xi with probability
2
expected value (or expectation) is µ = E[X] =i pi xi . Its variance is σ = Var[X] =E[(X − E[X])2 ] = E[X 2 ] − E[X]2 . Its standard deviation is σ.
• Linearity ofPexpectation says
Pm that, for values a1 , . . . , am and random variables X1 , . . . , Xm ,mwe have E[ j=1 aj Xj ] = j=1 aj E[Xj ] (which is easy to verify).
• Random variable X is independent from random variable Y , if the value of Y does not affectthe probability distribution of X, i.e., Pr[X = x] = Pr[X = x | Y = y] for all possible values
x, y. If X and Y are independent, then E[X · Y ] = E[X] · E[Y ].
186• Three basic upper bounds on the tails of probability distributions:Markov: if X is a nonnegative random variable with expectation µ, then Pr[X ≥ kµ] ≤ 1/k.
Proof: Since X is nonnegative, µ ≥ Pr[X ≥ kµ] · kµ.

Chebyshev: if X is a random variable with expectation µ and standard deviation σ, then
Pr[|X − µ| ≥ kσ] ≤ 1/k 2 .
Proof: Apply Markov to the random variable |X − µ|2 , whose expectation is σ 2 .

P
Chernoff/Hoeffding: if X = ni=1 Xi is the sum of n independent, identically distributed
random variables Xi ∈ {0, 1}, each with expectation Pr[Xi = 1] = p, then X has expectation2µ = np, and exponentially decreasing tail bound Pr[|X − µ| ≥ αn] ≤ 2e−2α n .
Proof idea: For all parameters λ, we have Pr[X − µ ≥ t] = Pr[eλX ≥ eλ(t+µ) ]. Upper bound the latterprobability by applying Markov to the random variable eλX . This is a product of n independent randomvariables eλXi , so its expectation is easy to analyze. Then choose λ to minimize the upper bound.

• A randomized algorithm is a classical algorithm that can flip random coins during its operation, meaning its behavior is partially determined by chance and its output is a randomvariable that depends on its input, rather than a deterministic function of its input. One canthink of a randomized algorithm as a probability distribution over deterministic algorithms(one deterministic algorithm for each setting of the coins).
• When we say a (randomized or quantum) algorithm has error probability ≤ 1/3, this typicallymeans in the worst case: for every possible input, the algorithm produces the correct answer
with probability ≥ 2/3, where probability is taken over the random coin flips and/or quantum
measurements during its operation. Such statements do not refer to “most” inputs under some
distribution unless stated explicitly.
• If a (randomized or quantum) algorithm produces the correct answer in expected running
time T (meaning for each input its expected running time is ≤ T ), then we can convert that
into an algorithm with worst-case running time 3T and error probability ≤ 1/3, as follows.
Run the original algorithm for 3T steps, and just cut it off if it hasn’t terminated by itself.
The probability of non-termination within 3T steps is at most 1/3 by Markov’s inequality.
Hence with probability ≥ 2/3 we will have the correct answer.
• The union bound is very useful for analyzing an algorithm with T randomized subroutines,
each of which has its own small failure probability ≤ 1/(3T ). If these failure events are independent, then the probability that none of the T subroutines fails is at least (1 − 1/(3T ))T ≥1 − T /(3T ) = 2/3 (the inequality uses the last bullet of B.1). But what if these events are
dependent on each other, which may well happen if the subroutines depend on what happens
elsewhere in the algorithm? Then by the union bound the probability that there is at least
one subroutine that fails is at most T · 1/(3T ) ≤ 1/3. In other words, the probability thatnone of the T subroutines fails is still ≥ 2/3.
• If a (classical or quantum) algorithm with 0/1-outputs has error probability ≤ 1/3, thenwe can cheaply reduce this error probability to small ε > 0, as follows. Choose odd n =2O(log(1/ε)) such that 2e−2α n ≤ ε for α = 1/6. Run the original algorithm n times andoutput the majority among the n output bits. The probability that this majority is wrong(i.e., that the number of correct output bits is more than αn below its expectation), is at
most ε by the Chernoff bound. Hence we output the correct answer with probability ≥ 1 − ε.
187

188

Appendix C

Hints for Exercises
Chapter 1
9. Find the maximal p such that I − 2p|−ih−| − 2p|1ih1| is still psd.
10. Consider what U has to do when |φi = |0i, when |φi = |1i, and when |φi is a superposition ofthese two.
13.b. Use the facts that Tr(D|ψihψ|) = hψ|D|ψi and that products of 2 distinct Paulis have trace 0.
This exercise is just superdense coding in disguise.

Chapter 2
6. Use Exercise 5.
7. Instead of measuring the qubit, apply a CNOT that “copies” it to a new |0i-qubit, which is thenleft alone until the end of the computation. Analyze what happens.
13. Use the Bernstein-Vazirani algorithm.

Chapter 3
6.c. Approximate the state of part (a) using the subroutine of part (b), and see
what happens if√
1 PN/2+2 N N
you apply Hadamards to the approximate state. Use the fact that 2N w=0
is nearly 1,w√
because this is the probability that if you flip N fair coins, N/2 − 2 N or more of them come up“heads.”

Chapter 4
3. Use |αi2 − βi2 | = |αi − βi | · |αi + βi | and the Cauchy-Schwarz inequality.
4.e. Use triangle inequality.
4.f. Drop all phase-gates with small angles φ < 1/n3 from the O(n2 )-gate circuit for F2n explainedin Section 4.5. Calculate how many gates are left in the circuit, and analyze the distance between
the unitaries corresponding to the new circuit and the original circuit.

Chapter 5
1.a. You may invoke here (without proof) the Schönhage-Strassen algorithm for fast multiplication [218, 160]. This allows you to multiply two n-bit integers mod N using O(n log(n) log log(n))
189steps (where n = dlog N e).1
3.a. The prime number theorem implies that Ω(N/ ln N ) of the numbers between 1 and N are
prime; also there is an efficient classical algorithm to test if a given number is prime [5]. You may
use these facts, but be explicit in how many bits your primes p and q will have.
3.b. Use the result of Exercise 1 (no need to rederive that here).
3.c. The set of all possible messages forms a group of size φ(N ). Euler’s Theorem says that in anygroup G, we have a|G| = 1 for all a ∈ G (here ‘1’ is the identity element in the group).

Chapter 6P2
2 ≤ 2 kM k + a small constant.
4.b. For M = K
i=1 Ei , show that kM k = M
3
5. You could use the SWAP-test from Section 16.6.

Chapter 7
4.b. Recall that if there are i > 0psolutions, then one variant of Grover’s algorithm finds a solution
using an expected number of O( N/i) queries.
5.e. Choose γ in (d) such that applying dk̃e rounds of amplitude amplification to A results in asolution for y with probability 1.
6.a. Try running the exact version of Grover (see end of Section 7.2) with different guesses for what
the actual t is.
7.a. Run the basic Grover search with a cleverly chosen number of iterations.
7.b. Use binary search on top of (a).
8.d. The eigenvalues of a 2-dimensional rotation matrix over angle λ are eiλ and e−iλ (you don’t need√√√to prove this). You may also assume a  1, so that the differences between a, sin a, arcsin a
are negligible. You may refer to the lecture notes for phase estimation without further proof, incl.
the fact that phase estimation gives a good n-bit approximation with high probability even if thephase cannot be represented exactly with n bits of precision.
8.e. Define
an A that involves one
to x√and where a = t/N . Invoke (d) with ε proportional√√query√√to 1/ N . You can use |ã − a| = | ã − a| · | ã + a| in your analysis of the approximation error.
9.b. Combine amplitude amplification with the algorithm of (a), for a smart choice of k. Youranswer may refer to the lecture notes for the details of amplitude amplification.
10. Start with m = xi for a random i, and repeatedly use Grover’s algorithm to find an index jsuch that xj < m and update m = xj . Continue this until you can find no element smaller than m,
and analyze the number of queries of this algorithm. You are allowed to argue about this algorithm
on a high level (i.e., things like “use Grover to search for a j such that. . . ” are OK), no need towrite out complete circuits. You do, however, have to take into account that the various runs ofGrover each have their own error probability√
11.b. What is the probability in (a) if you set s to roughly N ?
11.c. Choose a set S of size s = O(N 1/3 ), and classically query all its elements. First check if S
contains a collision. If yes, then you’re done. If not, then use Grover to find a j 6∈ S that collides
with an i ∈ S.
1

Shor used the Schönhage-Strassen algorithm in his original paper. We could also invoke the more recent improvement of Harvey and van der Hoeven [135], who remove the log log n factor.

190

Chapter 8
4.a. Choose a uniformly random vector v ∈ {0, 1}n , calculate ABv and Cv, and check whether
these two vectors are the same.
4.b. Consider the case where A is the all-0 matrix.
4.c. Modify the algorithm for collision-finding: use a quantum walk on the Johnson graph J(n, r),where each vertex corresponds to a set R ⊆ [n], and that vertex is marked if there are i, j ∈ R suchthat (AB)i,j 6= Ci,j . Optimize over r.
5.b. There’s no need to use the C, U, S-framework of the chapter here; the answer is much simpler.
View the 3n-step random walk algorithm as a deterministic algorithm with an additional inputr ∈ {0, 1}n × {1, 2, 3}3n , where the first n bits determine x, and the last 3n entries determine which
variable of the leftmost false clauses will be flipped in the 3n steps of the random walk. Use Groversearch on the space of all possible r, or amplitude amplification (no need to write out complete
circuits here).

Chapter 9
3. Use induction on m, and the fact that there exists a constant c such that for A, B of small norm
we have eA+B = eA eB + E for some E of norm kEk ≤ ckAk · kBk.
6. Calculate the subnormalized second-register state (h0| ⊗ I)(W −1 ⊗ I)V (W ⊗ I)|0i|ψi.
8.d. Like in the analysis of Grover’s algorithm and regular amplitude amplification (Chapter 7),
the product of two reflections on S is a rotation of S.
9. Use triangle inequality, kHk ≤ 1, and the fact that k! ≥ (k/e)k .
10.b. W2 just implements a rotation on the first qubit, by an angle that depends on Akj . If you
have a basis state |0i|ai where a ∈ [0, 1] is some real number
written in some fixed finite number√√of bits, then you can rotate the first qubit to a|0i + 1 − a|1i by a small circuit that does some
single-qubit gates on the first qubit conditioned on the bits in the |ai-part. That circuit is thesame for all values of a, so it’s independent of the particular |0i|ai you’re acting on. You may justassume you can do this circuit, without writing out its details.
11.d. Note that the computational basis states |xi are the eigenstates of P and hence also of U , so
the only thing you need to do is multiply with the right phases for them.
11.e. By conjugating with single-qubit gates you can change non-Z Paulis to Zs, in order to reduceto the case of (d).

Chapter 10
No hints for this chapter, sorry!

Chapter 11
4.a. Use Exercise 2.
4.b. Show that the symmetrized approximate polynomial r induced by the algorithm has degree
at least N .
6.c. Use the result of Exercise 5 for N = 2.
7.b. When defining the relation R, consider that the hardest task for this algorithm is to distinguish
inputs of weight N/2 from inputs of weight N/2 + 1.
9.b. Consider the Boolean-valued problem of distinguishing the inputs where 0 sits at an odd
191location i in the string x from those where 0 sits at an even location.
10. Show how you can use sorting to solve the Majority-problem and then use the lower boundfrom Exercise 7 to get an Ω(N ) lower bound on sorting. (It is actually known that sorting takesΩ(N log N ) comparisons even on a quantum computer, but you don’t have to show that.)
11.a. Reduce the bs(f )-bit OR function (restricted to inputs of weight 0 or 1) to f and invoke thelower bound that we know for OR.
12.b. Use induction on T and triangle inequality.
12.d. Add up the inequalities of (b) and (c) over all i, and use the Cauchy-Schwarz inequality.
13.b. Compare the expected value of a monomial of degree ≤ 2T under distributions U and D,
and then use the fact that a polynomial is a sum of monomials.

Chapter 122.a. Use that I = P0 P0 + P1 P1 .
2.b. Note that t = T here, so we’re considering the final states of an algorithm that, for every
input x, outputs the wrong value 1 − f (x) with probability ≤ ε.
2.c. Use (a), the fact that Pf (x) P1−f (y) + Pf (y) P1−f (x) = I whenever f (x) 6= f (y), and the fact that
Γxy = 0 whenever f (x) = f (y).
2.d. Cauchy-Schwarz and the definition of operator norm imply |hφ|M |ψi| ≤ k|φik · kM |ψik ≤k|φik · kM k · k|ψik for all matrices M and vectors |φi, |ψi.
3.b. Note that the |φti i’s are pairwise orthogonal due to having a different basis state in their query
register.
P
3.c. Show and use that I − Ox,± Oy,± = 2 i:xi 6=yi Pi . Also use that (Γi )xy = 0 whenever xi = yi .
2

3.d. Cauchy-Schwarz andPthe definition of operator norm imply |hφti |(I ⊗Γi )|φti i| ≤ kI ⊗ Γi k· |φti i .
4. Use that X and C − m
i=1 yi Ai are both psd.

Chapter 13
1. Use binary search, running the algorithm with different choices of k to “zoom in” on the largest
prime factor.
3.a. Use the last item of Appendix B.2 to make the error probability exponentially small.
3.c. Use the error analysis of Exercise 4.4.
4.a. Write |θx i = α|0i|φ0 i + β|1i|φ1 i, and consider the inner product between (Z ⊗ I)|θx i and |θx i.
4.b. Use part (a). Analyze the amplitude of |x, 0S−n i in the final state |ψx i, using ideas from theproof of BQP ⊆ PSPACE in Section 13.3. Note that in contrast to that proof, you cannot use
more than polynomial time for this exercise.

Chapter 14
3. Use binary search with different values of a, b to zoom in on the right value.
5.b. Argue about the penalty given by Hclock , which can’t be larger than λmin .
2√
5.d. Use hψ 00 |H|ψ 00 i =H|ψ 00 i and triangle inequality.
5.e. Use Eq. (14.3).
5.f. Use (e) and Cauchy-Schwarz.
5.g. Sum (f) over all (T + 1)2 pairs t, t0 to lower bound hψ 0 |ψ 00 i.
5.j. Once all three simplifying assumptions have been satisfied, we can invoke the energy lower
192

bound of Ω(1/T 2 ) proved in Section 14.3.1.
6.a. Invoke the Marriott-Watrous result mentioned at the end of Section 14.1 (without proving it).
7. Combine ideas from Exercises 6.b and 13.4.
8.a. Note that from the description of H you can infer the circuit Cn = UT · · · U1 for n-bit instances,and you can then run Ut · · · U1 in a controlled manner, for every t ∈ {0, . . . , T } of your choice.

Chapter 15
2.a. It suffices to use pure states with real amplitudes as encoding. Try to “spread out” the 4
encodings |φ00 i, |φ01 i, |φ10 i, |φ11 i in the 2-dimensional real plane as well as possible.
3. Use the fact that 1 classical bit of communication can only send 1 bit of information, no matter
how much entanglement Alice and Bob share. Combine this fact with superdense coding.
6.b. Think of the first n qubits as Alice and the last n qubits as Bob; use Holevo’s theorem.
7.a. Consider the positive and negative eigenvalues in the spectral decomposition of ρ0 − ρ1 , andanalyze the success probability minus the error probability.

Chapter 16
1. Argue that if Alice sends the same message for distinct inputs x and x0 , then Bob doesn’t knowwhat to output if his input is y = x.
2.a. Argue that if P is a projector then we can’t have both P |φi = |φi and P |ψi = 0.
2.c. Observe that among Alice’s possible n-bit inputs are the n codewords of the Hadamard codethat encodes log n bits (see Section 15.3); each pair of distinct Hadamard codewords is at Hamming
distance exactly n/2. Use part (a) to argue that Alice needs to send pairwise orthogonal states for
those n inputs, and hence her message-space must have dimension at least n.
3. Use the fact that 2 non-orthogonal states cannot be distinguished perfectly (Exercise 2), andthat a set of 2n vectors that are pairwise orthogonal must have dimension 2n .
5. Invoke the quantum random access lower bound, Theorem 4 of Section 15.2.
6. Partition the n positions into disjoint sets and run (in parallel) a separate r-message intersection
protocol for each of these sets.
8.b. Let Alice send a random row of C(x) (with the row-index) and let Bob send a random columnof C(y) (with the column-index).
9.a. Two distinct polynomials, each of degree ≤ d, are equal on at most d points of the domain Fp .
10.b. Run the protocol of part (a) on an initial state where Bob has a well-chosen superposition
over many |yi.
11.b. You can derive this from one of the communication lower bounds mentioned in this chapter,
you don’t need to prove this from scratch.
12. The matching M induces a projective measurement that Bob can do on the message he receives.
13.d. Alice could send a uniform superposition over all h ∈ H.

Chapter 17
1.b. You could write this out, but you can also get the answer almost immediately from part (a)and the fact that H T = H −1 .
2.b. It’s helpful here to write the EPR-pair in the basis |+i = √12 (|0i + |1i), |−i = √12 (|0i − |1i).
4. For every fixed input x, y, there is a classical strategy that gives a wrong output only on that193

input, and that gives a correct output on all other possible inputs. Use the shared randomness torandomly choose one of those deterministic strategies.
6.b. Argue that 41 hψ|C|ψi = Pr[win] − Pr[lose].
6.c. Use that A2x and By2 are the k-qubit identity matrix.
6.d. Use Cauchy-Schwarz to show (hψ|C|ψi)2 ≤ hψ|C 2 |ψi, and then upper bound the latter.
6.e. cos(π/8)2 = 12 + √18 .

Chapter 18
6. Use the encoding of Exercise 5, so that Alice and Bob need to cooperate to learn the key used
to change ρ.
7. Show that a unitary on Alice’s side of the state won’t change Bob’s local density matrix ρB .
9.a. The singular value decomposition (see end of Appendix A.5) of the d × d matrix M whose
entries are Mij = αij can be computed in polynomial time, you may assume this without proof.

Chapter 19
6.a. Start with a uniform superposition over all x ∈ {0, 1}n and end with an inverse QFT. You’re
allowed to use a unitary like |ci 7→ e2πic |ci since it does not depend on f .
7.a. You can diagonalize V by something like a Hadamard gate on the “middle two” basis states,|01i and |10i.
7.b. W consists of k 2-qubit SWAP-gates.
7.c. It’s helpful to write U iρη = I + iρη + F for some matrix F with kF k1 = O(η 2 ). This follows
from Taylor series and the fact that ρ has trace 1, you don’t need to prove this. Here the trace
norm kAk1 of a matrix A is defined as the sum of A’s singular values.
7.d. You can first prove this for the case where σ = |aiha| and ρ = |bihb| are pure states, and thenextend to general mixed states by linearity.
7.f. Apply part (d) r = O(t2 /ε) times with η = O(ε/t), choosing the constants in the O(·) suchthat rη = t and hence (U η )r = U t . Upper bound the overall error using triangle inequality.
8.a. Use the SWAP-test from Section 16.6. “O(1) given copies” means you are allowed to use any
number of copies of |φi and |ψi, as long as that number is independent of n. You may count the
3-qubit gate which is the controlled SWAP of a pair of qubits as an elementary gate here.

Chapter 20
1. Compute the trace Tr(E ∗ E) in two ways, and use the fact that Tr(AB) = 0 if A and B are
distinct Paulis, and Tr(AB) = Tr(I) = 2 if A and B are the same Pauli.
5. Given an unknown qubit α|0i + β|1i encoded using this code, you could split the 2k qubits into
two sets of k qubits each, and use each to recover a copy of the unknown qubit.

194

Bibliography[1] S. Aaronson. The learnability of quantum states. Proceedings of the Royal Society of London,
463(2088), 2007. quant-ph/0608142.
[2] S. Aaronson. Quantum machine learning algorithms: Read the fine print. Nature Physics,
11(4):291–293, April 2015.
[3] S. Aaronson and A. Ambainis. Quantum search of spatial regions. Theory of Computing,1(1):47–79, 2005. Earlier version in FOCS’03. quant-ph/0303041.
[4] S. Aaronson and Y. Shi. Quantum lower bounds for the collision and the element distinctness
problems. Journal of the ACM, 51(4):595–605, 2004.
[5] M. Agrawal, N. Kayal, and N. Saxena. PRIMES is in P. Annals of Mathematics, 160(2):781–
793, 2004.
[6] D. Aharonov, I. Arad, and T. Vidick. Guest column: The quantum PCP conjecture. ACM
SIGACT News, 44(2):47–79, 2013. arXiv:1309.7495.
[7] D. Aharonov and M. Ben-Or. Fault tolerant quantum computation with constant error rate.
SIAM Journal on Computing, 38(4):1207–1282, 2008. Earlier version in STOC’97. quantph/9611025.
[8] D. Aharonov and T. Naveh. Quantum NP - a survey, 2002. quant-ph/0210077.
[9] J. Allcock and C-Y. Hsieh. A quantum extension of SVM-perf for training nonlinear SVMs
in almost linear time. Quantum, 4:342, 2020. arXiv:2006.10299.
[10] O. Alrabiah, V. Guruswami, P. Kothari, and P. Manohar. A near-cubic lower bound for
3-query locally decodable codes from semirandom CSP refutation. Technical report, ECCC
TR–22–101, 2022. Available at http://www.eccc.uni-trier.de/eccc/.
[11] A. Ambainis. Communication complexity in a 3-computer model. Algorithmica, 16(3):298–
301, 1996.
[12] A. Ambainis. Quantum lower bounds by quantum arguments. Journal of Computer and
System Sciences, 64(4):750–767, 2002. Earlier version in STOC’00. quant-ph/0002066.
[13] A. Ambainis. Polynomial degree vs. quantum query complexity. Journal of Computer and
System Sciences, 72(2):220–238, 2006. Earlier version in FOCS’03. quant-ph/0305028.
195

[14] A. Ambainis. Quantum walk algorithm for element distinctness. SIAM Journal on Computing,37(1):210–239, 2007. Earlier version in FOCS’04. quant-ph/0311001.
[15] A. Ambainis. Quantum search with variable times. In Proceedings of 25th Annual Symposiumon Theoretical Aspects of Computer Science (STACS’08), pages 49–61, 2008. arXiv:1010.4458.
[16] A. Ambainis, K. Balodis, J. Iraids, M. Kokainis, K. Prūsis, and J. Vihrovs. Quantum speedups
for exponential-time dynamic programming algorithms. In Proceedings of 30th ACM-SIAM
SODA, pages 1783–1793, 2019. arXiv:1807.05209.
[17] A. Ambainis, A. Belovs, O. Regev, and R. de Wolf. Efficient quantum algorithms for (gapped)group testing and junta testing. In Proceedings of 27th ACM-SIAM SODA, pages 903–922,
2016. arXiv:1507.03126.
[18] A. Ambainis, A. Childs, B. Reichardt, R. Špalek, and S. Zhang. Any AND-OR formula of size
N can be evaluated in time N 1/2+o(1) on a quantum computer. SIAM Journal on Computing,39(6):2513–2530, 2010. Earlier version in FOCS’07.
[19] A. Ambainis, M. Mosca, A. Tapp, and R. de Wolf. Private quantum channels. In Proceedingsof 41st IEEE FOCS, pages 547–553, 2000. quant-ph/0003101.
[20] A. Anshu, S. Arunachalam, T. Kuwahara, and M. Soleimanifar. Sample-efficient learning ofquantum many-body systems. Nature Physics, 17:931––935, 2021. Earlier version in FOCS’20.
arXiv:2004.07266.
[21] J. van Apeldoorn and A. Gilyén. Quantum algorithms for zero-sum games. arXiv:1904.03180,
2019.
[22] J. van Apeldoorn, A. Gilyén, S. Gribling, and R. de Wolf. Quantum SDP-solvers: better upperand lower bounds. Quantum, 4:230, 2020. Earlier version in FOCS’17. arXiv:1705.01843.
[23] J. van Apeldoorn and A. Gilyén. Improvements in quantum SDP-solving with applications.
In Proceedings of 46th International Colloquium on Automata, Languages, and Programming, volume 132 of Leibniz International Proceedings in Informatics, pages 99:1–99:15, 2019.
arXiv:1804.05058.
[24] S. Apers and R. de Wolf. Quantum speedup for graph sparsification, cut approximationand Laplacian solving. In Proceedings of 61st IEEE Annual Symposium on Foundations ofComputer Science, pages 637–648, 2020. arXiv:1911.07306.
[25] P. K. Aravind. A simple demonstration of Bell’s theorem involving two observers and noprobabilities or inequalities. quant-ph/0206070, 2002.
[26] S. Arunachalam, J. Briët, and C. Palazuelos. Quantum query algorithms are completely
bounded forms. SIAM Journal on Computing, 48(3):903–925, 2019. Earlier version in
ITCS’18. arXiv:1711.07285.
[27] S. Arunachalam and R. de Wolf. Guest column: A survey of quantum learning theory.
SIGACT News, 48(2):41–67, 2017. arXiv:1701.06806.
196[28] S. Arunachalam and R. de Wolf. Optimizing the number of gates in quantum search. Quantum
Information and Computation, 17(4):251–261, 2017. arXiv:1512.07550.
[29] S. Arunachalam and R. de Wolf. Optimal quantum sample complexity of learning algorithms.
Journal of Machine Learning Research, 19, 2018. Earlier version in CCC’17. arXiv:1607.00932.
[30] F. Arute, ..., and J. Martinis. Quantum supremacy using a programmable superconducting
processor. Nature, 574:505–510, 2019. arXiv:1910.11333.
[31] A. Aspect, Ph. Grangier, and G. Roger. Experimental tests of realistic local theories via
Bell’s theorem. Physical Review Letters, 47:460, 1981.
[32] L. Babai. Graph isomorphism in quasipolynomial time. In Proceedings of 48th ACM STOC,
pages 684–697, 2016. arXiv:1512.03547.
[33] L. Babai and E. M. Luks. Canonical labeling of graphs. In Proceedings of 15th ACM STOC,
pages 171–183, 1983.
[34] L. Babai and S. Moran. Arthur-Merlin games: a randomized proof system, and a hierarchyof complexity classes. Journal of Computer and System Sciences, 36(2):254–276, 1988.
[35] Z. Bar-Yossef, T. S. Jayram, and I. Kerenidis. Exponential separation of quantum andclassical one-way communication complexity. SIAM Journal on Computing, 38(1):366–384,
2008. Earlier version in STOC’04.
[36] R. Beals. Quantum computation of Fourier transforms over symmetric groups. In Proceedingsof 29th ACM STOC, pages 48–53, 1997.
[37] R. Beals, H. Buhrman, R. Cleve, M. Mosca, and R. de Wolf. Quantum lower bounds bypolynomials. Journal of the ACM, 48(4):778–797, 2001. Earlier version in FOCS’98. quantph/9802049.
[38] S. Beauregard. Circuit for Shor’s algorithm using 2n + 3 qubits. Quantum Information andComputation, 3(2):175–185, 2003. quant-ph/0205095.
[39] J. S. Bell. On the Einstein-Podolsky-Rosen paradox. Physics, 1:195–200, 1964.
[40] A. Belovs. Learning-graph-based quantum algorithm for k-distinctness. In Proceedings of
53rd IEEE FOCS, pages 207–216, 2012. arXiv:1205.1534.
[41] A. Belovs. Span programs for functions with constant-sized 1-certificates. In Proceedings of43rd ACM STOC, pages 77–84, 2012. arXiv:1105.4024.
[42] A. Belovs. Applications of the Adversary Method in Quantum Query Algorithms. PhD thesis,
University of Latvia, 2014.
[43] A. Belovs. Quantum algorithms for learning symmetric juntas via adversary bound. Computational Complexity, 24(2):255–293, 2015. Earlier version in Complexity’14. arXiv:1311.6777.
[44] A. Belovs. Variations on quantum adversary, 27 Apr 2015. arXiv:1504.06943.
197

[45] A. Belovs and T. Lee. The quantum query complexity of composition with a relation.
arXiv:2004.06439, 2020.
[46] A. Belovs and B. Reichardt. Span programs and quantum algorithms for st-connectivity andclaw detection. In Proceedings of 20th European Symposium on Algorithms (ESA’12), pages
193–204, 2012. arXiv:1203.2603.
[47] P. A. Benioff. Quantum mechanical Hamiltonian models of Turing machines. Journal of
Statistical Physics, 29(3):515–546, 1982.
[48] C. Bennett, G. Brassard, C. Crépeau, R. Jozsa, A. Peres, and W. Wootters. Teleporting an
unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels. PhysicalReview Letters, 70:1895–1899, 1993.
[49] C. Bennett and S. Wiesner. Communication via one- and two-particle operators on EinsteinPodolsky-Rosen states. Physical Review Letters, 69:2881–2884, 1992.
[50] C. H. Bennett, E. Bernstein, G. Brassard, and U. Vazirani. Strengths and weaknesses of quantum computing. SIAM Journal on Computing, 26(5):1510–1523, 1997. quant-ph/9701001.
[51] C. H. Bennett and G. Brassard. Quantum cryptography: Public key distribution and cointossing. In Proceedings of the IEEE International Conference on Computers, Systems andSignal Processing, pages 175–179, 1984.
[52] D. Bernstein and T. Lange. Post-quantum cryptography. Nature, 549(6):188–194, 2017.
[53] E. Bernstein and U. Vazirani. Quantum complexity theory. SIAM Journal on Computing,26(5):1411–1473, 1997. Earlier version in STOC’93.
[54] D. Berry, A. Childs, R. Cleve, R. Kothari, and R. Somma. Exponential improvement inprecision for simulating sparse Hamiltonians. In Proceedings of 46th ACM STOC, pages
283–292, 2014. arXiv:1312.1414.
[55] D. Berry, A. Childs, R. Cleve, R. Kothari, and R. Somma. Simulating Hamiltonian dynamics
with a truncated Taylor series. Physical Review Letters, 114:090502, 2015. arXiv:1412.4687.
[56] D. Berry, A. Childs, and R. Kothari. Hamiltonian simulation with nearly optimal dependenceon all parameters. In Proceedings of 56th IEEE FOCS, pages 792–809, 2015. arXiv:1501.01715.
[57] J. Biamonte, P. Wittek, N. Pancotti, P. Rebentrost, N. Wiebe, and S. Lloyd. Quantum
machine learning. Nature, 549(7671), 2017. arXiv:1611.09347.
[58] J. D. Biamonte and P. J. Love. Realizable Hamiltonians for universal adiabatic quantum
computers. Physical Review A, 78(1)(012352), 2008. arXiv:0704.1287.
[59] J-F. Biasse and F. Song. Efficient quantum algorithms for computing class groups and solving
the principal ideal problem in arbitrary degree number fields. In Proceedings of 27th ACMSIAM SODA, pages 893–902, 2016.
[60] A. Blumer, A. Ehrenfeucht, D. Haussler, and M. K. Warmuth. Learnability and the VapnikChervonenkis dimension. Journal of the ACM, 36(4):929–965, 1989.
198

[61] A. Bookatz. QMA-complete problems. Quantum Information and Computation, 14(5–6):361–
383, 2014. arXiv:1212.6312.
[62] M. Boyer, G. Brassard, P. Høyer, and A. Tapp. Tight bounds on quantum searching.
Fortschritte der Physik, 46(4–5):493–505, 1998. Earlier version in Physcomp’96. quantph/9605034.
[63] F. Brandão, A. Kalev, T. Li, C. Lin, K. Svore, and X. Wu. Quantum SDP solvers: Large
speed-ups, optimality, and applications to quantum learning. In Proceedings of 46th International Colloquium on Automata, Languages, and Programming, volume 132 of Leibniz
International Proceedings in Informatics, pages 27:1–27:14, 2019. arXiv:1710.02581.
[64] F. Brandão and K. Svore. Quantum speed-ups for solving semidefinite programs. In Proceedings of 58th IEEE FOCS, pages 415–426, 2017. arXiv:1609.05537.
[65] G. Brassard, R. Cleve, and A. Tapp. The cost of exactly simulating quantum entanglement with classical communication. Physical Review Letters, 83(9):1874–1877, 1999. quantph/9901035.
[66] G. Brassard, P. Høyer, M. Mosca, and A. Tapp. Quantum amplitude amplification andestimation. In Quantum Computation and Quantum Information: A Millennium Volume,
volume 305 of AMS Contemporary Mathematics Series, pages 53–74. 2002. quant-ph/0005055.
[67] G. Brassard, P. Høyer, and A. Tapp. Quantum algorithm for the collision problem. ACM
SIGACT News (Cryptology Column), 28:14–19, 1997. quant-ph/9705002.
[68] A. Broadbent and A. B. Grilo. QMA-hardness of consistency of local density matrices withapplications to quantum zero-knowledge. In Proceedings of 61st IEEE FOCS, pages 196–205,
2020. arXiv:1911.07782.
[69] A. Broadbent and C. Schaffner. Quantum cryptography beyond quantum key distribution.
Designs, Codes and Cryptography, 78(1):351–382, 2016. arXiv:1510.06120.
[70] A. E. Brouwer and W. H. Haemers. Spectra of Graphs. Springer, 2012.
[71] N. H. Bshouty and J. C. Jackson. Learning DNF over the uniform distribution using aquantum example oracle. SIAM Journal on Computing, 28(3):1136—-1153, 1999. Earlier
version in COLT’95.
[72] H. Buhrman, R. Cleve, S. Massar, and R. de Wolf. Non-locality and communication complexity. Reviews of Modern Physics, 82:665–698, 2010. arXiv:0907.3584.
[73] H. Buhrman, R. Cleve, J. Watrous, and R. de Wolf. Quantum fingerprinting. Physical Review
Letters, 87(16), September 26, 2001. quant-ph/0102001.
[74] H. Buhrman, R. Cleve, and A. Wigderson. Quantum vs. classical communication and computation. In Proceedings of 30th ACM STOC, pages 63–68, 1998. quant-ph/9802040.
[75] H. Buhrman and R. Špalek. Quantum verification of matrix products. In Proceedings of 17th
ACM-SIAM SODA, pages 880–889, 2006. quant-ph/0409035.
199

[76] M. Bun and J. Thaler. Dual lower bounds for approximate degree and Markov-Bernsteininequalities. In Proceedings of 40th ICALP, volume 7965 of Lecture Notes in Computer
Science, pages 303–314, 2013.
[77] Y. Cao, J. Romero, J. Olson, M. Degroote, P. Johnson, M. Kieferová, I. Kivlichan, T. Menke,
B. Peropadre, N. Sawaya, S. Sim, L. Veis, and A. Aspuru-Guzik. Quantum chemistry in theage of quantum computing. Chemical Reviews, 119(19):10856–11091, 2019. arXiv:1812.09976.
[78] M. Cerezo, A. Arrasmith, R. Babbush, S. Benjamin, S. Endo, K. Fujii, J. McClean, K. Mitarai, X. Yuan, L. Cincio, and P. Coles. Variational quantum algorithms. Nature Reviews
Physics, 1, 2021. arXiv:2012.09265.
[79] S. Chakraborty, A. Gilyén, and S. Jeffery. The power of block-encoded matrix powers: improved regression techniques via faster Hamiltonian simulation. In Proceedings of 46th International Colloquium on Automata, Languages, and Programming, volume 132 of Leibniz
International Proceedings in Informatics, pages 33:1–33:14, 2019. arXiv:1804.01973.
[80] Y. Chen and R. de Wolf. Quantum algorithms and lower bounds for linear regression withnorm constraints. arXiv:2110.13086, 2021.
[81] N-H. Chia, A. Gilyén, T. Li, H-H. Lin, E. Tang, and C. Wang. Sampling-based sublinear lowrank matrix arithmetic framework for dequantizing quantum machine learning. In Proceedingsof 52nd ACM STOC, pages 387–400, 2020. arXiv:1910.06151.
[82] A. Childs. Lecture notes on quantum algorithms, 2017. Available at https://cs.umd.edu/~amchilds/qa/.
[83] A. Childs, R. Kothari, and R. Somma. Quantum algorithm for systems of linear equations with exponentially improved dependence on precision. SIAM Journal on Computing,46(6):1920–1950, 2017. arXiv:1511.02306.
[84] A. M. Childs, D. Gosset, and Z. Webb. The Bose-Hubbard model is QMA-complete. Theoryof Computing, 11(20):491–603, 2015. arXiv:1311.3297.
[85] A. M. Childs, Y. Su, M. C. Tran, N. Wiebe, and S. Zhu.
arXiv:1912.08854, 18 Dec 2019.

A theory of Trotter error.

[86] B. S. Cirel’son. Quantum generalizations of Bell’s inequality. Letters in Mathematical Physics,
4(2):93–100, 1980.
[87] J. F. Clauser, M. A. Horne, A. Shimony, and R. A. Holt. Proposed experiment to test local
hidden-variable theories. Physical Review Letters, 23(15):880–884, 1969.
[88] R. Cleve. The query complexity of order-finding. In Proceedings of 15th IEEE Conference on
Computational Complexity, pages 54–59, 2000. quant-ph/9911124.
[89] R. Cleve and H. Buhrman. Substituting quantum entanglement for communication. PhysicalReview A, 56(2):1201–1204, 1997. quant-ph/9704026.
200

[90] R. Cleve, W. van Dam, M. Nielsen, and A. Tapp. Quantum entanglement and the communication complexity of the inner product function. In Proceedings of 1st NASA QCQC
conference, volume 1509 of Lecture Notes in Computer Science, pages 61–74. Springer, 1998.
quant-ph/9708019.
[91] R. Cleve, A. Ekert, C. Macchiavello, and M. Mosca. Quantum algorithms revisited. In
Proceedings of the Royal Society of London, volume A454, pages 339–354, 1998. quantph/9708016.
[92] S. Cook. The complexity of theorem-proving procedures. In Proceedings of 3rd ACM STOC,
pages 151––158, 1971.
[93] J. W. Cooley and J. W. Tukey. An algorithm for the machine calculation of complex Fourier
series. Mathematics of Computation, 19(90):297–301, 1965.
[94] D. Coppersmith. An approximate Fourier transform useful in quantum factoring. IBM
Research Report No. RC19642, quant-ph/0201067, 1994.
[95] A. Cornelissen. Quantum gradient estimation and its application to quantum reinforcement
learning. Master’s thesis, Delft University, 2018.
[96] W. van Dam. Quantum oracle interrogation: Getting all information for almost half theprice. In Proceedings of 39th IEEE FOCS, pages 362–367, 1998. quant-ph/9805006.
[97] D. Deutsch. Quantum theory, the Church-Turing principle, and the universal quantum Turingmachine. In Proceedings of the Royal Society of London, volume A400, pages 97–117, 1985.
[98] D. Deutsch. Quantum computational networks. In Proceedings of the Royal Society of London,
volume A425, 1989.
[99] D. Deutsch and R. Jozsa. Rapid solution of problems by quantum computation. In Proceedingsof the Royal Society of London, volume A439, pages 553–558, 1992.
[100] A. Drucker and R. de Wolf. Quantum proofs for classical theorems. Theory of Computing,2011. ToC Library, Graduate Surveys 2. arXiv:0910.3376.
[101] V. Dunjko, J. Taylor, and H. Briegel. Advances in quantum reinforcement learning. IEEE
SMC, pages 282–287, 2017. arXiv:1811.08676.
[102] C. Dürr, M. Heiligman, P. Høyer, and M. Mhalla. Quantum query complexity of some graphproblems. SIAM Journal on Computing, 35(6):1310–1328, 2006. Earlier version in ICALP’04.
quant-ph/0401091.
[103] C. Dürr and P. Høyer. A quantum algorithm for finding the minimum. quant-ph/9607014,
18 Jul 1996.
[104] K. Efremenko. 3-query locally decodable codes of subexponential length. In Proceedings of
41st ACM STOC, pages 39–44, 2009.
[105] H. Ehlich and K. Zeller. Schwankung von Polynomen zwischen Gitterpunkten. Mathematische
Zeitschrift, 86:41–44, 1964.
201

[106] A. Einstein, B. Podolsky, and N. Rosen. Can quantum-mechanical description of physicalreality be considered complete? Physical Review, 47:777–780, 1935.
[107] P. van Emde Boas. Machine models and simulations. In van Leeuwen [239], pages 1–66.
[108] M. Ettinger, P. Høyer, and M. Knill. The quantum query complexity of the hidden subgroupproblem is polynomial. Information Processing Letters, 91(1):43–48, 2004. quant-ph/0401083.
[109] E. Farhi, J. Goldstone, and S. Gutmann. A quantum approximate optimization algorithm.
arXiv:1411.4028, 2014.
[110] O. Fawzi, A. Grospellier, and A. Leverrier. Constant overhead quantum fault-tolerancewith quantum expander codes. In Proceedings of 59th IEEE FOCS, pages 743–754, 2018.
arXiv:1808.03821.
[111] R. Feynman. Simulating physics with computers.
Physics, 21(6/7):467–488, 1982.

International Journal of Theoretical[112] R. Feynman. Quantum mechanical computers. Optics News, 11:11–20, 1985.
[113] L. Fortnow and J. Rogers. Complexity limitations on quantum computation. Journal ofComputer and System Sciences, 59(2):240–252, 1999. Earlier version in Complexity’98. Also
cs.CC/9811023.
[114] P. Frankl and V. Rödl. Forbidden intersections. Transactions of the American MathematicalSociety, 300(1):259–286, 1987.
[115] R. Freivalds. Probabilistic machines can use less running time. In Proceedings of 7th IFIP
Congress, pages 839–842, 1977.
[116] M. Fürer. Faster integer multiplication. SIAM Journal on Computing, 39(3):979–1005, 2009.
Earlier version in STOC’07.
[117] M. Garey and D. Johnson. Computers and Intractability : A Guide to the Theory of NPcompleteness. W. H. Freeman and Company, 1979.
[118] D. Gavinsky, J. Kempe, I. Kerenidis, R. Raz, and R. de Wolf. Exponential separation for oneway quantum communication complexity, with applications to cryptography. SIAM Journal
on Computing, 38(5):1695–1708, 2008. Earlier version in STOC’07. quant-ph/0611209.
[119] S. Gharibian, Y. Huang, Z. Landau, and S. W. Shin. Quantum hamiltonian complexity.
Foundations and Trends in Theoretical Computer Science, 10(3):159–282, 2015.
[120] A. Gilyén. Quantum Singular Value Transformation & Its Algorithmic Applications. PhD
thesis, University of Amsterdam, 2018.
[121] A. Gilyén, S. Arunachalam, and N. Wiebe. Optimizing quantum optimization algorithms
via faster quantum gradient computation. In Proceedings of 30th ACM-SIAM SODA, pages
1425–1444, 2019. arXiv:1711.00465.
202[122] A. Gilyén, Y. Su, G. H. Low, and N. Wiebe. Quantum singular value transformation andbeyond: exponential improvements for quantum matrix arithmetics. In Proceedings of 51st
ACM STOC, pages 193–204, 2019. arXiv:1806.01838.
[123] D. Gottesman. An introduction to quantum error correction and fault-tolerant quantum
computation. In Quantum Information Science and Its Contributions to Mathematics, Proceedings of Symposia in Applied Mathematics, volume 68, pages 13–58, 2010. arXiv:0904.2557.
[124] M. Grigni, L. Schulman, M. Vazirani, and U. Vazirani. Quantum mechanical algorithms
for the nonabelian hidden subgroup problem. Combinatorica, 24(1):137–154, 2004. Earlier
version in STOC’01.
[125] L. K. Grover. A fast quantum mechanical algorithm for database search. In Proceedings of
28th ACM STOC, pages 212–219, 1996. quant-ph/9605043.
[126] J. Haah, A. W. Harrow, Z. Ji, X. Wu, and N. Yi. Sample-optimal tomography of quantum
states. In Proceedings of 48th ACM STOC, pages 913–925, 2016. arXiv:1508.01797.
[127] L. Hales and S. Hallgren. An improved quantum Fourier transform algorithm and applications. In Proceedings of 41st IEEE FOCS, pages 515–525, 2000.
[128] S. Hallgren. Polynomial-time quantum algorithms for Pell’s equation and the principal ideal
problem. Journal of the ACM, 54(1):653–658, 2007. Earlier version in STOC’02.
[129] S. Hallgren, C. Moore, M. Roetteler, A. Russell, and P. Sen. Limitations of quantum
coset states for graph isomorphism. Journal of the ACM, 57(6):34, 2010. Earlier version
in STOC’06.
[130] S. Hallgren, A. Russell, and A. Ta-Shma. The hidden subgroup problem and quantum computation using group representations. SIAM Journal on Computing, 32(4):916–934, 2003.
Earlier version in STOC’00.
[131] S. J. Hallgren. Quantum Fourier Sampling, the Hidden Subgroup Problem, and Beyond. PhD
thesis, University of California, Berkeley, 2000.
[132] S. Hanneke. The optimal sample complexity of PAC learning. Journal of Machine Learning
Research, 17(38):1–15, 2016. arXiv:1507.00473.
[133] G. H. Hardy and E. M. Wright. An Introduction to the Theory of Numbers. Oxford University
Press, New York, fifth edition, 1979.
[134] A. Harrow, A. Hassidim, and S. Lloyd. Quantum algorithm for solving linear systems ofequations. Physical Review Letters, 103(15):150502, 2009. arXiv:0811.3171.
[135] D. Harvey and J. van der Hoeven. Integer multiplication in time O(n log n). Annals of
Mathematics, 193(2):563––617, 2021. Preprint hal-02070778 2019.
[136] J. Håstad. Some optimal inapproximability results. Journal of the ACM, 48(4):798–859, 2001.
Earlier version in STOC’97.
203

[137] B. Hensen, H. Bernien, A. E. Dréau, A. Reiserer, N. Kalb, M. S. Blok, J. Ruitenberg,
R. F. L. Vermeulen, R. N. Schouten, C. Abellán, W. Amaya, V. Pruneri, M. W. Mitchell,
M. Markham, D. J. Twitchen, D. Elkouss, S. Wehner, T. H. Taminiau, and R. Hanson.
Loophole-free Bell inequality violation using electron spins separated by 1.3 kilometres. Nature, 526, 29 October 2015.
[138] A. S. Holevo. Bounds for the quantity of information transmitted by a quantum communication channel. Problemy Peredachi Informatsii, 9(3):3–11, 1973. English translation in
Problems of Information Transmission, 9:177–183, 1973.
[139] P. Høyer, T. Lee, and R. Špalek. Negative weights make adversaries stronger. In Proceedingsof 39th ACM STOC, pages 526–535, 2007. quant-ph/0611054.
[140] R. Impagliazzo and A. Wigderson. P = BPP if E requires exponential circuits: Derandomizing
the XOR lemma. In Proceedings of 29th ACM STOC, pages 220–229, 1997.
[141] G. Ivanyos, F. Magniez, and M. Santha. Efficient quantum algorithms for some instances of
the non-Abelian hidden subgroup problem. International Journal of Foundations of Computer
Science, 14(5):723–740, 2003. Earlier version in SPAA’01. quant-ph/0102014.
[142] G. Ivanyos, L. Sanselme, and M. Santha. An efficient quantum algorithm for the hidden
subgroup problem in nil-2 groups. Algorithmica, 62(1–2):480–498, 2012. Earlier version in
LATIN’08. arXiv:0707.1260.
[143] R. Jain, Z. Ji, S. Upadhyay, and J. Watrous. QIP = PSPACE. Journal of the ACM,
58(6):30:1–30:27, 2011. Earlier version in STOC’10. arXiv:0907.4737.
[144] D. Janzing, P. Wocjan, and T. Beth. Non-identity check is QMA-complete. International
Journal of Quantum Information, 3(3):463–473, 2005. quant-ph/0305050.
[145] S. Jeffery, R. Kothari, and F. Magniez. Nested quantum walks with quantum data structures.
In Proceedings of 24th ACM-SIAM SODA, pages 1474–1485, 2013. arXiv:1210.1199.
[146] S. Jordan. Fast quantum algorithm for numerical gradient estimation. Physical Review
Letters, 95:050501, 2005. quant-ph/0405146.
[147] M. Kaplan, G. Leurent, A. Leverrier, and M. Naya-Plasencia. Breaking symmetric cryptosystems using quantum period finding. In Proceedings of CRYPTO’16, Part II, volume 9815 ofLecture Notes in Computer Science, pages 207–237, 2016. arXiv:1602.05973.
[148] J. Katz and L. Trevisan. On the efficiency of local decoding procedures for error-correcting
codes. In Proceedings of 32nd ACM STOC, pages 80–86, 2000.
[149] J. Kempe, A. Yu. Kitaev, and O. Regev. The complexity of the local Hamiltonian problem.
SIAM Journal on Computing, 35(5):1070–1097, 2006. Earlier version in FSTTCS’04. quantph/0406180.
[150] I. Kerenidis, J. Landman, A. Luongo, and A. Prakash. q-means: A quantum algorithm
for unsupervised machine learning. In Proceedings of the 33rd International Conference
on Neural Information Processing Systems (NIPS’19), Paper 372, page 4134–4144, 2019.
arXiv:1812.03584.
204[151] I. Kerenidis and A. Prakash. Quantum recommendation systems. In Proceedings of 8th
Innovations in Theoretical Computer Science Conference, volume 67 of Leibniz International
Proceedings in Informatics, pages 49:1–49:21, 2017. arXiv:1603.08675.
[152] I. Kerenidis and R. de Wolf. Exponential lower bound for 2-query locally decodable codes
via a quantum argument. Journal of Computer and System Sciences, 69(3):395–420, 2004.
Earlier version in STOC’03. quant-ph/0208062.
[153] S. Kimmel, G. H. Low C. Lin, M. Ozols, and T. Yoder. Hamiltonian simulation with optimal
sample complexity. npj Quantum Information, 3(13), 2017. arXiv:1608.00281.
[154] A. Kitaev and J. Watrous. Parallelization, amplification, and exponential time simulationof quantum interactive proof systems. In Proceedings of 32nd ACM STOC, pages 608–617,
2000.
[155] A. Yu. Kitaev. Quantum measurements and the Abelian stabilizer problem.
ph/9511026, 12 Nov 1995.

quant-[156] A. Yu. Kitaev. Quantum NP, January 1999. Talk given at AQIP’99 conference, DePaul
University, Chicago.
[157] B. Klartag and O. Regev. Quantum one-way communication is exponentially stronger thanclassical communication. In Proceedings of 43rd ACM STOC, 2011. arXiv:1009.3640.
[158] A. Klivans and D. van Melkebeek. Graph nonisomorphism has subexponential size proofs
unless the polynomial-time hierarchy collapses. SIAM Journal on Computing, 31(5):1501–
1526, 2002. Earlier version in STOC’99.
[159] M. Knill, R. Laflamme, and W. Zurek. Threshold accuracy for quantum computation. quantph/9610011, 15 Oct 1996.
[160] D. E. Knuth. The Art of Computer Programming. Volume 2: Seminumerical Algorithms.
Addison-Wesley, third edition, 1997.
[161] C-Y. Lai and H-C. Cheng. Learning quantum circuits of some T gates. IEEE Transactions
on Information Theory, 68(6):3951–3964, 2022. arXiv:2106.12524.
[162] F. Le Gall. Improved quantum algorithm for triangle finding via combinatorial arguments.
In Proceedings of 55th IEEE FOCS, pages 216–225, 2014. arXiv:1407.0085.
[163] T. Lee, F. Magniez, and M. Santha. Improved quantum query algorithms for triangle finding
and associativity testing. Algorithmica, 77(2):459–486, 2017. arXiv:1210.1014.
[164] T. Lee, R. Mittal, B. Reichardt, R. Špalek, and M. Szegedy. Quantum query complexity ofstate conversion. In Proceedings of 52nd IEEE FOCS, pages 344–353, 2011. arXiv:1011.3020.
[165] A. K. Lenstra and H. W. Lenstra, Jr. The Development of the Number Field Sieve, volume1554 of Lecture Notes in Mathematics. Springer, 1993.
[166] H. W. Lenstra, Jr. and C. Pomerance. A rigorous time bound for factoring integers. Journalof the American Mathematical Society, 5:483–516, 1992.
205

[167] L. Levin. Universal search problems (translated from the Russian). Problems of Information
Transmission, 9(3):115––116, 1973.
[168] L. Lin.
Lecture notes on quantum algorithms for scientific computation, 2022.
arXiv:2201.08309.
[169] L. Lin and Y. Tong. Optimal quantum eigenstate filtering with application to solving quantum
linear systems. arXiv:1910.14596, 31 Oct 2019.
[170] Y.-K. Liu. Consistency of local density matrices is QMA-complete. In Proceedings of 10th
International Workshop on Randomization and Computation (RANDOM 2006), volume 4110
of Lecture Notes in Computer Science, pages 438–449, 2006. quant-ph/0604166.
[171] Y.-K. Liu, M. Christandl, and F. Verstraete. Quantum computational complexity of the Nrepresentability problem: QMA complete. Physical Review Letters, 98(110503), 2007. quantph/0609125.
[172] S. Lloyd. Universal quantum simulators. Science, 273:1073–1078, 1996.
[173] S. Lloyd, M. Mohseni, and P. Rebentrost. Quantum algorithms for supervised and unsupervised machine learning, 1 Jul 2013. arXiv:1307.0411.
[174] S. Lloyd, M. Mohseni, and P. Rebentrost. Quantum principal component analysis. Nature
Physics, 10:631–633, 2013. arXiv:1307.0401.
[175] H-K. Lo and H. F. Chau. Unconditional security of quantum key distribution over arbitrarily
long distances. Science, 283:2050–2056, 1999. quant-ph/9803006.
[176] G. H. Low and I. L. Chuang. Hamiltonian simulation by uniform spectral amplification.
arXiv:1707.05391, 17 Jul 2017.
[177] G. H. Low and I. L. Chuang. Hamiltonian simulation by qubitization. arXiv:1610.06546, 20
Oct 2016.
[178] G. H. Low and I. L. Chuang. Optimal Hamiltonian simulation by quantum signal processing.
Physical Review Letters, 118(1):010501, 2017. arXiv:1606.02685.
[179] G. H. Low, T. J. Yoder, and I. L. Chuang. Methodology of resonant equiangular composite
quantum gates. Physical Review X, 6(4):041067, 2016. arXiv:1603.03996.
[180] R. A. Low. Learning and testing algorithms for the Clifford group. Physical Review A,
80(052314), 2009. arXiv:0907.2833.
[181] C. Lund, L. Fortnow, H. Karloff, and N. Nisan. Algebraic methods for interactive proof
systems. Journal of the ACM, 39(4):859–868, 1992. Earlier version in FOCS’90.
[182] F. Magniez, A. Nayak, J. Roland, and M. Santha. Search via quantum walk. SIAM Journal
on Computing, 40(1):142–164, 2011. Earlier version in STOC’07. quant-ph/0608026.
[183] F. Magniez, M. Santha, and M. Szegedy. Quantum algorithms for the triangle problem. In
Proceedings of 16th ACM-SIAM SODA, pages 1109–1117, 2005. quant-ph/0310134.
206

[184] U. Mahadev. Classical verification of quantum computations. In Proceedings of 59th IEEE
FOCS, pages 259–267, 2018. arXiv:1804.01082.
[185] Y. Manin. Vychislimoe i nevychislimoe (computable and noncomputable). Soviet Radio,
pages 13–15, 1980. In Russian.
[186] Y. Manin. Classical computing, quantum computing, and Shor’s factoring algorithm. quantph/9903008, 2 Mar 1999.
[187] C. Marriott and J. Watrous. Quantum Arthur-Merlin games. Computational Complexity,
14(2):122–152, 2005. Earlier version in CCC’04. arXiv:cs/0506068.
[188] D. Mayers. Unconditional security in quantum cryptography. quant-ph/9802025, 10 Feb
1998.
[189] M. Mohri, A. Rostamizadeh, and A. Talwalkar. Foundations of Machine Learning. MIT
Press, second edition, 2018.
[190] C. Moore, D. N. Rockmore, and A. Russell. Generic quantum Fourier transforms. ACM
Transactions on Algorithms, 2(4):707–723, 2006. quant-ph/0304064.
[191] C. Moore, A. Russell, and L. Schulman. The symmetric group defies strong Fourier sampling.
SIAM Journal on Computing, 37(6):1842–1864, 2008. quant-ph/0501056+66. Earlier version
in FOCS’05.
[192] M. Mosca and A. Ekert. The hidden subgroup problem and eigenvalue estimation on aquantum computer. In Proceedings of 1st NASA QCQC conference, volume 1509 of Lecture
Notes in Computer Science, pages 174–188. Springer, 1998. quant-ph/9903071.
[193] A. Nayak. Optimal lower bounds for quantum automata and random access codes. In
Proceedings of 40th IEEE FOCS, pages 369–376, 1999. quant-ph/9904093.
[194] I. Newman. Private vs. common random bits in communication complexity. Information
Processing Letters, 39(2):67–71, 1991.
[195] I. Newman and M. Szegedy. Public vs. private coin flips in one round communication games.
In Proceedings of 28th ACM STOC, pages 561–570, 1996.
[196] M. A. Nielsen and I. L. Chuang. Quantum Computation and Quantum Information. Cambridge University Press, 2000.
[197] R. O’Donnell and J. Wright. Efficient quantum tomography. In Proceedings of 48th ACM
STOC, pages 899–912, 2016. arXiv:1508.01907.
[198] C. H. Papadimitriou. Computational Complexity. Addison-Wesley, 1994.
[199] A. Peruzzo, J. McClean, P. Shadbolt, M-H. Yung, X-Q. Zhou, P. Love, A. Aspuru-Guzik,
and J. O’Brien. A variational eigenvalue solver on a photonic quantum processor. Nature
Communications, 3:24, 2014.
[200] J. Preskill. Fault-tolerant quantum computation. In H-K. Lo, S. Popescu, and T. P. Spiller,
editors, Introduction to Quantum Computation. World Scientific, 1998. quant-ph/9712048.
207

[201] J. Preskill. Quantum computing 40 years later. In A. Hey, editor, Feynman Lectures on
Computation. Taylor & Francis Group, second edition, 2022. arXiv:2106.10522.
[202] A. Razborov. Quantum communication complexity of symmetric predicates. Izvestiya of theRussian Academy of Sciences, mathematics, 67(1):159–176, 2003. quant-ph/0204025.
[203] P. Rebentrost, M. Mohseni, and S. Lloyd. Quantum support vector machine for big dataclassification. Physical Review Letters, 113(13):130503, 2014. arXiv:1307.0471.
[204] O. Regev. On lattices, learning with errors, random linear codes, and cryptography. Journalof the ACM, 56(6):34:1–34:40, 2009. Earlier version in STOC’13.
[205] B. Reichardt. Span programs and quantum query complexity: The general adversary boundis nearly tight for every Boolean function. In Proceedings of 50th IEEE FOCS, pages 544–551,
2009.
[206] B. Reichardt. Faster quantum algorithm for evaluating game trees. In Proceedings of 22nd
ACM-SIAM SODA, pages 546–559, 2011. arXiv:0907.1623.
[207] B. Reichardt. Span programs are equivalent to quantum query algorithms. SIAM Journal
on Computing, 43(3):1206–1219, 2014.
[208] B. Reichardt and R. Špalek. Span-program-based quantum algorithm for evaluating formulas.
Theory of Computing, 8:291–319, 2012. Earlier version in STOC’08. arXiv:0710.2630.
[209] J. Riordan and C. E. Shannon. The number of two-terminal series-parallel networks. Journalof Mathematics and Physics, 21:83––93, 1942.
[210] R. Rivest, A. Shamir, and L. Adleman. A method for obtaining digital signatures and publickey cryptosystems. Communications of the ACM, 21:120–126, 1978.
[211] R. L. Rivest. Cryptography. In van Leeuwen [239], pages 717–755.
[212] T. J. Rivlin and E. W. Cheney. A comparison of uniform approximations on an interval anda finite subset thereof. SIAM Journal on Numerical Analysis, 3(2):311–320, 1966.
[213] S. Saeedi and T. Arodz. Quantum sparse support vector machines, 2019. arXiv:1902.01879.
[214] S. Saeedi, A. Panahi, and T. Arodz. Quantum semi-supervised kernel learning. Quantum
Machine Intelligence, 3:24, 2021.
[215] M. Saks and A. Wigderson. Probabilistic Boolean decision trees and the complexity of evaluating game trees. In Proceedings of 27th IEEE FOCS, pages 29–38, 1986.
[216] M. Santha. Quantum walk based search algorithms. In Proceedings of 5th TAMC, pages
31–46, 2008. arXiv/0808.0059.
[217] T. Santoli and C. Schaffner. Using Simon’s algorithm to attack symmetric-key cryptographic
primitives. Quantum Information and Computation, 17(1& 2):65–78, 2017. arXiv:1603.07856.
[218] A. Schönhage and V. Strassen. Schnelle Multiplikation grosser Zahlen. Computing, 7:281–292,
1971.
208

[219] U. Schöning. A probabilistic algorithm for k-SAT and constraint satisfaction problems. In
Proceedings of 40th IEEE FOCS, pages 410–414, 1999.
[220] N. Schuch and F. Verstraete. Computational complexity of interacting electrons andfundamental limitations of density functional theory. Nature Physics, 5:732–735, 2009.
arXiv:0712.0483.
[221] M. Schuld and N. Killoran. Quantum machine learning in feature Hilbert spaces. PhysicalReview Letters, 122(13):040504, 2019. arXiv:1803.07128.
[222] M. Schuld and F. Petruccione. Machine Learning with Quantum Computers. Springer, second
edition, 2021.
[223] S. Shalev-Shwartz and S. Ben-David. Understanding machine learning: From theory to algorithms. Cambridge University Press, 2014.
[224] A. Shamir. IP = PSPACE. Journal of the ACM, 39(4):869–877, 1992. Earlier version in
FOCS’90.
[225] A. Shen. IP = PSPACE: Simplified proof. Journal of the ACM, 39(4):878–880, 1992.
[226] A. Sherstov. Approximating the AND-OR tree. Theory of Computing, 9(20):653–663, 2013.
[227] P. W. Shor. Scheme for reducing decoherence in quantum memory. Physical Review A,
52:2493, 1995.
[228] P. W. Shor. Polynomial-time algorithms for prime factorization and discrete logarithms on aquantum computer. SIAM Journal on Computing, 26(5):1484–1509, 1997. Earlier version in
FOCS’94. quant-ph/9508027.
[229] V. Shoup. Lower bounds for discrete logarithms and related problems. In Proceedings ofEurocrypt’97, volume 1233 of Lecture Notes in Computer Science, pages 256–266. Springer,
1997. Revised version available at http://www.shoup.net/papers/dlbounds1.pdf.
[230] D. Simon. On the power of quantum computation. SIAM Journal on Computing, 26(5):1474–
1483, 1997. Earlier version in FOCS’94.
[231] R. Špalek and M. Szegedy. All quantum adversary methods are equivalent. Theory of Computing, 2(1):1–18, 2006. Earlier version in ICALP’05, quant-ph/0409116.
[232] A. Steane. Multiple particle interference and quantum error correction. In Proceedings of theRoyal Society of London, volume A452, pages 2551–2577, 1996. quant-ph/9601029.
[233] M. Szegedy. Quantum speed-up of Markov chain based algorithms. In Proceedings of 45th
IEEE FOCS, pages 32–41, 2004. quant-ph/0401053.
[234] E. Tang. A quantum-inspired classical algorithm for recommendation systems. In Proceedingsof 51st ACM STOC, pages 217–228, 2019. arXiv:1807.04271.
[235] B. M. Terhal. Quantum error correction for quantum memories. Reviews of Modern Physics,
87:307, 2015. arXiv:1302.3428.
209

[236] L. Trevisan. Some applications of coding theory in computational complexity. Quaderni diMatematica, 13:347–424, 2004.
[237] A. M. Turing. On computable numbers, with an application to the Entscheidungproblem. In
Proceedings of the London Mathematical Society, volume 42, pages 230–265, 1936. Correction,
ibidem (vol. 43), pages 544–546.
[238] L. Valiant. A theory of the learnable. Communications of the ACM, 27(11):1134–1142, 1984.
[239] J. van Leeuwen, editor. Handbook of Theoretical Computer Science. Volume A: Algorithms
and Complexity. MIT Press, Cambridge, MA, 1990.
[240] L. Vandersypen, M. Steffen, G. Breyta, C. Yannoni, R. Cleve, and I. Chuang. Experimental
realization of an order-finding algorithm with an NMR quantum computer. Physical Review
Letters, 85(25):5452–5455, 2000. quant-ph/0007017.
[241] V. Vapnik and A. Chervonenkis. On the uniform convergence of relative frequencies of eventsto their probabilities. Theory of Probability & Its Applications, 16(2):264–280, 1971. English
translation of 1968 Russian paper in Dokl. Akad. Nauk. 181(4).
[242] T. Vidick and J. Watrous. Quantum proofs. Foundations and Trends in Theoretical Computer
Science, 11(1–2):1—-215, 2015.
[243] J. Watrous. Succinct quantum proofs for properties of finite groups. In Proceedings of 41stIEEE FOCS, pages 537–546, 2000. quant-ph/0011023.
[244] J. Watrous. Quantum algorithms for solvable groups. In Proceedings of 33rd ACM STOC,
pages 60–67, 2001.
[245] J. Watrous. PSPACE has 2-round quantum interactive proof systems. Theoretical Computer
Science, 292(3):575–588, 2003. Earlier version in STOC’99. arXiv:cs/9901015.
[246] J. Watrous. Quantum computational complexity. In Encyclopedia of Complexity and Systems
Science. Springer, 2009. arXiv:0804.3401.
[247] J. Watrous. The Theory of Quantum Information. Cambridge University Press, 2018. Available at https://cs.uwaterloo.ca/~watrous/TQI/.
[248] R. de Wolf. Quantum Computing and Communication Complexity. PhD thesis, University of
Amsterdam, 2001.
[249] W. K. Wootters and W. H. Zurek. A single quantum cannot be copied. Nature, 299:802–803,
1982.
[250] A. C-C. Yao. Some complexity questions related to distributive computing. In Proceedingsof 11th ACM STOC, pages 209–213, 1979.
[251] A. C-C. Yao. Quantum circuit complexity. In Proceedings of 34th IEEE FOCS, pages 352–360,
1993.
[252] S. Yekhanin. Towards 3-query locally decodable codes of subexponential length. Journal of
the ACM, 55(1), 2008. Earlier version in STOC’07.
210