2024 Kueng Quantum Computing
2024 Kueng Quantum Computing
4 Two-qubit circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.1 Classical reversible operations on 2 bits 45
4.1.1 Combining single-bit operations in parallel . . . . . . . . . . . . . . . . . . . . . 46
4.1.2 The Kronecker product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2 Quantum operations on 2 qubits 50
4.2.1 Quantum gates on 2 qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2.2 Quantum states on 2 qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2.3 Universal 2-qubit gate sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.2.4 Example 1: CNOT with control and target flipped . . . . . . . . . . . . . . . . . 54
4.2.5 Example 2: a two-bit random number generator . . . . . . . . . . . . . . . . . 55
6 Entanglement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.1 Entanglement 70
6.1.1 Rotated Bell states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2 The CHSH game and Bell inequalities 73
6.2.1 The CHSH game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.2.2 Optimal classical strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.2.3 Optimal quantum strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3 CHSH rigidity and monogamy of entanglement 79
6.4 Bell inequalities and the violation of local realism 79
6.5 The E91 protocol for quantum key distribution 80
7 Quantum teleportation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.1 Motivation 83
7.2 Background: marginal and conditional probabilities 85
7.2.1 Marginal probabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.2.2 Conditional probability distributions . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.2.3 Example 1: Bell state readout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
7.2.4 Example 2: Drawing straws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.3 Quantum 𝑇 -gate teleportation 91
7.4 Quantum state teleportation 94
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
1. Motivation and outline
The fundamental theorem of arithmetic states that every positive integer has
a unique prime factorization (if we arrange the factors in non-decreasing
order, i.e. 𝐹𝑖 − 1 ≤ 𝐹𝑖 ). And it is relatively easy to check that the maximum
number of factors 𝑚 must obey 𝑚 ≤ log2 (𝑁 ) ≈ 𝑛 . So, there can never be
too many factors. Also, and more remarkably, it is possible to check that each
proposed factor 𝐹𝑖 is actually a prime number. This is courtesy of the AKS
algorithm which also scales polynomially in 𝑛 . Together, these two insights
ensure that it is always possible to efficiently check whether a proposed integer
factorization (1.1) is valid. Here, efficiently means that the number of required
2 Lecture 1: Motivation and outline
operations scales (at most) polynomially in the representation size 𝑛 (bit length)
of 𝑁 .
But, how can we actually find an integer factorization in the first place?
The easiest algorithm is trial division which goes back to Fibonacci and is
often taught in middle school: systematically test whether 𝑁 is divisible by a
smaller number. For instance, 12 = 2 × 6 = 2 × 2 × 3 which is a valid integer
factorization. This algorithm works well if there are a lot of small prime factors,
because it is comparatively cheap to identify those. And subsequent divisions
reduce the remaining problem size considerably. But, trial division can become
extremely resource-intensive if this is not the case. The worst case occurs if
𝑁 √= 𝐹 0 × 𝐹 1 , where 𝐹 0 < 𝐹1 are unknown prime numbers of comparable size
≈ 𝑁 . In such a situation, we need very many trial divisions to find the √ first
prime factor. Indeed,√naively trying all numbers between 2 and 𝐹 0 ≈ 𝑁
requires a total of ≈ 𝑁 trial divisions. This number alone is exponentially
large in the bit size 𝑛 required to represent 𝑁 :
√
𝑁 = 𝑁 1/2 = 2log2 (𝑁 )/2 ≈ 2𝑛/2 .
It is possible to considerably improve the (worst-case) runtime of trial division cost of factoring algorithms
by only considering numbers that prime to begin with (e.g. don’t try 4, 6, 9, . . . scales super-polynomially in
at all). But, this is not enough to overcome this general worst-case scaling. The bit size 𝑛
number of required operations for every trial division variant known to date is
still dominated by 2𝑛/2 . It should be noted that trial division is not the best
known algorithm for integer factorization. But even the best current state of
the art – the general number field sieve – cannot factor a 𝑛 -bit number with
a number of basic operations that scales polynomially in 𝑛 . This feature is hardness of factoring is basis
actually exploited by widely employed cryptography schemes, most notably of RSA public-key encryption
RSA public-key encryption.
To summarize: integer factorization is an example of a problem that is
difficult to solve (best known algorithms scale exponentially in input size), but
easy to verify (correctness of a proposed factorization (1.1) can be checked in
only polynomially many steps). This is the trademark structure of a wide and
important class of problems – the problem class NP which you might remember
from your computational complexity lecture. Other example problems of this
kind include 3-SAT, the traveling salesman problem, knapsack, minesweeper
and many more. But, among NP-problems, integer factorization is special.
Firstly, we have strong reasons to believe that it is not quite as difficult as other
problems, like 3-SAT. Secondly, and more importantly for this course, we have
omitted an important detail in our discussion of known factoring algorithms.
We actually know an algorithm that is capable of factoring a 𝑛 -bit number
using a number of elementary operations that scales only polynomially in 𝑛 –
Shor’s algorithm. The “only” caveat is that this algorithm cannot be executed Shor’s algorithm can factor
on conventional hardware, but requires a different type of hardware that is integers efficiently, but
more expressive – a quantum computer. We will discuss the precise workings requires a quantum computer
of this breakthrough algorithm in this class, but also the underlying type of
computational model.
3 Lecture 1: Motivation and outline
input problem
CPU QPU
readout problem
macroscopic world quantum realm
The term Quantum Processing Unit (QPUs) captures the intended purpose more
accurately than the colloquially used term quantum computer. QPUs are not quantum computers are
designed to supersede conventional computers (like CPUs or GPUs) as a whole, special-purpose processing
but are specialized processing units that can further augment computing power. units (QPUs)
The result is a hybrid quantum-classical computer, schematically illustrated in
Figure 1.1. This combination produces a completely new and different type
of computing architecture that comes with novel opportunities, but also novel
challenges. We will discuss both throughout the course of this lecture.
5 Lecture 1: Motivation and outline
remains a global player in ion trap quantum computing. The spin-off company
Alpine Quantum Technologies is the first European company that actually sets
out to sell these quantum computers.
Optical architectures
So far, we have mainly talked about quantum computing platforms. But these
are only one aspect of the larger field of quantum technology. When it comes photons carry quantum
to communication and networks – think internet – light is a very promising information
carrier of information. Light can quickly and reliably cover large distances
to convey information. And, it comes in discrete packages of ‘light particles’,
called photons. These photons can be used to represent a qubit, e.g. via
7 Lecture 1: Motivation and outline
Synopsis
The above explanations are extremely crude and superficial, they sweep a lot of
important and groundbreaking insights under the rug. But we hope that they
convey a high-level message: it is actually possible to build quantum computing
platforms and there are, in fact, several ways to do so. And each comes
with their own advantages and disadvantages. It should also be noted that different ways to realize QPUs
qubits and elementary operations (single qubit + two-qubit) are not enough
by themselves. We also need a way to initialize the qubits (qubit initialization)
and way to access the final result (qubit readout). We will discuss all these
ingredients in the next lecture. It is also important to note that all these
operations are challenging (we operate on the tiniest scales imaginable) and
not perfect. Every operation is bound to incur a small error. And these errors
can, and do, accumulate when we start combining many operations to build
a larger circuit. Today, this severely hampers our ability to scale up quantum
computing technology. There are, however, ways to overcome these issues. We
will briefly cover this topic of quantum error correction towards the end of this
course.
8 Lecture 1: Motivation and outline
class. And this includes small-scales realizations of the most famous quantum
algorithms we know to date! Playtime will have arrived by January and the
exercise classes culminate in a group project where you really discuss and
implement a small-scale variant of a famous quantum algorithm. This should
be fun!
For the remainder of this chapter – and most lectures further down the road
– we adopt a hardware perspective and represent QPUs by quantum circuits.
Today, we focus on circuits that affect a single quantum bit, called qubit. We qubit = quantum bit
will see that these circuits can execute well-known logical functionalities (e.g.
negation), but other elementary gates don’t have a classical counterpart at
all. For illustrative purposes, we will heavily use the Quantum Circuit Library
developed by our very own JKU team member Jadwiga Wilkens [Wil23].
Equivalently, we can fully capture this (trivial) action by the following truth
table:
0 1
0 1 0 (identity truth table). (2.1)
1 0 1
A full pipeline with qubit initialization, identity gate (blue) and readout stage
looks as follows:
(2.2)
As intended, the final output bit 𝑜 is equal to the input bit 𝑏 . In formulas:
𝑜 = 𝑏 . This showcases that we can use a single-qubit QPU to reliably store one
bit of information within the quantum realm and recover it exactly at some
later point in time.
Another important logical gate is the negation, or bit-flip, operation: bit-flip (𝑿 )
0 1
0 0 1 (bit-flip truth table). (2.3)
1 1 0
(2.4)
Together, Eq. (2.2) and Eq. (2.4) showcases that we can use a hybrid quantum-
classical pipeline to implement the two most important single-bit operations.
13 Lecture 2: Single qubit circuits I
This, in particular, means that identity and bit-flip are reversible logical oper-
ations. They do not erase any information about the input bit. In fact, their
action can be readily undone by applying the same gate again. Note that not all
conceivable single-bit functions have this feature. There are in total 4 Boolean
functions that map a single bit onto a single bit. Identity and bit-flip are two of
them. The other two correspond to re-setting the bit to one particular value.
I.e. 𝑓 (𝑏) = 0 (reset to 0) or 𝑓 (𝑏) = 1 (reset to 1), for 𝑏 ∈ {0, 1}. Clearly, these
re-set operations are not reversible, because they completely erase the input bit.
The quantum implementations of identity and bit-flip do adhere to reversibility.
This is captured by the following streamlined circuit diagram equations: QPUs can execute reversible
single-bit logic
. (2.5)
, (2.6)
where ‘w.p. 1/2’ is short for ‘with probability 1/2’. This classical-quantum-
classical pipeline takes an arbitrary single-bit input 𝑏 and produces a uniformly
random output bit. We write
unif
𝑜 ∼ {0, 1}
to denote that 𝑜 = 0 and 𝑜 = 1 happen with equal probability 1/2 each. This
feature is a striking deviation from conventional logic which is fundamentally
deterministic. The execution of a Hadamard gate uses an interesting quantum
14 Lecture 2: Single qubit circuits I
effect, called superposition: a binary quantum system (qubit) can assume both
bit values at the same time.
If we readout (measure) such a superposition of binary values, the outcome
bit we obtain is truly random: both 𝑜 = 0 and 𝑜 = 1 occur with equal
probability. This is the same situation as a fair coin flip. The Hadamard gate
provides the means to observe true randomness by bringing a qubit into equal
superposition. And, equally strikingly, we can use another Hadamard gate to
exit superposition again. Much like identity and bit-flip, the Hadamard gate is
also reversible. In fact, it is its own inverse as well:
. (2.7)
Together, Eq. (2.6) and Eq. (2.7) reveal a striking quantum phenomenon. The
first equation showcases that the Hadamard gate can be used to generate
uniformly random bits. In standard binary logic, randomization requires an
external seed and cannot be undone without erasing the bit in question. Or,
put differently: the only way to map a random bit 𝑟 into a deterministic bit 𝑜
is to erase and reset. This breaks any correlations with the original input bit 𝑏 .
The Hadamard gate, however, is not like this at all! We can apply it twice to
completely undo its effect and recover a perfect correlation between input bit
𝑏 and output bit 𝑜 . This is impossible in classical logic (even when we allow for
true randomness).
The ‘truth table’ of the Hadamard gate reflects this, because it doesn’t
adhere to the rules of conventional logic:
0 1
√ √
0 1/ 2 1/ 2 (Hadamard ‘truth table’).
√ √
1 1/ 2 −1/ 2
The detailed numbers in this table should become clear later on. For now, we
emphasize two things:
(i) the magnitude of each entry is the same, that is 0 and 1 feature in equal
measure within the superposition;
(ii) the two rows (columns) are distinct. This means that information about
the input qubit is actually preserved.
We conclude this section with another quantum logic gate, the sign-flip gate.
The ‘truth table’ of the Hadamard gate already suggests that quantum logic can sign-flip (𝒁 )
feature positive and negative numbers. The sign-flip is used to change the sign
of the 1-contribution within a superposition:
0 1
0 1 0 (sign-flip ‘truth table’).
1 0 −1
15 Lecture 2: Single qubit circuits I
, (2.8)
which looks identical to the action of the identity gate in Eq. (2.2). Also, much
like the identity gate (and every other gate we’ve encountered so far), the
sign-flip gate is also it’s own reverse:
. (2.9)
, (2.10)
Definition 2.1 (single-qubit state vector). The state of a single qubit keeps track of
its quantum logical value. At each point, it is given by a 2-dimensional vector state of a qubit is a
normalized 2D vector
𝜓0
|𝜓 ⟩ := 𝝍 = ∈ ℂ2 .
𝜓1
The individual coefficients can be complex-valued numbers, but must obey
∥| 0⟩∥ 2 = ∥𝒆 0 ∥ 2 = | 1 | 2 + | 0 | 2 = 1,
∥| 1⟩∥ 2 = ∥𝒆 1 ∥ 2 = | 0 | 2 + | 1 | 2 = 1.
■
As Definition 2.1 suggests, state vectors can be used to keep track of qubits
throughout a sequence of quantum logical gates. This, however, necessitates a
formalism to unambiguously characterize the action of quantum gates. And a
way to imprint their action onto the current state vector of a qubit.
Definition 2.3 (single-qubit gate action). A single-qubit gate is fully described by
a 2 × 2 matrix single-qubit gates are unitary
2 × 2 matrices (‘truth tables’)
𝑈0,0 𝑈0,1
𝑼 = ∈ ℂ2×2 .
𝑈1,0 𝑈1,1
The action of gate 𝑼 on quantum state |𝜓 ⟩ = 𝝍 ∈ ℂ2 is captured by matrix-
vector multiplication : gate action on qubit state =
matrix-vector multiplication
𝑈0,0 𝑈0,1 𝜓0 𝑈0,0𝜓0 + 𝑈0,1𝜓1
|𝜓final ⟩ = 𝝍 final = 𝑼𝝍 = = ∈ ℂ2 .
𝑈1,0 𝑈1,1 𝜓1 𝑈1,0𝜓0 + 𝑈1,1𝜓1
What is more, each gate matrix 𝑼 must be unitary and, therefore, reversible:
†
𝑈¯0,0 𝑈¯1,0
† † 1 0 𝑈0,0 𝑈0,1
𝑼 𝑼 = 𝑼𝑼 = , where = (2.12)
0 1 𝑈1,0 𝑈1,1 𝑈¯0,1 𝑈¯1,1
denotes matrix adjungation (transposition plus taking complex conjugates1).
1Recall that the complex conjugate of a complex number 𝑧 = 𝑎 + i𝑏 is defined as 𝑧¯ = 𝑎 − i𝑏 .
17 Lecture 2: Single qubit circuits I
It is easy to check that both matrices are unitary matrices. What is more,
1 0 1 1
𝕀| 0⟩ =𝕀𝒆 0 = = = 𝒆 0 = | 0⟩,
0 1 0 0
1 0 0 0
𝕀| 1⟩ =𝕀𝒆 1 = = = 𝒆 1 = | 1⟩,
0 1 1 1
Exercise 2.5 (matrix representation of the Hadamard gate). The matrix representa-
tion of the Hadmard gate is given as
√ √
1/ 2 1/ 2
𝑯 = √ √ ∈ ℂ2×2 .
1/ 2 −1/ 2
1 1
|+⟩ =𝑯 | 0⟩ = 𝑯 𝒆 0 = √ (𝒆 0 + 𝒆 1 ) = √ (| 0⟩ + | 1⟩) , (2.13)
2 2
1 1
|−⟩ =𝑯 | 1⟩ = 𝑯 𝒆 1 = √ (𝒆 0 − 𝒆 1 ) = √ (| 0⟩ − | 1⟩) . (2.14)
2 2
Both expressions on the very right should be interpreted as ‘both 0 and
1 in equal measure’. Note, however that one combination has a ‘+’
inbetween, while the other one has a ‘−’. This sign difference ensures
that both superpositions remain distinct and can be undone again.
18 Lecture 2: Single qubit circuits I
|𝜓final ⟩ = 𝝍 final = 𝑼 𝑁 × · · · × 𝑼 2 × 𝑼 1𝝍 ∈ ℂ2 .
In words: we start our matrix-vector multiplication on the very right and keep
going. The convention to read circuit diagrams from left to right as well exactly
resembles this ordering:
. (2.15)
We now have all the pieces in place to initialize a qubit and keep track of its
state throughout a sequence of arbitrary many single qubit gates. All that is
missing now is a formula for executing the readout at the very end. That is, we
need to assign meaning to the following operation:
.
19 Lecture 2: Single qubit circuits I
.
20 Lecture 2: Single qubit circuits I
unif
This is just the definition of a perfect random bit 𝑜 ∼ {0, 1}. ■
Figure 2.3 Schematic illustration of the BB84-protocol: Alice and Bob use a
single-qubit circuit to communicate a single bit of information (purple). Each
player obfuscates this identity channel by either applying 𝕀 (do nothing) or 𝑯
(enter/leave superposition). If both players happen to apply the same gate, the
transmission is perfect (𝑠 = 𝑟 ). Otherwise, the output bit is completely random
unif
(𝑠 ∼ {0, 1}) . This dichotomy is impossible to achieve classically and allows
for sharing a key and detecting person in the middle attacks.
(i) Eve’s success: Eve guesses Alice’s obfuscation gate 𝑼 𝑎 correctly. Then,
she can perfectly recover Alice’s bit (𝑡 = 𝑟 ) and can re-initialize the qubit
22 Lecture 2: Single qubit circuits I
to exactly the correct quantum logical value. In so doing, she hides her
eavesdropping activity from Bob.
(ii) Eve’s failure: Eve doesn’t guess Alice’s obfuscation gate 𝑼 𝑎 correctly.
Then, she destroys the underlying bit message, gets a completely random
unif
bit (𝑡 ∼ {0, 1}) and re-initalizes the qubit with an uncorrelated, random
bit value.
And here is where things get interesting. If Alice uses private randomness
unif
to decide her obfuscation action (i.e. 𝑎 ∼ {0, 1}), then Eve has no way to
anticipate her move. And, in turn, she must fail about half of the time. Crucially,
whenever she guesses wrong, she re-inserts a random bit value to Bob. And
this interference can now be detected! After all, Alice and Bob expect to get
perfectly correlated bits whenever they happen to execute the same obfuscation
gate (which happens in about 1/2 of all cases): 𝑟 = 𝑠 . An interception of
Eve in the middle must break this perfect correlation. And repeating the
protocol sufficiently often (with new private randomness in each go) will allow
Alice+Bob to detect eavesdropping by comparing some of their input/output
values over a public channel. More precisely, they execute 𝑇 ≫ 1 rounds
of their protocol and, after completion, they broadcast their private random
bitstrings 𝒂, 𝒃 ∈ {0, 1}𝑇 . This allows them to discard all uncorrelated bits
and focus on the instances where perfect correlations should happen: 𝑎𝑡 = 𝑏𝑡
should imply 𝑠𝑡 = 𝑟𝑡 . This already shrinks the possible bits to roughly 𝑇 /2.
They then select certain instances within this remaining string to check whether
𝑠𝑡 = 𝑟𝑡 is actually true. This is again achieved via public communication over
insecure channels. An instance where 𝑠𝑡 ≠ 𝑟𝑡 rises suspicion. Assuming the
hardware works perfectly as intended (which is a very strong assumption), this
can only be the signature of an eavesdropper!
This ability to detect actions of an eavesdropper are a core feature of
23 Lecture 2: Single qubit circuits I
quantum cryptography protocols. Here, we have only scratched the surface and
discussed the key ideas behind one of the oldest and most basic protocols of this
type. However, at this point, you have all the information you need to execute
a proper analysis of the entire protocol – under the additional assumption
that Eve intercepts in the middle via readout plus initialization and only uses
single-qubit gates that mimic the actions of Alice and Bob.
Exercise 2.9 (complete analysis of the BB84-protocol). Perform a rigorous treat-
ment of the BB84-protocol under the additional assumption that Eve’s gates are
𝑽 ,𝑽 ′ ∈ {𝕀, 𝑯 }. This results in a total of 2 × 4 × 2 = 16 different incarnations
of the intercepted protocol – one for each choice of 𝑎 (Alice), as well as 𝑽 ,𝑽 ′
(Eve) and 𝑏 (Bob). How many of these incarnations lead to a undetectable and
successful attack, i.e. 𝑠 = 𝑟 , as well as 𝑡 = 𝑟 ? How many of these incarnations
leave traces of Eve’s actions that can be detected by Alice and Bob? And how
unif
many leave Eve completely clueless, i.e,. 𝑡 ∼ {0, 1}?
Use your findings to argue that Eve does not stand a chance if Alice+Bob repeat
the protocol many times and use private randomness to choose 𝑎 and 𝑏 .
It turns out that the aforementioned assumptions on the type of attack can
be removed completely. A proper security analysis for any type of quantum
attack did take another 29 years to come up with [Tom+13]. Needless to say,
these arguments go beyond the scope of this introductory lecture.
Problems
Problem 2.10 (random number generator). Do the computation in Example 2.8
for input bit 𝑏 = 0.
Problem 2.11 (gate composition rule). Prove Proposition 2.6.
Problem 2.12 (Reversibility of all gates introduced so far). Use the sequential gate
composition rule (Proposition 2.6) to rigorously prove the following circuit
24 Lecture 2: Single qubit circuits I
identities:
This, in particular, ensures that all these gates are reversible and to constitute
their own inverses.
Problem 2.13 (some useful circuit identities). Use the sequential gate composition
rule (Proposition 2.6) to rigorously prove the following circuit identities:
Note that this implies that two Hadamard gates convert 𝑿 -gate (bit-flip) into 𝒁 -
gate (sign-flip) and vice versa. Hint: use the following matrix representations
of all gates involved:
√ √
0 1 1 0 1/ 2 1/ 2
𝑿 = , 𝒁 = and 𝑯 = √ √ .
1 0 0 −1 1/ 2 −1/ 2
Problem 2.14 (matrix representation of the Hadamard gate, see Exercise 2.5). The
matrix representation of the Hadamard gate is given as
√ √
1/ 2 1/ 2
𝑯 = √ √ ∈ ℂ2×2 .
1/ 2 −1/ 2
1 1
|+⟩ =𝑯 | 0⟩ = 𝑯 𝒆 0 = √ (𝒆 0 + 𝒆 1 ) = √ (| 0⟩ + | 1⟩) , (2.18)
2 2
1 1
|−⟩ =𝑯 | 1⟩ = 𝑯 𝒆 1 = √ (𝒆 0 − 𝒆 1 ) = √ (| 0⟩ − | 1⟩) . (2.19)
2 2
Both expressions on the very right should be interpreted as ‘both 0 and
1 in equal measure’. Note, however that one combination has a ‘+’
inbetween, while the other one has a ‘−’. This sign difference ensures
that both superpositions can be undone again.
3 Verify reversibility by showing 𝑯 2 = 𝕀 via matrix-vector multiplication.
Problem 2.15 (complete analysis of the BB84-protocol, see Exercise 2.9). Perform a
rigorous treatment of the BB84-protocol under the additional assumption that
Eve’s gates are 𝑽 ,𝑽 ′ ∈ {𝕀, 𝑯 }. This results in a total of 2 × 4 × 2 = 16 different
incarnation of the intercepted protocol – one for each choice of 𝑎 (Alice), as
well as 𝑽 ,𝑽 ′ (Eve) and 𝑏 (Bob). How many of these incarnations lead to a
undetectable and successful attack, i.e. 𝑠 = 𝑟 , as well as 𝑡 = 𝑟 ? How many of
these incarnations leave traces of Eve’s actions that can be detected by Alice
unif
and Bob? And how many leave Eve completely clueless, i.e,. 𝑡 ∼ {0, 1}?
Use your findings to argue that Eve does not stand a chance if Alice+Bob repeat
the protocol many times and use private randomness to choose 𝑎 and 𝑏 .
3. Single qubit circuits II
(3.1)
This deep result is known as the fundamental theorem of algebra. The collection
of all such 𝑧 ’s forms the field of complex numbers ℂ. Much like normal numbers,
we can add complex numbers using familiar rules: addition & multiplication
𝑧 + 𝑧 ′ = (𝑎 + i𝑏) + (𝑎 ′ + i𝑏 ′ ) = (𝑎 + 𝑎 ′ ) + i (𝑏 + 𝑏 ′ ) ,
i.e. we add real and imaginary parts of complex numbers separately. Multiplica-
tion takes a bit more work and we must also use the formal definition i2 = −1
to obtain
+i
iR
C
exp (iϕ)
−1 ϕ +1 exp (iϕ)
sin(ϕ)
ϕ
R
−i cos(ϕ)
Figure 3.1 Complex unit circle (left) and Euler’s formula (right): (Left) It is
instructive to view the field of complex numbers as a 2-dimensional plane
(real+imaginary part). The unit circle within this plane contains complex
numbers 𝑧 ∈ ℂ with absolute value |𝑧 | = 1. These are called complex
phases and can be parametrized by a single angle 𝜑 . (Right) Euler’s theorem
provides the justification for our notation of complex phases: exp ( i 𝜑 ) =
cos (𝜑 ) + i sin ( 𝜑 ) .
The 𝑥 -coordinate tabulates the purely real part (ℝ), while the 𝑦 -coordinate
tabulates the purely imaginary part (iℝ). General complex numbers have
nontrivial coordinates in both and therefore live in a complex plane. Prominent
real and imaginary numbers obey |𝑧 | = 1, e.g. | + 1 | = | − 1 | = 1 and also
| + i | = | − i | = 1. These four points therefore live on the unit circle within the
complex plane. We refer to Fig. 3.1 (left) for a visual
√ illustration.
Complex numbers 𝑧 ∈ ℂ that obey |𝑧 | = 𝑧¯𝑧 = 1 are called (complex)
phases. These are points on the complex unit circle and can be conveniently complex phase
represented by a single angle 𝜑 ∈ [ 0, 2𝜋) in radiants1:
cos (𝜑 )
𝒛= ∈ ℝ2 ⇔ 𝑧 = cos (𝜑 ) + i sin (𝜑 ) ∈ ℂ.
sin (𝜑 )
Finally, we can use Euler’s theorem to compactly express the right-hand repre-
sentation as a single exponential function:
exp ( i 𝜑 ) = cos ( 𝜑 ) + i sin (𝜑 ) . (3.3)
The geometric intuition behind this celebrated result is displayed in Fig. 3.1
(right). We leave a rigorous proof as an instructive exercise at the end of this
section.
Example 3.1 (‘showoff’ formula). The following mathematical formula combines
i, e and 𝜋 in a perfectly correct fashion:
ei𝜋 = exp ( i𝜋) = −1.
It describes an angle representation of the ‘west pole’ (−1) on the complex unit
circle (recall that 180◦ ↔ 𝜋 ). ■
1Here are the conversion rules for the four most important angles: 0◦ ↔ 0, 90◦ ↔ 𝜋/2,
180◦ ↔ 𝜋 , 270◦ ↔ 3𝜋/4 and 360◦ ↔ 2𝜋 .
29 Lecture 3: Single qubit circuits II
The last thing we need to know about complex phases is that they play
nicely with each other when it comes to multiplication. Let exp ( i 𝜑 ) =
cos (𝜑 ) + i sin (𝜑 ) and exp ( i 𝜑 ′ ) = cos (𝜑 ′ ) + i sin (𝜑 ′ ) be two complex phases.
We can use the multiplication rule (3.2) and trigonometric identities to compute
Fact 3.2 (complex phase). A complex number 𝑧 ∈ ℂ is called a complex multiplication rule for
√
phase if |𝑧 | = 𝑧¯ × 𝑧 = 1. It can be represented as 𝑧 = exp ( i 𝜑 ) , where complex phases
𝜑 ∈ [0, 2𝜋) is a single angle. Multiplication of two complex phases is the
same as adding the corresponding angles, i.e.
Let us do a simple example that cycles through the four prominent points on
the complex unit circle:
i = exp ( i𝜋/2) ,
2
i =i × i = exp ( i𝜋/2) × exp ( i𝜋/2) = exp ( i (𝜋/2 + 𝜋/2)) = exp ( i𝜋) = −1,
i3 =i × i2 = exp ( i𝜋/2) × exp ( i𝜋) = exp ( i (𝜋/2 + 𝜋)) = exp ( i3𝜋/2) = −i,
i4 =i × i3 = exp ( i𝜋/2) × exp ( i3𝜋/2) = exp ( i (𝜋/2 + 3𝜋/2)) = exp ( i2𝜋) = 1.
Exercise 3.3 (Proof of Euler’s theorem). Prove Eq. (3.3) by using i2 = −1 and the
following three Taylor series expansions:
∑︁∞ 𝑧 𝑘 ∑︁∞ 𝑧 2𝑘 ∑︁∞ 𝑧 2𝑘 +1
exp (𝑧) = , cos (𝑧) = (−1) 𝑘 , sin (𝑧) = (−1) 𝑘 .
𝑘 =0 𝑘 ! 𝑘 =0 ( 2𝑘 ) ! 𝑘 =0 ( 2𝑘 + 1) !
Figure 3.2 Schematic illustration of a single-qubit processor from Lecture 2 (see also
Fig. 2.2 there): a single-qubit processor takes a single bit 𝑏 ∈ {0, 1} as input
and produces a single-bit output 𝑜 ∈ {0, 1}. The logic in-between is executed
on the quantum level, where different logical operations become available. The
readout stage is also special and can give rise to true randomness.
This qubit state vector is a 2-dimensional vector with complex entries that can
be used to keep track of the quantum logic content when we apply quantum
gates. The action of each single-qubit gate is described by a complex-valued
matrix 𝑼 ∈ ℂ2 × 2 that is also unitary, i.e. 𝑼 †𝑼 = 𝑼𝑼 † = 𝕀. The action of one
gate matrix 𝑼 on state vector |𝜓 ⟩ = 𝝍 can be computed with matrix-vector
multiplication:
′ 𝑈0,0 𝑈0,1 𝜓0 𝑈0,0𝜓0 + 𝑈0,1𝜓1
𝝍 = 𝑼𝝍 = = .
𝑈1,0 𝑈1,1 𝜓1 𝑈1,0𝜓0 + 𝑈1,1𝜓1
Note that each formula features the absolute value of a complex number. And
such absolute values are invariant under multiplication with any complex phase
exp ( i 𝜑 ) :
Example 3.4 (states). The following four state vectors all describe a logical 0 bit
(‘everything is in zero’):
1 i −1 −i
| 0⟩ = , +i | 0⟩ = , −| 0⟩ = , −i | 0⟩ = .
0 0 0 0
■
31 Lecture 3: Single qubit circuits II
Example 3.5 (gates). The following two unitary matrices describe the same gate
action:
exp (−i𝜋/8) 0 1 0
and .
0 exp ( i𝜋/8) 0 exp ( i𝜋/4)
■
Non-example 3.6 (states). The following two states are not equivalent
√ √
1 +1/√2 1 1/ 2
|+⟩ = √ (| 0⟩ + | 1⟩) = and | i+⟩ = √ (| 0⟩ + i | 1⟩) = √ ,
2 +1/ 2 2 i/ 2
This phase invariance of both state vectors and gate actions is an important
feature of quantum computing and also deserves a prominent display.
Fact 3.7 (phase invariance of state vectors and gate matrices). Two state vectors phase invariance of state
|𝜓 ⟩, |𝜓 ′ ⟩ encode the same information content if |𝜓 ′ ⟩ = exp ( i 𝜑 ) |𝜓 ⟩ for vectors & gate matrices
some 𝜑 ∈ [ 0, 2𝜋) . Likewise, two gate matrices 𝑼 , 𝑼 ′ encode the same
action if 𝑼 ′ = exp ( i 𝜑 ′ ) 𝑼 for some 𝜑 ′ ∈ [ 0, 2𝜋) . If this is the case, we
succinctly write
|𝜓 ′ ⟩ = 𝝍 ′ ∼ 𝝍 = |𝜓 ⟩ and also 𝑼 ′ ∼ 𝑼 .
The quantum circuit model allows us to combine these elementary gates to con-
struct new quantum logical functionalities. Note that many gate combinations
must be trivial because both 𝑿 and 𝑯 are reversible. In particular,
𝑿 2 = 𝑿 × 𝑿 = 𝕀 and 𝑯 2 = 𝑯 × 𝑯 = 𝕀,
. (3.4)
Each of them features the minus sign in a different location. We can also
sandwich the 𝑿 gate between two 𝑯 s to obtain the sign-flip gate: sign-flip gate 𝒁
. (3.5)
This matrix 𝒁 is also called the Pauli-z gate, while 𝑿 is known as the Pauli-x
gate. Finally, we can combine 𝑿 and 𝒁 to get an action that is equivalent to
the Pauli-y gate 𝒀 :
0 −1 0 −i 0 −i
𝑿𝒁 = = (−i) ∼ =𝒀, (3.6)
1 0 i 0 i 0
where we have used the gate invariance under global phases from Fact 3.7. This
phase invariance of quantum gate actions, in fact, also implies that we are done.
We cannot reach any new functionalities anymore. Also, note that Eq. (3.5)
allows us to replace the elementary 𝑿 -gate with an elementary 𝒁 -gate. After
all, we can transform one into the other by investing two Hadamard gates.
Lemma 3.8 The two elementary gates 𝑿 (bit-flip) and 𝑯 (Hadamard) generate
a total of 8 functionally distinct quantum functionalities: one identity (𝕀), three
Pauli gates (𝑿 ,𝒀 , 𝒁 ) and four Hadamard-type gates displayed Eq. (3.4).
We leave a proof of this technical statement as an instructive exercise
that can be easily automated. Fig. 3.3 tries to visualize this as actions on
the Bloch sphere. The Bloch sphere is a convenient geometric representation
of single-qubit states that you might have seen in the Quantum Information
lecture. It uses a geometric analogy between single-qubit state vectors (with Bloch sphere representation
of single-qubit state vectors
(optional)
33 Lecture 3: Single qubit circuits II
introduces complex numbers into our gate model. It is also closely related to
the sign-flip gate. Indeed,
2 1 0 1 0 1 0 1 0
𝑺 =𝑺 ×𝑺 = × = = = 𝒁,
0 i 0 i 0 i2 0 −1
The phase gate is the first gate we encounter that is not its own reverse. If we
want to undo the action of 𝑺 , we must apply 𝑺 † = 𝑺 3 . A single application of
the phase gate inserts complex numbers into rows or columns of existing gate
matrix descriptions. Whether it is rows or columns depends on the ordering of
gates. For instance,
1 0 1 1 1 1 1 1
𝑺 ×𝑯 = ×√ =√ , while
0 i
2 2 1 −1 i −i
1 1 1 1 0 1 1 i
𝑯 × 𝑺 =√ × =√ .
2 1 −1 0 i 2 1 −i
We can now use a combination of 𝑺 and 𝑯 to generate the actual Pauli-Y matrix
from Eq. (3.6):
𝒀 = 𝑺 × 𝑯 × 𝒁 × 𝑯 × 𝑺 3.
34 Lecture 3: Single qubit circuits II
Figure 3.3 All 8 functionally distinct quantum gates formed from only the gates 𝑿
and 𝑯 applied to the zero | 0⟩ state visualized on a Bloch Sphere.
35 Lecture 3: Single qubit circuits II
Theorem 3.11 (universal gate set). Together, the elementary Clifford gates Hadamard+T generate every
𝑯 , 𝑺 and the T-gate 𝑻 form a universal gate set: Every 2 × 2 unitary matrix 2 × 2 unitary matrix
can be approximated to an arbitrary degree with sequences comprised of
only 𝑯 and 𝑻 (we actually don’t need 𝑺 , because 𝑺 = 𝑻 2 ).
This powerful statement stems from group theory and a proof would go
beyond the scope of this lecture. Here, we instead emphasize the implications.
There are infinitely many unitary 2 × 2 matrices that are distinct from each
other (even if we take into account phase invariance). Nonetheless, we can
approximate each and every such matrix with sequential quantum circuits that
only feature 𝑯 (Hadamard) and 𝑻 (T-gate). What is more, such universal
gate sets are easy to find. The elementary Clifford gates {𝑯 , 𝑺 } only need one
additional non-Clifford gate 𝑼 to become universal2. The precise nature of this
additional third gate 𝑼 does not matter at all!
2For technical reasons, we might actually need one additional gate 𝑼 , as well as its inverse
𝑼 †.
36 Lecture 3: Single qubit circuits II
Figure 3.4 (a) A Bloch sphere showing the labeling of the axis. (b) The single qubit
quantum states reached with only combinations of 𝑿 and 𝑯 , see Lemma 3.8. (c)
The single qubit quantum states reached with only Clifford gates, see Definition 3.10.
(d) The single qubit quantum states reached with arbitrary long combinations of
Clifford gates and the 𝑻 gate as stated in Theorem 3.11.
Theorem 3.12 (efficient single-qubit synthesis (Solovay-Kitaev Theorem)). Let efficient single-qubit circuit
a synthesis
G be a universal gate set , e.g. G = {𝑯 ,𝑻 } and let 𝜀 be a desired
approximation accuracy. Then, for every unitary 2 × 2 matrix 𝑼 , there
exists a sequence of (at most)
Some elementary gate sets even achieve 𝑐 = 1, in which case Eq. (3.7) is
tight up to a constant factor. We emphasize that the required circuit depth
only scales (poly)logarithmically in the desired target accuracy. Or, to put it
differently: (after some burn-in period,) the approximation error of a quantum
37 Lecture 3: Single qubit circuits II
Lemma 3.14 All three Pauli rotations are 2𝜋 -periodic (up to a global phase) and
obey an angle addition rule. In formulas, we have for 𝑤 = 𝑥, 𝑦 , 𝑧 ,
regardless of 𝜃 , 𝜃 ′ ∈ ℝ.
Again, we leave a rigorous derivation as an instructive exercise. Note that
this angle addition rule is very similar to the phase multiplication rule from
Fact 3.2. Lemma 3.14 ensures 𝑅𝑤 (𝜃 ) ∝ 𝑅𝑤 (𝜃 mod 2𝜋) (2𝜋 -periodicity) and
also completely specifies the reverse operation:
Now suppose that we execute multiple Pauli rotations around the same axis.
Then, a similar argument highlights that the order of rotations does not matter:
𝑹 𝑤 (𝜃 )𝑹 𝑤 (𝜃 ′ ) = 𝑹 𝑤 (𝜃 + 𝜃 ′ ) = 𝑹 𝑤 (𝜃 ′ + 𝜃 ) = 𝑹 𝑤 (𝜃 ′ )𝑹 𝑤 (𝜃 ).
This means that we can accumulate and/or permute different Pauli rotations
of the same kind at will – an extremely useful feature. The following circuit
visualization depicts a straightforward extension of this formula to 𝐷 + 1
different rotations: rotations across same axis
play nicely
, (3.10)
𝑹 𝑤 (𝜃 )𝑹 𝑤 ′ (𝜃 ) ≠ 𝑹 𝑤 ′ (𝜃 ′ )𝑹 𝑤 (𝜃 ) whenever 𝑤 ≠ 𝑤 ′
𝜋
1 1+𝑖 1−𝑖
12 𝑹𝑥 × 𝑹 𝑦 − 𝜋2
−1 − 𝑖 1 − 𝑖
2 2
1 1 + 𝑖 −1 + 𝑖
13 𝑹 𝑥 − 𝜋2 × 𝑹 𝑦 𝜋
1+𝑖 1−𝑖
2 2
1 1−𝑖 1+𝑖
14 𝑹 𝑥 − 𝜋2 × 𝑹 𝑦 − 𝜋2
1+𝑖 1+𝑖
−
2
𝜋
𝜋
1 1 + 𝑖 −1 − 𝑖
15 𝑹𝑦 × 𝑹𝑥
−𝑖 1−𝑖
2 2 2 1
1 1−𝑖 1−𝑖
16 𝑹 𝑦 − 𝜋2 × 𝑹 𝑥 𝜋
1−𝑖 1+𝑖
−
2 2
𝜋
1 1 − 𝑖 −1 + 𝑖
17 𝑹𝑦 × 𝑹 𝑥 − 𝜋2
1+𝑖 1+𝑖
2 2
1 1+𝑖 1+𝑖
18 𝑹 𝑦 − 𝜋2 × 𝑹 𝑥 − 𝜋2 2 −1 + 𝑖 1 −𝑖
√
𝜋
2 1 1
19 𝑿 𝑹𝑦
1 −1
2 2
√
2 −1 1
20 𝑿 𝑹 𝑦 − 𝜋2 2
√
1 1
𝜋
2 −1 −𝑖
21 𝒀 𝑹𝑥 2 2
𝑖 1
√
2 1 −𝑖
22 𝒀 𝑹 𝑥 − 𝜋2 2 𝑖 −1
√
𝜋
𝜋
𝜋
2 0 −1 − 𝑖
23 𝑹𝑥 × 𝑹𝑦 × 𝑹𝑥
1−𝑖
2 2 2 2 0
√
2 0 −1 + 𝑖
24 𝑹 𝑥 − 𝜋2 × 𝑹 𝑦 𝜋
× 𝑹 𝑥 − 𝜋2
2 2 1+𝑖 0
Table 3.1 All single-qubit Clifford gates that can be constructed using only 𝑯
(Hadamard) and 𝑺 (phase). The first column also provides a decomposition
into (at most) 3 Pauli rotations and/or Pauli gates.
40 Lecture 3: Single qubit circuits II
This angle is exactly twice as large as the angle required for the T-gate.
3 The sign gate 𝒁 is equivalent to a 𝑧 -rotation with angle 𝜃 = 𝜋 :
exp (−i𝜋/2) 0 1 0
𝑹 𝑧 (𝜋) = ∼ = 𝒁.
0 exp ( i𝜋/2) 0 exp ( i𝜋)
This angle is exactly twice as large as the angle required for the phase
gate and four times as large as the angle required for the T-gate.
4 The Hadamard gate 𝑯 is equivalent to a combination of an 𝑥 -rotation
and a 𝑦 -rotation with angle 𝜋 and 𝜋/2 each:
𝑹 𝑥 (𝜋) × 𝑹 𝑦 (𝜋/2)
cos (𝜋/2) −i sin (𝜋/2) cos (𝜋/4) − sin (𝜋/4)
= ×
−i sin (−𝜋/2) cos (𝜋/2) sin (𝜋/4) cos (𝜋/4)
0 1 1 1 −1 1 1 1
=(−i) ×√ = (−i) √ ∼ 𝑯.
1 0 2 1 1 2 1 −1
(3.11)
This circuit cleverly exploits a cute feature of the parity: the parity of a sum is
the sum of the parities modulo 2. In this strategy, each student computes the
parity of their number and, once she receives the bit, she either flips it (if their
number is odd) or does nothing (if their number is even). This ensures that the
final outcome bit is
In words: the outcome bit is 1 if and only if 𝑘 tot is an odd number. Otherwise, it
evaluates to 0. Executing this strategy allows the students to win this restricted
parity of sum computation with certainty.
So, let’s increase the difficulty level. Instead of distributing integers
𝑘 0 , . . . , 𝑘𝐷 −1 ∈ ℤ, the instructor now distributes rational numbers 𝑘 0 , . . . , 𝑘𝐷 −1 ∈
ℚ (i.e. fractions) with the additional promise that the total sum 𝑘 tot =
𝑘 0 + · · · + 𝑘𝐷 −1 ∈ ℤ still adds up to an integer value. He then asks the students
to come up with a strategy that again only involves a single bit of commu-
nication between them. This modification is quite nasty because the parity
is not well-defined for general rational numbers. This prevents the students
from re-using their winning strategy from before. In fact, we believe that it is
42 Lecture 3: Single qubit circuits II
. (3.12)
Instead of an individual bit, the students now pass an individual qubit between
themselves. They can choose to apply a quantum gate and/or perform a readout
and initialize a new qubit. A moment of thought reveals that only the very
last student should perform an actual readout. And only the very first student
should initialize their qubit. All students in the middle apply a quantum gate
that depends on the fraction 𝑘𝑑 ∈ ℚ they received. The strategy depicted in
Eq. (3.12) suggests to use a Pauli-y rotation across angle 𝜃𝑘 = 𝜋𝑘 . The phase
addition rule for Pauli rotations from Eq. (3.10) highlights why this strategy is
a good idea:
𝑹 𝑦 (𝜋𝑘𝐷 −1 ) × · · · × 𝑹 𝑦 (𝜋𝑘 0 ) = 𝑹 𝑦 (𝜋 (𝑘𝐷 −1 + · · · + 𝑘 0 )) = 𝑹 𝑦 (𝜋𝑘 tot ) .
Or, in pictures:
And, with the additional promise that 𝑘 tot is integer, we can conclude that
the final state vector is
|𝜓 (𝑘 tot )⟩ =𝑹 𝑦 (𝜋𝑘 tot )| 0⟩
cos (𝜋𝑘 tot /2) − sin (𝜋𝑘 tot /2) 1
=
sin (𝜋𝑘 tot /2) cos (𝜋𝑘 tot /2) 0
cos (𝜋𝑘 tot /2)
=
− sin (𝜋𝑘 tot /2)
(
±| 0⟩ if 𝑘 tot even,
=
±| 1⟩ if 𝑘 tot odd.
43 Lecture 3: Single qubit circuits II
So, going quantum allows the students to always win a very constrained
multi-player challenge for which no optimal classical strategy is known.
Problems
Problem 3.17 (Proof of Euler’s theorem, see Exercise 3.3). Prove exp ( i 𝜑 ) = cos (𝜑 )+
i sin (𝜑 ) by using i2 = −1 and the following three Taylor series expansions:
∑︁∞ 𝑧 𝑘 ∑︁∞ 𝑧 2𝑘 ∑︁∞ 𝑧 2𝑘 +1
exp (𝑧) = , cos (𝑧) = (−1) 𝑘 , sin (𝑧) = (−1) 𝑘 .
𝑘 =0 𝑘 ! 𝑘 =0 ( 2𝑘 ) ! 𝑘 =0 ( 2𝑘 + 1) !
Problem 3.18 (Finding all gates generated by 𝑯 and 𝒁 , see Exercise 3.9). Verify
the correctness of Lemma 3.8 by writing a piece of code that generates gate
combinations of certain length, computes their matrix representation via matrix-
matrix multiplication and terminates once no new functionally distinct matrices
can be achieved (i.e. all newly generated matrices are equivalent to existing
ones up to a global phase).
Problem 3.19 (formal proofs of matrix exponential identities, see Exercise 3.16).
A 1-qubit quantum processing unit (QPU) is a great starting point for gaining Agenda:
a better understanding of the distinctions between classical and quantum
1 motivation
computing by introducing the concept of superposition. However, to harness
2 classical operations and
the full power of quantum phenomena in quantum computing, we require a
their truth tables
multi-qubit QPU and new logical quantum operations that address (at least) 2 3 Kronecker product vs.
qubits matrix product
In this lecture, we make a first step in this direction and delve into the 4 XOR and CNOT gate
world of 2-qubit gate logic. We begin by exploring the classical bit level, first 5 universal 2-qubit gate
making sure that the gates are reversible, then examining concepts like the set and its implications
sequential and parallel application of logical gates with a truth table, which are
Figure 4.1 Schematic illustration of a two-qubit processor: Input and output consist
of 2 combined conventional bits. In-between, depicted in blue, the 2-qubit logic
operates at the quantum level.
45 Lecture 4: Two-qubit circuits
Figure 4.2 Illustration of all 1-bit logical operations as maps. (a) The identity
operation (do nothing), a valid reversible mapping; (b) the bit-flip operation,
another valid reversible mapping; (c) a reset to 0, not reversible.
Figure 4.3 Illustration of some 2-bit logical operations as maps. (a) and (b) are
examples of reversible mappings. (c) and (d) are examples of mappings that
are not reversible: In (c) 01 is mapped to both 00 and 10 and in (d) both 00
and 01 are mapped to 00.
00 01 10 11 00 01 10 11
00 0 0 1 0 00 0 1 0 0
01 0 0 0 1 01 1 0 0 0
10 1 0 0 0 10 0 0 0 1
11 0 1 0 0 11 0 0 1 0
(a) Flipping the first bit (b) Flipping the second bit
00 01 10 11 00 01 10 11
00 0 0 0 1 00 1 0 0 0
01 0 0 1 0 01 0 1 0 0
10 0 1 0 0 10 0 0 1 0
11 1 0 0 0 11 0 0 0 1
Figure 4.4 Logical truth tables for all parallel combinations of bit flip (𝑿 ) and
identity (𝕀). Fig. 4.5 displays the corresponding quantum circuit realizations.
Figure 4.5 Quantum circuits that realize all parallel combinations of bit flip (𝑿 )
and identity (𝕀). (a) flip the first bit and leave the second. (b) flip the second
bit and leave the first. (c) flip both bits at the same time (parallel). (d) don’t
do anything to both bits. Fig. 4.4 depicts the associated truth tables.
The order of gates, or rather the matrices underneath, within the Kronecker
product ⊗ is crucial since gates left of the ⊗ are only acting on the first (qu)bit
and gates written on the right are only acting on the second (qu)bit. This
is similar to the fact that ordering also matters a lot in the ordinary matrix
product × which describes sequential gate applications: 𝑨 × 𝑩 ≠ 𝑩 × 𝑨 in
general. An example for the importance of ordering can be seen in Chapter
3 where the different combinations of 𝑯 and 𝑿 are shown, more precisely
Equation 3.4. Looking at the matrix representation it very clearly shows that
𝑯 × 𝑿 ≠ 𝑿 × 𝑯.
The same holds for the Kronecker product, in general, 𝑨 ⊗ 𝑩 ≠ 𝑩 ⊗ 𝑨 . This Ordering of gates matters!
can already be seen in the truth table representation of bit-flip and identity
combinations in Fig. 4.4: 𝑿 ⊗ 𝕀 ≠ 𝕀 ⊗ 𝑿 .
(𝑨 ⊗ 𝑩) × (𝑪 ⊗ 𝑫) = (𝑨 × 𝑪 ) ⊗ (𝑩 × 𝑫). (4.1)
This has a neat consequence to grasp what it means to apply two gates in
parallel: When you use two gates at the same time, it’s kind of like using one
gate on the first bit and leaving the other bit alone. Then you use the second
gate on the other bit, while keeping the first one unchanged with an identity
gate. Putting this explanation into an equation gives
(𝑨 ⊗ 𝕀) × (𝕀 ⊗ 𝑩) = (𝑨 ⊗ 𝑩).
49 Lecture 4: Two-qubit circuits
It is easy to count the total number of classical 2-bit truth tables (matrices)
which arise from Kronecker products of reversible single-bit operations. In
circuit language, this corresponds to the parallel application of single-bit gates
and there are exactly 2 × 2 = 4 of them (either 𝑿 or 𝕀 on each bit). This number
(4) is much smaller than the total number of reversible two-bit circuits (24).
So, there must be circuits whose truth table cannot be expressed as a single
Kronecker product.
One such gate is a reversible implementation of the XOR operation, called
Controlled Not or CNOT in quantum computing. This operation flips the truth
content of the second bit if and only if the first bit value is 1. Else if the first bit
value is 0, nothing happens: 2-bit CNOT gate
00 01 10 11
00 1 0 0 0
01 0 1 0 0 (CNOT0→1 ’truth table’). (4.2)
10 0 0 0 1
11 0 0 1 0
This operation always requires 2 bits: a control bit and a target bit. Here the
first bit denoted as 0 is the control bit and the second bit denoted as 1 is the
target bit, written as 0 → 1 in the caption of the CNOT. Note that CNOT can be
viewed as a reversible implementation of the exclusive or, or XOR, operation:
CNOT0→1 (𝑏 0 , 𝑏 1 ) = (𝑏 0 , XOR (𝑏 0 , 𝑏 1 )) = (𝑏 0 , 𝑏 0 ⊕ 𝑏 1 ) .
In quantum computing, we use the following symbol to denote a 2-(qu)bit
CNOT gate:
(4.3)
Control and target (qu)bit are clearly singled out in this symbol. There is also
the CNOT1→0 operation, where control and target qubit are flipped. We will
discuss it in a later subsection.
Since information is flowing from the control bit to the target bit, this gate
cannot be viewed as acting separately on the first and separately on the second
bit. It always acts simultaneously on both bits and cannot be written in any
other way if there are only two bits available.
50 Lecture 4: Two-qubit circuits
1 0 1 0
1 1 1 1 0 1 0 −1 0 −1
© ª
𝑯 ⊗𝒁 = √ ⊗ =√ (4.4)
®
®.
2 1 −1 0 −1 2 1 0 −1 0 ®
« 0 −1 0 1 ¬
Note that this 4 × 4 matrix is again a unitary matrix. In fact, it is its own reverse.
Using Eq. (4.1), we obtain
(𝑯 ⊗ 𝒁 ) × (𝑯 ⊗ 𝒁 ) = (𝑯 × 𝑯 ) ⊗ (𝒁 × 𝒁 ) = 𝕀 ⊗ 𝕀,
i.e. do nothing on the first qubit and do nothing on the second qubit. ■
This display succinctly summarizes a total of four possible input state vectors:
1 0
1 1 0 ® 1 0 1 ®
© ª © ª
| 00⟩ = ⊗ = ®, | 01⟩ = ⊗ = ®,
0 0 0 ® 0 1 0 ®
« 0 ¬ « 0 ¬
0 0
0 1 0 ® 0 0 0 ®
© ª © ª
| 10⟩ = ⊗ = ®, | 11⟩ = ⊗ = ®.
1 0 1 ® 1 1 0 ®
« 0 ¬ « 1 ¬
Note that these four vectors are precisely the four different possibilities of a
4-dimensional vector with exactly one 1 and zero everywhere else. The position
of the single 1 is in one-to-one correspondence with the underlying bitstring.
A general 2-qubit state vector arises from applying (unitary) quantum gates
to one such initialization. This can produce complex-valued state entries, but
must not change the overall normalization of the state vector.
Definition 4.3 (2-qubit quantum state). The state of a 2-qubit system is character-
ized by a 4-dimensional state vector 2-qubit state vectors are
4-dim, normalized vectors
𝜓00 with complex-valued entries
© ª
𝜓
|𝜓 ⟩ = 𝝍 = 01 ® ∈ ℂ4 . (4.6)
®
𝜓10 ®
« 𝜓11 ¬
Each state vector entry corresponds to one of the 4 = 22 possible bit strings
(00, 01, 10, 11). The following reformulation makes this precise:
∑︁1
|𝜓 ⟩ = 𝜓00 | 00⟩ + 𝜓01 | 01⟩ + 𝜓10 | 10⟩ + 𝜓11 | 11⟩ = 𝜓𝑏 0𝑏 1 |𝑏 0𝑏 1 ⟩.
𝑏 0 ,𝑏 1 =0
The coefficients can be complex-valued numbers and must obey the normaliza-
tion condition
Analogous to 1-qubit quantum states, the state vector entries tell us the
relative contribution of a particular 2-bit string to the current quantum logical
content. A 2-qubit readout procedure converts them into probabilities of
observing the underlying bit string.
52 Lecture 4: Two-qubit circuits
Fact 4.4 (2-qubit readout). Let |𝜓 ⟩ ∈ ℂ4 be a 2-qubit state vector. Then, we can
perform a readout of both the first and second qubit. This results in a single
2-bit string 𝑜 0𝑜 1 ∈ {0, 1}2 and the probability of observing a concrete value is
given by the squared modulus of the underlying state vector (Born’s rule):
2
Pr |𝜓 ⟩ [𝑜 0𝑜 1 ] = 𝜓𝑜0𝑜1 for 𝑜 0𝑜 1 ∈ {0, 1}2 . (4.8)
Eq. (4.8) succinctly tabulates the following four outcome probabilities when
reading out a general 2-qubit state |𝜓 ⟩ :
𝜓0,0𝜓1,0
© ª
𝜓0 , 0 𝜓1,0 𝜓 𝜓
|𝜓 ⟩ = |𝜓0 ⟩ ⊗ |𝜓1 ⟩ = ⊗ = 0,0 1,1 ® ∈ ℂ4 . (4.9)
®
𝜓0 , 1 𝜓1,1 𝜓0,1𝜓1,0 ®
« 𝜓0,1𝜓1,1 ¬
■
(𝑼 ⊗ 𝑽 ) (𝝍 0 ⊗ 𝝍 1 ) = 𝑼𝝍 0 ⊗ 𝑽 𝝍 1 . (4.10)
But not every 2-qubit quantum state is of this particular form! As discussed in
the classical 2-bit gate section, there are gates whose action cannot be described
as a single gate acting on the first qubit and another single gate acting on
the second qubit. As in the classical case the most prominent candidate is
the quantum CNOT gate whose matrix representation is indeed the same,
53 Lecture 4: Two-qubit circuits
see the truth table (4.2) and the diagram as written in Fig. 4.3. In quantum
computing, this gate and its properties have huge implications in terms of
computing strength in the quantum realm which will be discussed in more
detail in the next lecture. Much like in classical circuit logic, these operations
allow to conditionally modify qubits. This is essential to build more complicated
functionalities out of simple elementary building blocks.
Theorem 4.6 (efficient 2-qubit synthesis). Let G be a universal 2-qubit gate efficient 2-qubit circuit
seta , e.g. G = {𝑯 ,𝑻 , 𝑪 𝑵 𝑶𝑻 } and let 𝜀 ′ be a desired approximation synthesis
accuracy. Then, for every unitary 4 × 4 matrix 𝑼 containing 𝑚 𝑪 𝑵 𝑶𝑻
gates and arbitrarily many single-qubit gates, there exists a sequence of (at
most)
𝐷 = O (𝑚 log𝑐 (𝑚/𝜀 ′ )) (4.11)
gates that approximates the action of 𝑼 up to accuracy 𝜀 ′ . Here, 𝑐 ∈
[1, 3 + 𝑜 ( 1)] is a constant that depends on the universal gate set in question.
a Theoriginal statement also requires that this gate set either contains inverses or can
generate them in a constant number of steps.
This theorem resembles the Theorem 3.12 of the universal 1-qubit gate set with
the big difference that the number of one standing-out gate, the CNOT gate,
plays a role in the depth of the approximating circuit. This should at first be
surprising since this kind of special treatment of one gate did not happen in
the 1-qubit case. To grasp a better understanding of this above stated theorem,
we will look at the case where there is an arbitrary circuit with single-qubit
unitaries and 𝑚 CNOT gates, mixed randomly together.
Taking a closer look at the role of the CNOT gate, it becomes clear that any
application of it is a somehow disruptive operation conditionally modifying one
qubit state. If we would zoom into one wire, let’s say the wire of the second
qubit, all the single-qubit gate operations between two CNOT gates can be
summarized to one unitary (by simply calculating the matrix product of them).
This arbitrary unitary can now be approximated with O ( log𝑐 ( 1/𝜀)) many 𝑯
54 Lecture 4: Two-qubit circuits
Figure 4.6 Flipping CNOT control and target using 4 Hadamard gates. This
circuit identity shows that the target and control qubits can be interchanged
by applying a single-qubit Hadamard gate on every qubit before and after the
CNOT gate.
(𝑯 ⊗ 𝑯 ) 𝑪 𝑵 𝑶𝑻 (𝑯 ⊗ 𝑯 ) (4.12)
1 1 1 1 1 0 0 0 1 1 1 1
1 1 −1 1 −1 ® 0 1 0 0 ® 1 1 −1 1 −1 ®
© ª© ª © ª
= (4.13)
2 1 1 −1 −1 ® 0 0 0 1 ® 2 1 1 −1 −1 ®
® ® ®
« 1 −1 −1 1 ¬ « 0 0 1 0 ¬ « 1 −1 −1 1 ¬
1 0 0 0
0 0 0 1 ®
© ª
= ®. (4.14)
0 0 1 0 ®
« 0 1 0 0 ¬
55 Lecture 4: Two-qubit circuits
Figure 4.7 Random number generator with 2 qubits. This quantum circuit accepts
two classical bits, 𝑏 ∈ {0, 1} which initialize the two quantum states in either
| 0⟩ or | 1⟩ . Applying a Hadamard to both qubits and then measuring results in
two independent random bits.
Basic 2-bit logic now allows us to recognize the truth table of CNOT1→0 – i.e.
an XOR operation on the first bit – in the final matrix:
This result implies that by acting locally on the two qubits we can change the
flow of information!
𝜓00
© ª
𝜓01 ®
|𝜓 ⟩ = ® = (𝑯 ⊗ 𝑯 ) (| 1⟩ ⊗ | 1⟩)
𝜓10 ®
« 𝜓11 ¬
√ √ √ √
1/ 2 1/ 2 1/ 2 1/ 2 0 0
= √ √ ⊗ √ √ ⊗
1/ 2 −1/ 2 1/ 2 −1/ 2 1 1
1/2 1/2 1 /2 1 /2 0 1/2
1/2 − 1/2 1 / 2 − 1/2 ® ® 1/2
0 −
© ª© ª © ª
= ® ® =
®
®.
1/2 1/2 −1/2 −1/2 ® 0 ® −1/2 ®
« 1/2 −1/2 −1/2 1/2 ¬ « 1 ¬ « 1/2 ¬
Now recall that the outcome probabilities are the squared magnitudes of
the state vector entries, namely |𝜓0 ⟩, |𝜓1 ⟩, |𝜓2 ⟩, |𝜓3 ⟩ . Analogous to the rule
56 Lecture 4: Two-qubit circuits
for single-qubit readout (Definition 2.7), we now compute: every outcome is equally
likely
Pr |𝜓 ⟩ [ 00] = |⟨00 |𝜓 ⟩| 2 = |𝜓0 | 2 = | 1/2 | 2 = 1/4,
Pr |𝜓 ⟩ [ 01] = |⟨01 |𝜓 ⟩| 2 = |𝜓1 | 2 = |−1/2 | 2 = 1/4.
Pr |𝜓 ⟩ [ 10] = |⟨10 |𝜓 ⟩| 2 = |𝜓2 | 2 = |−1/2 | 2 = 1/4.
Pr |𝜓 ⟩ [ 11] = |⟨11 |𝜓 ⟩| 2 = |𝜓3 | 2 = | 1/2 | 2 = 1/4.
We see that all the possible 4 outcomes are equally likely. Let us now focus
only on the first bit, without loss of generality. The probability of measuring an
outcome 0 on it is given by
∑︁1
Pr [𝑜 0 = 0] = Pr [𝑜 0 = 0, 𝑜 1 = 𝑘 ] = 1/4 + 1/4 = 1/2.
𝑘 =0
unif
This is just the definition of a perfect random bit 𝑜 ∼ {0, 1} which we saw
in Example 2.8. We now have a device which can generate 2 random bits
simultaneously. It is important to note that these 2 bits are independent of each
other. This is not always the case and in the next two lectures, we will see
examples of creating correlations with quantum circuits which cannot be done
classically.
5. Bell states & Superdense Coding
Today, we will start analyzing and exploiting the extraordinary correlations Agenda:
that become possible when working with quantum circuits. As we shall see, the
(joint) quantum state of two qubits (𝑛 = 2) can be correlated in ways that are 1 Bell States
2 Equivalence Theorem
inconceivable from a classical perspective. This has both important conceptual
3 Superdense Coding
implications, as well as practical ones. 4 Implications for circuit
verification & learning
5.1 Motivation: The Bell state
Our starting point is the output of the following, seemingly innocuous, quantum
circuit, Fig. 5.1. It contains two qubits, one Hadamard (superposition) gate
and a CNOT (classical gate).
We can use the unitary matrix framework to compute all amplitudes of the
resulting quantum state:
Figure 5.1 Circuit generating a Bell state. This quantum circuit initializes both
qubits in 0, then applies Hadamard to the first qubit, followed by a CNOT.
58 Lecture 5: Bell states & Superdense Coding
Let us now compute the probability of each readout outcome in the same Bell state: √1 (| 00⟩ + | 11⟩)
2
manner as we did for the single-qubit quantum random number generator (see
Example 2.8 in Lecture 2):
√ 2
Pr |𝜓Bell ⟩ [𝑜 0 = 0, 𝑜 1 = 0] = |⟨00 |𝜓 ⟩| 2 = |𝜓0 | 2 = 1/ 2 = 1/2,
Pr |𝜓Bell ⟩ [𝑜 0 = 0, 𝑜 1 = 1] = |⟨01 |𝜓 ⟩| 2 = |𝜓1 | 2 = | 0 | 2 = 0.
Pr |𝜓Bell ⟩ [𝑜 0 = 1, 𝑜 1 = 0] = |⟨10 |𝜓 ⟩| 2 = |𝜓2 | 2 = | 0 | 2 = 0.
√ 2
Pr |𝜓Bell ⟩ [𝑜 0 = 1, 𝑜 1 = 1] = |⟨11 |𝜓 ⟩| 2 = |𝜓3 | 2 = 1/ 2 = 1/2.
Out of the four possible amplitudes, only two are nonzero and equal to 1/2.
This looks a lot like the value of two random coins that are perfectly correlated
with each other. Both coins always show the same value (0 or 1) with a perfectly correlated outcomes
probability of 1/2 each.
Case (b) (𝑯 on first qubit, 𝕀 on second qubit) pilots us into new territory. We
can use the matrix-vector framework to compute the 2-qubit state vector just
59 Lecture 5: Bell states & Superdense Coding
Figure 5.2 Four simple circuits including the Bell state. (a) Bell state followed
by a measurement. Outcomes are perfectly correlated. (b) A Hadamard gate
applied to the first qubit destroys the correlation. (c) A Hadamard gate applied
to the second qubit also destroys the correlation. (d) A Hadamard gate applied
to both qubits preserves the correlation.
This is the signature of two independent and uniformly random readout bits:
unif unif
Case (b): 𝑜 0 ∼ {0, 1} and 𝑜 1 ∼ {0, 1} .
60 Lecture 5: Bell states & Superdense Coding
The third case (c) (𝕀 on the first qubit and 𝑯 on the second qubit) paints a
picture that is strikingly similar to case (b):
Note that this final state vector is virtually identical to case (b). In turn,
performing the readout also yields the same result:
unif unif
Case (c): 𝑜 0 ∼ {0, 1} and 𝑜 1 ∼ {0, 1} .
The final case (d) (apply 𝑯 to the first qubit and apply 𝑯 to the second qubit)
produces a final state vector that is identical to case (a) (do nothing at all).
Figure 5.3 Local equivalence of Bell state. Applying a T gate on either of the two
qubits in a Bell state leads to the same final quantum state.
qubits! What is happening here? Is this because of the Hadamard gate or the
specific properties of the Bell state?
What is more, there does not exist a classical device which behaves in the
same way under such conditions. Namely, producing perfectly correlated bits,
then producing random bits if a Hadamard gate is applied to either register
and yet correlated ones if the Hadamard gate is applied to both. This is what No classical equivalence
we call stronger than classical correlations and you will see more examples of
this in future lectures.
For now, let us do a quick calculation with a different gate to see whether a
similar situation also arises.
Example 5.1 (T gate on one qubit of a Bell state while doing nothing to the other.). Let
us now consider the two circuits depicted in Fig. 5.3 and compute the final two
qubit state vector just prior to the readout stage. For the first circuit (𝑻 on first
qubit, 𝑰 on second qubit), we obtain
|𝜓final−left ⟩ = (𝑻 ⊗ 𝕀) |𝜓Bell ⟩
1
= (𝑻 ⊗ 𝕀) √ (| 00⟩ + | 11⟩)
2
1
= √ ((𝑻 ⊗ 𝕀) | 00⟩ + (𝑻 ⊗ 𝕀) | 11⟩)
2
1
= √ ((𝑻 | 0⟩) ⊗ (𝕀| 0⟩) + (𝑻 | 1⟩) ⊗ (𝕀| 1⟩))
2
1
=√ ( 1 × | 0⟩) ⊗ (+1 × | 0⟩) + ei𝜋/4 × | 1⟩ ⊗ (+1 × | 1⟩)
2
1 i𝜋/4
=√ 1 × 1 × | 00⟩ + e × 1 × | 11⟩
2
1
=√ | 00⟩ + ei𝜋/4 | 11⟩ .
2
This final result should not come as a complete surprise. The T-gate does
nothing to | 0⟩ and applies a phase shift by ei𝜋/4 to the | 1⟩ -state. Viewed from
this angle, it is also not really a surprise that the second circuit in Fig. 5.3
62 Lecture 5: Bell states & Superdense Coding
These are some of the properties that make the Bell State so special and worth
dedicating a whole lecture to! The above observations are a signature of a
more general and remarkable feature of the Bell state.
Theorem 5.2 (gate equivalence for Bell states). Let 𝑼 be an arbitrary single- Gate Equivalence
qubit unitary matrix. Then, (𝑈 ⊗𝕀)|𝜓Bell ⟩ = (𝕀⊗𝑈 ᵀ )|𝜓Bell ⟩
𝑼 ⊗ 𝕀|𝜓Bell ⟩ = (𝕀 ⊗ 𝑽 0 ) (𝕀 ⊗ 𝑽 1 ) · · · (𝕀 ⊗ 𝑽 𝑁 ) |𝜓Bell ⟩
=𝕀 ⊗ (𝑽 0𝑽 1 · · ·𝑽 𝑁 ) |𝜓Bell ⟩. (5.5)
63 Lecture 5: Bell states & Superdense Coding
Figure 5.4 Visualization of Corollary 5.3: The following three circuits are all
equivalent in the sense that they produce the same final quantum state. There
is no way of distinguishing these circuits.
■
Here is an immediate consequence of Theorem 5.2 that justifies the particular
result of circuit Fig. 5.2 (d) where applying Hadamard gates to both qubits did
not change the final state.
Corollary 5.3 Let 𝑼 ,𝑽 be arbitrary single-qubit gates. Then,
=𝕀 ⊗ 𝑽 × 𝑼 ᵀ |𝜓Bell ⟩.
Figure 5.5 Circuit generating all the four Bell states. Depending on the input bits,
𝑏 , a different state is generated.
𝑿 0 = 𝕀, 𝑿 1 = 𝑿 and 𝒁 0 = 𝕀, 𝒁 1 = 𝒁 .
65 Lecture 5: Bell states & Superdense Coding
Exercise 5.5 Prove Proposition 5.4, e.g. by directly computing all advertised
2-qubit states and verifying equality.
Figure 5.7 Scheme of the superdense coding protocol. Charlie prepares Bell State
and sends one part to Alice and the other part to Bob. Alice performs a quantum
operation on her qubit depending on which 2 bits (𝑏 0𝑏 1 ) ∈ ( 00, 01, 10, 11)
she wants to send to Bob. Then she sends her qubit to Bob which applies
a CNOT01 gate and a Hadamard gate on the first qubit. A measurement
performed by Bob in the computational basis will reveal which 2 bits Alice sent
him.
party, here called Charlie. As one can see in the diagram in Fig. 5.7 the prepared
qubit pair is the first bell basis state as stated in Eq. (5.1). Alice then applies
quantum operations to her qubit to encode the two classical bits she wants to
send to Bob. She has four different options to encode her message and for Bob
to decode the sent qubit correctly:
. (5.10)
After Alice applies one of the four operations, she sends her qubit to Bob. Bob,
already holding the other part of the Bell state qubit pair or receiving it at
the same time performs a measurement in the first bell basis by applying a
CNOT01 gate where Alice’s qubit is the control qubit and his qubit the target
qubit and after that a Hadamard gate on Alice’s qubit before measuring and
recording the classical bit string.
This protocol takes advantage of Proposition 5.4, the fact that Alice’s action
on her part of the Bell state is equivalent to changing the qubit initialization of
Bob, see Fig. 5.8. Since the CNOT and Hadamard gate are reversible, Alice’s
actions directly influence the result of the readout operations of Bob.
67 Lecture 5: Bell states & Superdense Coding
Figure 5.8 Diagrams sketching the equivalences in the superdense coding protocol.
5.5 Bell states as universal inputs for quantum circuit verification & learning
Let us conclude today’s lecture with another application of Bell states: they
serve as powerful stimuli to probe unknown single-qubit circuits. This has
applications for formal verification of quantum logic, as well as quantum circuit
design (equivalence checking, synthesis, compilation).
Today, we only discuss the single-qubit base case, where all these tasks
are not too daunting (yet). The underlying procedure does, however, readily
extend to 𝑛 -qubit circuits and (Kronecker products of) Bell states on 2𝑛 qubits.
And there, these genuinely quantum ideas can truly start to make a difference.
We will discuss this in a future lecture and/or in a group project.
For now, let us set the stage and build the foundation for using Bell states
as inputs to probe entire single-qubit circuits: ‘one input state vector to rule
them all’.
2×2 𝑈0,0 𝑈0,1
Theorem 5.6 Applying a single-qubit circuit 𝑼 ∈ ℂ = to
𝑈1,0 𝑈1,1
one half of a Bell state produces a state vector that preserves all information:
𝑈0,0 𝑈0,0
1 𝑈 1 𝑈
© ª © ª
(𝑼 ⊗ 𝕀) |𝜓Bell ⟩ = √ 0,1 and (𝕀 ⊗ 𝑼 ) |𝜓Bell ⟩ = √ 1,0
® ®
® ®.
2 𝑈1,0 ® 2 𝑈0,1 ®
« 𝑈1,1 ¬ « 𝑈1,1 ¬
Note that these state vectors describe two flattening operations of the 2D
array 𝑼 : row vectorization (left) and column vectorization (right).
68 Lecture 5: Bell states & Superdense Coding
𝕀0,0 1
1 𝕀0,1 ® 1 0 ®
© ª © ª
𝑼 =𝕀: (𝕀 ⊗ 𝕀) |𝜓Bell ⟩ = √ ® = √ ®,
2 𝕀1,0 ® 2 0 ®
𝕀
« 1, 1 ¬ « 1 ¬
𝑯 0,0 +1
1 𝑯 0,1 ® 1 +1 ®
© ª © ª
𝑼 = 𝑯 (a) : (𝑯 ⊗ 𝕀) |𝜓Bell ⟩ = √ ®= ®,
2 𝑯 1,0 ® 2 +1 ®
« 𝑯 1,1 ¬ « −1 ¬
𝑯 0,0 +1
1 𝑯 1,0 ® 1 +1 ®
© ª © ª
𝑼 = 𝑯 (b) : (𝕀 ⊗ 𝑯 ) |𝜓Bell ⟩ = √ ®= ®.
2 𝑯 0,1 ® 2 +1 ®
« 𝑯 1,1 ¬ « −1 ¬
This mathematical relation between actions (think: circuit) and state vectors is
remarkably general and known as the Choi-Jamiolkowski isomorphism. We will
see later that it extends to 𝑛 -qubit circuits (2𝑛 × 2𝑛 matrices) and 2𝑛 -qubit
states (22𝑛 different amplitudes). It even applies to quantum actions that
cannot be described by a single quantum circuit (e.g. a randomized quantum
algorithm), but this would go beyond the scope of this introductory lecture.
1
1 1 0 ®
© ª
|𝜓Bell ⟩ = √ (| 00⟩ + | 11⟩) = √ ® ∈ ℂ4
2 2 0 ®
« 1 ¬
1Strictly speaking, single-bit functions are an annoying border case here. If we insist on
reversibility, checking input 𝑥 = 0 tells us everything about input 𝑥 = 1. This one-to-one
correspondence is, however, lost if we either drop reversibility or consider 𝑛 -bit inputs with
𝑛 ≥ 2. The quantum approach requires reversibility, but works for any number of input qubits.
69 Lecture 5: Bell states & Superdense Coding
𝑈0,0 0 𝑈0,1 0
1 0 0 𝑈0,0 0 𝑈0,1
© ª
𝑈0,0 𝑈0,1
(𝑼 ⊗ 𝕀) = ⊗ = ® ∈ ℂ4 × 4
®
𝑈1,0 𝑈1,1 0 1 𝑈1,0 0 𝑈1,1 0 ®
« 0 𝑈1,0 0 𝑈1,1 ¬
Finally, we use matrix-vector multiplication to derive the first formula:
𝑈0,0 𝑈0,1 0 0
1 0 𝑈1,1 0 0
© ª
𝑈0,0 𝑈0,1 𝑈
(𝕀 ⊗ 𝑼 ) = ⊗ = 1,0
®
0 1 0 0 𝑈0,0 𝑈0,1
®
𝑈1,0 𝑈1,1 ®
« 0 0 𝑈1,0 𝑈1,1 ¬
and we instead obtain
(𝕀 ⊗ 𝑼 ) |𝜓Bell ⟩
𝑈0,0 𝑈0,1 0 0 1 𝑈0,0
𝑈1,1 0 0 1 0 ® 1 𝑈1,0
© ª © ª © ª
𝑈
= 1,0 ®× √ ®= √
® ®
®,
0 0 𝑈0,0 𝑈0,1 ® 2 0 ® 2 𝑈0,1 ®
« 0 0 𝑈1,0 𝑈1,1 ¬ 1
« ¬ « 𝑈1,1 ¬
as advertised. ■
6. Entanglement
|𝜓 ⟩𝐴𝐵 = | 𝜑 ⟩𝐴 ⊗ | 𝜑 ⟩𝐵 . (6.1)
Definition 6.1 (entanglement, bipartite case). A pure bipartite quantum state |𝜓 ⟩𝐴𝐵
is entangled if and only if it is not a product state (i.e. not separable). This entangled quantum states are
means that it is impossible to write |𝜓 ⟩𝐴𝐵 in the form of Eq. (6.1). not separable
The Bell states are, of course, not of this form, i.e. there is no way to write
a Bell state such that it factorizes into an individual state | 𝜑 ⟩𝐴 for Alice and
an individual state |𝜑 ⟩𝐵 for Bob. There also exist measures to quantify the
amount of entanglement in a quantum state, and the Bell states are indeed
maximally entangled. Bell states are maximally
As we will see later, entangled states can give rise to correlations whose entangled
“strength” cannot be achieved by any classical process. Moreover, entanglement
71 Lecture 6: Entanglement
Note that we use polarization (or spin) angles here, which are half as large
as angles on the Bloch sphere. So, we do not need all the factors 1/2 as in
Lecture 3. Rotation matrices are comparatively intuitive and obey very nice
composition and inversion rules.
Fact 6.2 Let 𝑹 (𝜃 𝐴 ), 𝑹 (𝜃 𝐵 ) be two rotation matrices. Then,
𝑹 (𝜃 𝐴 )𝑹 (𝜃𝐵 ) =𝑹 (𝜃 𝐴 + 𝜃𝐵 ) (composition),
𝑇 −1
𝑹 (−𝜃 𝐴 ) =𝑹 (𝜃 𝐴 ) = 𝑹 (𝜃 𝐴 ) (transposition/inversion).
Exercise 6.3 Verify the composition rule of Fact 6.2 by computing the matrix
product and using trigonometric identities. Then, conclude the transposi-
tion/inversion rule directly from the composition rule.
It is interesting to consider Bell states, where each qubit is rotated by a
different angle. From now on we use subscript 𝐴 to denote the first qubit and
subscript 𝐵 to denote the second qubit. This notation convention will become
clear later on. For 𝜃 𝐴 , 𝜃 𝐵 , we define
Figure 6.1 Preparing the state |𝜓Bell (𝜃 𝐴 , 𝜃 𝐵 )⟩ by rotating each qubit at an angle
𝜃 A and 𝜃 B respectively.
Alice Bob
qubit 𝐴 Bell qubit 𝐵
𝑅 (𝜃 𝐴 ) 𝑅 (𝜃𝐵 )
source
‘large distance’
.
This visualization depicts a scenario that is equivalent to the circuit in Fig. 6.1.
But, the underlying geometry is very different. Since their creation, the two
qubits have travelled in opposite directions. The recipients, Alice and Bob,
are very far away from each other, apply rotations independently and perform
single-qubit measurements. Nonetheless, the measurement outcomes they can
obtain remain very correlated. And, what is more severe, rotations performed
by Alice appear to affect Bob’s side and vice versa. This alternative viewpoint
isolates the strangeness of the following, mathematically valid, statement.
Lemma 6.4 For any 𝜃 𝐴 , 𝜃 𝐵 ∈ [ 0, 2𝜋) , the outcome probabilities of measuring
the rotated Bell state in Eq. (6.2) always obey Bell states preserve
correlations under joint
1 rotations
Pr |𝜓Bell (𝜃 𝐴 ,𝜃𝐵 ) ⟩ [𝑜 = 00] = Pr |𝜓Bell (𝜃 𝐴 ,𝜃𝐵 ) ⟩ [𝑜 = 11] = cos2 (𝜃 𝐴 − 𝜃 𝐵 ) ,
2
1
Pr |𝜓Bell (𝜃 𝐴 ,𝜃𝐵 ) ⟩ [𝑜 = 01] = Pr |𝜓Bell (𝜃 𝐴 ,𝜃𝐵 ) ⟩ [𝑜 = 10] = sin2 (𝜃 𝐴 − 𝜃𝐵 ) .
2
Proof. Let us combine Corollary 5.3, Theorem 5.2 and the defining properties
1Armando Rastelli from the physics department at JKU is, in fact, one of the world-leading
experts in fabricating such entangling photon sources.
73 Lecture 6: Entanglement
𝑥 𝑦 𝑥 𝑦 𝑥 𝑦
Bell pair
A B A Λ B A B
𝑎 𝑏 𝑎 𝑏 𝑎 𝑏
Figure 6.2 Three variants of the CHSH game: Two players, A (for Alice) and
B (for Bob), play as partners in the following setting. A quizmaster (red)
provides each with a uniformly random input 𝑥 ∈ {0, 1} for A and 𝑦 ∈ {0, 1}
for Bob. They then have to output one bit (blue) each. They win the game if
𝑎 ⊕ 𝑏 = 𝑥 ∧ 𝑦 . The interesting twist is that A and B cannot talk to each other
once the game has started. There are three potential scenarios that meet these
overall desiderata: (Left): A and B perform purely deterministic strategies (grey
boxes that implement a single-bit function). (Center:) similar setting, but A
and B share some joint random seed Λ (green) before the game starts. This
allows them to potentially hedge bets and gamble. (Right:) In the quantum
variant of the CHSH game, A and B share a Bell state (magenta) which they
can rotate and measure after the game has started.
The players win if the two output bits obey 𝑎 ⊕ 𝑏 = 𝑥 ∧ 𝑦 , so the optimal
strategy depends on both input bits. More precisely:
This looks like an easy and somewhat boring game. But, remember that Alice
and Bob cannot talk to each other! And while three game settings suggest an
easy winning strategy, the fourth setting (perfect anti-correlation) asks for a
completely orthogonal strategy. And, since A and B only have access to one
input bit, how should they prepare for this situation?
Proposition 6.5 The best deterministic classical strategy for the CHSH game
wins with probability 3/4 = 0.75.
Proof. Both players, Alice and Bob, receive a (uniformly random) bit and are
tasked to produce a single output bit. There are only four different single-bit
functions that make sense in this context:
Recall that there are 4 possible inputs for the CHSH game. Three of them
( ( 0, 0), ( 0, 1), ( 1, 0) ) ask for perfectly correlated output bits ( ( 0, 0) or ( 1, 1) )
while only one input ( 1, 1) requires perfectly anti-correlated output bits ( ( 0, 1)
or ( 1, 0) ). Importantly, Alice (Bob) doesn’t have access to the full input string,
they only see the first (second) bit. So, there is no way to prepare a strategy to
handle the fourth scenario. Instead, it seems better to always provide correlated
outputs, e.g. by jointly agreeing to always output 0 (Alice and Bob always apply
𝑓 0 to their input) or, equivalently, by jointly agreeing to always output 1 (Alice
and Bob both apply 𝑓 3 to their input bits). Such a perfectly correlated strategy
succeeds in 3 of the 4 possible scenarios. Since all four scenarios occur with
equal probability, the overall probability of success is 3/4 = 0.75, as advertised.
An exhaustive search over all possible combinations of 42 = 16 function
combinations underscores that these strategies are indeed as good as it gets. ■
The above proof reveals a dilemma that arises when Alice and Bob want
to come up with a very good strategy for the CHSH game. Each of them only
receives one-half of the input string, and they must not (cannot) communicate
while the game is going on. This partial information is not enough for them
to discern whether the interesting special case (input ( ( 1, 1) which asks for
anti-correlated bits) has actually happened. And so, it does not seem to make
sense to pay attention to this special case at all. Stubbornly outputting 0,
regardless of the actual input, looks like a highly competitive strategy.
An interesting question is now whether there are randomized strategies that
allow Alice and Bob to do better than that. A randomized strategy could look
as follows: before the game starts, Alice and Bob are allowed to meet, conspire
and exchange information. They could use this opportunity to share a random
seed Λ that allows them to hedge bets and ‘gamble’ later on in the game. This
shared random seed should really be viewed as a mathematical abstraction of
a joint strategy that may involve additional information, as well as multiple
strategies.
But, to not interfere with the defining rule of the CHSH game, we insist
that the shared random seed is (statistically) independent from the random
bits 𝑥 and 𝑦 the referee is going to use once the game actually starts in
76 Lecture 6: Entanglement
earnest. This assumption is crucial and actually sufficient to prove the following
generalization of Proposition 6.5.
Theorem 6.6 (Bell inequality for CHSH). Any classical strategy conceivable – best classical CHSH strategy
even those that use (arbitrary amounts of) shared randomness between wins with probability ≤ 0.75
both players – can win the CHSH game with a probability of at most
3/4 = 0.75. Hence, the Bell inequality for the CHSH game, limiting all
class
classical strategies, reads: 𝑝 succ ≤ 34 .
Proof sketch of Theorem 6.6. The overall idea is that shared randomness cannot
improve over the best deterministic strategy. A shared random seed allows the
players to switch between different deterministic strategies – depending on the
value of the random seed. The resulting probability of success then becomes a
weighted sum over winning probabilities of individual deterministic strategies:
∑︁ ∑︁
𝑝 succ = Pr [ success|strategy 𝑘 ] 𝑝 (𝑘 ) with 𝑝𝑘 ≥ 0, 𝑝 (𝑘 ) = 1.
𝑘 𝑘
Bell state between them before the game starts, see Fig. 6.2 (right). Once the
game begins, each player uses the input bit to perform a certain rotation on
their half of the Bell state and measure their qubit:
𝑥 𝑦
𝑎 𝑏 .
At first sight, this setup looks a bit asymmetric. Bob features an additional
rotation gate 𝑅 (𝜑 ) while Alice doesn’t. Due to the invariants of a rotated Bell
state, this is in fact the most general setup conceivable. Consider now the
scenario where Alice receives input bit 𝑥 and Bob receives input bit 𝑦 . After
applying rotations, they produce a rotated Bell state that depends on 𝑥 and 𝑦 .
We succinctly write
|𝜓 (𝑥, 𝑦 )⟩ := |𝜓Bell (𝑥 𝜃 𝐴 , 𝑦 𝜃𝐵 + 𝜑 )⟩ = 𝑹 (𝑥 𝜃 𝐴 ) ⊗ 𝑹 (𝑦 𝜃𝐵 + 𝜑 )|𝜓Bell ⟩.
Note that since this state depends on the rotation angles 𝜃 𝐴 , 𝜃 𝐵 , 𝜑 ∈ [ 0, 2𝜋) ,
Lemma 6.4 conveniently provides us with the associated outcome probabilities
for perfectly correlated and anti-correlated measurement outcome bits:
1
Pr |𝜓 (𝑥,𝑦 ) ⟩ [𝑜 = 00] = |𝜓 (𝑥, 𝑦 )⟩ [𝑜 = 11] =cos2 (−𝑥 𝜃 𝐴 + 𝑦 𝜃 𝐵 + 𝜑 ) ,
2
1
Pr |𝜓 (𝑥,𝑦 ) ⟩ [𝑜 = 01] = |𝜓 (𝑥, 𝑦 )⟩ [𝑜 = 10] = sin2 (−𝑥 𝜃 𝐴 + 𝑦 𝜃 𝐵 + 𝜑 ) .
2
We can now use these probabilities to analyze the success probability in each
CHSH game setting as a function of the rotation angles involved:
1 (𝑥, 𝑦 ) = ( 0, 0) which asks for 0 = 𝑥 ∧ 𝑦 = 𝑎 ⊕ 𝑏 . In words, Alice and
Bob win the game if their output bits are perfectly correlated, that is they
should output either (𝑎, 𝑏) = ( 0, 0) or (𝑎, 𝑏) = ( 1, 1) . The probability
of success is
𝑝 succ ( 0, 0) = Pr |𝜓 ( 0,0 ) ⟩ [𝑜 = 00] + Pr |𝜓 ( 0,0 ) ⟩ [𝑜 = 11]
1 1
= cos2 (−0𝜃 𝐴 + 0𝜃 𝐵 + 𝜑 ) + cos2 (−0𝜃 𝐴 + 0𝜃 𝐵 + 𝜑 )
2 2
2
= cos (𝜑 ) .
2 (𝑥, 𝑦 ) = ( 0, 1) which asks for 0 = 𝑥 ∧ 𝑦 = 𝑎 ⊕ 𝑏 . Again, Alice and Bob
win if their output bits are perfectly correlated. The probability of success
is
𝑝 succ ( 0, 1) = Pr |𝜓 ( 0,1 ) ⟩ [𝑜 = 00] + Pr |𝜓 ( 0,1 ) ⟩ [𝑜 = 11]
1 1
= cos2 (−0𝜃 𝐴 + 1𝜃 𝐵 + 𝜑 ) + cos2 (−0𝜃 𝐴 + 1𝜃 𝐵 + 𝜑 )
2 2
2
= cos (𝜃 )
𝐵 +𝜑 .
78 Lecture 6: Entanglement
We can now take into account the distribution of inputs (𝑥, 𝑦 ) to combine
all these four probabilities into a single success probability. By assumption,
all possible 2-bit inputs occur with equal probability 1/22 = 1/4 (uniform
distribution). So, the overall probability of success becomes
1 2
cos (𝜑 ) + cos2 (𝜃 𝐵 + 𝜑 ) + cos2 (−𝜃 𝐴 + 𝜑 ) + sin2 (−𝜃 𝐴 + 𝜃 𝐵 + 𝜑 ) .
𝑝 succ =
4
We are now in a position to optimize the quantum strategy by choosing
𝜃 𝐴 , 𝜃𝐵 , 𝜑 to make this success probability as large as possible. The cosine
function becomes large if all the angles are (relatively) close to zero and is
symmetric, i.e. cos (−𝛼) = cos (+𝛼) . Here is one choice that yields the same
success probability for each of the four challenges:
It achieves
1 √
𝑝 succ = cos2 (𝜋/8) = 2 + 2 ≳ 0.85.
4
Although not perfect, this success probability is considerably larger than the
best classical success probability (3/4 = 0.75) conceivable. In fact, it can
be shown that this quantum success probability is optimal. Even by using
(arbitrary) quantum resources and (arbitrary) quantum circuits one cannot
beat this threshold. This is worth a prominent display.
Theorem 6.7 (optimal quantum strategy for the CHSH game). For the CHSH
game (2 players), there is an optimal quantum strategy that (only) uses
2-qubit Bell states and two single-qubit rotations for each player. This best quantum CHSH strategy
wins with probability > 0.85
79 Lecture 6: Entanglement
√
strategy achieves a success probability of 𝑝 succ = ( 2 + 2)/4 ≳ 0.85.
This fact subsumes two strong observations: (i) playing a CHSH game and
winning with optimal success probability essentially certifies that the underlying
protocol works as intended. There is no additional need for benchmarking monogamy of entanglement: if
and/or bug fixing. This remarkable feature is also called ‘self-testing’. two quantum systems are
(ii) the quantum correlations within a two-qubit Bell state are maximally strong. maximally entangled they
cannot be entangled with a
They are, in fact, so strong that it is impossible to still couple this quantum
third one
system to another one. This feature is known as monogamy of entanglement.
The worldview of local realism implies Bell inequalities. Over many decades,
Bell inequalities have been violated in laboratories all around the world. The
2022 Nobel Prize in Physics was awarded to some of the most significant of
these experiments.
would necessarily manifest itself in a (much) smaller success probability for the
CHSH game. Alice and Bob, however, can check for exactly that and abort their
protocol if their imitation of the CHSH game is not as successful as it ought to
be.
The actual E91 protocol uses 3 different rotations for each participant (Alice
and Bob) that are depicted in Fig. 6.3. A quick look at them reveals that two of
each are perfectly aligned with each other. These are well-suited to establish
shared randomness (via perfect correlation of Bell outcome measurements).
On the other hand, two of each, are also perfectly suited to play the winning
strategy for the CHSH game. A full and secure execution of the E91 protocol
requires access to many shared Bell pairs so that we can generate sufficiently
long shared private keys and also have enough statistics to approximately
determine the CHSH success probability. We encourage you to have a closer
look by yourself and implement a variant of the E91 protocol using, for instance,
QISKIT to simulate the generation and subsequent measurement of Bell states.
Such a small coding project would also allow you to discover for yourself, how
powerful the CHSH game is at detecting potential attacks on the Bell state.
A brutal man-in-the-middle-attack could, for instance, involve an additional
third qubit which the eavesdropper swaps into the circuit to funnel out one-half
of the entangled state. The CHSH test, however, would detect such a clumsy
attack almost immediately.
Exercise 6.9 Go through our high-level description of the E91 protocol and
make it precise. Which pairs of basis rotations allow for extracting a pair of
perfectly correlated, uniformly random bits? Which pairs of basis rotations
instead allow for playing a CHSH game? Optional: use QISKIT to simulate the
E91 protocol in the presence of a malicious eavesdropper who tampers with the
pristine Bell-state preparation circuit.
√ Show that the (estimated) CHSH success
probability really drops below ( 2 + 2)/4 in any such scenario.
82 Lecture 6: Entanglement
θB = π/8
θA = 0 θB = 0
θA = −π/8 θB = −π/8
θA = −π/4
Figure 6.3 Illustration of the E91 protocol: Two players – Alice on the left and
Bob on the right – share many perceived Bell pairs (blue) among. For each
Bell state, they perform independent rotations that are selected uniformly
from three options (red circle for Alice, green circle for Bob) and follow it
up with a computational basis measurement (magenta). Two of the three
angles are the same on each side. The entire process gives each party a list
of measurement settings and corresponding results. They then share their
measurement settings over a public channel. If the same angle was measured –
this occurs in 2 of the 9 setting combinations – then the perfect correlations
of Bell state measurements provide them with one shared random bit. In 4
out of 9 cases, their measurement setting combination belongs to the CHSH
game. Then, they also communicate their measurement outcomes as they are
required for the calculation of the success probability. If the estimated success
probability is (close to) optimal, they can be sure that the entire protocol has
worked as intended. In particular, no eavesdropping whatsoever can have taken
place. If the success probability is not close to optimal, something fishy must
have happened. Alice and Bob then abort the protocol, because their shared
key may not be correct and/or secure.
7. Quantum teleportation
The following rigorous statement fully resolves this question for the case of a
single qubit1.
The requirements put forth by this statement are best visualized in another
1A generalization to 𝑛 ≥ 1 qubits is relatively straightforward, but would go beyond the
scope of this lecture.
84 Lecture 7: Quantum teleportation
picture:
for every input state |𝜓 ⟩ and every subsequent unitary gate 𝑼 . This characteri-
zation of equivalence is intuitive: two (black box) subroutines are equivalent if
and only if it is impossible to detect any functional difference between the two.
It should not come as a surprise that quantum circuits can ‘hide’ functional
differences better than conventional circuits. The following example highlights
that different input states and different unitaries can both be necessary to
detect them.
Example 7.2 (checking different input states |𝜓 ⟩ and unitaries 𝑼 matters for Theo-
rem 7.1). Consider 𝑨 = 𝕀 (do nothing) and 𝑩 = 𝒁 (sign flip). Then,
𝑩 | 0⟩ = | 0⟩ = 𝑨 | 0⟩ and 𝑩 | 1⟩ = −| 1⟩ ∼ | 1⟩ = 𝑨 | 1⟩,
but the two gates are √ clearly not equivalent. To see this, set √ |𝜓 ⟩ = |+⟩ =
𝑯 | 0⟩ = (| 0⟩ + | 1⟩)/ 2 (and recall |−⟩ = 𝑯 | 1⟩ = (| 0⟩ − | 1⟩)/ 2) ). Then,
√ √
𝑩 |𝜓 ⟩ =𝑩 |+⟩ = 𝑩 (| 0⟩ + | 1⟩) / 2 = (| 0⟩ − | 1⟩) / 2 = |−⟩ = 𝑯 | 1⟩,
𝑨 |𝜓 ⟩ =𝑨 |+⟩ = |+⟩ = 𝑯 | 0⟩.
Both states describe equal superpositions between 0 and 1 and produce equiva-
lent readout probabilities:
1
Pr𝑩 |𝜓 ⟩ [𝑜 0 = 0] =Pr |+⟩ [𝑜 0 = 0] = |⟨0 |+⟩| 2 = ,
2
1
Pr𝑨 |𝜓 ⟩ [𝑜 0 = 0] =Pr | −⟩ [𝑜 0 = 0] = |⟨0 |−⟩| 2 = .
2
Nonetheless, the actual states are very different from each other. Applying one
subsequent Hadamard gate 𝑼 = 𝑯 reveals this difference: 𝑼 𝑩 |𝜓 ⟩ = 𝑯 |−⟩ =
𝑯 × 𝑯 | 1⟩ = | 1⟩ , while 𝑼 𝑨 |𝜓 ⟩ = 𝑯 |+⟩ = 𝑯 × 𝑯 | 0⟩ = | 0⟩ . This ensures
Pr𝑼 𝑩 |𝜓 ⟩ [𝑜 0 = 0] =Pr | 1 ⟩ [𝑜 0 = 0] = 0,
Pr𝑼 𝑨 |𝜓 ⟩ [𝑜 0 = 0] =Pr | 0 ⟩ [𝑜 0 = 1] = 1.
These readout probabilities are as different as they get: one always produces 0
and one always produces 1. ■
This example showcases that we may need the ability to choose different
input states and different subsequent unitaries to unravel a functional difference
between quantum sub-routines. Theorem 7.1 then follows from carefully
arguing that this is enough to unravel all functional differences between
single-qubit circuits. We leave this analysis as an instructive exercise.
85 Lecture 7: Quantum teleportation
Exercise 7.3 (Proof of Theorem 7.1). Provide a proof of Theorem 7.1 for the special
case where both 𝑨 and 𝑩 are single-qubit gates.
At this point, it is worthwhile to emphasize that Theorem 7.1 also applies
to more general quantum subroutines. The subroutines we analyze today,
for instance, involve more than one qubit. A readout is performed on these
auxiliary qubits. And, depending on the outcome obtained (𝑜𝑘 = 0 or 𝑜𝑘 = 1),
we perform different quantum gates on the remaining qubit wire. For instance,
where double lines indicate the conditional application of a quantum gate (if
readout is 1, we apply the gate; otherwise we do nothing).
In order to properly analyze such quantum (sub-)routines, we need a
framework that allows us to reason about such conditional operations, i.e.
(gate) actions that depend on a certain – possibly randomly sampled – readout
bit we have observed earlier.
Likewise, the two conditional probabilities for the second event (𝑜 1 ) are
Pr [𝑜 0 = 0, 𝑜 1 = 𝑡 ]
Pr [𝑜 1 = 𝑡 |𝑜 0 = 0] = for 𝑡 = 0, 1,
Pr [𝑜 0 = 0]
Pr [𝑜 0 = 1, 𝑜 1 = 𝑡 ]
Pr [𝑜 1 = 𝑡 |𝑜 0 = 1] = for 𝑡 = 0, 1.
Pr [𝑜 0 = 1]
(Care must be taken when the denominator approaches zero. This would mean
that we condition on an event that can (almost) never happen).
Note that there are two conditional probability distributions for each event:
one that assumes 𝑜 0/1 = 0 and one that assumes 𝑜 0/1 = 1. Each of them is a
valid probability distribution in its own right. Non-negativity follows directly
from the construction. Normalization, on the other hand, follows from the
fact that the relevant marginal distribution features in the denominator. For
instance,
Í1
∑︁1
𝑠 =0 Pr [𝑜0 = 𝑠 , 𝑜 1 = 0] Pr [𝑜 1 = 0]
Pr [𝑜 0 = 𝑠 |𝑜 1 = 0] = = =1
𝑠 =0 Pr [𝑜 1 = 0] Pr [𝑜 1 = 0]
and we obtain the same result for all other conditional probability distributions.
Similar to marginal probability distributions, Definition 7.5 also readily
extends to more than two binary variables. However, the number of different
87 Lecture 7: Quantum teleportation
Pr [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 , 𝑜 2 = 𝑢]
Pr [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 |𝑜 2 = 𝑢] = for 𝑠 , 𝑡 = 0, 1,
Pr [𝑜 2 = 𝑢]
Pr [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 , 𝑜 2 = 𝑢]
Pr [𝑜 0 = 𝑠 , 𝑜 2 = 𝑢 |𝑜 1 = 𝑡 ] = for 𝑠 , 𝑢 = 0, 1,
Pr [𝑜 1 = 𝑡 ]
Pr [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 , 𝑜 2 = 𝑢]
Pr [𝑜 1 = 𝑡 , 𝑜 2 = 𝑢 |𝑜 0 = 𝑠 ] = for 𝑡 , 𝑢 = 0, 1.
Pr [𝑜 0 = 𝑠 ]
Pr [𝑜 0 = 𝑠 |𝑜 1 = 𝑡 ] Pr [𝑜 1 = 𝑡 ]
Pr [𝑜 1 = 𝑡 |𝑜 0 = 𝑠 ] = .
Pr [𝑜 0 = 𝑠 ]
Pr [𝑜 1 = 𝑡 |𝑜 0 = 𝑠 ] = Pr [𝑜 0 = 𝑠 |𝑜 1 = 𝑡 ]
1
|𝜓Bell ⟩ = 𝑪 𝑵 𝑶𝑻 (𝑯 ⊗ 𝕀) | 00⟩ = √ (| 00⟩ + | 11⟩) .
2
1
Pr |𝜓Bell ⟩ [𝑜 0 = 𝑠 ] = Pr |𝜓Bell ⟩ [𝑜 1 = 𝑠 ] = for 𝑠 = 0, 1. (7.3)
2
This display highlights two things: (i) the two marginal probabilities are
identical and (ii) each marginal probability is equivalent to a uniformly random
bit (think: coin toss).
89 Lecture 7: Quantum teleportation
Pr |𝜓Bell ⟩ [𝑜 0 = 0, 𝑜 1 = 0] 1/2
Pr |𝜓Bell ⟩ [𝑜 0 = 0 |𝑜 1 = 0] = = = 1,
Pr |𝜓Bell ⟩ [𝑜 1 = 0] 1/2
where we have inserted Eq. (7.2) for the numerator and Eq. (7.3) for the
denominator. In a similar fashion, we obtain
Pr |𝜓Bell ⟩ [𝑜 0 = 1, 𝑜 1 = 0] 0
Pr |𝜓Bell ⟩ [𝑜 0 = 1 |𝑜 1 = 0] = = = 0.
Pr |𝜓Bell ⟩ [𝑜 1 = 0] 1/2
This confirms that these two conditional probabilities indeed form a valid
probability distribution. Both probabilities are non-negative and add up to one.
Conditioning on 𝑜 1 = 1 instead, tells a similar story, but with reversed roles:
Pr |𝜓Bell ⟩ [𝑜 0 = 0, 𝑜 1 = 1] 0
Pr |𝜓Bell ⟩ [𝑜 0 = 0 |𝑜 1 = 1] = = = 0,
Pr |𝜓Bell ⟩ [𝑜 1 = 1] 1/2
Pr |𝜓Bell ⟩ [𝑜 0 = 1, 𝑜 1 = 1] 1/2
Pr |𝜓Bell ⟩ [𝑜 0 = 1 |𝑜 1 = 1] = = = 1.
Pr |𝜓Bell ⟩ [𝑜 1 = 1] 1/2
This display highlights another feature of Bell state readout: the first outcome
bit is perfectly correlated with the second outcome bit: 𝑜 0 = 𝑜 1 . It should not
come as a surprise that this perfect correlation persists if we exchange the roles
of the two outcome bits. We leave this as an instructive exercise.
Exercise 7.8 (Bell readout probabilities conditioned on the first outcome bit 𝑜 0 ). Use
Eq. (7.2) and Eq. (7.3) to derive the following conditional probability distribu-
tions: (
1 if 𝑡 = 𝑠 ,
Pr |𝜓Bell ⟩ [𝑜 1 = 𝑡 |𝑜 0 = 𝑠 ] =
0 else if 𝑡 ≠ 𝑠 .
This ensures that the drawing of the straws is fair: each player has the same
odds of winning/losing.
However, all five players draw from the same hat. This introduces depen-
dencies between the individual scores of the players involved. Conditional
probabilities are the proper way to reason about these effects which become
most pronounced if we look at the score of the last player’s conditional on the
score of all players before them. For instance,
Pr [𝑜 0 = 0, 𝑜 1 = 0, 𝑜 2 = 0, 𝑜 3 = 0, 𝑜 4 = 1]
Pr [𝑜 4 = 1 |𝑜 3 = 0, 𝑜 2 = 0, 𝑜 1 = 0, 𝑜 0 = 0] =
Pr [𝑜 0 = 0, 𝑜 1 = 0, 𝑜 2 = 0, 𝑜 3 = 0]
Pr [𝑜 0 = 0, 𝑜 1 = 0, 𝑜 2 = 0, 𝑜 3 = 0, 𝑜 4 = 1]
=
Pr [𝑜 0 = 0, 𝑜 1 = 0, 𝑜 2 = 0, 𝑜 3 = 0, 𝑜 4 = 0] + Pr [𝑜 0 = 0, 𝑜 1 = 0, 𝑜 2 = 0, 𝑜 3 = 0, 𝑜 4 = 1]
1/5
= = 1.
0 + 1/5
Pr [𝑜 4 = 0 |𝑜 3 = 0, 𝑜 2 = 0, 𝑜 1 = 0, 𝑜 0 = 0] = 0.
Note that this final conditional probability distribution for 𝑜 4 is actually deter-
ministic: player five is guaranteed to lose if players one, two, three, and four all
win. A converse of this observation is also true. Suppose, for concreteness, that
player three loses, i.e. 𝑜 2 = 1. Then, player five has no chance of also losing. In
formulas,
Pr [𝑜 4 = 1 |𝑜 3 = 0, 𝑜 2 = 1, 𝑜 1 , = 0, 𝑜 0 = 0] = 0,
Pr [𝑜 4 = 0 |𝑜 3 = 0, 𝑜 2 = 1, 𝑜 1 , = 0, 𝑜 0 = 0] = 1
91 Lecture 7: Quantum teleportation
and we leave the actual derivation as a quick exercise. By now it should not
come as a surprise that the same is true if any of the other players already lost.
We can succinctly summarize our insights in the following display
h ∑︁3 i h ∑︁3 i
Pr 𝑜 4 = 1 𝑜𝑘 = 0 = 1 while Pr 𝑜 4 = 1 𝑜𝑘 = 1 = 0.
𝑘 =0 𝑘 =0
In words: player five must lose (𝑜 4 = 1) if everybody else wins before and they
must win (𝑜 4 = 0) if somebody else has already lost.
The subroutine depicted in Fig. (7.1) takes a single qubit as input and also
outputs a single qubit. It, therefore, corresponds to an effective single-qubit
operation that we can execute if we have a quantum computer with (at least)
two qubits. The main result of this section highlights that this effective operation
is equivalent to one we already know.
92 Lecture 7: Quantum teleportation
1
|𝑇 ⟩ = 𝑻 𝑯 | 0⟩ = √ | 0⟩ + ei𝜋/4 | 1⟩ ,
2
which is known as a magic state . Theorem 7.9 then tells us that we can use magic state: |𝑇 ⟩ = 𝑻 𝑯 | 0⟩
one such magic state to effectively apply a single 𝑇 gate to another (arbitrary)
qubit. In pictures,
and this version of the protocol is known as magic state injection. It only magic state injection
features Clifford gates (𝑺 , 𝑯 , 𝑪 𝑵 𝑶𝑻 and 𝑿 = 𝑯 𝑺 2𝑯 ), as well as one single-
qubit readout operation. Magic state injection does, however, convert access
to one magic state |𝑇 ⟩ in an effective application of a 𝑇 -gate which is not a
Clifford gate. This trick will become important once we discuss quantum error
correction and fault-tolerant quantum computation.
Let us now move on to actually prove Theorem 7.9. Theorem 7.1 tells us
that it is enough to show
The other side requires quite a bit more work. But, we have all the necessary
prerequisites to analyze it as well. Let us start with tracking the two-qubit state
vector throughout the quantum circuit. We can write |𝜓 ⟩ = 𝛼 | 0⟩ + 𝛽 | 1⟩ with
93 Lecture 7: Quantum teleportation
Next, we apply two CNOT-gates with different control qubits. On a bit logic
level, they act as
𝛼 𝛽 𝛼 ei𝜋/4 𝛽 ei𝜋/4
| 𝜑 1 ⟩ =𝑪 𝑵 𝑶𝑻 2→1 | 𝜑 0 ⟩ = √ | 00⟩ + √ | 11⟩ + √ | 10⟩ + √ | 01⟩ and
2 2 2 2
i𝜋/4 i𝜋/4
𝛼 𝛽 𝛼e 𝛽e
| 𝜑 2 ⟩ =𝑪 𝑵 𝑶𝑻 1→2 | 𝜑 1 ⟩ = √ | 00⟩ + √ | 10⟩ + √ | 11⟩ + √ | 01⟩.
2 2 2 2
We can use elementary (state) vector and Kronecker operations to rewrite this
state suggestively as
1 e−i𝜋/4
| 𝜑 2 ⟩ = √ | 0⟩ ⊗ 𝛼 | 0⟩ + ei𝜋/4 𝛽 | 1⟩ + √ | 1⟩ ⊗ ei𝜋/4 𝛽 | 0⟩ + ei𝜋/2 𝛼 | 1⟩
2 2
1 e − i𝜋/4
= √ | 0⟩ ⊗ (𝑻 (𝛼 | 0⟩ + 𝛽 | 1⟩)) + √ | 1⟩ ⊗ 𝑺 † ei𝜋/4 𝛽 | 0⟩ + 𝛼 | 1⟩
2 2
1 e − i𝜋/4
= √ | 0⟩ ⊗ (𝑻 |𝜓 ⟩) + √ | 1⟩ ⊗ 𝑺 † 𝑿 𝛼 | 0⟩ + ei𝜋/4 𝛽 | 1⟩
2 2
1 e − i𝜋/4
= √ | 0⟩ ⊗ (𝑻 |𝜓 ⟩) + √ | 1⟩ ⊗ 𝑺 † 𝑿𝑻 |𝜓 ⟩ . (7.6)
2 2
This reformulation of the state | 𝜑 2 ⟩ already tells us quite a bit about the
quantum logical configuration just before reading out the first qubit. It is a
superposition of two distinct contributions: one for each classical readout value
associated with the first qubit. If the readout value is 𝑜 0 = 0, we don’t do
anything to the remaining qubit and obtain
1 1 1
Pr (𝕀⊗𝑼 ) | 𝜑 final ⟩ [𝑜 0 = 0] = |⟨0 |𝑼𝑻 |𝜓 ⟩| 2 + |⟨1 |𝑼𝑻 |𝜓 ⟩| 2 = ,
2 2 2
1 1 1
Pr (𝕀⊗𝑼 ) | 𝜑 final ⟩ [𝑜 0 = 1] = |⟨0 |𝑼𝑻 |𝜓 ⟩| 2 + 2
|⟨1 |𝑼𝑻 |𝜓 ⟩| = ,
2 2 2
and the conditional outcome probabilities become
Theorem 7.10 (correctness of quantum teleportation). The teleportation subrou- quantum state teleportation
tine in Fig. 7.2 acts like an effective one-qubit operation. Every input state on
the top right gets exactly transferred to the bottom left, i.e. |𝜓out ⟩ = |𝜓in ⟩ .
single-qubit state |𝜓 ⟩ , an arbitrary single qubit unitary 𝑼 and set out to show
(7.7)
The equality sign here indicates that the outcome probabilities associated with
𝑜2 ∈ {0, 1} (left) and 𝑜 ∈ {0, 1} (right) must be identical. We have also
already streamlined this display a bit by incorporating the two-qubit Bell state.
This readily allows us to write down the actual 3-qubit starting state. For
|𝜓 ⟩ = 𝛼 | 0⟩ + 𝛽 | 1⟩ (with 𝛼, 𝛽 ∈ ℂ and |𝛼 | 2 + |𝛽 | 2 = 1), we obtain
1
| 𝜑 0 ⟩ =|𝜓 ⟩ ⊗ |𝜓Bell ⟩ = (𝛼 | 0⟩ + 𝛽 | 1⟩) ⊗ √ (| 00⟩ + | 11⟩)
2
𝛼 𝛼 𝛽 𝛽
= √ | 000⟩ + √ | 011⟩ + √ | 100⟩ + √ | 111⟩
2 2 2 2
The CNOT between qubits 1 and 2 turns this state into
| 𝜑 2 ⟩ = (𝑯 ⊗ 𝕀 ⊗ 𝕀) | 𝜑 1 ⟩
𝛼 𝛼 𝛽 𝛽
= √ | + 00⟩ + √ | + 11⟩ + √ | − 10⟩ + √ | − 01⟩
2 2 2 2
𝛼 𝛼 𝛼 𝛼
= | 000⟩ + | 100⟩ + | 011⟩ + | 111⟩
2 2 2 2
𝛽 𝛽 𝛽 𝛽
+ | 010⟩ − | 110⟩ + | 001⟩ − | 101⟩.
2 2 2 2
Written as is, this final 3-qubit state looks rather complicated. However, an
interesting structure reveals itself if we start grouping the amplitudes in terms
of the possible outcome bits for qubit 1 (𝑜 0 ) and qubit 2 (𝑜 1 ):
1 1
| 𝜑 2 ⟩ = | 00⟩ ⊗ (𝛼 | 0⟩ + 𝛽 | 1⟩) + | 01⟩ ⊗ (𝛼 | 1⟩ + 𝛽 | 0⟩)
2 2
1 1
+ | 10⟩ ⊗ (𝛼 | 0⟩ − 𝛽 | 1⟩) + | 11⟩ ⊗ (𝛼 | 1⟩ − 𝛽 | 0⟩)
2 2
1 1
= | 00⟩ ⊗ (|𝜓 ⟩) + | 01⟩ ⊗ (𝑿 |𝜓 ⟩)
2 2
1 1
+ | 10⟩ ⊗ (𝒁 |𝜓 ⟩) + | 11⟩ ⊗ (𝑿 𝒁 |𝜓 ⟩) ,
2 2
Problems
Problem 7.12 (Proof of Theorem 7.1). Consider two single-qubit gate matrices
𝑨, 𝑩 (unitaries). Show that they must be equivalent (i.e. 𝑩 = ei 𝜑 𝑨 for some
𝜑 ∈ [ 0, 2𝜋) ) if the following equality is true for all input states |𝜓 ⟩ and all
subsequent unitary gates 𝑼 :
Pr𝑼 𝑩 |𝜓 ⟩ [𝑜 = 𝑠 ] = Pr𝑼 𝑨 |𝜓 ⟩ [𝑜 = 𝑠 ] for 𝑠 = 0, 1.
Challenging bonus question: is it really necessary to consider all possible
input states, as well as all possible unitaries?
Problem 7.13 (Bayes’ theorem). Prove the following statement known as Bayes’
theorem:
Pr [𝑜 0 = 𝑎 |𝑜 1 = 𝑏] Pr [𝑜 1 = 𝑏]
Pr [𝑜 1 = 𝑏 |𝑜 0 = 𝑎] = .
Pr [𝑜 0 = 𝑎]
Context: Bayes’ theorem highlights that the direction of correlations can be
inverted. As such, it plays a pivotal role in statistics.
Problem 7.14 (Drawing straws revisited). Recall the drawing straws scenario,
Ex. 7.2.4. What happens if everyone were to put back in the hat their straw
after their turn? What would the probability of winning or losing be? Would it
change after every turn? Justify your findings with the mathematical formulas
developed in this lecture.
Problem 7.15 (Perfect correlations go both ways). Suppose that we have a joint
distribution of two binary variables that obey
(
1 if 𝑠 = 𝑡 ,
Pr [𝑜 1 = 𝑡 |𝑜 0 = 𝑠 ] = (7.8)
0 else if 𝑠 ≠ 𝑡 .
In words: the value of 𝑜 0 completely determines the value of 𝑜 1 (perfect
correlation). Use Bayes’ rule to show that this also implies
(
1 if 𝑠 = 𝑡 ,
Pr [𝑜 0 = 𝑠 |𝑜 1 = 𝑡 ] =
0 else if 𝑠 ≠ 𝑡 .
Is the converse direction also true? That is, does
Pr [𝑜 1 = 𝑡 |𝑜 0 = 𝑠 ] = Pr [𝑜 0 = 𝑠 |𝑜 1 = 𝑡 ]
necessarily imply perfect correlations in the sense of Eq. (7.8)?
Problem 7.16 (proof of correctness for quantum state teleportation). Consider the
following two quantum circuits
,
100 Lecture 7: Quantum teleportation
Pr𝑼 |𝜓 ⟩ [𝑜 = 𝑢] for 𝑢 = 0, 1.
2 Compute all joint readout probabilities of the final right-hand side state:
Pr | 𝜑 final ⟩ [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 , 𝑜 2 = 𝑢] for 𝑠 , 𝑡 , 𝑢 = 0, 1.
3 Use your result from 2 to derive the marginal probabilities for readout
bits one and two, i.e. Pr | 𝜑 final ⟩ [𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 ] for 𝑠 , 𝑡 = 0, 1.
4 Combine your results from 2 and 3 to compute all conditional probabilities
Pr | 𝜑 final ⟩ [𝑜 2 = 𝑢 |𝑜 0 = 𝑠 , 𝑜 1 = 𝑡 ] . Conclude that
regardless of the bit values for 𝑜 0 and 𝑜 1 . In other words: the state
teleportation always operates as intended!
5 Suppose that Bob becomes impatient and performs a readout on his qubit
before receiving the readout values of Alice (and before performing the
conditional corrections). Then, the full teleportation protocol is cut short
and effectively becomes
Problem 7.17 (quantum repeaters). Consider the following quantum circuit that
involves 4 qubits and two partial measurements on qubit 2 and 3:
1 Compute the two-qubit output state 𝜌 out (𝑜0 , 𝑜1 ) for the special case
where 𝑜 0 , 𝑜 1 = 0. Can you recognize it?
2 What is the probability of obtaining 𝑜0 = 𝑜1 = 0 when performing the
partial measurement?
3 Argue that this circuit actually encompasses a quantum repeater for
spreading entanglement across larger distances. But, the way we have
set it up is probabilistic. The entanglement exchange protocol only works
with a certain success probability (which one?).
4 Optional: do a full analysis that applies to all possible measurement
outcomes 𝑜 0 , 𝑜 1 ∈ {0, 1}. Can you correct the protocol (using 𝑜 0 and 𝑜 1 )
such that it is guaranteed to work in a deterministic fashion?
8. General 𝑛 -qubit architectures
We can use these basic building blocks to construct state vectors of more
complex bit configurations. The case 𝑛 = 2, for instance, featured prominently
in Lecture 4. There are in total 4 = 22 bit strings of length 𝑛 = 2. And we can
use the Kronecker product to construct all of them from the basic state vectors
1A 𝑛 -qubit architecture can also feature partial readout and conditional gate applications
(see Lecture 7). We disregard this option here for the sake of keeping things simple.
104 Lecture 8: General 𝑛 -qubit architectures
in Eq. (8.2):
1 1 𝑇 2
| 00⟩ =| 0⟩ ⊗ | 0⟩ = ⊗ = 1 0 0 0 = 𝒆 0 ∈ ℂ4 = ℂ2 ,
0 0
1 0 𝑇 2
| 01⟩ =| 0⟩ ⊗ | 1⟩ = ⊗ = 0 1 0 0 = 𝒆 1 ∈ ℂ4 = ℂ2 ,
0 1
0 1 𝑇 2
| 10⟩ =| 1⟩ ⊗ | 0⟩ = ⊗ = 0 0 1 0 = 𝒆 2 ∈ ℂ4 = ℂ2 ,
1 0
0 0 𝑇 2
| 11⟩ =| 1⟩ ⊗ | 1⟩ = ⊗ = 0 0 0 1 = 𝒆 3 ∈ ℂ4 = ℂ2 ,
1 1
where we have written down the final expression as a row vector (transposition)
to save a bit of paper space. Note that this identification between bitstrings
(left) and standard basis vectors (right) is even nicer than one might expect:
the 2-bit string on the left corresponds to a bit encoding ⌞𝑙 ⌟ of the standard
basis vector index. For 𝑙 between 0 and 3 = 22 − 1,
𝜓00
∑︁1 ©
𝜓01
ª 2
|𝜓 ⟩ = 𝜓𝑏 0𝑏 1 |𝑏 0𝑏 1 ⟩ = 𝝍 = ® ∈ ℂ4 = ℂ2 . (8.4)
®
𝑏 0 ,𝑏 1 =0 𝜓10 ®
« 𝜓11 ¬
This state vector must obey the, by now, familiar normalization condition:
∑︁1 2
∥𝝍 ∥ 2 = ⟨𝜓 |𝜓 ⟩ = 𝜓𝑏 0𝑏 1 = 1.
𝑏 0 ,𝑏 1 =0
Comparing Eq. (8.4) with Eq. (8.1) already provides us with a blueprint
on how to scale up these vector representations further. State vectors of
𝑛 -bit strings can be constructed by forming 𝑛 -fold Kronecker products of the
basic bit configurations (8.2) involved. Each Kronecker product doubles the
number of dimensions involved. So, we end up with state vectors that live in a
105 Lecture 8: General 𝑛 -qubit architectures
𝑛
2𝑛 -dimensional complex space ℂ2 : 𝑛 -qubit bitstring
configurations
1 1 1
| 0 · · · 00⟩ =| 0⟩ ⊗ · · · ⊗ | 0⟩ ⊗ | 0⟩ = ⊗ ··· ⊗ ⊗
0 0 0
𝑇 𝑛
= 1 0 ··· 0 0 = 𝒆 0 ∈ ℂ2 ,
1 1 0
| 0 · · · 01⟩ =| 0⟩ ⊗ · · · ⊗ | 0⟩ ⊗ | 1⟩ = ⊗ ··· ⊗ ⊗
0 0 1
2𝑛
𝑇
= 0 1 0 ··· 0 = 𝒆1 ∈ ℂ ,
..
.
1 0 0
| 01 · · · 1⟩ =| 0⟩ ⊗ | 1⟩ ⊗ · · · ⊗ | 1⟩ = ⊗ ⊗ ··· ⊗
0 1 1
𝑛
= 0 · · · 0 1 0 = 𝒆 2𝑛 −2 ∈ ℂ2 ,
0 0 0
| 11 · · · 1⟩ =| 1⟩ ⊗ | 1⟩ ⊗ · · · ⊗ | 1⟩ = ⊗ ⊗ ··· ⊗
1 1 1
2𝑛
= 0 0 · · · 0 1 = 𝒆 2𝑛 −1 ∈ ℂ .
A general 𝑛 -qubit state vector can form a superposition of all these 2𝑛 𝑛 -bit
configurations: 𝑛 -qubit state vector has 2𝑛
(complex-valued) amplitudes
𝜓0···00
© ª
∑︁1 𝜓0···01 ®
.. ® ∈ ℂ2𝑛 .
®
|𝜓 ⟩ = 𝜓𝑏 0 ···𝑏 𝑛 −1 |𝑏 0 · · · 𝑏 𝑛 −1 ⟩ = . (8.6)
𝑏 0 ,...,𝑏 𝑛 − 1 =0 ®
𝜓 ®
01···1 ®
« 𝜓11···1 ¬
Each amplitude 𝜓𝑏 0 ···𝑏 𝑛 −1 can be a complex number, but together they must
obey the following normalization condition:
∑︁1 2
∥𝝍 ∥ 2 = ⟨𝜓 |𝜓 ⟩ = 𝜓𝑏 0 ···𝑏 𝑛 −1 = 1.
𝑏 0 ,...,𝑏 𝑛 − 1 =0
Note that this sum ranges over all 2𝑛 different amplitudes that feature in
Eq. (8.6).
Exercise 8.1 The following representation of a general state puts more emphasis
on the exponential amount of different superpositions that are allowed:
∑︁2𝑛 −1 𝑛
∑︁2𝑛 −1
𝝍= 𝜓𝑙 𝒆 𝑙 ∈ ℂ2 or |𝜓 ⟩ = 𝜓𝑙 |⌞𝑙 ⌟⟩.
𝑙 =0 𝑙 =0
1 0 0 0
ª
0 1 0 0 ® 1 0 0 0
©
𝑪 𝑵 𝑶𝑻 1→2 = ®= ⊗𝕀+ ⊗ 𝑿,
0 0 0 1 ® 0 0 0 1
« 0 0 1 0 ¬
| {z } | {z }
| 0 ⟩⟨ 0 | | 1 ⟩⟨ 1 |
1 0 0 0
0 0 0 1 ® 1 0 0 0
© ª
𝑪 𝑵 𝑶𝑻 2→1 = ®=𝕀⊗ +𝑿 ⊗ ,
0 0 1 0 ® 0 0 0 1
« 0 1 0 0 ¬
| {z } | {z }
| 0 ⟩⟨ 0 | | 1 ⟩⟨ 1 |
where the subscript denotes the ‘flow of information’ from control to target.
Much like in conventional Boolean circuitry, we can now take these ele-
mentary gates and combine them to construct nontrivial functionalities on 𝑛
qubits. Such a quantum circuit has to map a 2𝑛 -dimensional state vector |𝜓in ⟩
(𝑛 -qubit input state) to another 2𝑛 -dimensional state vector |𝜓out ⟩ (𝑛 -qubit
output state). This action is described by a 2𝑛 × 2𝑛 circuit matrix 𝑼 : 𝑛 -qubit circuit fully described
by a 2𝑛 × 2𝑛 circuit matrix
𝑛
|𝜓out ⟩ = 𝑼 |𝜓in ⟩ for all |𝜓in ⟩ ∈ ℂ2 . (8.7)
(8.8)
The r.h.s displays a sequential combination of 12 gate layers. We can use the
Kronecker product to compute a 23 × 23 matrix representation for each of them:
𝑪 0 = 𝕀 ⊗ 𝕀 ⊗ 𝑯 , 𝑪 1 = 𝕀 ⊗ 𝑪 𝑵 𝑶𝑻 1→2 , 𝑪 2 = 𝕀 ⊗ 𝕀 ⊗ 𝑻 † ,
𝑪 3 = | 0⟩⟨0 | ⊗ 𝕀 ⊗ 𝕀 + | 1⟩⟨1 | ⊗ 𝕀 ⊗ 𝑿 (why?),
𝑪 4 = 𝕀 ⊗ 𝕀 ⊗ 𝑻 , 𝑪 5 = 𝕀 ⊗ 𝑪 𝑵 𝑶𝑻 1→2 , 𝑪 6 = 𝕀 ⊗ 𝕀 ⊗ 𝑻 † ,
𝑪 7 = 𝑪 3 , 𝑪 8 = 𝕀 ⊗ 𝑻 ⊗ 𝑻 , 𝑪 9 = 𝑪 𝑵 𝑶𝑻 1→2 ⊗ 𝑯 ,
𝑪 10 = 𝑻 ⊗ 𝑻 † ⊗ 𝕀 and 𝑪 11 = 𝑪 𝑵 𝑶𝑻 1→2 ⊗ 𝕀.
The final gate matrix then corresponds to the (ordered) matrix product of the
12 matrices that describe the individual layers:
𝑼 = 𝑪 11 × 𝑪 10 × 𝑪 9 × 𝑪 8 × 𝑪 7 × 𝑪 6 × 𝑪 5 × 𝑪 4 × 𝑪 3 × 𝑪 2 × 𝑪 1 × 𝑪 0 . (8.9)
Exercise 8.3 Derive the matrix representation (8.10) yourself by completing the
argument from the example: (i) form all 12 layer matrices 𝑪 0 , . . . , 𝑪 11 using
a Kronecker product construction, (ii) combine these 12 layers sequentially
by computing the matrix product in Eq. (8.9). Hint: don’t do this by hand.
Instead, write a piece of code that does it for you. Computers are good at this
type of linear algebra.
108 Lecture 8: General 𝑛 -qubit architectures
Kronecker and matrix products have another nice feature: they play nicely
with unitary matrices2.
Lemma 8.4 (Kronecker and matrix product respect unitary structure). The Kronecker
product of two (or more) unitary matrices is again a unitary matrix. Likewise,
the matrix product of two (or more) unitary matrices is again a unitary matrix.
The proof readily follows from the following appealing features of Kronecker
and matrix products: (𝑨 ⊗ 𝑩) † = 𝑨 † ⊗ 𝑩 † , (𝑨 ⊗ 𝑩) (𝑪 ⊗ 𝑫) = (𝑨𝑪 ) ⊗ (𝑩𝑫)
and, finally, (𝑼 × 𝑽 ) † = 𝑽 † × 𝑼 † . We leave it as an instructive exercise in
(multi-)linear algebra.
Exercise 8.5 Prove Lemma 8.4.
The following proposition is now an immediate consequence of Lemma 8.4
and the way we construct matrix representations of general 𝑛 -qubit circuits.
Proposition 8.6 (circuit matrix). The functionality of every 𝑛 -qubit circuit is every 𝑛 -qubit circuit is fully
completely described by a × circuit matrix 𝑼 . This matrix is unitary and
2𝑛 2𝑛 captured by a unitary 2𝑛 × 2𝑛
Kronecker & matrix products allow us to construct it from the circuit diagram. matrix
Theorem 8.7 (Solovay-Kitaev (𝑛 -qubit case)). Every unitary 2𝑛 × 2𝑛 matrix 𝑼 every 2𝑛 × 2𝑛 unitary matrix
can be approximated to arbitrary precision by a 𝑛 -qubit quantum circuit admits a 𝑛 -qubit circuit
that is solely comprised of 𝑯 , 𝑺 , 𝑪 𝑵 𝑶𝑻 (Clifford) and 𝑻 -gates. approx. (Solovay-Kitaev)
initialization:
𝑛
|𝑏 0 · · · 𝑏 𝑛 −1 ⟩ = 𝒆 𝑏 0 +2×𝑏 1 +···+2𝑛 −1 ×𝑏 𝑛 −1 ∈ ℂ2 . (8.11)
Now, let 𝑠 be the size of the quantum circuit, i.e. the total number of nontrivial
gates. Then, we can re-express the circuit as a sequential combination of 𝑠
layers, where each layer contains exactly one nontrivial gate:
𝑼 = 𝑪 𝑠 −1 × · · · × 𝑪 1 .
The individual layer matrices must be Kronecker products of exactly one
nontrivial gate matrix with only identity matrices (𝕀). For a single-qubit gate 𝑽
at qubit wire 𝑎 ∈ {0, . . . , 𝑛 − 1}, we get
𝑪𝑘 = 𝕀 ⊗ · · · ⊗ 𝕀 ⊗𝑽 ⊗ 𝕀 ⊗ · · · ⊗ 𝕀 (8.12)
| {z } | {z }
(𝑎 − 1 ) times (𝑛 − 𝑎 ) times
𝑪 𝑘 =𝕀 ⊗ · · · ⊗ 𝕀 ⊗ | 0⟩⟨0 | ⊗ 𝕀 ⊗ · · · ⊗ 𝕀
| {z } | {z }
𝑎 times (𝑛 − 𝑎 − 1 ) times
+𝕀 ⊗ · · · ⊗ 𝕀 ⊗ | 1⟩⟨1 | ⊗ 𝕀 ⊗ · · · ⊗ 𝕀 ⊗ 𝑿 ⊗ 𝕀 ⊗ · · · ⊗ 𝕀 . (8.13)
| {z } | {z } | {z }
𝑠 times (𝑏 − 𝑎 − 1 ) times (𝑛 − 𝑏 − 1 ) times
𝑪 𝑘 =𝕀 ⊗ · · · ⊗ 𝕀 ⊗ | 0⟩⟨0 | ⊗ 𝕀 ⊗ · · · ⊗ 𝕀
| {z } | {z }
𝑎 times (𝑛 − 𝑎 − 1 ) times
+𝕀 ⊗ · · · ⊗ 𝕀 ⊗ 𝑿 ⊗ 𝕀 ⊗ · · · ⊗ 𝕀 ⊗ | 1⟩⟨1 | ⊗ 𝕀 ⊗ · · · ⊗ 𝕀 . (8.14)
| {z } | {z } | {z }
𝑏 times (𝑎 − 𝑏 − 1 ) times (𝑛 − 𝑎 − 1 ) times
Correctness of the implementation follows directly from the truth table of the
Toffoli gate (8.10): the third bit is flipped from 0 to 1 if and only if 𝑏 0 = 𝑏 1 = 1.
Otherwise, it stays in 0.
Note that the Toffoli gate is typically not a native gate on a quantum
computer. We can, however, use Example 8.2 to decompose 𝑪 𝑪 𝑵 𝑶𝑻 into a
combination of 2 Hadamards, 25 𝑻 gates and 6 𝑪 𝑵 𝑶𝑻 s. This produces the
following overhead in terms of elementary quantum gates.
Lemma 8.13 (reversible implementation of AND (∧)). We can realize one two-bit
AND-gate using one additional qubit (initialized in 0), 6 𝑪 𝑵 𝑶𝑻 gates and 27
single-qubit gates (i.e. 33 elementary gates in total).
Exercise 8.14 (impossibility of implementing ∧ with two qubits). Argue that it is
impossible to realize a logical AND operation with only two qubits.
Reversible OR (∨)
Finally, we need to realize the logical OR operation (∨):
(
0 if 𝑏 0 = 0 and 𝑏 1 = 0,
𝑏0 ∨ 𝑏1 =
1 else (𝑏 0 = 1 or 𝑏 1 = 1).
(qu)-bit wire. The following 3-qubit circuit again uses a single Toffoli gate: reversible OR: 3 qubits, 1
Toffoli gate, 5 bitflips
For most circuits, circuit size 𝑠 is the dominant cost parameter. Theorem 8.16
then highlights that the overheads scale (at most) linearly in this dominant cost
factor: nr. of qubits = 𝑂 (𝑠 ) and nr. of quantum gates = 𝑂 (𝑠 ) .
Corollary 8.17 (linear overhead when moving from classical to quantum). Every clas- linear overhead permits
sical circuit can also be executed on a quantum architecture. The overhead is executing classical circuits on
(at most) linear in the original circuit size. quantum hardware
b0 ¬
∨
∧ b̄0 ∨ b1 ∧ b0 ∨ b̄1
(8.16)
∨
b1 ¬
This circuit goes from left to right and contains 𝑠 = 5 Boolean gates (two ¬,
two ∨ and one ∧). Here is a quantum implementation of the same functionality
which we read from right to left instead:
In order to compile it into elementary quantum gates, we can use the decom-
position of the Toffoli gate (two-fold controlled-NOT gate) into 𝑯 ,𝑻 ,𝑻 † and
𝑪 𝑵 𝑶𝑻 from Example 8.2. Doing so produces an actual quantum circuit that
acts on
𝑛′ = 5 = 2 + 3
qubit wires. The first two wires carry the logical inputs 𝑏 0 and 𝑏 1 . Qubits 3, 4
and 5 compute intermediate logical values. Incidentally, the final logical value
is also the output of the circuit. There are 𝑠˜ = 3 non-reversible operations (∧
and ∨). Using Lemma 8.13 and Lemma 8.15, we can invest one additional
qubit wire and a total of 33 (∧) and 38 (∨) elementary quantum gates to
implement these functionalities in a reversible fashion. Logical negation (¬)
is easier by comparison. We can achieve it by applying 𝑿 and (potentially)
reverting this bit flip again at a later stage to recover the original truth value
back. To summarize:
1 For each non-reversible operation (∧, ∨), we need one additional qubit
wire and (at most) 38 elementary quantum gates.
2 For each output bit, we (may) need an additional qubit wire that is
initialized to 0. A single 𝑪 𝑵 𝑶𝑻 allows us to copy the relevant truth
variable into this wire.
8.4 Synopsis
Today, we started to compare classical and quantum (hardware) architectures
directly with each other. In particular, we have seen that quantum hardware
is never much worse than classical hardware. Theorem 8.16 states that every
classical circuit can also be executed on a quantum architecture with (at most)
linear overhead. In contrast, the transition from quantum to classical hardware
looks much more daunting. Theorem 8.9 states that it is possible to simulate
quantum architectures with classical software (and hardware, by extension).
But, the overhead in cost is substantial: our sparse matrix-vector subroutine
could only guarantee a runtime of 2𝑛 × circuit-size for a general 𝑛 -qubit circuit.
This exponential overhead grows quickly. For 𝑛 = 10, we obtain 2𝑛 = 1024 –
which is still manageable. But already 𝑛 = 100 produces 2100 ≈ 1.26 × 1030 –
this overhead quickly exhausts even the most powerful supercomputers.
linear
At this point, we should point out that sparse matrix-vector multiplication classical −→ quantum
is only one approach to simulate quantum architectures on classical hardware. exponential
quantum −→ classical
This approach is also called array-based simulation because it involves large
arrays (matrices and vectors). Other approaches include tensor network-based
simulations, stabilizer-based simulations, simulation based on decision diagrams
and many more. These all have their own strengths and weaknesses. But,
ultimately, each and every classical simulator developed to date starts to struggle
with an exponential cost increase (in the number of qubits 𝑛 ).
Exercise 8.20 (consequences of efficient classical simulation of quantum architectures).
Suppose that it was possible to simulate a general 𝑛 -qubit architecture with
only polynomial overhead (in 𝑛 ). I.e. every quantum circuit with 𝑠 gates can
be simulated with poly (𝑛) × 𝑠 arithmetic operations. Shor’s algorithm is such a
quantum circuit: it factorizes a 𝑛 bit integer by repeatedly executing a quantum
circuit of size 𝑠 = 𝑂 (𝑛 3 ) . Use this piece of information to conclude that efficient
classical simulation of quantum circuits would imply a polynomial-runtime
algorithm (in bit size 𝑛 ) for integer factorization. What would this mean for
the RSA public key encryption protocol?
9. Amplitude amplification circuits
9.2 Setup
Consider a 𝑛 -bit Boolean function
𝑓 : {0, 1}𝑛 → {0, 1} .
Our task is to find a satisfying assignment: task: find 𝒃 ∈ {0, 1}𝑛 s.t.
𝑓 (𝒃) = 1 (‘positive answer’)
𝒃 = 𝑏 0 · · · 𝑏 𝑛 −1 ∈ {0, 1}𝑛 such that 𝑓 (𝒃) = 1.
Let us start by collecting important cost parameters. The first one is the cost
of computing 𝑓 (𝒃) for a given input. To ease our transition into the quantum
118 Lecture 9: Amplitude amplification circuits
realm, we don’t consider the function 𝑓 directly, but a Boolean circuit 𝐶 𝑓 that
implements it. The circuit size
Together, circuit size and ratio of positive answers bound the expected runtime
of a simple randomized solution strategy:
Proof of Proposition 9.1. The proof follows from computing the state vector of
the (𝑛 + 𝑠 + 1) qubits from beginning to end. In the beginning, we have
| 𝜑 0 ⟩ = | 0 . . . 0⟩ = (| 0⟩) ⊗ (𝑛+𝑠 +1 ) . Applying Hadamards to the first 𝑛 qubits
produces a (partial) superposition
| 𝜑 1 ⟩ =𝑯 ⊗𝑛 ⊗ 𝕀⊗ (𝑠 +1 ) | 0⟩ ⊗ (𝑛+𝑠 +1 ) = (𝑯 | 0⟩) ⊗𝑛 ⊗ | 0⟩ 𝑠 +1
1 ∑︁1 1 ∑︁
=√ |𝑏 0 . . . 𝑏 𝑛 −1 ⟩ ⊗ | 0⟩ ⊗ (𝑠 +1 ) = √ |𝒃 0𝑠 0⟩.
2𝑛 𝑏 ,...,𝑏
0 𝑛 −1=0 2𝑛 𝒃 ∈ { 0,1 } 𝑛
119 Lecture 9: Amplitude amplification circuits
It is now time to apply the purple circuit block from Fig. 9.1:
1 ∑︁
| 𝜑2⟩ = 𝑪 𝑓 | 𝜑1⟩ = √ |𝒃 0𝑠 𝑓 (𝒃)⟩.
2𝑛 𝒃 ∈ { 0,1 } 𝑛
How many trials do we need until we are guaranteed to sample (at least) one
bit string that obeys 𝑓 (𝒃) = 1? To answer this question, let 𝑇 denote the
total number of times we evaluate the circuit (i.e. the total number of random
bitstrings 𝒃 we produce with readout). Then, the probability of never sampling
a positive answer is
Many important search problems fall into this broad category. Let us
provide two examples.
𝑛
Example 9.2 (SAT). Let 𝑓 : {0, 1} → {0, 1} be a Boolean formula in CNF. search for positive answers
Then, the task of finding a positive answer 𝑓 (𝒃) = 1 also solves the famous covers satisfiability (SAT)
satisfiability problem. CNF formulas also have efficient circuit implementations,
i.e. size (𝑓 ) = poly (𝑛) . So, evaluating 𝑓 (or constructing the circuit 𝐶 𝑓 ) is not
the main bottleneck. What makes this problem hard is that we may have to
check exponentially many inputs: the ratio of positive answers 𝑟 ( 𝑓 ) can be as
small as 𝑟 (𝑓 ) = 1/2𝑛 . ■
Example 9.3 (unstructured data base search). We can also interpret the Boolean unstructured data base search
function 𝑓 : {0, 1}𝑛 → {0, 1} as a label function in an unstructured database also covered
of bit encodings. Viewed from this angle, the task of finding 𝒃 ∈ {0, 1}𝑛 with
𝑓 (𝒃) = 1 boils down to finding a database entry with the label ‘yes’. Problems
of this kind often occur as subroutines in more involved algorithms. ■
and scales linearly in the inverse ratio of positive answers (1/𝑟 ( 𝑓 ) ). Note total classical cost is
furthermore that the ratio of positive answers can very well be exponentially ≈ size ( 𝑓 )/𝑟 ( 𝑓 )
small (𝑟 (𝑓 ) = 1/2𝑛 if there is exactly one positive answer). In these cases, the
total cost (9.1) also explodes exponentially.
Let us now present a high-level idea that uses quantum circuits to achieve a
quadratic improvement in total cost. The resulting quantum circuit 𝑮 will have
(quantum) circuit size
√︁
size (𝑮 ) = 𝑂 ( size ( 𝑓 ) + 𝑛) / 𝑟 (𝑓 ) , (9.2)
where 𝑂 denotes the big-O notation which supresses constants and subleading
terms. The first contribution is comparable to the cost of executing the circuit total quantum cost is
√︁ √︁
𝐶 𝑓 once. The second contribution is where things get interesting: 1/ 𝑟 ( 𝑓 ) = ≈ size ( 𝑓 )/ 𝑟 ( 𝑓 )
√︁
1/𝑟 (𝑓 ) is quadratically smaller than the 1/𝑟 (𝑓 ) -term that dominates the
classical cost (9.1). How can we hope to achieve such a quadratic improvement?
There are two main ideas that we shall now cover.
121 Lecture 9: Amplitude amplification circuits
Figure 9.2 Geometric intuition behind amplitude amplification: view the uniform
superposition |𝜔⟩ as a combination of the superposition of bad input strings
|𝜓bad ⟩ ( 𝑓 (𝒃) = 0) and the superposition of good input strings √︁|𝜓good ⟩ ( 𝑓 (𝒃) =
1). The amplitude of |𝜓good ⟩ is proportional to 𝜃 ≈ sin (𝜃 ) = 𝑟 (𝑓 ) ≪ 1 (top
left). A reflection about |𝜓bad ⟩ (top center) followed by a reflection about |𝜔⟩
(top right) implement a rotation 𝑹 that amplifies this amplitude (bottom right).
A sequential application of many rotations amplifies this good amplitude to
approximately everything (bottom left).
1 ∑︁
|𝜔⟩ = (𝑯 | 0⟩) ⊗𝑛 = √ |𝒃⟩
2𝑛 𝒃 ∈ { 0,1 } 𝑛
1 ∑︁ 1 ∑︁
=√ |𝒃⟩ + √ |𝒃⟩
2𝑛 𝒃 : 𝑓 (𝒃 )=0 2𝑛 𝒃 : 𝑓 (𝒃 )=1
√︂ √︂
𝑡 − (𝑓 ) 1 ∑︁ 𝑡 + ( 𝑓 ) 1 ∑︁
= √︁ |𝒃⟩ + √︁ |𝒃⟩
2𝑛 𝑡 − (𝑓 ) 𝒃 : 𝑓 (𝒃 )=0 2𝑛 𝑡+ ( 𝑓 ) 𝒃 : 𝑓 (𝒃 )=1
√︂ √︂
2𝑛 − 𝑡 + (𝑓 ) 𝑡+ (𝑓 )
= |𝜓bad ⟩ + |𝜓good ⟩
2 𝑛 2𝑛
√︁ √︁
= 1 − 𝑟 ( 𝑓 )|𝜓bad ⟩ + 𝑟 (𝑓 )|𝜓good ⟩. (9.3)
ultimately leverages this quadratic discrepancy. To make our life easier later
on, we replace the amplitudes in Eq. (9.3) with trigonometric functions. Let
𝜃 ∈ [0, 2𝜋) be the angle that obeys
√︁
𝑟 (𝑓 ) = sin (𝜃 ), such that |𝜔⟩ = cos (𝜃 )|𝜓bad ⟩ + sin (𝜃 )|𝜓good ⟩. (9.4)
We refer to Fig. 9.2 (top left) for a visual illustration. The problem is that for uniform superposition |𝜔⟩
𝜃 ≪ 1 (which happens if 𝑟 (𝑓 ) ≪ 1), cos (𝜃 ) ≈ 1 and sin (𝜃 ) ≈ 0. This is also contains both bad and good
why our first quantum circuit needs so many trials to get a positive answer. bitstrings
However, it is also true that the uniform superposition |𝜔⟩ = |𝑯 ⊗𝑛 | 0 . . . 0⟩
does contain some share of the good answers: sin (𝜃 ) > 0 whenever 𝑟 ( 𝑓 ) > 0.
We refer to Fig. 9.2 (left) for a visual illustration. The second quantum idea
is designed to increase the amplitude of |𝜓good ⟩ at the cost of diminishing the
amplitude of |𝜓bad ⟩ .
Idea II: amplify the amplitude belonging to the superposition of ‘good’ bitstrings
Recall that quantum circuits act as unitary matrices on state vectors. What is
more, we can view Eq. (9.4) as an effective single-qubit state vector with only
two amplitudes:
cos (𝜃 )
|𝜔⟩ = cos (𝜃 )|𝜓bad ⟩ + sin (𝜃 )|𝜓good ⟩ = with ⟨𝜓bad |𝜓good ⟩ = 0.
sin (𝜃 )
Next, suppose that we are somehow able to implement the following rotation
gate on this effective qubit:
cos ( 2𝜃 ) − sin ( 2𝜃 )
𝑹= . (9.5)
sin ( 2𝜃 ) cos ( 2𝜃 )
because sin (𝛼+𝛽) = sin (𝛼) cos (𝛽)+cos (𝛼) sin (𝛽) and cos (𝛼+𝛽) = cos (𝛼) cos (𝛽)−
sin (𝛼) sin (𝛽) . More generally, we obtain for 𝑇 ≥ 2 iteratively increase amplitude
of good bitstrings within |𝜔⟩
𝑇 cos (( 2𝑇 + 1)𝜃 )
𝑹 |𝜔⟩ = 𝑹 × · · · × 𝑹 |𝜔⟩ = .
| {z } sin (( 2𝑇 + 1)𝜃 )
𝑇 times
at the cost of the cosine-contribution. The extreme case occurs at angle 𝜋/2
where sin (𝜋/2) = 1 and cos (𝜋/2) = 0. That is, if we choose
the resulting quantum state will (almost) only feature good contributions:
Note that the final expression only features ‘good’ bit strings 𝒃 ∈ {0, 1}𝑛 such
that 𝑓 (𝒃) = 1. Any one of them solves our problem! And performing the
readout will provide us with precisely√︁one of them. Finally, note that 𝜃 is
in one-to-one correspondence with 1/ 𝑟 (𝑓 ) , courtesy of Eq. (9.4) and the
fact that sin (𝜃 ) ≈ 𝜃 for 𝜃 ≪ 1 (in fact sin (𝜃 ) ≤ 𝜃 for all 𝜃 ∈ [ 0, 2𝜋) ). The
following rigorous proposition is an immediate consequence of our analysis.
Proposition 9.4 (amplitude amplification, high-level). Fix a satisfiable Boolean
function 𝑓 : {0, 1}𝑛 → {0, 1} with ratio√︁of positive answers 𝑟 ( 𝑓 ) ∈ ( 0, 1]
and set 𝜃 ∈ [ 0, 2𝜋) such that sin (𝜃 ) = 𝑟 (𝑓 ) . Suppose that it is possible
to generate a 𝑛 -qubit circuit 𝑹 that acts as Eq. (9.5) on |𝜓bad ⟩ and |𝜓good ⟩ .
√︁
Then, 𝑇♯ ≈ 𝜋/( 4 𝑟 ( 𝑓 )) sequential applications of 𝑹 (approximately) turn the
uniform superposition |𝜔⟩ = 𝑯 ⊗𝑛 | 0 . . . 0⟩ into a superposition |𝜓good ⟩ of only
positive answers.
Note that the term approximately is actually necessary in Proposition 9.4.
The optimal choice of 𝑇♯ in Eq. (9.6) requires us to approximate the possibly
irrational fraction 𝜋/( 2𝜃 ) with an integer 2𝑇♯ + 1. This necessarily introduces
rounding errors. Fortunately, these rounding errors are small and sine is a
smoothly varying function. In particular, 2𝑇♯ + 1 ≈ 𝜋/( 2𝜃 ) is enough to ensure
sin ( 2𝑇♯ + 1)𝜃 ≈ sin (𝜋/2) = 1 via a continuity argument.
In words: This unitary matrix reflects ‘good input states’ and leaves ‘bad
input states’ as they are.
Proof. We can without loss restrict our attention to the first 𝑛 qubits plus the
last one. The part in the middle is only required to reversibly implement logical
∧, ∨. It starts in 0 and ends in 0. The remaining√circuit prepares the last qubit
in the state |−⟩ = 𝑯 𝑿 | 0⟩ = 𝑯 | 1⟩ = (| 0⟩ − | 1⟩)/ 2. We then XOR the value of
𝑓 (𝒃) to it. For 𝒃 ∈ {0, 1}𝑛 , we obtain
√
𝑪 𝑓 × 𝕀⊗𝑛 ⊗ (𝑯 𝑿 ) |𝒃 0⟩ =|𝒃⟩ ⊗ (| 0 ⊕ 𝑓 (𝒃)⟩ − | 1 ⊕ 𝑓 (𝒃)⟩) / 2
The final 𝑿 and 𝑯 convert the |−⟩ -state back into the | 0⟩ -state we start with:
Eq. (9.7) subsumes all these actions on different bit strings into a single
display. ■
125 Lecture 9: Amplitude amplification circuits
We can use Lemma 9.5 to infer the action of 𝑼 𝑓 on the effective qubit
spanned by |𝜓bad ⟩ and |𝜓good ⟩ . Linearity ensures
1 ∑︁
𝑼 𝑓 |𝜓bad ⟩ = √︁ 𝑼 𝑓 |𝒃⟩
𝒃 : 𝑓 (𝒃 )=0
2𝑛 ( 1 − 𝑟 (𝑓 ))
1 ∑︁
= √︁ (−1) 𝑓 (𝒃 ) |𝒃⟩
𝒃 : 𝑓 (𝒃 )=0
2𝑛 ( 1 − 𝑟 (𝑓 ))
1 ∑︁
= √︁ |𝒃⟩
𝒃 : 𝑓 (𝒃 )=0
2𝑛 ( 1 − 𝑟 (𝑓 ))
= + |𝜓bad ⟩
and, likewise
1 ∑︁
𝑼 𝑓 |𝜓good ⟩ = √︁ 𝑼 𝑓 |𝒃⟩
𝒃 : 𝑓 (𝒃 )=1
2𝑛 𝑟 (𝑓 )
1 ∑︁
= √︁ (−1) 𝑓 (𝒃 ) |𝒃⟩
𝒃 : 𝑓 (𝒃 )=1
2𝑛 𝑟 (𝑓 )
1 ∑︁
= − √︁ |𝒃⟩
𝒃 : 𝑓 (𝒃 )=1
2𝑛 𝑟 (𝑓 )
= − |𝜓good ⟩.
In words: this is a reflection about the state |𝜔⟩ , i.e. 𝑺 |𝜔⟩ = −|𝜔⟩ and
𝑺 |𝜈⟩ = +|𝜈⟩ whenever ⟨𝜔 |𝜈⟩ = 0 (orthogonality).
Exercise 9.7 (Proof of Lemma 9.6). Show that the circuit depicted in Fig. 9.3 is
indeed described by Eq. (9.9).
We can use |𝜔⟩ = cos (𝜃 )|𝜓bad ⟩ + sin (𝜃 )|𝜓good ⟩ (Eq. (9.4)) to infer the
action of 𝑺 on the effective qubit spanned by |𝜓bad ⟩ and |𝜓good ⟩ . To declutter
126 Lecture 9: Amplitude amplification circuits
This is now a proper rotation matrix. Note furthermore that this effective a combination of diffusion
single-qubit functionality has exactly the form we need for Proposition 9.4. and function oracles acts as
an effective rotation
𝑛
Theorem 9.8 (amplitude amplification circuit). Let 𝑓 : {0, 1} → {0, 1} be a amplitude amplification
achieves quadratic speedup
√︁ with ratio of positive answers 𝑟 (𝑓 ) and circuit size size (𝑓 ) .
Boolean function
Set 𝑇♯ ≈ 𝜋/( 4 𝑟 (𝑓 ) . Then, the circuit displayed in Fig. 9.4 almost produces
a uniform superposition of all bitstrings 𝒃 such that 𝑓 (𝒃) = 1. A readout of
the first 𝑛 qubits produces one of them with a very high probability.
√︁
The total size of this circuit is 𝑂 size ( 𝑓 )/ 𝑟 (𝑓 ) (assuming size (𝑓 ) ≥ 𝑛 ).
For sufficiently large input sizes 𝑛 ≫ 1, this becomes much cheaper than the
total cost of 3 × size (𝑓 )/𝑟 (𝑓 ) required to execute a random search protocol
(Algorithm 9.1). This quadratic discrepancy becomes particularly pronounced if
the ratio of positive answers 𝑟 ( 𝑓 ) is very small (𝑟 (𝑓 ) ≈ 1/2𝑛 ).
Next, we point out that the quantifier ‘almost’ in Theorem 9.8 takes into
account rounding
√︁ issues when choosing the optimal number of iterations
𝑇♯ ≈ 𝜋/( 4 𝑟 (𝑓 ) . We can handle this by repeating the circuit multiple times
until we get an output 𝒃 that fulfils 𝑓 (𝒃) = 1 (evaluating the function for a
single input is very cheap by comparison). And continuity arguments ensure
that the probability of getting a good string is very close to sin (𝜋/2) = 1.
A more serious issue is the fact that the number of repetitions 𝑇♯ depends
on the ratio of positive answers 𝑟 (𝑓 ) . And this ratio may not be known
in advance! To make matters worse, it is absolutely possible to overshoot
amplitude amplification. If we get 𝑇♯ wrong by a factor of 2, for instance, we amplitude amplification can
overshoot
128 Lecture 9: Amplitude amplification circuits
∥𝑭 𝒙 ∥ 22 = (𝑭 𝒙 ) † (𝑭 𝒙 ) = 𝒙 † 𝑭 † 𝑭 𝒙 = 𝒙 † 𝕀𝒙 = 𝒙 †𝒙 = ∥𝒙 ∥ 22 for every 𝒙 ∈ ℂ𝐷 ,
2 2 2 2 1
= 𝒆 𝑙†𝒇 𝑘 = 𝒆 𝑙† 𝑭 𝒆 𝑘
𝒇𝑘 𝑙 = [𝑭 ] 𝑘 ,𝑙 = . (10.1)
𝐷
In words: all coefficients of all Fourier basis vectors – or, in fact, every entry
in the the Fourier-type matrix itself – must have the same magnitude. This
indeed ensures that the Fourier-type transformation maps (very) sparse vectors
𝒙 ∈ ℂ𝐷 to (very) dense vectors. Fourier type transform:
We can recognize a quantum computing interpretation of these two math- unitary matrix with ‘flat’
ematical properties if we set 𝐷 = 2𝑛 (𝑛 qubits), see Fig. 10.1 for a visual matrix entries
𝑛 𝑛
illustration. Length preservation (aka unitarity) ensures that 𝑭 ∈ ℂ2 × 2
describes the truth table of a valid 𝑛 -qubit quantum circuit. And the flatness
130 Lecture 10: Quantum Fourier-type transforms
Figure 10.1 General layout of a Fourier type circuit: a 𝑛 -qubit circuit comprised
of poly (𝑛) gates effectively implements a Fourier-type (unitary+flat) matrix
multiplication in 𝐷 = 2𝑛 dimensions.
condition (10.1) demands that this quantum circuit maps every deterministic bit
encoding |𝑏 0 · · · 𝑏 𝑛 − 1 ⟩ into a uniform superposition of all 2𝑛 possible bitstrings.
What is more, all these uniform superpositions must be disjoint and perfectly
distinguishable. After all
(
1 if 𝑘 = 𝑙 ,
𝒇 𝑘† 𝒇 𝑙 = 𝒆 𝑘† 𝑭 † 𝑭 𝒆 𝑙 = 𝒆 𝑘† 𝒆 𝑙 =
0 else if 𝑘 ≠ 𝑙 .
which satisfies the flatness condition (10.1). These two features ensure that the
Hadamard gate maps the two possible deterministic input states | 0⟩ and | 1⟩
131 Lecture 10: Quantum Fourier-type transforms
onto uniform superpositions that are perfectly distinguishable from each other:
1 1 +1
|+⟩ =𝑯 | 0⟩ = √ (| 0⟩ + | 1⟩) = √ =: 𝒇 0 ∈ ℂ2 ,
2 2 +1
1 1 +1
|−⟩ =𝑯 | 1⟩ = √ (| 0⟩ − | 1⟩) = √ = 𝒇 1 ∈ ℂ2 .
2 2 − 1
■
the entries of the smaller matrices involved. And these are themselves always
+1 and −1.
These arguments readily extend to larger Kronecker products of Hadamard
gates and give rise to an infinite family of Fourier-type transformations. The
following result is an immediate consequence of this observation:
𝑾 𝑯 (𝐷 ) = 𝑯 ⊗ log2 (𝐷 ) (10.4)
Hadamard transform matrix from the Kronecker product definition in Eq. (10.4).
This 𝑛 -qubit circuit is arguably as easy and cheap as it gets: a single layer of 𝑛 quantum realization of WH
parallel single-qubit gates is enough. transform requires 𝑛
Hadamard gates
10.2.3 Fast Walsh-Hadamard transform
We now show how one can use the quantum circuit implementation of the Walsh-
Hadamard transformation matrix 𝑾 𝑯 (𝐷 ) from Sub. 10.2.2 to construct a fast
classical transformation. That is, an alternative way to compute matrix-vector
multiplications
whose resource cost scales much more favorably than the general cost of (order)
𝐷 2 for multiplying a 𝐷 × 𝐷 matrix with a 𝐷 -dimensional vector. Remarkably,
we will get an almost quadratic improvement.
Theorem 10.4 (Fast (classical) Walsh-Hadamard transform). Fix 𝐷 = 2𝑛 . Then, Fast (classical)
we can compute the Walsh-Hadamard transform 𝑾 𝑯 (𝐷 ) × 𝒙 of any vector Walsh-Hadamard transform
𝒙 ∈ ℂ𝐷 with only (order) log2 (𝐷) × 𝐷 ≪ 𝐷 2 (classical) operations.
Proof. First, let us assume that the vector 𝒙 ∈ ℂ𝐷 is normalized to unit length,
𝑛
i.e. ∥𝒙 ∥ 2 = 1. Then, we can interpret the 2𝑛 coefficients of 𝒙 ∈ ℂ2 as
amplitudes belonging to a superposition of all 2𝑛 possible 𝑛 -bit configurations
|𝑏 0 · · · 𝑏 𝑛 −1 ⟩ :
∑︁2𝑛 −1 ∑︁1
|𝜉 ⟩ = [𝒙 ] 𝑙 |⌞𝑙 ⌟⟩ = [𝒙 ] 2𝑛 −1𝑏 0 +···2𝑏 𝑛 −2 +𝑏 𝑛 −1 |𝑏 0 · · · 𝑏 𝑛 −1 ⟩.
𝑙 =0 𝑏 0 ,...,𝑏 𝑛 − 1 =0
𝑾 𝑯 (𝐷 ) × 𝒙 = 𝑯 ⊗𝑛 |𝜉 ⟩.
The circuit on the right contains 𝑛 layers. And each layer only contains a single
Hadamard gate. This reformulation is desirable, when we attempt to simulate
this circuit on classical hardware. Indeed,
⊗ (𝑛 − 1 ) ⊗ (𝑛 − 1 )
𝑾 = 𝕀 ⊗𝑯 ×···× 𝑯 ⊗ 𝕀
| {z }
𝑛 matrix products
and each matrix on the right is extremely sparse: only 𝑠 = 2 entries in each
row/column are different from zero. This observation allows us to decompose
the full matrix-vector multiplication into a sequence of 𝑛 sparse matrix-vector
multiplications:
𝒚 0 = 𝒙 , 𝒚 1 = 𝑯 ⊗ 𝕀⊗ (𝑛 −1 ) 𝒚 0 , . . . , 𝒚 𝑛 −1 = 𝕀⊗ (𝑛 −1 ) ⊗ 𝑯 𝒚 𝑛 −2 .
and use the strategy developed above to execute the bracketed matrix-vector
product. To obtain the final,
unnormalized, result, we only need to multiply
each entry of 𝑾 𝑯 (𝐷 ) × 𝒙ˆ ∈ ℂ by the single number ∥𝒙 ∥ 2 . This can again
𝐷
be done with only (order) 𝐷 elementary operations. So, the total overhead
of this pre- and post-processing is (order) 𝐷 which is smaller than the cost of
executing the normalized matrix-vector multiplication. ■
transform (DFT) follows from an alternative route that is well defined for any
dimension 𝐷 . The starting point is to recognize +1 and −1 as solutions to the
quadratic equation 𝑥 2 = +1. In other words: (−1) = exp ( i2𝜋/2) =: 𝜔 2 is a
second root of unity and (+1) can be interpreted as the 0th power of this root:
(+1) = exp ( 0) = exp ( i2𝜋/2 × 0) = 𝜔 20 . Inserting these interpretations of ±1
into the Hadamard gate produces
𝜔 20×0 𝜔 20×1
1 +1 +1 1 𝜔 20 𝜔 20 1
𝑯 =√ =√ =√ .
2 +1 −1 2 𝜔 20 𝜔 21 2 𝜔 21×0 𝜔 21×1
Note that the reformulation on the very right – where we express the powers as
product of row and column index – is very reminiscent of the entry formula
of the general Walsh-Hadamard transform in Theorem 10.2. Doing this for
the Hadamard gate might look overly complicated on first sight. But, the
interpretation on the very right suggests a way to generalize this matrix structure
to 𝐷 = 3 dimensions. We replace the second root of unity 𝜔 2 = exp ( 2𝜋 i/2)
with a third root of unity 𝜔 3 = exp ( 2𝜋 i/3) . I.e. one solution of the cubic
equation 𝑥 3 = +1. Then, we use products of column and row indices to
populate a 3 × 3 matrix:
𝑭 †(3 ) × 𝑭 ( 3 ) = 𝕀3×3 .
Let us do one more example before stating the general definition. For 𝐷 = 4,
our fourth root of unity becomes 𝜔 4 = exp ( 2𝜋 i/4) = i. In this dimension, the
137 Lecture 10: Quantum Fourier-type transforms
DFT matrix is populated with the imaginary unit i, as well as its powers:
𝜔 40×0 𝜔 40×1 𝜔 40×2 𝜔 40×3 i0 i0 i0 i0
1 𝜔 41 × 0 𝜔 41 × 1 𝜔 41 × 2 𝜔 41 × 3 ® 1 i0 i1 i2 i3 ®
© ª © ª
𝑭 (4) = √ 2×0 ®=
𝜔 42×1 𝜔 42×2 𝜔 42×3 ® 2 i0 i2 i4 i6 ®
®
4 𝜔4
3×0
« 𝜔4 𝜔 43×1 𝜔 43×2 𝜔 43×3 ¬ 0 3 6
« i i i i ¬
9
+1 +1 +1 +1
1 +1 +i −1 −i ®
© ª
= ® ∈ ℂ4×4 . (10.7)
2 + 1 −1 + 1 −1 ®
« + 1 −i −1 + i ¬
Here, we have used i2 = −1, i3 = −i and i4 = +1 to simplify the powers of i.
This matrix certainly obeys the flatness condition ( | ± i | = | ± 1 | = 1) and is
also unitary.
Exercise 10.6 (𝑭 ( 4 ) is a unitary matrix). Show that the matrix 𝑭 ( 4 ) is unitary, i.e.
𝑭 †(4 ) × 𝑭 ( 4 ) = 𝕀4×4 . Hint: the adjoint features both transposition and complex
conjugation, also i2 = −1.
We are now ready to present the 𝐷 -dimensional discrete Fourier transform
(DFT) matrix. It is a straightforward extension from the examples we just did
for 𝐷 = 2 (Hadamard gate, base case), 𝐷 = 3 and 𝐷 = 4.
Definition 10.7 (Discrete Fourier Transform (DFT) in 𝐷 dimensions). Fix a dimension Discrete Fourier Transform
𝐷 ∈ ℕ and let 𝜔 𝐷 = exp ( 2𝜋 i/𝐷) ∈ ℂ be a 𝐷 th root of unity (i.e. a solution (DFT)
to 𝑥 𝐷 = +1). The 𝐷 -dimensional Discrete Fourier Transform (DFT) is a
complex-valued 𝐷 × 𝐷 matrix 𝑭 (𝐷 ) with entries
1
𝑭 (𝐷 ) 𝑘 ,𝑙 = √ 𝜔 𝐷𝑘 ×𝑙 with 𝑘 , 𝑙 ∈ {0, . . . , 𝐷 − 1}.
(10.8)
𝐷
By construction, the DFT matrix is a Fourier-type matrix. In fact, this is
where the name comes from.
Proposition 10.8 The DFT matrix defined in Eq. (10.8) is a unitary matrix
that also obeys the flatness condition from Eq. (10.1). In other words: the
𝐷 -dimensional DFT is a Fourier-type transform.
The proof is an extension of our arguments for 𝐷 = 2, 𝐷 = 3 and 𝐷 = 4 to
general dimensions. It follows from elementary properties of complex phases,
in particular, 𝐷 -th roots of unity.
Proof of Proposition 10.8. Let us first show that the matrix is unitary, i.e. 𝑭 †(𝐷 ) ×
𝑭 (𝐷 ) = 𝕀𝐷 ×𝐷 . We do this by showing that 𝑷 = 𝑭 †(𝐷 ) 𝑭 (𝐷 ) obeys [𝑷 ] 𝑎,𝑏 = 𝛿𝑎,𝑏 =
[𝕀] 𝑎,𝑏 for 𝑎, 𝑏 ∈ {0, . . . , 𝐷 − 1} arbitrary. To this end, use 𝜔¯𝐷 𝑥 = 𝜔¯ 𝐷𝑥 = 𝜔 −𝑥 ,
𝜔 𝑎 × 𝜔 𝑏 = 𝜔 𝑎+𝑏 (why?) and the rules of matrix multiplication to deduce
∑︁𝐷 −1 ∑︁𝐷 −1
[𝑷 ] 𝑎,𝑏 = 𝑭 † 𝑎,𝑘 × [𝑭 ] 𝑘 ,𝑏 = 𝑭¯ 𝑘 ,𝑎 × [𝑭 ] 𝑘 ,𝑏
𝑘 =0 𝑘 =0
1 ∑︁𝐷 − 1 𝑘 ×𝑎 1 ∑︁𝐷 − 1 𝑘 (𝑏 −𝑎 )
= 𝜔¯ 𝐷 × 𝜔 𝐷𝑘 ×𝑏 = 𝜔𝐷 .
𝐷 𝑘 =0 𝐷 𝑘 =0
138 Lecture 10: Quantum Fourier-type transforms
1 ∑︁𝐷 − 1 1 ∑︁𝐷 − 1
[𝑷 ] 𝑎,𝑎 = 𝜔 𝐷𝑘 (𝑎 −𝑎 ) = 𝜔 𝐷0 = 1.
𝐷 𝑘 =0 𝐷 𝑘 =0
The second case (ii) 𝑏 ≠ 𝑎 is more interesting. In this case, the exponent of
𝜔 𝐷 is never zero and the sum lets us jump around on the complex unit circle.
But, we do so with equal spacing and (almost) up where we started. Taking the
average over all points we visited produces the origin of the circle (we haven’t
moved on average). And this origin is 0. So,
1 ∑︁𝐷 − 1
[𝑷 ] 𝑎,𝑏 = 𝜔 𝐷𝑘 (𝑏 −𝑎 ) = 0.
𝐷 𝑘 =0
This establishes [𝑷 ] 𝑎,𝑏 = 𝛿𝑎,𝑏 = 𝕀𝑎,𝑏 for any 𝑎, 𝑏 ∈ {0, . . . , 𝐷 − 1}. In short:
𝑭 †(𝐷 ) 𝑭 (𝐷 ) = 𝕀𝐷 ×𝐷 .
The flatness condition is easy by comparison. Every entry of the DFT matrix
obeys
2 2
1 1 1
= √ 𝜔 𝐷𝑘 ×𝑙 | exp ( 2𝜋 i/𝐷 (𝑘 × 𝑙 ))| 2 =
𝑭 (𝐷 ) 𝑘 ,𝑙
= ,
𝐷 𝐷 𝐷
1 1
𝑾 𝑯 ( 2𝑛 ) 𝑘 ,𝑙 = √ (−1) 𝑘 ×𝑙 = √ exp ( i2𝜋/2 (𝑘 × 𝑙 )) ,
2𝑛 2𝑛
1
𝑭 ( 2𝑛 ) 𝑘 ,𝑙
=√ exp ( i2𝜋/2𝑛 (𝑘 × 𝑙 )) .
2𝑛
+1 +1 +1 +1 +1 +1 +1 +1
1 +1 −1 +1 −1 1 +1 +i −1 −i ®
© ª © ª
𝑾 𝑯 (4) = vs. 𝑭 ( 4 ) =
®
®.
2 +1 +1 −1 −1 2 + 1 −1 + 1 −1 ®
®
®
« +1 −1 −1 +1 ¬ « + 1 −i −1 + i ¬
139 Lecture 10: Quantum Fourier-type transforms
Note that the angle of this phase type rotation gate depends inverse exponen-
tially on its input (𝑘 ↦→ 1/2𝑘 ). Many familiar single-qubit gates are special
cases of this object:
𝑹 ( 0) = 𝕀, 𝑹 ( 1) = 𝒁 , 𝑹 ( 2) = 𝑺 and 𝑹 ( 3) = 𝑻 .
Here, the second qubit is the control and the first qubit is the target. This
operational definition is equivalent to the following 2-qubit truth table: controlled Z rotation 𝑪 𝑹 (𝑘 )
1 0 0 0
0 1 0 0
© ª
𝑪 𝑹 (𝑘 ) = 𝕀2×2 ⊗ | 0⟩⟨0 | + 𝑹 (𝑘 ) ⊗ | 1⟩⟨1 | = ® ∈ ℂ4×4
®
0 0 1 0 ®
« 0 0 0 𝜔 2𝑘 ¬
and we use the following gate symbol to describe it in a larger circuit:
.
140 Lecture 10: Quantum Fourier-type transforms
. (10.9)
Let us ignore the qubit labels on the left hand side for now and compute a
circuit representation of the right hand side. This circuit is comprised of three
sequential layers:
+1 0 +1 0
1 +1 +1 1 0 1 0 +1 0 +1
© ª
𝑳 0 =𝑯 ⊗ 𝕀 = √ ⊗ =√
®
®,
2 +1 −1 0 1 2 +1 0 −1 0 ®
« 0 + 1 0 −1 ¬
1 0 0 0 1 0 0 0
0 1 0 0 ® 0 1 0 0 ®
© ª © ª
𝑳 1 =𝑪 𝑹 ( 2) = ®= ®,
0 0 1 0 ® 0 0 1 0 ®
« 0 0 0 𝜔 22
¬ « 0 0 0 i ¬
+1 +1 0 0
1 0 1 +1 +1 1 +1 −1 0 0
© ª
𝑳 2 =𝕀 ⊗ 𝑯 = ⊗√ =√
®
®.
0 1 2 +1 −1 2 0 0 +1 +1 ®
« 0 0 +1 −1 ¬
So, the total circuit becomes
𝑫𝑭𝑻 ( 4 ) = 𝑳 2 × 𝑳 1 × 𝑳 0
+1 +1 0 0 1 0 0 0 +1 0 +1 0
1 + 1 −1 0 0 ® 0 1 0 0 ® 1 0 +1 0 +1
© ª © ª © ª
=√ ®× ®× √
®
0 0 +1 + 1 ® 0 0 1 0 ® 2 +1 0 −1 0
®
2 ®
« 0 0 +1 −1 ¬ « 0 0 0 i ¬ « 0 +1 0 −1 ¬
+1 +1 0 0 +1 0 +1 0
1 + 1 −1 0 0 ® 0 +1 0 +1 ®
© ª © ª
= ®×
0 0 +1 + 1 ® +1 0 −1 0 ®
®
2
« 0 0 +1 −1 ¬ « 0 + i 0 −i ¬
+1 +1 +1 +1
1 +1 −1 +1 −1 ®
© ª
= ®. (10.10)
2 +1 +i −1 −i ®
« + 1 −i −1 + i ¬
This already looks a lot like the 4-dimensional DFT matrix from Eq. (10.9),
but close inspection reveals that we are not quite there yet. Certain column
entries are not at the exactly right position yet. This can be resolved by
reversing/swapping the output qubits involved, i.e. 𝑞0 ↔ 𝑞1 . For two qubits,
141 Lecture 10: Quantum Fourier-type transforms
1 0 0 0
0 0 1 0 ®
© ª
𝑺𝑾 𝑨𝑷 = (10.11)
0 1 0 0 ®
®
« 0 0 0 1 ¬
and can be realized by concatenating three CNOT gates:
1 0 0 0 +1 +1 +1 +1
0 0 1 0 1 +1 +i −1 −i ®
© ª © ª
𝑺𝑾 𝑨𝑷 × 𝑫𝑭𝑻 ( 4 ) = ®×
®
0 1 0 0 +1 −1 +1 −1 ®
®
® 2
« 0 0 0 1 ¬ « +1 −i −1 +i ¬
+1 +1 +1 +1
1 +1 −1 +1 −1
© ª
=
®
®.
2 +1 +i −1 −i ®
« +1 −i −1 +i ¬
This matrix is now exactly equivalent to the circuit matrix in Eq. (10.10). This
also explains our notational convention in Eq. (10.9): the 2-qubit circuit on
the right hand side reproduces the 4-dimensional DFT matrix 𝑫𝑭𝑻 ( 4 ) up to a
relabelling of the output qubits.
• Reversed order of output qubits: the purple high-level circuit block reverses
the ordering of the qubits involved. There are two ways to deal with this:
142 Lecture 10: Quantum Fourier-type transforms
Figure 10.2 Quantum circuit realization of the discrete Fourier transform: this
𝑛 -qubit circuit involves 𝑛 Hadamard gates, as well as 𝑛 (𝑛 − 1)/2 controlled Z
rotations. Note furthermore that the ordering of the outcome qubits becomes
reversed in the process.
(i) hardware solution: we can use SWAP gates introduced in Eq. (10.11)
to physically re-arrange qubit wires in a way that reproduces the original
qubit ordering. (ii) software solution: remember that the qubit ordering
has changed and adjust the action of future gates and the interpretation
of readout bits accordingly. E.g. the readout of the first qubit wire now
produces 𝑜𝑛 − 1 instead of 𝑜 0 .
• Recursive block structure: the DFT implementation in terms of quantum
gates features log2 (𝐷) = 3 distinctive blocks. Each of them starts
with a Hadamard gate and follows it up with controlled rotations on
subsequent qubits. These controlled rotations start with angle 21 for the
first neighboring qubit and go up to 4 = 23 − 1 for the second neighboring
qubit.
Exercise 10.9 Verify the correctness of this 3-qubit realization of the DFT in
𝐷 = 8, e.g. by computing Kronecker and matrix products on paper or by using
your own classical simulation tool.
Theorem 10.10 (Quantum Fourier Transform (QFT) circuit). In dimensions 𝐷 = Quantum Fourier transform:
2𝑛 , the DFT matrix defined in Def. 10.7 can be realized by a high-level 𝑛 qubit realization of DFT
𝑛 -qubit circuit depicted in Fig. 10.2. This circuit involves 𝑛 Hadamard gates, matrix with 𝑂 (𝑛 2 ) gates
as well as 𝑛 (𝑛 − 1)/2 = 𝑂 (𝑛 2 ) controlled Z rotations 𝑹 (𝑙 ) by angles 1/2𝑙
with 𝑙 = 2, . . . , 𝑛 . Importantly, this circuit also reverses the order of the
qubits involved. This circuit is called a Quantum Fourier Transform (QFT).
approximations. The details of this extra overhead are, however, very dependent
on the elementary gate set used (which affects the exponent 𝑐 in Solovay-Kitaev)
and the desired accuracy of the overall circuit.
Corollary 10.11 (approximating the DFT matrix with elementary quantum gates). It realizing the DFT requires
is possible to (very) accurately approximate the high-level QDFT circuit from poly (𝑛) elementary quantum
Fig. 10.2 with poly (𝑛) elementary quantum gates, e.g. 𝑯 ,𝑻 , 𝑪 𝑵 𝑶𝑻 . gates
Theorem 10.12 (Fast discrete Fourier Transform (FFT)). For 𝐷 = 2𝑛 , the Fourier Fast classical discrete Fourier
transform admits a fast matrix-vector multiplication. For any 𝒙 ∈ ℂ𝐷 , transform (FFT)
we can compute 𝑭 𝐷 × 𝒙 with only (order) log22 (𝐷) × 𝐷 ≪ 𝐷 2 (classical)
operations.
Note that this is much better than the naive cost of 𝐷 2 associated with
naive matrix-vector multiplication in 𝐷 dimensions. Additional improvements
allow to implement the Fast Fourier Transform at (order) log2 (𝐷) 2 × 𝐷 cost
only. The proof is very similar to our derivation of the Fast classical Walsh-
Hadamard transform: use sparse matrix-vector multiplication to compute the
DFT as a sequence of 𝑛 (𝑛 + 1)/2 sparse (and often even diagonal) matrix-vector
multiplications in 𝐷 = 2𝑛 dimensions. We leave it as an instructive exercise.
Exercise 10.13 (Proof of Theorem 10.12). Use the 𝑛 -qubit simulation framework
from Lecture 8 and the concrete FDFT circuit from Figure 10.2 to compute
𝑭 (𝐷 ) × 𝒙 with only order 𝑛 2 × 2𝑛 = log2 (𝐷) 2 × 𝐷 elementary operations.
We emphasize that the fast Fourier transform, also known as FFT, has been
a cornerstone in many branches of computational science. Applications range
from signal processing to image analysis. Today, we managed to derive it as
a by-product of our quest to find quantum circuit realizations of the Fourier
transform. Sometimes, merely thinking in a quantum fashion can provide us
with insights that are valuable outside the strict scope of quantum computing
itself!
145 Lecture 10: Quantum Fourier-type transforms
10.4 Synopsis
The formal description of 𝑛 -qubit quantum circuits is intimately connected to
matrix-vector multiplications in 𝐷 = 2𝑛 dimensions. We have developed this
correspondence in Lecture 8 to use matrix-vector multiplications in order to
describe general quantum circuits. Today, we started to venture in the opposite
direction: we identified two very prominent 𝐷 × 𝐷 matrices – the Walsh-
Hadamard transform and the discrete Fourier transform – and strove to realize
them as 𝑛 -qubit quantum circuits comprised of only poly (𝑛) = polylog (𝐷)
elementary quantum gates. This can be an exponential compression in both
‘memory’ and ‘runtime’ for executing Fourier-type transforms: quantum circuits can offer
exponential improvements for
(i) ‘memory’ (aka number of qubits): 𝑛 qubits are (in principle) enough to matrix-vector multiplications
store a general 𝐷 = 2𝑛 -dimensional vector in its amplitudes.
(ii) ‘runtime’ (aka circuit size): poly (𝑛) gates are enough to implement WH
transform and the DFT on the quantum level.
Today, we discuss one of the most important quantum algorithmic primitives: Agenda:
quantum phase estimation. At face level, this quantum circuit addresses a rather
1 Background: eigenval-
abstract (and seemingly simple) problem from matrix analysis: learn something
ues and eigenvectors
about eigenvalues of a unitary matrix given access to the associated eigenvector.
2 Quantum Phase Estima-
But, the quantum circuit framework puts an interesting twist on this problem tion (QPE) circuits
and offers a new, genuinely quantum approach. Known as quantum phase 3 Analysis
estimation, this circuit family uses the (inverse) quantum Fourier transform
from last lecture as an important building block.
Quantum phase estimation plays a prominent role as a subroutine in
several famous quantum algorithms. Examples are quantum approximate
counting (which we will briefly discuss today) and Shor’s algorithm for integer
factorization (which we will discuss next week).
Theorem 11.1 (Spectral theorem for normal matrices). Let 𝑩 ∈ ℂ𝐷 ×𝐷 be a eigenvalue decomposition for
† † normal matrices
normal matrix, i.e. 𝑩 𝑩 = 𝑩𝑩 . Then, we can decompose 𝑩 as
Figure 11.1 Setup in quantum phase estimation: we are given a classical description
of an 𝑛 -qubit circuit 𝑼 and a 𝑛 -qubit quantum state |𝜓 ⟩ such that 𝑼 |𝜓 ⟩ =
e2𝜋 i𝜃 |𝜓 ⟩ with 𝜃 ∈ [ 0, 1) . Our task is to approximate the phase 𝜃 ∈ [ 0, 1) up
to 𝑚 bits of accuracy.
1
|𝜓+ ⟩ = √ (| 0⟩ − i | 1⟩) obeys 𝑹 (𝜃 )|𝜓+ ⟩ = e2𝜋 i𝜃 |𝜓+ ⟩.
2
1
|𝜓− ⟩ = √ (| 0⟩ + i | 1⟩) obeys 𝑹 (𝜃 )|𝜓 − ⟩ = e2𝜋 i ( 1 −𝜃 ) |𝜓 − ⟩
2
Figure 11.2 Quantum phase estimation circuit (QPE): this circuit works on (𝑚 + 𝑛)
qubits and produces an 𝑚 -bit approximation 𝑜 0 · · · 𝑜𝑚 − 1 of the phase 𝜃 ∈ [ 0, 1)
by reading out the first 𝑚 qubits. The circuit itself requires access to the 𝑛 -
qubit state |𝜓 ⟩ (red), executes 𝑚 controlled applications of powers of the
𝑛 -qubit circuit 𝑼 (blue boxes) and also features a 2𝑚 -dimensional inverse
quantum Fourier transform (purple). Note that, in general, the size of this
𝑚 −1
circuit increases exponentially in the phase resolution 𝑚 : 𝑼 2 corresponds
to sequentially applying the circuit 𝑼 a total of 2𝑚 − 1 times.
think: 𝑛 -qubit circuit – must have (at least) one normalized, 2𝑛 -dimensional
𝑛
vector |𝜓 ⟩ ∈ ℂ2 – think: 𝑛 -qubit state vector – that obeys quantum phase estimation
promise
𝑼 |𝜓 ⟩ = e2𝜋 i𝜃 |𝜓 ⟩ with phase 𝜃 ∈ [0, 1) .
Theorem 11.6 (Quantum Phase Estimation (QPE) circuits; informal). Suppose that Quantum Phase Estimation
we have access to a 𝑛 -qubit circuit 𝑼 with size size (𝑼 ) and a 𝑛 -qubit (QPE) circuit functionality
state |𝜓 ⟩ such that 𝑼 |𝜓 ⟩ = e2𝜋 i𝜃 |𝜓 ⟩ with 𝜃 ∈ [ 0, 1) . Then, for any
𝑚 = 1, 2, 3, . . ., the Quantum Phase Estimation (QPE) circuit displayed in
Fig. 11.2 finds a ‘good’ 𝑚 -bit approximation of the phase 𝜃 ∈ [ 0, 1) with
high probability. This circuit operates on (𝑚 +𝑛) qubits and, without further
assumptions on 𝑼 , requires a total of 𝑂 (( 2𝑚 − 1) size (𝑼 )) elementary
quantum gates.
Note that the size of this circuit scales very poorly in the number of
approximation bits 𝑚 . This scaling becomes a bit less daunting if we remember
that a 𝑚 -bit approximation of 𝜃 actually approximates 2𝑚 𝜃 up to constant
accuracy 𝜖 . Hence, we need a total 2𝑚 = 𝑂 ( 1/𝜖) controlled applications of 𝑼
and only 𝑚 = 𝑂 ( log ( 1/𝜖)) additional readout qubits.
150 Lecture 11: Quantum Phase Estimation
Figure 11.3 Visualization of the phase kickback effect: under the assumption that
𝑼 |𝜓 ⟩ = e2𝜋 i𝜃 |𝜓 ⟩ , we can bring one control qubit into uniform superposition,
apply a conditional 𝑼 -circuit to the 𝑛 -qubit state |𝜓 ⟩ in order to kick back the
phase e2𝜋 i𝜃 into the amplitudes of the superposition within the control qubit.
The next question is: what does it mean to find a ‘good’ 𝑚 -bit approximation
of the unknown phase 𝜃 ∈ [ 0, 1) . Our analysis will provide the following rigor-
ous and deterministic statement for the special case that 𝜃 can be represented
exactly by 𝑚 bits.
Proposition 11.7 (Quantum Phase Estimation (QPE) circuits, rigorous special case).
Instantiate the assumptions from Theorem 11.6 and suppose furthermore
that 2𝑚 𝜃 is an integer with bit representation ⌞ 2𝑚 𝜃 ⌟ = 𝑡𝑚 − 1 · · · 𝑡 0 ∈ {0, 1}𝑚 .
Then, the Quantum Phase Estimation circuit displayed in Fig. 11.2 is guaranteed
to produce 𝑜𝑚 − 1 = 𝑡𝑚 − 1 , . . . , 𝑜 0 = 𝑡 0 (i.e. perfect and deterministic recovery).
A ‘good’ approximation generalizes this behavior to phases that do not have
an exact 𝑚 -bit representation. In this case, it is possible to show that the
readout bits 𝑜𝑚 − 1 , . . . , 𝑜 0 ∈ {0, 1} yield one of the best 𝑚 -bit approximations
to 𝜃 with probability at least 40%. In contrast, all other bit strings (aka bad
approximations) only occur with probability at most 25%. Hence, we can run
QPE multiple times and take a majority vote to quickly isolate one of the best
𝑚 -bit approximations to 𝜃 . Although not really difficult per se, this rigorous
justification of a ‘good’ approximation would, however, go beyond the scope
of this introductory course. We will instead content ourselves with rigorously
deriving Proposition 11.7 and sketching the way to generalize it for the special
cases of 𝑚 = 1 and 𝑚 = 2.
11.3 Analysis
11.3.1 Phase kickback effect
At the heart of quantum phase estimation is an interesting observation about
the action of controlled circuit application on 𝑛 -qubit states that correspond to
an eigenvector of the unitary circuit 𝑼 . This effect is called phase kickback and
151 Lecture 11: Quantum Phase Estimation
Proof. By direct computation. The circuit displayed in Fig. 11.3 has three
sequential layers. We use (𝑛 + 1) -qubit state vectors | 𝜑 0 ⟩, | 𝜑 1 ⟩, | 𝜑 2 ⟩ to track
and reformulate the underlying quantum logic throughout the circuit evolution.
We start with | 𝜑 0 ⟩ = | 0⟩ ⊗ |𝜓 ⟩ and then move on to bring the first qubit into
uniform superposition:
1
= √ (| 0⟩ ⊗ |𝜓 ⟩ + | 1⟩ ⊗ |𝜓 ⟩) .
2
Now, we apply the circuit 𝑼 in a controlled fashion: if the first qubit is in | 0⟩ ,
we do nothing. Else if the first qubit is in | 1⟩ , we apply 𝑼 . This produces the
final quantum state vector
1
| 𝜑 2 ⟩ =𝑪𝑼 | 𝜑 1 ⟩ = √ (𝑪𝑼 | 0⟩ ⊗ |𝜓 ⟩ + 𝑪𝑼 | 1⟩ ⊗ |𝜓 ⟩)
2
1
= √ (| 0⟩ ⊗ |𝜓 ⟩ + | 1⟩ ⊗ (𝑼 |𝜓 ⟩)) .
2
Figure 11.4 Visualization of QPE with 𝑚 = 1 readout qubit: the (inverse) Quantum
Fourier transform in 𝐷 = 2 dimensions is simply the Hadamard gate. This
produces a simple special case where 𝜃 = 0 ensures 𝑜 0 = 0 and 𝜃 = 1/2
ensures 𝑜 0 = 1. In other words: 𝑜 0 = 2𝜃 whenever 2𝜃 is an integer.
Lemma 11.9 (𝑚 = 1 readout bit QPE, promise problem). Suppose that either 𝜃 = 0 1-bit QPE with promise
or 𝜃 = 1/2, i.e. 2𝜃 = 21 𝜃 is an integer. Then, the 𝑚 = 1-qubit QPE circuit
illustrated in Fig. 11.4 produces a deterministic readout bit
(
0 if 𝜃 = 0,
𝑜0 =
1 else if 𝜃 = 1/2.
Note that this outcome bit exactly encodes the exact bit representation of
2𝜃 = 21 𝜃 ∈ {0, 1}.
Proof. We can use the phase kickback effect in Lemma 11.8 to compute the
(𝑛 + 1) qubit state | 𝜑 2 ⟩ directly after the controlled application of 𝑼 :
| 𝜑 2 ⟩ = 𝑪𝑼 𝑯 ⊗ 𝕀⊗𝑛 |+⟩ ⊗ |𝜓 ⟩ = |𝑟 (𝜃 )⟩ ⊗ |𝜓 ⟩.
From now on, only the single-qubit state |𝑟 (𝜃 )⟩ matters. The promise 𝜃 = 0
or 𝜃 = 1/2 manifests itself in two distinct single-qubit states we need to
distinguish:
1 1
|𝑟 ( 0)⟩ = √ | 0⟩ + e2𝜋 i0 | 1⟩ = √ (| 0⟩ + | 1⟩) = |+⟩,
2 2
1 1
|𝑟 ( 1/2)⟩ = √ | 0⟩ + e2𝜋 i ( 1/2 ) | 1⟩ = √ (| 0⟩ − | 1⟩) = |−⟩.
2 2
So, the task boils down to distinguishing the uniform superposition |+⟩ from
the uniform superposition |−⟩ . This can be achieved with 100% success chance
by applying a Hadamard gate and performing a readout in the computational
basis: |+⟩ ↦→ 𝑯 |+⟩ = | 0⟩ vs. |−⟩ ↦→ 𝑯 |−⟩ = | 1⟩ . ■
153 Lecture 11: Quantum Phase Estimation
Note that we can achieve a much stronger result than Proposition 11.9
(which relies on a promise) by keeping 𝜃 as a variable in the analysis and 1-bit analysis without promise
computing the action of the Hadamard gate (inverse Fourier transform for
𝐷 = 2) on |𝑟 (𝜃 )⟩ directly. To make this task as simple as possible, we first
suggestively rewrite the single qubit phase state as
1 1
|𝑟 (𝜃 )⟩ = √ | 0⟩ + e2𝜋 i𝜃 | 1⟩ = √ e2𝜋 i/2 ( 2𝜃 ) ×0 | 0⟩ + e2𝜋 i/2 ( 2𝜃 ) ×1 | 1⟩
2 2
1 ∑︁1 1 ∑︁1
=√ e ( 2𝜋 i/2 ) ( 2𝜃 )𝑎 0 |𝑎 0 ⟩ = √ 𝜔 2( 2𝜃 ) ×𝑎0 |𝑎 0 ⟩,
2 𝑎 0 =0 2 𝑎 0 =0
where 𝜔 2 = exp ( 2𝜋 i/2) = (−1) is a second root of unity. The Hadamard gate
describes the (inverse) Fourier transform in dimension 𝐷 = 21 = 2. We can
write this inverse transform as
1 ∑︁1
𝑯 =√ 𝜔 2−𝑏 ×𝑐 |𝑏⟩⟨𝑐 |
2 𝑏,𝑐 =0
and obtain
1 ∑︁1 1 ∑︁1
𝑯 |𝑟 (𝜃 )⟩ = √ 𝜔 2−𝑏 ×𝑐 |𝑏⟩⟨𝑐 | √ 𝜔 2( 2𝜃 ) ×𝑎0 |𝑎 0 ⟩
2 𝑏,𝑐 =0 2 𝑎 0 =0
1 ∑︁1
= 𝜔 ( 2𝜃 ) ×𝑎0 −𝑏 ×𝑐 |𝑏⟩⟨𝑐 |𝑎 0 ⟩
2 𝑎 0 ,𝑏,𝑐 =0 2
∑︁1 1 ∑︁1
( ( 2𝜃 ) −𝑏 ) ×𝑐
= 𝜔 |𝑏⟩.
𝑏=0 2 𝑐 =0 2
Figure 11.5 Plot of the readout probabilities for QPE with 𝑚 = 1 qubit: the blue line
displays the probability of reading out 𝑜 0 = 0 (𝑦 -axis) as a function of 𝜃 ∈ [ 0, 1)
(𝑥 -axis). This probability peaks at 𝜃 = 0 (and 𝜃 = 1 due to periodicity): which
corresponds to the first promise case in Lemma 11.9. The yellow line displays
the probability of reading out 𝑜 0 = 1 as a function of 𝜃 ∈ [ 0, 1) . This probability
peaks at 𝜃 = 1/2 which corresponds to the second promise case in Lemma 11.9.
The actual probabilities do, however, interpolate smoothly between these two
extreme cases. This is what we mean by stating that quantum phase estimation
provides ‘good’ bit approximations of the underlying phase 𝜃 even if it cannot
be represented exactly.
QPE circuit illustrated in Fig. 11.6 produces a deterministic readout bit string
00 if 𝜃 = 0,
01 else if 𝜃 = 1/4,
𝑜 1𝑜 0 =
10 else if 𝜃 = 1/2,
11
else if 𝜃 = 3/4.
Note that this outcome bit string encodes the exact bit representation of
22 𝜃 ∈ {0, 1, 2, 3}.
Proof. The proof is a straightforward extension from the 1-bit base case. First
note that the two controlled applications of 𝑼 and 𝑼 2 act on completely
separate control qubits. The eigenvalue equation ensures 𝑼 |𝜓 ⟩ = e2𝜋 i𝜃 |𝜓 ⟩ and
also 𝑼 2 |𝜓 ⟩ = 𝑼 × 𝑼 |𝜓 ⟩ = e2𝜋 i2𝜃 |𝜓 ⟩ . Hence, we can apply the phase kickback
lemma (Lemma 11.8) twice and obtain the following visual simplification:
From now on, we can discard the final 𝑛 qubits (which are still in state |𝜓 ⟩ )
and can fully focus on the first two readout qubits. Similar to before, we can
rewrite |𝑟 ( 2𝜃 )⟩ ⊗ |𝑟 (𝜃 )⟩ in a suggestive fashion:
| 𝜑˜after kickback (𝜃 )⟩ =|𝑟 ( 2𝜃 )⟩ ⊗ |𝑟 (𝜃 )⟩ (11.2)
1 ∑︁1
= √ exp ( 2𝜋 i ( 2𝜃 ) × 𝑎 1 ) |𝑎 1 ⟩
2 𝑎 1 =0
1 ∑︁1
⊗ √ exp ( 2𝜋 i𝜃 × 𝑎 0 ) |𝑎 0 ⟩
2 𝑎 0 =0
1 ∑︁1
= exp ( 2𝜋 i𝜃 × ( 2𝑎 1 + 𝑎 0 )) |𝑎 1 𝑎 0 ⟩
2 𝑎 1 ,𝑎 0 =0
1 ∑︁3
= exp ( 2𝜋 i𝜃 × 𝑗 ) |⌞𝑗 ⌟⟩
2 𝑗 =0
1 ∑︁3 ( 4𝜃 ) ×𝑗
=√ 𝜔4 |⌞𝑗 ⌟⟩. (11.3)
4 𝑗 =0
156 Lecture 11: Quantum Phase Estimation
Here, we have tacitly moved from bit strings 𝑎 1 𝑎 0 ∈ {0, 1}2 to the actual integer
𝑗 = 2𝑎 1 + 𝑎 0 ∈ {0, 1, 2, 3} this bit string encodes (equivalently: ⌞𝑗 ⌟ = 𝑎 1 𝑎 0 ).
The resulting expression features a sum over 𝐷 = 4 index elements which
suggests a connection to the Fourier transform in 𝐷 = 22 = 4 dimensions.
Rewriting the complex phase as a power of a fourth root of unity 𝜔 4 =
exp ( 2𝜋 i/4) = (+i) further underscores this connection.
We are now ready to use the promises we have on 𝜃 . By assumption, there
are four distinct possibilities:
Note that, similar to the 1-bit readout case, we can also execute a general
inverse Fourier transform to get closed-form expressions of the final two-qubit
amplitudes. We can write the 𝐷 = 22 = 4 dimensional inverse Fourier transform 2-bit readout analysis without
matrix as promise
−1 1 ∑︁3 −𝑘 ×𝑙
𝑸 𝑭𝑻 ( 4 ) = √ 𝜔4 |⌞𝑘 ⌟⟩⟨⌞𝑙 ⌟|.
4 𝑘 ,𝑙 =0
From now on, we can discard the final 𝑛 qubits (which continue to reside in
the state |𝜓 ⟩ ) and focus on the 𝑚 -qubit state after all kickbacks:
1 ∑︁1 ( 2𝑚 𝜃 ) × ( 2𝑚 − 1 𝑎 𝑚 − 1 +···+2𝑎 1 +𝑎 0 )
=√ 𝜔 2𝑚 |𝑎 𝑚 −1 · · · 𝑎 1 𝑎 0 ⟩
2𝑚 𝑎 𝑚 − 1 ,...,𝑎 1 ,𝑎 0 =0
1 ∑︁2𝑚 − 1 ( 2𝑚 𝜃 ) ×𝑗
=√ 𝜔 2𝑚 |⌞𝑗 ⌟⟩.
2𝑚 𝑗 =0
The
amplitude expression within the bracket peaks for the integer 𝑘 ∈
0, 1, . . . , 2𝑚 − 1
− 1 that is closest to 2𝑚 −1 𝜃 . The extreme case occurs if
2𝑚 𝜃 = 𝑘 ♯ for exactly one 𝑘 ♯ . In this case, we obtain a simple, deterministic
expression for | 𝜑˜final ⟩ :
∑︁2𝑚 −1 1 ∑︁2𝑚 −1 (𝑘 −𝑘 ) ×𝑙
𝑚
| 𝜑˜final 𝑘 ♯ /2 ⟩= 𝜔 2𝑚♯ |⌞𝑘 ⌟⟩
𝑘 =0𝑚 2 𝑙 =0
∑︁2𝑚 −1
= 𝛿𝑘 ,𝑘♯ |⌞𝑘 ⌟⟩ = |⌞𝑘 ♯ ⌟⟩.
𝑘 =0
1 × 1 mod 2 = 1 = 1 mod 2,
2 × 1 mod 2 = 1 + 1 mod 2 = 0 mod 2,
3 × 1 mod 2 = 1 + 1 + 1 mod 2 = 1 mod 2,
..
.
Example 12.1 (first 10 digits modulo 𝑁 for 𝑁 = 3, 4, 5). The first ten digits (ℤ10 =
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) assume the following values in different modular
161 Lecture 12: Shor’s algorithm for integer factorization
arithmetic frameworks:
𝑁 = 3 : ℤ10 ↦→ {0, 1, 2, 0, 1, 2, 0, 1, 2, 0} ,
𝑁 = 4 : ℤ10 ↦→ {0, 1, 2, 3, 0, 1, 2, 3, 0, 1} ,
𝑁 = 5 : ℤ10 ↦→ {0, 1, 2, 3, 4, 0, 1, 2, 3, 4} .
We are now ready to present a key fact from modular arithmetic on which we
build our integer factorization algorithm.
∗ ). Fix 𝑁 ∈ ℕ. Then, for every 𝑎 ∈ ℤ∗ there must exist
Fact 12.2 (order of 𝑎 in ℤ𝑁 order finding problem
𝑁
a positive integer 𝑟 such that 𝑎 𝑟 = 1 mod 𝑁 . The smallest such 𝑟 is called the
order of 𝑎 in ℤ𝑁∗ . ■
gcd (𝑎, 𝑁 ) ≠ 1, there can be no order to begin with (why?). Note that the
∗ is closely related to periodicities, like the ones we saw above.
order 𝑟 of 𝑎 in ℤ𝑁
More precisely, it is the period of the function 𝑓𝑎,𝑁 (𝑥) = 𝑎 𝑥 mod 𝑁 . Indeed,
Let us familiarize ourselves with this concept by executing two concrete example
calculations.
Example 12.3 (order of 𝑎 = 13 in ℤ∗15 ). Let us consider the set ℤ∗15 from Eq. (12.2)
and choose 𝑎 = 13. We can then evaluate the order by trial search over
candidate exponents 𝑟 = 1, 2, 3, . . .:
Example 12.4 (order of 𝑎 = 2 in ℤ35 ). Let us consider the set ℤ∗35 from Eq. (12.3)
and choose 𝑎 = 2. We can then evaluate the order by trial search over the
candidate exponent. Since 21 , 22 , 23 , 24 , 25 < 35 = 𝑁 , we can start our search
at 𝑟 = 6:
This allows us to conclude that the order of 𝑎 = 2 in ℤ∗35 is 𝑟 = 12. We can also
see that the cost of trial search over possible exponents can grow very quickly
once 𝑁 becomes somewhat large. ■
These examples highlight that order finding is possible. But the number
of trial exponentiations can grow quickly once 𝑁 becomes (somewhat) large.
This increase in cost seems to be a fundamental problem. To date, no efficient
classical algorithm is known that can determine the order of 𝑎 in ℤ𝑁 ∗ with
Theorem 12.5 (integer factorization via order finding). Suppose that 𝑁 = 𝑝 ×𝑞 is (classical) reduction from
an odd product of two distinct primes. Then, Algorithm 12.1 is guaranteed integer factorization to order
to terminate and output (at least) one factor: 𝑓 0 ∈ {𝑝, 𝑞 } or 𝑓 1 ∈ {𝑝, 𝑞 }. finding
This result implies that order finding is at least as difficult as (our special
case of) integer factorization. Typically, such reduction arguments are used
to argue that a problem is difficult. Here, we will do the opposite. We will
develop an efficient algorithm for order finding in order to argue that integer
factorization becomes cheap if we had access to a quantum computer.
7 if 𝑟 is odd then
8 failure, move back to step 2
9 else if 𝑟 is even then
10 set 𝑥 = 𝑎 𝑟 /2 mod 𝑁 and compute (𝑥 + 1), (𝑥 − 1)
11 if (𝑥 ± 1) = 0 mod 𝑁 then
12 failure, move back to step 2
13 else if (𝑥 ± 1) ≠ 0 mod 𝑁 then
14 success, compute 𝑓 0 = gcd (𝑥 + 1, 𝑁 ) and 𝑓 1 = gcd (𝑥 − 1, 𝑁 )
and break while loop
15 output 𝑓 0 and 𝑓 1
can arise: 𝑟 may be odd or 𝑟 may be even. If 𝑟 is odd, the algorithm fails
and we try again with a different 𝑎 ∈ ℤ𝑁 . Else if 𝑟 is even, then 𝑟 /2 is a
positive integer and we can compute 𝑥 = 𝑎 𝑟 /2 mod 𝑁 . The modular version of
(𝑎 + 𝑏) × (𝑎 − 𝑏) = 𝑎 2 − 𝑏 2 then ensures
2
(𝑥 + 1) × (𝑥 − 1) mod 𝑁 = 𝑎 𝑟 /2 − 1 mod 𝑁
=𝑎 𝑟 − 1 mod 𝑁
=0 mod 𝑁 ,
This starts to look very close to a factorization. However, this display becomes
completely trivial if either (𝑥 + 1) or (𝑥 − 1) is itself equal to a multiple of 𝑁 .
The last if-condition in line 11 of Alg. 12.1 checks for precisely this possibility.
If (𝑥 ± 1) = 0 mod 𝑁 , then we have learned nothing new and restart. Else
if (𝑥 ± 1) ≠ 0 mod 𝑁 , Eq. (12.4) must contain nontrivial information about
the factors. Using 𝑁 = 𝑝 × 𝑞 , we rewrite it as (𝑥 + 1) × (𝑥 − 1) = 𝑘 × 𝑝 × 𝑞
for some 𝑘 ∈ ℕ and (𝑥 ± 1) ≠ 𝑘 ′ × 𝑝 × 𝑞 . This is only possible if either
gcd (𝑥 + 1, 𝑁 ) ∈ {𝑝, 𝑞 } or gcd (𝑥 − 1, 𝑁 ) ∈ {𝑝, 𝑞 } (or both). ■
So far, Algorithm 12.1 looks rather abstract and difficult to grasp. It is
therefore instructive to execute it in small-scale examples.
164 Lecture 12: Shor’s algorithm for integer factorization
Example 12.6 (Factoring 𝑁 = 15 with Algorithm 12.1). Suppose that we start with
𝑎 = 13 which obeys gcd ( 13, 15) = 1 and therefore doesn’t yet provide any
information about the factors of 𝑁 = 15. To change this, we use trial
exponentiation to find the order of 𝑎 = 13 in ℤ∗15 . We already did that in
Example 12.3: 𝑟 = 4. This number is even and we can use it to define
𝑥 = 𝑎 𝑟 /2 mod 15 = 132 mod 15 = 4 and, in turn, (𝑥 + 1) = 5, (𝑥 − 1) = 3.
Neither of these numbers is a multiple of 15, so the last condition is also met
and we are guaranteed to learn something about the factors of 15. Indeed,
Example 12.7 (Factoring 𝑁 = 35 with Algorithm 12.1). Here, we will also discuss
choices of 𝑎 for which the algorithm fails. If this happens, we start over with a
new choice of 𝑎 ∈ ℤ35 :
Try 𝑎 = 11 and use brute force to identify the order of 11 in ℤ∗35 : 𝑟 = 3
which is not even and we have to start over.
Try 𝑎 = 2 and use brute force to identify the order of 2 in ℤ∗35 : 𝑟 = 12
which is even and allows us to define 𝑥 = 𝑎 𝑟 /2 mod 35 = 26 mod 35 = 29.
Fortunately, neither (𝑥 + 1) = 30 nor (𝑥 − 1) = 28 are themselves multiples of
𝑁 . So, computing their gcds with 𝑁 reveals at least one factor (and, by chance,
we in fact get both of them again):
We don’t know any classical algorithm for this order finding problem that scales
polynomially in the bit length of 𝑁 . Trial and error, for instance, may take
us exponentially in 𝑛 many attempts to find the order. However, unlike the
original factoring problem, order finding is much more amenable to a genuine
quantum solution. In fact, we can use phase estimation for it. This was Shor’s
seminal insight in 1994.
165 Lecture 12: Shor’s algorithm for integer factorization
Figure 12.1 Quantum phase estimation circuit: Let 𝑼 be a 𝑛 -qubit unitary and
let |𝜓 ⟩ be a state vector representation of an eigenvector with eigenvalue
(‘phase’) exp ( 2𝜋 i𝜃 ) of 𝑼 . Then, for 𝑚 ≥ 1, the advertised (𝑚 + 𝑛) -qubit
circuit approximates the first 𝑚 bits of the (eigen-)phase 𝜃 ∈ ( 0, 2𝜋) . More
precisely, with high probability, the 𝑚 -bit readout ⌞𝑦 ⌟ describes an integer
approximation 𝑦 ∈ {0, . . . , 2𝑚 − 1} of 2𝑚 × 𝜃 .
Note that this fact says nothing about the cost of executing the phase
estimation circuit. This depends on the way we construct |𝜓 ⟩ and – which is
𝑘
much more severe – how we implement the controlled application of 𝑼 2 =
𝑼 × · · · × 𝑼 for 𝑘 = 1, . . . , 2𝑚 − 1. This gate count quickly explodes if one is
not careful. Fortunately, for Shor’s algorithm, a trick will allow us to deal with
this issue nicely.
With a slight abuse of notation, we denote an entire bit string by the number
𝑧 ∈ ℤ𝑁 it encodes. Note, moreover, that we can also encode modular arithmetic
in these state vector labels. In particular,
These displays ensure that both 𝑨 𝑎 and 𝑴 𝑎 are classical reversible circuits
(and therefore also unitary). What is more, they can be implemented with only
𝑂 (𝑛 2 ) elementary quantum gates.
Exercise 12.9 (quantum circuit implementation of reversible addition and reversible
multiplication). Sketch how you would construct a quantum implementation of efficient quantum circuits for
the permutation matrices 𝑨 𝑎 (addition by 𝑎 modulo 𝑁 ) and 𝑴 𝑎 (multiplication addition & multiplication by 𝑎
by 𝑎 modulo 𝑁 ) on 𝑛 = ⌊ log2 (𝑁 )⌋ + 1 qubits. Show that the number of modulo 𝑁 (𝑂 (𝑛 2 ) gates)
elementary gates required does not exceed 𝑂 (𝑛 2 ) .
We leave the proof as an instructive exercise. Instead, let us emphasize
that the multiplication operator 𝑴 𝑎 looks to be connected to the order 𝑟 of
𝑎 in ℤ𝑁∗ in a nontrivial fashion that we might be able to exploit. In order to
make this correspondence precise, we must take a look at the eigenvalues and
eigenvectors of 𝑴 𝑎 .
Proposition 12.10 (eigenvalues+eigenvectors of the modular multiplication operator).
For 𝑁 , 𝑎 ∈ ℤ𝑁 ∗ with gcd (𝑎, 𝑁 ) = 1, let 𝑟 be the order of 𝑎 in ℤ∗ and set (many) eigenvalues of
𝑁
𝜔𝑟 = exp ( 2𝜋 i/𝑟 ) (𝑟 -th root of unity). Then, the modular multiplication circuit modular multiplication circuit
𝑴 𝑎 defined in Eq. (12.8) has the following 𝑟 eigenvalue+eigenvector pairs: by 𝑎 isolate order 𝑟
𝑗 1 ∑︁𝑟 − 1 −𝑗 ×𝑘
𝜆 𝑗 = 𝜔𝑟 = exp ( 2𝜋 i (𝑗 /𝑟 )) and |𝜓𝑗 ⟩ = √ 𝜔𝑟 |𝑎 𝑘 ⟩𝑁
𝑟 𝑘 =0
for 𝑗 = 0, . . . , 𝑟 − 1.
Proof sketch. Let us start with an explicit calculation for the special case 𝑗 = 0:
1
𝑴 𝑎 |𝜓0 ⟩𝑁 = √ 𝑴 𝑎 | 1⟩𝑁 + 𝑴 𝑎 |𝑎⟩𝑁 + · · · + 𝑴 𝑎 |𝑎 𝑟 −2 ⟩𝑁 + 𝑴 𝑎 |𝑎 𝑟 −1 ⟩𝑁
𝑟
1
= √ |𝑎⟩𝑁 + |𝑎 2 ⟩𝑁 + · · · + |𝑎 𝑟 −1 ⟩𝑁 + |𝑎 𝑟 ⟩𝑁
𝑟
1
= √ |𝑎⟩𝑁 + |𝑎 2 ⟩𝑁 + · · · + |𝑎 𝑟 −1 ⟩𝑁 + | 1⟩𝑁
𝑟
=(+1)|𝜓0 ⟩ = 𝜔𝑟0 |𝜓0 ⟩𝑁 .
Here, we have used |𝑎 𝑟 ⟩𝑁 = | 1⟩𝑁 which follows from the fact that 𝑟 is the
order of 𝑎 in ℤ𝑁 ∗ (𝑎 𝑟 = 1 mod 𝑁 ). In short, 𝑴 |𝜓 ⟩ = 𝜔 0 |𝜓 ⟩ which is the
𝑎 0 𝑟 0
defining property of an eigenvector |𝜓0 ⟩ with eigenvalue 𝜔𝑟0 . Verifying the
remaining (𝑟 − 1) eigenvalue equations with 𝑗 = 1, . . . , 𝑟 − 1 can be achieved
in a similar fashion (hint: use 𝜔𝑟𝑟 = 1). We leave it as an exercise. ■
Exercise 12.11 (eigenvalues and eigenvectors of the modular addition operator). Fix
∗ and let 𝑟 be the order of 𝑎 in ℤ∗ . Identify at least 𝑟
𝑁 ∈ ℕ, 𝑎 ∈ ℤ𝑁 𝑁
168 Lecture 12: Shor’s algorithm for integer factorization
We refer to standard textbooks for a proof of this fact and a review of the
continued fraction algorithm which also allows to recover the order 𝑟 itself.
Note also that this fact only guarantees a successful approximation with a
certain probability of success, namely greater than 40%. So, it can happen
that we get unlucky with our quantum phase estimation approximation ⌞𝑦 ⌟ .
This issue can be offset by repeating the entire procedure multiple times and
classically checking the observed outcomes ⌞𝑦𝑘 ⌟ for consistency (is it really a
fraction? is it really minimal? and does the period 𝑟 feature?)
Here is another noteworthy and essential feature that renders the quantum
phase estimation circuit more efficient than one might naively assume
𝑘
Lemma 12.13 (efficient circuit implementation of 𝑴 𝑎2 ). For each 𝑘 = 0, . . . , 𝑚 , we
2𝑘
can implement the 2𝑘 -th power 𝑴 𝑎 of 𝑴 𝑎 as 𝑴 𝑎 2𝑘 . The latter is another
multiplication matrix that can be implemented with only 𝑂 (𝑛 2 ) elementary
quantum gates.
169 Lecture 12: Shor’s algorithm for integer factorization
Proof. The following equation is valid for all 𝑛 -bit strings 𝑧 ∈ {0, 1}𝑛
𝑘 𝑘
𝑴 𝑎2 |𝑧⟩𝑁 = 𝑴 𝑎 × · · · × 𝑴 𝑎 |𝑧⟩𝑁 = |𝑎 2 𝑧⟩𝑁 = 𝑴 𝑎 2𝑘 |𝑧⟩𝑁 .
| {z }
2𝑘 times
The technical fineprint3 from above ensures that this suffices to conclude that
𝑘
the two matrices 𝑴 𝑎2 and 𝑴 𝑎 2𝑘 must be identical overall. ■
Lemma 12.13 ensures that we can implement each controlled operation in
quantum phase estimation (central part of Fig. 12.1) with only 𝑂 (𝑛 2 ) gates. efficient implementation of
Since there are 𝑚 = ( 2𝑛 + 1) such controlled circuits, this produces a total cost phase estimation circuit
of 𝑂 (𝑛 3 ) gates for the central block. The cost of the initial Walsh Hadamard (𝑂 (𝑛 3 ) gates)
transform is 𝑚 = 2𝑛 + 1 = 𝑂 (𝑛) while the cost of the final inverse QFT is
𝑂 (𝑚 2 ) = 𝑂 (𝑛 2 ) . This produces a total cost of 𝑂 (𝑛) +𝑂 (𝑛 3 ) +𝑂 (𝑛 2 ) = 𝑂 (𝑛 3 )
gates to execute the full quantum phase estimation circuit. The only thing
missing now is the preparation of an eigenvector |𝜓 𝑗 ⟩ (ideally with 𝑗 ≠ 0).
Explicitly constructing one |𝜓 𝑗 ⟩ in a deterministic fashion is a daunting task.
We can, however, easily prepare the uniform superposition over all possible
eigenvectors |𝜓 𝑗 ⟩ . This is the content of the following lemma.
Lemma 12.14 Let |𝜓 𝑗 ⟩𝑁 be the eigenvectors of 𝑴 𝑎 defined in Proposition 12.10. efficient preparation of a
Then, we have superposition of eigenvectors
1 ∑︁𝑟 − 1 (0 gates)
√ |𝜓𝑗 ⟩𝑁 = | 1⟩𝑁 = | 0 · · · 01⟩.
𝑟 𝑗 =0
Proof. This follows from an identity that we already saw in previous lectures.
Summing over all (powers) of an 𝑟 -th root of unity produces 0 (amplitudes
cancel):
∑︁ ∑︁
1 ∑︁𝑟 − 1 1 𝑟 −1 0 1 𝑟 −1 −𝑗
√ |𝜓𝑗 ⟩𝑁 = 𝜔𝑟 | 1⟩𝑁 + 𝜔 |𝑎⟩𝑁
𝑟 𝑗 =0 𝑟 𝑗 =0 𝑟 𝑗 =0 𝑟
∑︁
1 𝑟 −1 −𝑗 (𝑟 − 1 )
+··· + 𝜔 |𝑎 𝑟 −1 ⟩𝑁
𝑟 𝑗 =0 𝑟
=1 × | 1⟩𝑁 + 0 × |𝑎⟩𝑁 + · · · + 0 × |𝑎 𝑟 −1 ⟩𝑁
=| 1⟩𝑁 .
■
This is the last ingredient that we needed to implement order finding on
a quantum computer: we can simply initialize the second 𝑛 -qubit register in
| 0 · · · 01⟩ = | 1⟩𝑁 and view this deterministic bit string as a uniform superposi-
tion of all 𝑟 eigenvectors |𝜓 𝑗 ⟩ . Linearity of the quantum computing formalism
3This is a continuation of the previous footnote. We let every modular multiplication circuit act
trivially on input configurations 𝑦 that don’t encode elements 𝑧 ∈ ℤ𝑁 : 𝑴 𝑎 |𝑦 ⟩ = |𝑦 ⟩ = 𝑴 2𝑘 |𝑦 ⟩ .
𝑎
170 Lecture 12: Shor’s algorithm for integer factorization
Figure 12.2 quantum part of Shor’s algorithm: This adaptation of quantum phase
estimation is designed to solve the order finding problem for 𝑎 in ℤ𝑁 . The circuit
requires 3𝑛 + 1 qubits, where 𝑛 = ⌊ log2 (𝑁 )⌋ + 1, and initializes them in the bit
string 0 · · · 01. Subsequently, we apply a Quantum Fourier Transform on the first
𝑚 = ( 2𝑛 + 1) gates and follow it up with 𝑚 controlled applications of different
arithmetic multiplication circuits 𝑴 𝑎 𝑘 with 𝑘 = 1, 2, . . . , 22𝑚 − 1 . Finally, we
apply an inverse Quantum Fourier Transform on the first ( 2𝑚 + 1) qubits and
read them out to obtain a bit string representation of 𝑦 ∈ {0, 2𝑚 − 1} that is
likely to encode the order 𝑟 of 𝑎 in ℤ𝑛 : 𝑦 /2𝑚 ≈ 𝑗 /𝑟 for some 𝑗 = 0, . . . , 𝑟 − 1
with constant probability of success ( ≥ 0.2).
Note that this circuit has a lot of structure and can be divided into three
qualitatively different blocks: a quantum Fourier transform (on one part of
the qubits) followed by a classical reversible circuit followed by the inverse
quantum Fourier transform (again on one part of the qubits):
†
𝑼 = QFT22𝑛+1 ⊗ 𝕀⊗𝑛 𝑹 QFT22𝑛+1 ⊗ 𝕀⊗𝑛 .
would be easy to compute classically for every |𝒃⟩ ∈ {0, 1}3𝑛+1 . A sequential
combination of these three quantum subroutines, however, would yield an
exponential improvement over the best known approach for order finding. This
exponential speedup becomes much more relevant if we use it as a (quantum)
subroutine in Algorithm 12.1. There, all other computational steps can be
executed on a classical computer in cubic runtime 𝑂 (𝑛 3 ). Hence, the following
corollary is an immediate consequence of Theorem 12.15 and Theorem 12.5
(reformulate factoring as an order finding problem).
Corollary 12.16 (Efficient hybrid quantum-classical algorithm for Integer Factorization
(Shor, 1994)). Let 𝑁 = 𝑝 × 𝑞 , with 𝑝, 𝑞 prime and set 𝑛 = ⌊ log2 (𝑁 )⌋ + 1. Then, hybrid quantum-classical
we can determine one factor (𝑝 or 𝑞 ) by repeating Algorithm 12.1 sufficiently algorithm solves integer
often. The order finding step, in particular, is outsourced to a ( 3𝑛 + 1) -qubit factorization at 𝑂 (𝑛 3 ) cost
architecture which executes a circuit of size 𝑂 (𝑛 3 ). This also bounds the overall
cost of all remaining classical computing steps.
Contrast this 𝑂 (𝑛 3 ) scaling with the best known fully classical factorization
strategy for 𝑁 = 𝑝 × 𝑞 with 𝑝, 𝑞 prime that scales exponentially in 𝑛 1/3 .
Problems
Problem 12.17 (quantum circuit implementation of reversible addition and reversible
multiplication). Sketch how you would construct a quantum implementation of
the permutation matrices 𝑨 𝑎 (addition by 𝑎 modulo 𝑁 ) and 𝑴 𝑎 (multiplication
by 𝑎 modulo 𝑁 ) on 𝑛 = ⌊ log2 (𝑁 )⌋ + 1 qubits. Show that the number of
elementary gates required does not exceed 𝑂 (𝑛 2 ) .
Problem 12.18 (eigenvalues and eigenvectors of modular addition operator). Fix
𝑁 ∈ ℕ, 𝑎 ∈ ℤ𝑁 ∗ and let 𝑡 the smallest integer that obeys 𝑡 × 𝑎 = 1 mod 𝑁 .
that we can actually do with them. (Machine) learning can serve as a guiding
motivation in this regard. There, the broad goal is not to solve a computationally
hard problem, but to learn something that is initially hidden from us. And switch cost from runtime
such learning processes come with their own reasonable cost parameters, in (algorithms) to training data
particular training data size. This is not a computational cost parameter, size (machine learning)
but a statistical one. How much data (information) do we need in order
to distill underlying principles? And this statistical nature plays nicely with
quantum computing architectures which also produce outcome bit strings that
are statistical in nature.
In fact, this correspondence goes even deeper. Because in quantum comput-
ing, we can manipulate the way we generate data by adjusting the quantum
circuit we use prior to measurements. And it is reasonable to expect that some
quantum circuit executions produce more valuable outcome data than others.
This effect is also well-known in machine learning: ‘good data’ lets you learn
quickly while ‘bad data’ may require a lot more training effort.
And today, we shall use an ML-inspired view on learning problems based on
quantum (computing) experiments to identify exponential quantum advantages.
Let us get a bit more concrete and jump into the details of preparing the
initial quantum state |𝜓ˆ0 ⟩ (where then the message is imprinted on).
Recall that Player 1 possesses a private ternary string 𝒘 ∈ {𝑥, 𝑦 , 𝑧 }𝑛 and
imprints it into a 𝑛 -qubit state vector . This state vector starts with randomly
unif
initializing the first 𝑛 − 1 qubits: 𝑏ˆ0 , . . . , 𝑏ˆ𝑛 − 2 ∼ {0, 1}. The final 𝑛 -th qubit
is then initialized such that parity of the total sum is even:
unif
|𝜓ˆ0 ⟩ = |𝑏ˆ0 , . . . , 𝑏ˆ𝑛 −2 , 𝑏ˆ0 ⊕ · · · ⊕ 𝑏ˆ𝑛 −2 ⟩ with 𝑏ˆ0 , . . . , 𝑏ˆ𝑛 −2 ∼ {0, 1}. (13.1)
We use a hat (‘ˆ’) to explicitly delineate the fact that the initialization bit is
randomly generated. The even parity of sum constraint then fully determines
the value of the last bit: 𝑏ˆ𝑛 − 1 = 𝑏ˆ0 ⊕ · · · ⊕ 𝑏ˆ𝑛 − 2 ∈ {0, 1} in a deterministic
fashion. randomly generated qubit
initialization |𝜓ˆ0 ⟩
Example 13.1 ( |𝜓ˆ0 ⟩ for 𝑛 = 1 and 𝑛 = 2 qubits). For a single qubit, the sum of
parity constraint is completely binding. The result must be
For 𝑛 = 2, there are two bit strings with even parity. The state vector assumes
either initialization with equal probability:
(
| 0, 0⟩ with prob. 1/2,
(𝑛 = 2) : |𝜓ˆ0 ⟩ =
| 1, 1⟩ with prob. 1/2.
■
1 How does the number of state copies required (i.e. the money spent),
scale with the number of qubits 𝑛 and, by extension, with the size of the
hidden string? This is our toy model for training data size. It is reasonable
to expect that this cost will grow. But, does it grow polynomial (efficient
scaling) or exponential (prohibitively expensive scaling)?
2 Does the way the state copies are processed have an impact on this cost
parameter? After all, different ways of accessing this quantum state
vector may lead to readout bits that carry more or less information about
the underlying secret. This is our way of varying the quality of training
data.
175 Lecture 13: Learning from quantum experiments
The first statement highlights that the cost for any conventional approach scales
(at least) exponentially in the number of qubits 𝑛 . The second statement, in
stark contrast, states that there is a quantum-enhanced whose cost scales (at
most) linearly in the number of qubits 𝑛 .
where |𝜓ˆ0 ⟩ is the randomly initialized 𝑛 -qubit state from Eq. (13.1) (with a
sum-of-parity constraint). The reason why this string involves trits instead of
bits is based on the elementary building blocks of our encoding. It uses the
three most prominent single-qubit gates, namely identity, Hadamard and phase
gates:
1 0 1 1 1 1 0
𝕀= , 𝑯 =√ , 𝑺= .
0 1 2 1 −1 0 i
We will use these gates to imprint the secret key onto (probabilistic mixtures
of) 𝑛 -qubit computational basis states. For 𝑤 ∈ {𝑥, 𝑦 , 𝑧 }, we set
𝑽 𝑧 = 𝕀, 𝑽 𝑥 = 𝑯 and 𝑽 𝑦 = 𝑺 × 𝑯 . (13.2)
Verify the following relation between these Pauli matrices and the unitary
transformations in Eq. (13.2):
𝑿 = 𝑽 𝑥† × 𝒁 × 𝑽 𝑥 , 𝒀 = 𝑽 †𝑦 × 𝒁 × 𝑽 𝑦 , 𝒁 = 𝑽 †𝑧 × 𝒁 × 𝑽 𝑧 .
These three unitaries allow us to imprint exactly one trit 𝑤 ∈ {𝑥, 𝑦 , 𝑧 } on a
single qubit computational basis state. This encoding strategy readily extends
to 𝑛 -trit strings 𝒘 = (𝑤 0 , . . . , 𝑤𝑛 − 1 ) ∈ {𝑥, 𝑦 , 𝑧 }𝑛 and 𝑛 qubits: concrete encoding strategy
(13.3)
Here, |𝜓ˆ0 ⟩ = |𝑏ˆ0 , . . . , 𝑏ˆ𝑛 − 2 , 𝑏ˆ0 ⊕ · · · ⊕ 𝑏ˆ𝑛 − 2 ⟩ is the randomly constructed input
string from Eq. (13.1). With the encoding strategy at hand, we can introduce
the two different approaches on how to access this quantum state.
(13.4)
177 Lecture 13: Learning from quantum experiments
The big-Ω notation highlights that the cost grows (at least) exponentially
in 𝑛 . This is a very general statement and the proof is not easy. Technically
speaking it requires an additional randomization over one sign factor for each
qubit and employs advanced proof techniques from statistical learning theory,
probability theory and quantum computing. Such a level of sophistication
is necessary to handle arbitrary quantum circuits and arbitrary classical data
processing, including any machine learning model.
The underlying idea, however, is rather simple and boils down to our data
hiding strategy (13.3). Although it looks simple, it does imprint the secret trit
string into a 𝑛 -qubit system |𝜓ˆ (𝒘 )⟩ that must be interpreted as a probability
distribution over a total of 2𝑛 /2 different quantum state vectors
different from each other as possible. This ensures that we actually occupy
radically different corners of this huge 𝑛 -qubit amplitude space. And this makes
it extremely difficult to do anything (substantially) smarter than iteratively
asking binary questions: is 𝒘 = 𝒗 , where 𝒗 ∈ {𝑥, 𝑦 , 𝑧 }𝑛 is our current best
guess. And since there are 3𝑛 possible guesses, we are forced to ask this
question exponentially often (in 𝑛 ). We will sketch a single-qubit caricature of
this effect in Annex 1 below.
(13.5)
Here, 𝑼 ˆ can be an arbitrary quantum circuit on 2𝑛 qubits (𝑛 qubits for the first
state copy and another 𝑛 qubits for the second state copy).
It is easy to see that this framework is at least as general as the conventional
approach. After all, we can always choose to divide up the general 2𝑛 -qubit
179 Lecture 13: Learning from quantum experiments
unitary circuit into two parallel (and uncorrelated) 𝑛 -qubit unitary circuits, i.e.
𝑼ˆ = 𝑼 1 ⊗ 𝑼 2 . Doing so effectively reduces one run of this two-copy protocol
into two independent runs of the conventional (single-copy) protocol. But
from this new point of view, such a Kronecker product construction starts to
look rather restrictive. What if we instead use this additional expressiveness
to insert correlations (think: CNOTs) and superpositions (think: Hadamards)
between qubits from the first copy of |𝜓ˆ (𝒘 )⟩ (top) and the second copy of
|𝜓ˆ (𝒘 )⟩ (bottom)? Thinking further along these lines highlights that this new,
quantum-enhanced approach is capable of doing something that the conventional
approach cannot fully mimic (at least not with an exponential overhead in
repetitions): creating entanglement between qubits from each copy directly
at the quantum level. The following constructive result highlights that such
quantum-enhanced readout protocols become a game changer for our data
hiding challenge:
𝑇qe = 𝑂 (𝑛)
repetitions. The quantum part of this procedure is very cheap and illustrated
in Fig. 13.1. A total of 𝑇qe repetitions produce enough statistical data to
?
check 𝒗 = 𝒘 for every candidate 𝒗 ∈ {𝑥, 𝑦 , 𝑧 }𝑛 in linear time.
Figure 13.1 Quantum enhanced learning protocol: this 2𝑛 -qubit circuit processes
two copies of |𝜓ˆ (𝒘 )⟩ in parallel. The circuit executes a total of 𝑛 Bell basis
measurements that each connect the 𝑘 -th qubit of the first copy with the
𝑘 -th qubit of the second copy. This readout stage requires exactly 𝑛 single
qubit gates (𝕀, 𝑯 , 𝑺 × 𝑯 ) and exactly 𝑛 two-qubit CNOT gates. Each data
hiding state is also comparatively cheap to create: we need two random 𝑛 -bit
initializations and (at most) 2𝑛 single qubit gates (𝕀, 𝑯 , 𝑺 × 𝑯 ). Viewed as one
circuit from beginning to end, this demonstration requires 2𝑛 qubits, (at most)
3𝑛 single-qubit gates and exactly 𝑛 CNOT gates.
𝑏ˆ𝑛 −1 = 𝑏ˆ0 ⊕· · ·⊕ 𝑏ˆ𝑛 −2 (note that 𝑏ˆ𝑛 −1 is itself not random, but fully determined
by the first (𝑛 − 1) random bits). Subsequently, we need to imprint the 𝑛 -trit
string 𝒘 = (𝑤 0 , . . . , 𝑤𝑛 − 1 ) ∈ {𝑥, 𝑦 , 𝑧 }𝑛 by applying 𝑽 𝑤0 ⊗ · · · ⊗ 𝑽 𝑤𝑛 −1 to our
randomized initial state |𝑏ˆ0 , . . . , 𝑏ˆ𝑛 − 1 ⟩ (with even sum of parity). But this is
also cheap, because we apply one single qubit unitary to each qubit.
Next, we need to have a look at the different readout protocols. Conventional
readout protocols are quite tricky, because the model is very general. Any
collection of unitary circuits is fair game, even ones with exponential circuit
size. Fortunately, implementing a conventional strategy is not the main point
here. Rigorous math tells us that any such approach must be bad! So, let
us instead focus on the quantum-enhanced protocol. There, we must first
prepare two copies of |𝜓ˆ (𝒘 )⟩ in parallel. This is not difficult, but requires 2𝑛
available (and working) qubits. If we have a quantum computer with, say, 53
qubits, then we can only play the data hiding game up to 𝑛 = ⌊ 53/2⌋ = 26
qubits. The subsequent entangling procedure involves a total of 𝑛 parallel
CNOT gates followed by 𝑛 parallel Hadamard gates. And, finally, we need to
perform measurements on all 2𝑛 qubits involved. This is again a routine task
for any working quantum computer. So, in summary, a full execution of our
data hiding game with quantum-enhanced readout boils down to the following
depth-4 circuit which involves 4𝑛 gates:
(13.6)
Note that all CNOT gates affect different qubit pairs and can therefore be
stacked into a single gate layer of depth one. This looks doable even on existing
quantum computers that are noisy (which limits available circuit depth) and
comparatively small (which limits the maximum 𝑛 we can go to). And, in
fact, it has been done. Google – who operates one of the largest and most
reliable quantum computers to date – teamed up with researchers from Caltech
and JKU (yours truly) to actually run a slight modification of our data hiding
game [Hua+22]. The results are depicted in Figure 13.2
182 Lecture 13: Learning from quantum experiments
(c)
)
Prediction Accuracy (Q) (C
s LB
Prediction Accuracy (C)
rou
go
Ri
𝑯 | 0⟩ = |+⟩ if 𝑤 = 𝑥,
|𝜓ˆ (𝑤 )⟩ = 𝑽 | 0⟩ = 𝑺 × 𝑯 | 0⟩ = | i+⟩ else if 𝑤 = 𝑦 ,
𝕀| 0⟩ = | 0⟩
else if 𝑤 = 𝑧.
Note that both
1 1
|+⟩ = 𝑯 | 0⟩ = √ (| 0⟩ + | 1⟩) and | i+⟩ = 𝑺 × 𝑯 | 0⟩ = √ (| 0⟩ + i | 1⟩) .
2 2
(13.7)
Here, we have already suggestively included the encoding procedure on the
right hand side. A quick look at this single-qubit circuit architecture already
tells us that two things can happen:
1 𝑣 = 𝑤 (correct guess): in this case, the two unitaries in Eq. (13.7) cancel
out and we end up simply measuring the zero state | 0⟩ . More formally,
2
†
Pr𝑽 † |𝜓ˆ (𝑤 ) ⟩ [ 0] = ⟨0 |𝑽 𝑤 𝑽 𝑤 | 0⟩ = 1 = |⟨0 |𝕀| 0⟩| 2 = 1.
𝑤
𝑇conv ( 1) ≳ 4 × 31 , (13.8)
where 4 takes into account the (expected) number of circuit evaluations required
to distinguish a deterministic distribution (correct guess) from the uniform one
(incorrect guess).
However, the form of Eq. (13.8) suggests an exponential dependence on the
number of qubits. Indeed, as 𝑛 increases, the total number of secret trit strings
𝒘 ∈ {𝑥, 𝑦 , 𝑧 }𝑛 grows as 3𝑛 . And, if randomly guessing the correct string is
essentially our only chance, we will feel this exponential growth in the number
of options.
Exercise 13.6 Extend this analysis to 𝑛 = 2 and 𝑛 = 3 qubits. Show that the
number of ‘guess circuits’ you need will grow indeed proportionally to 32 and
33 , respectively. This is a strong indicator of exponential growth in the number
of qubits. Hint: the random initialization of |𝜓ˆ0 ⟩ plays an important role here.
We emphasize that such a generalization is not enough to deduce Theo-
rem 13.3. After all, we are analyzing only one particular readout strategy (guess
the correct string by unravelling) and not all of them. It does, however, convey
the main gist: our secret imprinting is designed in a way that makes it very
difficult to extract ‘global information’ about the secret string 𝒘 ∈ {𝑥, 𝑦 , 𝑧 }𝑛 .
185 Lecture 13: Learning from quantum experiments
There are three different circuit configurations — one for each 𝑤 ∈ {𝑥, 𝑦 , 𝑧 } –
that want to be analyzed. We learn everything about the measurement outcome
if we compute the final 2-qubit quantum state
| 𝜑 (𝑤 )⟩ = (𝑯 ⊗ 𝕀)𝑪 𝑵 𝑶𝑻 (𝑽 𝑤 ⊗ 𝑽 𝑤 )| 0, 0⟩.
1 𝑤 = 𝑥 , i.e. 𝑽 𝑤 = 𝑽 𝑥 = 𝑯 :
| 𝜑 (𝑥)⟩ = (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 (𝑯 ⊗ 𝑯 ) | 0, 0⟩
= (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 |+, +⟩
= (𝑯 ⊗ 𝕀) |+, +⟩ = | 0, +⟩
1
= √ (| 0, 0⟩ + | 0, 1⟩)
2
2 𝑤 = 𝑦 , i.e. 𝑽 𝑤 = 𝑽 𝑦 = 𝑺 × 𝑯 :
|𝜑 (𝑦 )⟩ = (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 (𝑺𝑯 ⊗ 𝑺𝑯 ) | 0, 0⟩
= (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 | i+, i+⟩
1
= (𝑯 ⊗ 𝕀) (| 0, 0⟩ + i | 0, 1⟩ + i | 1, 1⟩ − | 1, 0⟩)
2
1
= √ (| 1, 0⟩ + i | 0, 1⟩) .
2
3 𝑤 = 𝑧 , i.e. 𝑽 𝑤 = 𝑽 𝑧 = 𝕀:
| 𝜑 (𝑧)⟩ = (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 (𝕀 ⊗ 𝕀) | 0, 0⟩
= (𝑯 ⊗ 𝕀) 𝑪 𝑵 𝑶𝑻 | 0, 0⟩
= (𝑯 ⊗ 𝕀) | 0, 0⟩ = |+, 0⟩
1
= √ (| 0, 0⟩ + | 1, 0⟩) .
2
So, in summary, the three different choices for 𝑤 lead to different outcome
probability distributions for the two readout bits. If we collect the probabilities
for obtaining 00, 01, 10 and 11 in a 4-dimensional vector, we obtain
1 0 1 Pr | 𝜑 (𝑤 ) ⟩ [00]
1 1 ® 1 1 1 0 ® Pr | 𝜑 (𝑤 ) ⟩ [01]
© ª © ª © ª
𝒑𝑥 = ® , 𝒑𝑦 = ® , 𝒑𝑧 = ® (13.9)
®
.
2 0 ® 2 1 ® 2 1 ® Pr | 𝜑 (𝑤 ) ⟩ [10]
0
« ¬ « 0 ¬ « 0 ¬ Pr | 𝜑 (𝑤 ) ⟩ [11]
186 Lecture 13: Learning from quantum experiments
Note that these three possible outcome distributions are very different from
each other. A (small) constant number of quantum circuit repetitions (coin
tosses) allow us to do a 2-step identification procedure.
Suppose, for the sake of illustration, that the underlying secret is 𝑤 = 𝑥 .
Then, 𝒑 𝑥 tells us that we obtain outcome 00 with probability 1/2. And we
expect to see this outcome after only 2 repetitions (why?). As soon as we
observe 00 once, we can exclude 𝑤 = 𝑦 for the hidden string (𝒑 𝑦 has 0 weight
on 00) and are left with two options: 𝑤 = 𝑥 or 𝑤 = 𝑧 . We then invest a
couple of extra repetitions (coin tosses) to look for outcome 01. As soon as
we observe this outcome, we can also rule out 𝒑 𝑧 and can be sure that the
underlying hidden trit is 𝑤 = 𝑥 . We expect that 2 additional repetitions are
enough (why?). The search procedure for other trits is analogous and gets by
with equally few runs of the quantum-enhanced readout procedure.
In summary, we can conclude that the quantum-enhanced readout protocol
gets by with
𝑇qe ( 1) = const where const ≈ 4
repetitions only. What is more, this procedure is fixed and not conditional on a
guess by us. The fixed Bell-type measurement allows us to correctly uncover
the secret trit 𝑤 after very few repetitions of the same quantum circuit. These
are all excellent signs for a benign generalization to 𝑛 ≥ 1 qubits.
Bibliography
[Bel64] J. Bell. “On The Einstein Podolsky Rosen Paradox”. In: Physics 1.3 (1964),
pages 195–200. doi: https://doi.org/10.1103/PhysicsPhysiqueFizika.
1.195.
[BB14] C. H. Bennett and G. Brassard. “Quantum cryptography: Public key
distribution and coin tossing”. In: Theor. Comput. Sci. 560 (2014), pages 7–
11. doi: 10.1016/j.tcs.2014.05.025. url: https://doi.org/10.
1016/j.tcs.2014.05.025.
[Ben+93] C. H. Bennett et al. “Teleporting an unknown quantum state via dual
classical and Einstein-Podolsky-Rosen channels”. In: Phys. Rev. Lett. 70 (13
1993), pages 1895–1899. doi: 10.1103/PhysRevLett.70.1895. url:
https://link.aps.org/doi/10.1103/PhysRevLett.70.1895.
[DN05] C. M. Dawson and M. A. Nielsen. The Solovay-Kitaev algorithm. 2005.
arXiv: quant-ph/0505030 [quant-ph].
[Eke91] A. Ekert. “Quantum Cryptography Based on Bell’s Theorem”. In: Phys. Rev.
Lett. 67.6 (1991), pages 661–663. doi: https://doi.org/10.1103/
PhysRevLett.67.661.
[GC99] D. Gottesman and I. L. Chuang. “Demonstrating the viability of universal
quantum computation using teleportation and single-qubit operations”.
In: Nature 402.6760 (1999), pages 390–393. doi: 10.1038/46503. url:
https://doi.org/10.1038/46503.
[HKP21] H.-Y. Huang, R. Kueng, and J. Preskill. “Information-Theoretic Bounds on
Quantum Advantage in Machine Learning”. In: Phys. Rev. Lett. 126 (19
2021), page 190505. doi: 10.1103/PhysRevLett.126.190505. url:
https://link.aps.org/doi/10.1103/PhysRevLett.126.190505.
188 Lecture 13: Learning from quantum experiments