0% found this document useful (0 votes)
56 views

Oskinquantum Notes PDF

This document contains lecture notes on quantum computing from a class taught at the University of Washington. The notes cover topics such as linear algebra, the postulates of quantum mechanics, quantum algorithms like Deutsch's algorithm and Shor's algorithm, quantum gates, error correction, and more. The material is based on a textbook and is presented over approximately 16 hours of lectures. The LaTeX source code for the notes is made freely available online.

Uploaded by

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

Oskinquantum Notes PDF

This document contains lecture notes on quantum computing from a class taught at the University of Washington. The notes cover topics such as linear algebra, the postulates of quantum mechanics, quantum algorithms like Deutsch's algorithm and Shor's algorithm, quantum gates, error correction, and more. The material is based on a textbook and is presented over approximately 16 hours of lectures. The LaTeX source code for the notes is made freely available online.

Uploaded by

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

Quantum Computing - Lecture Notes

Mark Oskin
Department of Computer Science and Engineering
University of Washington

Abstract

The following lecture notes are based on the book Quantum Computation and Quantum In-
formation by Michael A. Nielsen and Isaac L. Chuang. They are for a math-based quantum
computing course that I teach here at the University of Washington to computer science grad-
uate students (with advanced undergraduates admitted upon request). These notes start with a
brief linear algebra review and proceed quickly to cover everything from quantum algorithms
to error correction techniques. The material takes approximately 16 hours of lecture time to
present. As a service to educators, the LATEXand Xfig source to these notes is available online
from my home page: http://www.cs.washington.edu/homes/oskin. In addition, under
the section “course material” from my web page, in the spring quarter/2002 590mo class you
will find a sequence of homework assignments geared to computer scientists. Please feel free to
adapt these notes and assignments to whatever classes your may be teaching. Corrections and
expanded material are welcome; please send them by email to [email protected].

The following work is supported in part by NSF CAREER Award ACR-0133188.

1
Contents

1 Linear Algebra (short review) 4

2 Postulates of Quantum Mechanics 5

2.1 Postulate 1: A quantum bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2 Postulate 2: Evolution of quantum systems . . . . . . . . . . . . . . . . . . . . . . 6

2.3 Postulate 3: Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.4 Postulate 4: Multi-qubit systems . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 Entanglement 9

4 Teleportation 11

5 Super-dense Coding 15

6 Deutsch’s Algorithm 16

6.1 Deutsch-Jozsa Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

7 Bloch Sphere 22

7.1 Phase traveling backwards through control operations . . . . . . . . . . . . . . . . 27

7.2 Phaseflips versus bitflips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

8 Universal Quantum Gates 29

8.1 More than two qubit controlled operations . . . . . . . . . . . . . . . . . . . . . . 31

8.2 Other interesting gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

8.3 Swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2
9 Shor’s Algorithm 33

9.1 Factoring and order-finding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

9.2 Quantum Fourier Transform (QFT) . . . . . . . . . . . . . . . . . . . . . . . . . . 34

9.3 Shor’s Algorithm – the easy way . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

9.4 Phase estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

9.5 Shor’s Algorithm – Phase estimation method . . . . . . . . . . . . . . . . . . . . 40

9.6 Continuous fraction expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

9.7 Modular Exponentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

10 Grover’s Algorithm 43

11 Error Correction 46

11.1 Shor’s 3 qubit bit-flip code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

11.2 Protecting phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

11.3 7 Qubit Steane code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

11.4 Recursive error correction and the threshold theorem . . . . . . . . . . . . . . . . 53

3
1 Linear Algebra (short review)

The following linear algebra terms will be used throughout these notes.

Z - complex conjugate
if Z a b i then Z a b i

ψ - vector, “ket” i.e.


c1
c2

cn

ψ - vector, “bra” i.e.


c1 c2 cn

ϕ ψ - inner product between vectors ϕ and ψ .


Note for QC this is on n space not n !
Note ϕ ψ ψϕ
2 3
Example: ϕ , ψ
6i 4
3
ϕψ 2 6i 6 24i
4

ϕ ψ - tensor product of ϕ and ψ .


Also written as ϕ ψ
2 3 6
2 3 2 4 8
Example: ϕ ψ
6i 4 6i 3 18i
6i 4 24i

A - complex conjugate of matrix A.


1 6i 1 6i
if A then A
3i 2 4i 3i 2 4i

AT - transpose of matrix A.
1 6i 1 3i
if A then AT
3i 2 4i 6i 2 4i

A† - Hermitian conjugate (adjoint) of matrix A.


Note A† AT
1 6i 1 3i
if A then A†
3i 2 4i 6i 2 4i

4
ψ - norm of vector ψ
ψ ψψ
Important for normalization of ψ i.e. ψ ψ

ϕ A ψ - inner product of ϕ and A ψ .


or inner product of A† ϕ and ψ

2 Postulates of Quantum Mechanics

An important distinction needs to be made between quantum mechanics, quantum physics and
quantum computing. Quantum mechanics is a mathematical language, much like calculus. Just
as classical physics uses calculus to explain nature, quantum physics uses quantum mechanics to
explain nature. Just as classical computers can be thought of in boolean algebra terms, quantum
computers are reasoned about with quantum mechanics. There are four postulates to quantum
mechanics, which will form the basis of quantum computers:

Postulate 1: Definition of a quantum bit, or qubit.

Postulate 2: How qubit(s) transform (evolve).

Postulate 3: The effect of measurement.

Postulate 4: How qubits combine together into systems of qubits.

2.1 Postulate 1: A quantum bit

Postulate 1 (Nielsen and Chuang, page 80):

“Associated to any isolated physical system is a complex vector space with inner prod-
uct (i.e. a Hilbert space) known as the state space of the system. The system is
completely described by its state vector, which is a unit vector in the system’s state
space.”

Consider a single qubit - a two-dimensional state space. Let φ 0 and φ1 be orthonormal basis
for the space. Then a qubit ψ a φ0 b φ1 . In quantum computing we usually label the basis
with some boolean name but note carefully that this is only a name. For example, φ 0 0 and
φ1 1 . Making this more concrete one might imagine that “ 0 ” is being represented by an
up-spin while “ 1 ” by a down-spin. The key is there is an abstraction between the technology

5
(spin state or other quantum phenomena) and the logical meaning. This same detachment occurs
classically where we traditionally call a high positive voltage “1” and a low ground potential “0”.
2
Note that ψ a 0 b 1 must be a unit vector. In other words, ψ ψ 1 or a b2 1. For
quantum computing a b

This formalism for a quantum bit is a direct extension of one way to describe a classical computer.
That is, way may write that a classical bit ω is in the state ω x 0 y 1 . The only difference
is x and y are defined not over the complex numbers but rather from the set 0 1 . That is x y
0 1 . The same normalization condition applies x 2 y 2 1. This normalization condition is
not a property of quantum mechanics but rather of probability theory.

2.2 Postulate 2: Evolution of quantum systems

Postulate 2 (Nielsen and Chuang, page 81):

“The evolution of a closed quantum system is described by a unitary transformation.


That is, the state ψ of the system at time t 1 is related to the state of ψ of the system
at time t2 by a unitary operator U which depends only on times t 1 and t2 .”

I.e. ψ Uψ.

The fact that U cannot depend on ψ and only on t 1 and t2 is a subtle and disappointing fact.
We will see later that if U could depend on ψ then quantum computers could easily solve NP
complete problems! Conceptually think of U as something you can apply to a quantum bit but you
cannot conditionally apply it. The transform occurs without any regard to the current state of ψ .

Example:

ψ a0 b1
0 1
U
1 0
0 1 a b
ψ Uψ b0 a1
1 0 b a

Example:

Let ψ 10 01 0
1 1 1
U
2 1 1
1 1 1 1 1 1 1 1
ψ Uψ 0 1
2 1 1 0 2 1 2 2

6
Important: U must be unitary, that is U †U I

Example:

1 1 1 1 1 1
U then U †
2 1 1 2 1 1
1 1 1 1 1 1 1 2 0
U †U 2 I
2 2 1 1 1 1 0 2

2.3 Postulate 3: Measurement

Postulate 3 (Nielsen and Chuang, page 84):

“Quantum measurements are described by a collection M m of measurement oper-


ators. These are operators acting on the state space of the system being measured.
The index m refers to the measurement outcomes that may occur in the experiment. If
the state of the quantum system is ψ immediately before the measurement then the
probability that result m occurs is given by:
pm †M ψ
ψ Mm m
and the state of the system after measurement is:
Mm ψ

ψ Mm Mm ψ
The measurement operators satisfy the completeness equation:
†M ψ
∑m ψ Mm m I
The completeness equation expresses the fact that probabilities sum to one:
1 ∑m p m †M ψ ”
∑m ψ Mm m

Some important measurement operators are M0 0 0 and M1 1 1

1 1 0
M0 10
0 0 0

0 0 0
M1 01
1 0 1

Observe that M0† M0 M1† M1 I and are thus complete.

Example:

ψ a0 b1
p0 ψ M0† M0 ψ

7
Note that M0† M0 M0 , hence
1 0 a
p0 ψ M0 ψ a b
0 0 b
a
= a b a2
0

Hence the probability of measuring 0 is related to its probability amplitude a by way of a 2 .

It important to note that the state after measurement is related to the outcome of the measurement.
For example, suppose 0 was measured, then the state of the system after this measurement is
re-normalized as:
M0 ψ a
a a 0

As a side note we are forced to wonder if Postulate 3 can be derived from Postulate 2. It seems
natural given that measurement in the physical world is just interacting a qubit with other qubits.
Thus it seems strange to have measurement be its own postulate. At this point though physicists
don’t know how derive the measurement postulate from the other three, so we shall just have to be
pragmatic and accept it.

2.4 Postulate 4: Multi-qubit systems

Postulate 4 (Nielsen and Chuang, page 94):

“The state space of a composite physical system is the tensor product of the state
spaces of the component physical systems. [sic] e.g. suppose systems 1 through n
and system i is in state ψi , then the joint state of the total system is ψ 1 ψ2
ψn .”

Example:

Suppose ψ1 a 0 b 1 and ψ2 c 0 d 1 , then:


ψ1 ψ2 ψ1 ψ2 a c0 0 a d0 1 b c1 0 b d1 1
ac 00 ad 01 bc 10 bd 11

Why the tensor product? This is not a proof, but one would expect some way to describe a com-
posite system. Tensor product works for classical systems (except the restricted definition of the
probability amplitudes makes it so that the result is a simple concatenation). For quantum systems
tensor product captures the essence of superposition, that is if system A is in state A and B in state
B then there should be some way to have a little of A and a little of B. Tensor product exposes
this.

8
3 Entanglement

Entanglement is a uniquely quantum phenomenon. Entanglement is a property of a multi-qubit


state space (multi-qubit system) and can be thought of as a resource. To explain entanglement we’ll
examine the creation and destruction of an EPR pair of qubits named after Einstein, Podolsky, and
Rosen.

Suppose you begin with a qubit ψ 1 in a zero 0 state.

1 1 1
Let U H
2 1 1

1 1 1
Then let ψ1 H ψ1 0 1 0 1
2 2 2

Now take another qubit ψ2 also in the zero 0 state. The joint state-space probability vector is
the tensor product of these two:

1 1
ψ1 ψ2 ψ1 ψ2 00 0 01 10 0 11
2 2

Now define a new unitary transform:

1 0 0 0
0 1 0 0
CNot
0 0 0 1
0 0 1 0

(As an exercise show that CNot is unitary), but for now lets just apply CNot to our two qubits:

1 1
1 0 0 0 2 2
0 1 0 0 0 0 1
ψ1 ψ2 CNot ψ1 ψ2 1 00 11
0 0 0 1 0 2
2 1
0 0 1 0 0 2

The key to entanglement is the property that the state space cannot be decomposed into component
spaces. That is, for our example, there does not exists any ϕ 1 and ϕ2 such that ϕ1 ϕ2
1
00 11 .
2

To illustrate why entanglement is so strange, lets consider performing a measurement just prior to
applying the CNot gate. The two measurement operators (for obtaining a 0 or a 1 ) are:

9
1 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
M02 and M12
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 1

1
Recall that just prior to the CNot the system is in the state ψ 1 ψ2 00 0 01
2
1
10 0 11 , hence the result of measuring the second qubit will clearly be 0 . Note that
2

M02 M02 M02 . Therefore:

p0 ψ1 ψ2 M0†2 M02 ψ1 ψ2 ψ1 ψ2 M02 ψ1 ψ2


1 1
1 0 0 0 2 2
1 1 0 0 0 0 0 1 1 0
0 0 1 0 0 1 1
2 2 0 0 1 0 2 2
2 2
0 0 0 0 0 0

1
2
0
1
2
Mm ψ 0
After measurement: † 1 ψ1 ψ2
ψ Mm Mm ψ

We can see that measurement had no effect on the first qubit. It remains in a superposition of 0
and 1 . Now lets consider the same measurement but just after the CNot gate is applied. Here:

1
ψ ψ1 ψ2 2
00 11

Now it is not clear whether the second qubit will return a 0 or a 1 , both outcomes are equally
likely. To see this, lets calculate the probability of obtaining 0 :

p0 ψ M0†2 M02 ψ ψ M02 ψ


1 1
1 0 0 0 2 2
1 1 0 0 0 0 0 1 1 0 1
00 00 2
2 2 0 0 1 0 0 2 2 0
0 0 0 0 1
2
0

Hence, after the CNot gate is applied we have only a 1 2 chance of obtaining 0 . Of particular
interest to our discussion, however, is what happens to the state vector of the system:

10
1
1 0 0 0 2
Mm ψ 1 0 0 0 0 0
After measurement: †
ψ Mm Mm ψ 1 2 0 0 1 0 0
0 0 0 0 1
2
1
2
1
1 0 0
00
1 2 0 0
0 0

This is the remarkable thing about entanglement. By measuring one qubit we can affect the prob-
ability amplitudes of the other qubits in a system! How to think about this process in an abstract
way is an open challenge in quantum computing. The difficulty is the lack of any classical analog.
One useful, but imprecise way to think about entanglement, superposition and measurement is that
superposition “is” quantum information. Entanglement links that information across quantum bits,
but does not create any more of it. Measurement “destroys” quantum information turning it into
classical. Thus think of an EPR pair as having as much “superposition” as an unentangled set of
qubits, one in a superposition between zero and one, and another in a pure state. The superposition
in the EPR pair is simply linked across qubits instead of being isolated in one.

This, admittedly fuzzy way of thinking about these concepts is useful when we examine telepor-
tation. There we insert an unknown quantum state (carrying a fixed amount of “quantum informa-
tion”) into a system of qubits. We mix them about with additional superposition and entanglement
and then measure out the superposition we just added. The net effect is the unknown quantum
state remains in the joint system of qubits, albeit migrated through entanglement to another physi-
cal qubit.

4 Teleportation

Contrary to its sci-fi counterpart, quantum teleportation is rather mundane. Quantum teleportation
is a means to replace the state of one qubit with that of another. It gets its out-of-this-world name
from the fact that the state is “transmitted” by setting up an entangled state-space of three qubits
and then removing two qubits from the entanglement (via measurement). Since the information
of the source qubit is preserved by these measurements that “information” (i.e. state) ends up in
the final third, destination qubit. This occurs, however, without the source (first) and destination
(third) qubit ever directly interacting. The interaction occurs via entanglement.

1
Suppose ψ a0 b 1 and given an EPR pair 2
00 11 the state of the entire system is:

11
Generate EPR pair and distribute to each end

Destination
in state A

Fixup
result
Source Transmit classical information
in state A
(destroyed in process)

Figure 1: Teleportation works by pre-transmitting an EPR pair to the source and destination. The
qubit containing the state to be “teleported” interacts with onehalf of this EPR pair creating a joint
state space. It is then measured and only classical information is transmitted to the destination.
This classical information is used to “fixup” the destination qubit

a
0
0
1 1 a
a0 00 11 b1 00 11
2 2 b
0
0
b

Perform the CNot operation and you obtain

a
0
0
1 1 a
a0 00 11 b1 10 01
2 2 0
b
b
0

Next we apply the H gate. However, as an aside, lets examine what happens when we apply the H
gate to 0 and to 1 . Recall that:
1 1 1
H
2 1 1

1 1 1 1 1 1
H0
2 1 1 0 2 1

12
|y> H

|0>

|0> H X Z |y>

Figure 2: Quantum circuit depicting teleportation. Note that in this diagram single lines represent
quantum data while double lines represent classical information.

1 1 1 0 1 1
H1
2 1 1 1 2 1

Thus, applying H to our system we have:

a
b
b
1 1 1 1 a
ϕ a 0 1 00 11 b 0 1 10 01 2
2 2 2 a
b
b
a

We can rewrite this expression as:

a
b
b
a
1
2 00 a 0 b1 01 a 1 b0 10 a 0 b1 11 a 1 b0
a
b
b
a

Which we can shorten to:

1 1 0 0 1 1 0 0 i
2 00 ψ 01 ψ 10 ψ 11 i ψ
0 1 1 0 0 1 i 0

These gates are the famous “Pauli” (I,X,Z,Y) operators and this is also written as:

13
1
2 00 I ψ 01 X ψ 10 Z ψ 11 iY ψ

And of interest to us with teleportation:

1
ϕ 2 00 I ψ 01 X ψ 10 Z ψ 11 X Z ψ

This implies that we can measure the first and second qubit and obtain two classical bits. These
two classical bits tell us what transform was applied to the third qubit. Thereby we can “fixup”
the third qubit by knowing the classical outcome of the measurement of the first two qubits. This
fixup is fairly straightforward, either applying nothing, X , Z or both X and Z. Lets work through
an example:

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
M10
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

† †
P 10 ϕ M10 M10 ϕ ϕ M10 ϕ , since here M10 M10 . Thus:

0
0
0
1 0
M10 ϕ 2 a
b
0
0

0
0
0
1 1 0 1
Therefor: ϕ M10 ϕ 2 abbaa b ba 2 4 a a b b
a
b
0
0

Recall that by definition of a qubit we know that a a b b 1, hence the probability of mea-
suring 01 is 1 4. The same is true for the other outcomes.

14
5 Super-dense Coding

Super dense coding is the less popular sibling of teleportation. It can actually be viewed as the
process in reverse. The idea is to send two classical bits of information by only sending one
quantum bit. The process starts out with an EPR pair that is shared between the receiver and
sender (the sender has one half and the receiver has the other).

Pre−communicated EPR pair

b0b1

Interpret
Transmit

Figure 3: Super-dense coding works by first pre-communicating an EPR pair. To send two bits
of classical information one half of this EPR pair (a single qubit) is manipulated and sent to the
other side. The two qubits (the one pre-communicated and the one sent) are then interacted and
the resulting two bits of classical information is obtained.
1
ψ 2
00 11

To send information apply particular quantum gates:

00: apply I (i.e. do nothing)

01: apply Z

10: apply X

11: apply iY (i.e. both X and Z)

1
1 0 1 1 1 0
00: 00 11 00 11
0 1 2 2 2 0
1

1
1 0 1 1 1 0
01: 00 11 00 11
0 1 2 2 2 0
1

0
0 1 1 1 1 1
10: 00 11 10 01
1 0 2 2 2 1
0

15
0
0 i 1 1 1 1
11: i 00 11 01 10
i 0 2 2 2 1
0

These states are known as bell basis states. They key to super-dense coding is that they are or-
thonormal from eachother and are hence distinguishable by a quantum measurement.

H bit 0

bit 1

Figure 4: To obtain the two bits of classical information a bell-basis measurement is performed.

Examining this process in more detail:

1 1
ψ00 00 11 0 0 1 1
2 2
1
apply CNot gives us: 0 0 1 0
2
1 1
apply H gives us: 0 1 0 0 1 0
2 2
1
2 00 10 00 10 00

1 1
ψ01 2
00 11 2
0 0 1 1
apply CNot gives us: 12 0 0 1 0
1 1
apply H gives us: 0 1 0 1 0 0
2 2
1
2 00 10 10 00 10

1 1
ψ01 10 01 1 0 0 1
2 2
1
apply CNot gives us: 1 1 0 1
2
1 1
apply H gives us: 0 1 1 0 1 1
2 2
1
2 01 11 01 11 01

Leave the last one for homework.

6 Deutsch’s Algorithm

Deutsch’s algorithm is a perfect illustration of all that is miraculous, subtle, and disappointing
about quantum computers. It calculates a solution to a problem faster than any classical computer

16
ever can. It illustrates the subtle interaction of superposition, phase-kick back, and interference.
Finally, unfortunately, is solves a completely pointless problem.

Deutsch’s algorithm answers the following question: suppose f x is either constant or balanced,
which one is it? If f x were constant then for all x the result is either 0 or 1. However, if f x
were balanced then for one half of the inputs f x is 0 and for the other half it is 1 (which x’s
correspond to 0 or 1 is completely arbitrary). To answer this question classically, we clearly need
to query for both x 0 and x 1, hence two queries are required. Quantum mechanically though
we will illustrate how this can be solved in just one query.

x x

Uf
y y f(x)

Figure 5: Suppose U f implements f , x is input as 0 1 2 and y as 0 , then the remarkable


aspect of quantum computing is the output is equal to 0 f 0 1 f 1 2.

We begin by illustrating how superposition of quantum state creates quantum parallelism or the
ability to compute on many states simultaneously.

Given a function f x : 0 1 0 1 using a quantum computer, use two qubits x y and trans-
form them into x y f x (where represents addition modular two). We use two qubits since
we wish to leave the input x or the query register, “un-changed”. The second qubit, y, acts as a
result register. Let U f be the unitary transform that implements this. This is illustrated in Figure 5.

Suppose we wish to calculate f 0 , then we could input x as 0 , and y, our output register, as 0
and apply the U f transform.

The input is written as 0 0 00.

The output is transformed by U f to be 0 0 f 0 .

Suppose we wish to calculate f 1 , then we could input x as 1 , and y, our output register, as 0
and apply the U f transform.

The input is written as 1 0 10.

The output is transformed by U f to be 1 0 f 1 .

But this is not a classical computer – we can actually query the results of 0 and 1 simultaneously
using quantum parallelism. For this, let x equal 0 1 2 and y equal 0.

00 10
The input ψ1
2

17
0 f 0 1 f 1
The output ψ2 2

Remarkable: U f is applied to 0 and 1 simultaneously! This is known as quantum paral-


lelism.

Problem: sounds good, but measurement produces either 0 f 0 or 1 f 1 . Hence we


need to be clever about what type of question we ask, and how we go about extracting the answer.

The solution is to use another quantum mechanical property: interference.

|0> H x x H

Uf
|1> H y y f(x)

Figure 6: Deutsch’s Algorithm uses quantum parallelism and interference to extract information
about a global property of the solution space.

Key:
Deutsch’s algorithm, as all known quantum algorithms that provide exponential
speedup over classical systems do, answers a question about a global property of a
solution space. These are often called promise problems, whereby the structure of
the solution space is promised to be of some form and by carefully using superposi-
tion, entanglement and interference we can extract information about that structure.
The reason these problems obtain exponential improvement over all known clas-
sical algorithms is that classically one has to calculate every point in the solution
space in order to obtain full knowledge about this structure. Quantum mechan-
ically we calculate every point using quantum parallelism. Unfortunately this is
often not how most algorithms are phrased. Usually we work with problems that
are phrased of the form “what x gives a value of f x with the desired property?”
Thus far, quantum computers can only provide square-root improvement to such
query-based problems.

Let ψ0 be the initial state vector and ψ1 be the state of the system prior to applying U f . Let
ψ2 be the state of the system after applying U f and ψ3 be the state of the system prior to
measurement.

Input: ψ0 01

It may seem strange to start out with a result register of 1 instead of 0, but ignore this for now, we
will return to it shortly. Apply the H gate to the query and result registers to obtain:

1 1
ψ1 2
0 1 2
0 1

Now, lets examine y f x:

18
1 1
Suppose f x 0 then y f x y 0 2
0 0 1 0 2
0 1

1 1
Suppose f x 1 then y f x y 1 0 1 1 1 0 1
2 2

We can compactly describe this behavior in the following formula:

f x 1
y f x 1 2
0 1

1
Thus, U f transforms x 2
0 1 into:

f x 1
1 x 2
0 1

Or we can say that:

1 1 1 f 0 f 1
Uf 0 1 0 1 2 1 0 0 1 1 1 0 1
2 2

Suppose f is constant, that is f 0 f 1 , then:

1 f 0 f 1
2 1 0 0 1 1 1 0 1

1 f 0
2 1 0 0 1 1 0 1

1
2 0 0 1 1 0 1

1 1
0 1 0 1
2 2

Suppose instead that f is balanced, that is f 0 f 1 , then:

1 f 0 f 1
2 1 0 0 1 1 1 0 1

1 f 0 f 0
2 1 0 0 1 1 1 1 0 1

1 f 0
2 1 0 0 1 1 0 1

1
2 0 0 1 1 0 1

1 1
2
0 1 2
0 1

Now run the x qubit through an H gate to get ψ 3

19
1
0 0 1 if f 0 f 1
ψ3 2
1
1 0 1 if f 0 f 1
2

Since in our case f 0 f 1 0 f 0 f 1 we can write this as

0 1
ψ3 f 0 f 1 2

Hence it is possible to measure x to find f 0 f 1.

Key:
Note that f 0 f 1 is a global property of f x . Classically it would require
two evaluations of f x to find this answer. Using a quantum computer we are
able to evaluate both answers simultaneously and then interfere these answers to
combine them together. Another more subtle point is that the phase of the result
qubit transfers to the query qubit. This is a special case of phase kick back. In
effect, the query qubit acts as a control of whether or not to flip the result qubit.
While the result qubit is potentially flipped by the state of the query qubit, the
phase of the query qubit is altered by the phase of the result (or target) qubit! We
will explore this property in more detail later, since it is the key to Shor’s algorithm.

6.1 Deutsch-Jozsa Algorithm

The Deutsch-Jozsa algorithm is a generalization of Deutsch’s algorithm.

Suppose f x : 2n 0 1 and that f is either constant or balanced. The goal is determine which
one it is. Classically it is trivial to see that this would require (in worst case) querying just over
half the solution space, or 2n 2 1 queries. The Deutsch-Jozsa algorithm answers this question
with just one query!

n n
|00....0> H x x H
Uf
|1> H y y f(x)

Figure 7: The Deutsch-Jozsa algorithm is simply a multi-qubit generalization of Deutsch’s algo-


rithm

The starting state of the system ψ0 is fairly straightforward

ψ0 0 n 1

The symbolic notation 0 n simply means n consecutive 0 qubits.

20
We then apply the H n transform. This symbol means to apply the H gate to each of the n qubits
(in parallel, although this does not matter. The key is only that the H gate is applied once to each
qubit). One way to define this transform is:

n 1i j
H i ∑j j
2n

This notation is rather terse, but what it is saying is that given any arbitrary state vector, it will be
composed of components i . Each component of this state vector is transformed into a superposi-
tion of components j . For example, lets examine a single qubit:

a0 b1

Apply H 1 to get:
00 01 10 11
1 1 1 1 1 1
a 2
0 a 2
1 b 2
0 b 2
1 2
a b 0 2
a b 1

When we look at the actual transform as we have been writing it in the past we find:

1 1 1 a a b a b
0 1
2 1 1 b 2 2

Returning back to ψ0 we transform it by:

ψ1 H n 0 nH 1

1 0 1
∑ x
x 01 n 2n 2

The notation 0 1 n means all possible bit strings of size n. For example, if n 2, this would be
“00”, “01”, “10”, and “11”.

We then apply the transform U f that implements f x to obtain the state ψ 2 :

f x
1 0 1
ψ2 ∑ x
x 01 n 2n 2

Finally we apply another H n transform to obtain ψ3 :

xz f x
1 0 1
ψ3 ∑ ∑ z
z 01 nx 01 n 2n 2

The key to the Deutsch-Jozsa algorithm is the rather subtle point: Observe the probability ampli-

21
tude of z 0 n . Consider when f x is constant. Since z 0 n , we know that 1 x z f x is
either 1 or 1 for all values of x (since z is equal to zero x z must be equal to zero. Further f x
was constant). Hence, if f x is constant the probability amplitude for z 0 n is expressed as:

1
∑ n
1
x 01 n 2

Hence when you measure the query register you will obtain a zero. Since postulate one tells that
the probabilities must sum to 1, if f x is constant, then we must measure a zero.

On the other hand, lets consider if f x is balanced. Then 1 x z f x will be 1 for some x
and 1 for other x’s. This is where the balanced requirement comes into play. Since all x’s
are considered, and the function is perfectly balanced, the probability of obtaining z 0 n is
expressed as:

1 1
∑ 2n ∑ 2n 0
x1 x2

Where x1 is the set of x’s such that f x is equal to 0 and x 2 are those x’s where f x is equal to
1. Hence you will not measure 0 when f x is balanced since the probability amplitudes perfectly
destructively interfere to produce a probability of zero for that quantity.

What will be measured if the function is balanced? Anything except 0.

7 Bloch Sphere

The block sphere is a useful visualization tool for single quantum bits. Before discussing it, we
need to refresh our complex math a little.

A complex number Z x y i can be expressed in polar form:

x rcos θ

y rsin θ

Z r cos θ isin θ reiθ

Z re iθ

Suppose ψ a0 b 1 and a 2 b2 1

Claim: a eiγ cos θ2 and b ei γ ϕ sin θ2

22
Clearly eiγ cos θ2 is a fully general way of expressing all values of a that can still be normalized to
1. Lets examine a 2 :

a2 eiγ cos θ2 e iγ cos θ


2 cos2 θ2

Hence, b 2 1 cos2 θ2 sin2 θ2 , therefore:

b2 ei γ ϕ sin θ2 e iγ ϕ sin θ2 sin2 θ2

Hence, another way to express an arbitrary single qubit is:

ψ eiγ cos θ2 0 ei γ ϕ sin θ2 1

ψ eiγ cos θ2 0 eiϕ sin θ2 1

Claim: eiγ ψ ψ under measurement.

Let M be the measurement operator, then the probability of measuring M is:

ψe iγ M † Meiγ ψ ψ M†M ψ

Hence, the global phase of a quantum bit does not matter. It is not observable, under any measure-
ment. Therefore it is sufficient to write a quantum bit as:

ψ cos θ2 0 eiϕ sin θ2 1

|0>

y
x

|1>
Figure 8: The Bloch sphere is a useful visualization technique for single qubits and unitary trans-
form on them.
I refer you to Examples 4.8 and 4.9 from the book for rigorous mathematical proofs, but here note:

23
Any single qubit state is a point on the surface of the Bloch sphere.

Any unitary transform becomes a rotation on this sphere: U e iγ Rn̂ θ . This is a rotation
across some arbitrary angle n̂ and a global phase shift. More usefully this can be broken down into:

U eiγ Rz β Ry ϕ Rz δ

Rotations about the X , Y , and Z axis are related to the Pauli operators:

0 1 0 i 1 0
X Y Z
1 0 i 0 0 1

Before discussing this precisely, lets build up to the R y rotation. Lets assume that:

cos θ2 sin θ2
Ry θ
sin θ2 cos θ2

Recall the relations:

sin A B sin A cos B cos A sin B


cos A B cos A cos B sin A sin B
ϕ ϕ
Assume a qubit in the state: cos 2 0 sin 2 1 , then rotating this by R y θ is:

cos θ2 sin θ2 cos ϕ2


sin θ2 cos θ2 sin ϕ2

cos θ 2 cos ϕ 2 sin θ 2 sin ϕ 2 θ ϕ θ ϕ


cos 2 0 sin 2 1
sin θ 2 cos ϕ 2 cos θ 2 sin ϕ 2

Which is what we would expect. Decomposing R y θ further:

cos θ2 sin θ2 cos θ2 0 0 sin θ2


Ry θ
sin θ2 cos θ2 0 cos θ2 sin θ2 0

cos θ
I i sin θ
Y e iθY 2
2 2

This e iθY 2 notation relates the Pauli operators back to rotations on the Bloch sphere:

Rx θ e iθX 2 cos θ2 I i sin θ2 X

cos θ2 0 0 i sin θ2 cos θ2 i sin θ2


0 cos θ2 i sin θ2 0 i sin θ2 cos θ2

24
Ry θ e iθY 2 cos θ2 I i sin θ2 Y

cos θ2 0 0 i i sin θ2 cos θ2 sin θ2


0 cos θ2 i i sin θ2 0 sin θ2 cos θ2

Rz θ e iθZ 2 cos θ2 I i sin θ2 Z

cos θ2 0 i sin θ2 0 e iθ 2 0
0 cos θ2 0 i sin θ2 0 e iθ 2

Claim: Any single qubit unitary transform can be decomposed into the following:

U e iα R β Ry γ Rz δ
z

Consider an arbitrary transform:

a b
U
c d

Since U is unitary:

a c a b 1 0
U †U I or
b d c d 0 1

Which implies:

a a c c 1
b b d d 1
a b c d 0
b a d c 0

Assuming an arbitrary form for a e ia then a eia cos γ


and
2

1 eia cos γ
2 e ia cos γ
2 c c

c c 1 cos2 2γ

Which implies that c e ic sin γ


. We can then rewrite our unitary equations:
2

cos2 2γ sin2 2γ 1
b b d d 1
eia cos 2γ b eic sin 2γ d 0
b e ia cos 2γ d e ic sin 2γ 0

25
From the last two equations it should be clear that b e ib sin 2γ and d e id cos γ
2 (it is
possible to invert where the negative sign is placed, but it is equivalent), which gives us:

cos2 2γ sin2 2γ 1
sin2 2γ cos2 2γ 1
eia cos 2γ e ib sin γ
2 eic sin 2γ e id cos γ
2 0
eib sin 2γ e ia cos γ
2 eid cos 2γ e ic sin 2γ 0

Focusing on the last two equations we have:

ei a b cos γ
2 sin γ
2 ei c d cos γ
2 sin γ
2
ei b a cos γ
2 sin γ
2 ei d c cos γ
2 sin γ
2

Or quite simply: a b c d

There are many solutions with three free variables, but a clever one (for our purposes) is:

a δ β 2 α
b δ β 2 α
c δ β 2 α
d δ β 2 α

This makes:

e iα e iδ 2 e iβ 2 cos γ 2 e iα eiδ 2 e iβ 2 sin γ 2


U iα e iδ 2 eiβ 2 sin γ 2
e e iα eiδ 2 eiβ 2 cos γ 2

e iδ 2 e iβ 2 cos γ 2 eiδ 2 e iβ 2 sin γ 2


e iα
e iδ 2 eiβ 2 sin γ 2 eiδ 2 eiβ 2 cos γ 2

e iβ 2 0 e iδ 2 cos γ 2 eiδ 2 sin γ 2


e iα
0 eiβ 2 e iδ 2 sin γ 2 eiδ 2 cos γ 2

e β 2 0 cos γ 2 sin γ 2 e δ 2 0
e iα
0 eβ 2 sin γ 2 cos γ 2 0 eδ 2

e iα R β Ry γ Rz δ
z

π π π
Claim: H Rz 2 Rx 2 Rz 2

e iπ 4 0 e iπ 4 0 1 0 1 0
Rz π
eiπ 4
2 0 eiπ 4 0 eiπ 4 0 e 2
iπ 0 i

26
π cos π 4 isin π 4 1 1 i
Rx 2 isin π 4 cos π 4 2 i 1

π π π 1 1 0 1 i 1 0
Rz 2 Rx 2 Rz 2 2 0 i i 1 0 i

1 1 0 1 1 1 1 1
2 0 i i i 2 1 1

Note: is there a similar visualization for two or n qubits?

7.1 Phase traveling backwards through control operations

Using our new canonical description of a qubit we can illustrate a fundamental aspect of quantum
computing, that is the notion that with controlled operations the target qubit is amplitude flipped
on the basis of the control qubit, but the control qubit is phase flipped by the target. This is a key
component of the Deutsch-Jozsa algorithm and as we will see shortly Shor’s algorithm as well.

Consider two qubits:

cos θ 0 eiφ sin θ 1 cos σ 0 eiλ sin σ 1

cos θ 0 cos σ 0 eiλ sin σ 1 eiφ sin θ 1 cos σ 0 eiλ sin σ 1

Perform a CNot operation:

cos θ 0 cos σ 0 eiλ sin σ 1 eiφ sin θ 1 eiλ sin σ 0 cos σ 1

Now return this back to “normal form”:

cos θ 0 cos σ 0 eiλ sin σ 1 ei φ λ sin θ 1 sin σ 0 e iλ cos σ 1

Recall that:

π
sin θ cos θ 2
π
cos θ sin θ 2

Thus we can write:

cos θ 0 cos σ 0 eiλ sin σ 1 ei φ λ sin θ 1 cos σ π


2 0 e iλ sin σ π
2 1

27
cos θ 0 cos σ 0 eiλ sin σ 1 ei φ λ sin θ 1 cos σ π
2 0 e iλ sin σ π
2 1

cos θ 0 cos σ 0 eiλ sin σ 1 ei φ λ π sin θ 1 cos σ π


2 0 ei π λ sin σ π
2 1

Observe the phase shift that occurs on the first (control qubit). The phase of the target, λ, has now
become part of the phase of the control.

7.2 Phaseflips versus bitflips

Observe that:

1 1 1 1 0 1 1 0 X Z
H
2 1 1 2 1 0 0 1 2

H X H Z

Figure 9: An X rotation surrounded by H gates is a Z rotation


Claim: HX H Z

X Z X Z
X
2 2

X Z X 2 XZ
2 2

X Z I XZ
2 2

XI XXZ ZI ZXZ
2

X Z Z X
2

2Z
2 Z

Conversely:

H Z H X

Figure 10: Conversely, a Z rotation surrounded by H gates is an X rotation

Claim: HZH X

X Z X Z
Z
2 2

28
X Z ZX Z 2
2 2

X Z ZX I
2 2

XZX XI ZZX ZI
2

Z XI IX Z
2

2X
2 X

8 Universal Quantum Gates

Quantum technologies will not be able to directly implement any quantum gate. Fortunately there
is a method to synthesize any arbitrary quantum gate from only a small minimal set. This universal
set is the quantum analog of the universal gate (NOR or NAND) for classical systems. A universal
set of operations are: H, X , T , and CNot. In this section we will show how any single qubit gate
can be implemented from H, X and T . For multiple qubit gates I refer you to pages 189-191 in
your book.

The T gate is sometimes referred to as the π 8 gate. It is a rotation about the Z axis by π 4:

1 0 e iπ 8 0
T π 8 eiπ 8 Rz π 4
0 e 4

0 eiπ 8

The essential idea with synthesizing single qubit gates is that any single qubit gate is going to take
a qubit which is a point on the Bloch sphere from one position to another. While an arbitrary single
qubit gate will do this with arbitrary precision, for computation purposes we can approximate the
single qubit gate. So long as we can approximate it to arbitrary precision from only a basic set of
gates, then in theory anyway we can synthesize the arbitrary gate. One can view this approximation
as dividing up the surface of the Bloch sphere into patches, circles each of which is ε small in size.

The intuition behind approximating an arbitrary rotation is we are going to form a rotation of an
irrational amount about some axis. The key is the irrationality of the amount (lets name it Δ). By
being irrational we are assured that k1 2π Δ k2 2π Δ for all choices of k1 k2 . To understand
the significance of this, imagine a circle. Assuming we are somewhere on the circumference of
this circle, if we move Δ amount in one direction we will never get back to where we started by
continuing to move Δ increments in the same direction (the only way to get back is to move Δ).

Assuming we are at some point on this circle and we move Δ distance around the circumference
then we will move be at some other unique point. Performing this operation again, we will be
at yet another unique point. Eventually these unique points cover within ε distance the entire

29
circumference. This covering holds for the surface of the Bloch sphere as well as a circle.

So the big question is how do we move an irrational amount? Lets examine T HT H

i π8 Z i π8 X
T HT H e e

Note this is using the relation HZH X . This is equal to:

π π π π
cos 8 I i sin 8 Z cos 8 I i sin 8 X

cos2 π
8 I i cos π
8 sin π
8 IX i sin π
8 cos π
8 IZ i2 sin2 π
8 ZX

cos2 π
8 I sin2 π
8 ZX i cos π
8 sin π
8 IX sin π
8 cos π
8 IZ

Recall that iY ZX , hence:

cos2 π
8 I i sin2 π
8 Y i cos π
8 sin π
8 IX sin π
8 cos π
8 IZ

cos2 π
8 I i sin π
8 cos π
8 X Z sin π
8 Y

We are now back to our “canonical form” for a rotation, except we are rotating some amount
cos θ2 cos2 π8 . The key is θ is irrational.

The angle at which this rotation occurs is along the vector:

n̂ cos π8 sin π8 cos π8

This irrational rotation of amount θ along the vector n̂ we will denote as R n̂ θ . We are close to fin-
ishing, the only thing left is the ability to move along an orthogonal vector m̂. This is accomplished
using something similar to HZH X . Simply rotate along HR n̂ θ H.

i π8 X i π8 Z
HRn̂ θ H HT HT HH HT HT e e

π π π π
cos 8 I i sin 8 Z cos 8 I i sin 8 Z

Which we note is the same except for the sin2 π8 X Z, instead of ZX , hence iY instead of iY .
Hence, a new orthogonal rotation Rm̂ along the vector:

m̂ cos π8 sin π8 cos π8

Hence, using our decomposition idea we can approximate any rotation to arbitrary precision:

U Rn̂ β θ Rm̂ γ θ Rn̂ δ θ

30
8.1 More than two qubit controlled operations

Setup undo−Setup

|0> X X |0>
X
|0> X X |0>

Figure 11: Generalizations of the Toffoli gate are constructed by simply composing a “super con-
trol” and then de-composing it.

8.2 Other interesting gates

Claim: The control and target of a CNot gate can be swapped when surrounding the input and
output with H gates.

H H

H H

Figure 12: The control and target of a CNOT gate can be swapped when the inputs are surrounded
by H gates.

Suppose two qubits:

ψ1 a0 b1
ψ2 c0 d1

ψ ψ1 ψ2

ac 00 ad 01 bc 10 bd 11

Now apply the two H gates:

1
2 ac 0 1 0 1 ad 0 1 0 1
bc 0 1 0 1 bd 0 1 0 1

31
1
2 ac 00 01 10 11 ad 00 01 10 11
bc 00 01 10 11 bd 00 01 10 11

Apply the CNot gate:

1
2 ac 00 01 11 10 ad 00 01 11 10
bc 00 01 11 10 bd 00 01 11 10

1
2 ac 00 01 10 11 ad 00 01 10 11
bc 00 01 10 11 bd 00 01 10 11

1
2 ac 0 1 0 1 ad 0 1 0 1
bc 0 1 0 1 bd 0 1 0 1

Apply the H gates:

ac 00 ad 11 bc 10 bd 01

ac 00 bd 01 bc 10 ad 11

Which is as if the control and target qubits where swapped!

8.3 Swap

|y1> |y2>

|y2> |y1>

Figure 13: A swap gate exchanges the state of two qubits.

A Swap gate is three back to back CNot gates as shown in Figure 13.

Suppose two qubits:

a c
b d

ac 00 ad 01 bc 10 bd 11

Apply the first CNot:

ac 00 ad 01 bd 10 bc 11

32
Apply the second CNot:

ac 00 bc 01 bd 10 ad 11

Apply the third CNot:

ac 00 bc 01 ad 10 bd 11

ca 00 cb 01 da 10 db 11

c a
d b

9 Shor’s Algorithm

Shor’s algorithm is used to factor numbers into their components (which can potentially be prime).
It does this in roughly O n3 quantum operations, while the best known classical algorithms are
exponential. Since the difficulty of factoring is believed to be exponentially hard it forms the basis
of most modern crypto systems. Hence, being able to factor in polynomial time on a quantum
computer has attracted significant interest.

In this section we are going to begin by constructing a set of tools needed to actually implement
Shor’s algorithm. Then we put these tools together to actually factor. Our first tool is how factoring
is related to another problem: order finding.

9.1 Factoring and order-finding

For positive x, N such that x N, the order of x modulo N is the least positive integer r such that
xr modN 1

Why do we care about this problem:

Suppose N 77 and x 10

r : 0 1 2 3 4 5 6 7 8 9 10 11 12 13
xr N : 1 10 23 76 67 54 1 10 23 76 67 54 1 10

Suppose N 15 and x 2

r: 0 1 2 3 4 5 6 7 8 9
xr N: 1 2 4 8 1 2 4 8 1 2

33
Suppose N 15 and x 4

r: 0 1 2 3 4 5 6 7 8 9
xr N: 1 4 1 4 1 4 1 4 1 4

Suppose N 15 and x 11

r: 0 1 2 3 4 5 6 7 8 9
xr N : 1 11 1 11 1 11 1 11 1 11

Observe that the period of repetition is one less than a factor of N! Shor’s algorithm can be
summarized in this way:

Choose some random x (actually x co-prime of N)

Use quantum parallelism to compute x r for all r simultaneously.

Interfere all of the xr ’s to obtain knowledge about a global property of the structure (i.e. the
period) of the solutions.

Use this period to find the factor of N

|0> 2t
2t j s/r
!QFT
H

yx^j mod N

t
|000....1> y yx^j mod N

Figure 14: Overview of Shor’s algorithm

9.2 Quantum Fourier Transform (QFT)

The Quantum Fourier Transform (QFT) implements the analog of the classical Fourier Transform.
It transforms a state space of size 2n from the amplitude to the frequency domain (just as the
Fourier transform can be viewed as a transform from 2n numbers into a range of size 2n containing
the frequency components from the domain.

The classical Fourier Transform is defined as:


2n 1
n
yk 1
2n ∑ x j e2πi jk 2
j 0

34
The QFT is similarly defined:

2n 1
n
j 1
2n ∑ e2πi jk 2 k
k 0

Thus an arbitrary quantum state is transformed:

2n 1 2n 1 2n 1 2n 1
n
∑ xj j ∑ yk k 1
2n ∑ ∑ x j e2πi jk 2 k
j 0 k 0 k 0 j 0

Example:

00000 01000 10000 11000

is transformed to:

00000 00100 01000 011000


10000 10100 11000 11100

i.e.:

0 8 16 24

is transformed to:

0 4 8 12 16 20 24 28

So how do we implement the QFT? This derivation is in the book at pages 216-219, but we will
expand many of the steps and deviate from it slightly for clarity:

The transform is defined as:


2n 1
n
j 1
2n ∑ x j e2πi jk 2 k
k 0

Note that j is a binary number and can be decomposed into the form:
n
j j 1 2n 1 j 2 2n 2 j n 20 ∑ j i 2n i
i 1

Similarly for k
n
k ∑ ki2n i
i 1

35
Re-express the transform as
n

1
2n 1 2πi j ∑ kl 2n l
2n

2n ∑e l 1 k
k 0

Canceling the 2n terms we have:


n
l
1
2n 1 2πi j ∑ kl 2
2n ∑e l 1 k
k 0

Now decompose the exponent:

2n 1
1 2 n
1
2n ∑ e2πi jk12 e2πi jk2 2 e2πi jkn 2 k
k 0

Similarly, decompose the summation:

1 1 1
1 2 n
1
2n ∑ ∑ ∑ e2πi jk1 2 e2πi jk2 2 e2πi jkn 2 k1 k2 kn
k1 0 k2 0 kn 0

Now, pull out the n’th component:

1 1 1 1
1 2 n n
1
∑ ∑ ∑ e2πi jk1 2 e2πi jk2 2 e2πi jkn 2 k1 k2 kn 1 ∑ e2πi jkn2 k
2n
k1 0 k2 0 kn 1 0 kn 0

Similarly for all components and we have:

1 1 2 n
0 e2πi jk1 2 1 0 e2πi jk2 2 1 0 e2πi jkn2 1
2n

Next, lets define a new notation:


jl jl 1 jm
0 j l jl 1 jm 2 22 2m l 1

(Suspend your skepticism on why we need this notation for a short while.) Note:
n

k
2πi2 k
∑ j l 2n l
kj n 1 kj n 2 kj 0
e2πi j2 e l 1 e2πi2 12 e2πi2 22 e2πi2 22

n 1 kj n 2 kj n n kj
e2πi2 1 e2πi2 2 e2πi2 n

36
n i k
Suppose that ji 0 then e2πi2 ji 1

Suppose that ji 1 and 2n i k 1 then the exponent is a multiple of 2πi, hence equal to 1

Suppose that ji 1 and 2n i k 1, i.e., n i k 0 then lets look at k 1


1
0 e2πi j2 1 0 e2πi0 jn 1

For k 2:
2
0 e2πi j2 1 0 e2πi0 jn 1 jn 1

and similarly for the rest. Hence, can rewrite the transform as:

1
2n
0 e2πi0 jn 1 0 e2πi0 jn 1 jn 1 0 e2πi0 j1 j2 jn 1

which matches what is in your book again.

To see how to actually implement this, lets look at any one of the qubits and how it should be
transformed:

1
2
0 e2π0 jl jn 1

Pull off the first component:

1
0 e2πi0 jl e2π0 jl 1 jn 2 1
2

Looking at the first component only:

1 1 1 jl
0 e2πi0 jl 1 0 e2πi jl 2 1 0 1 1
2 2 2

This is just an H gate!

What about e2π0 jl 1 jn 2 ? Use a rotation:

1 0
Rk 2πi 2k
0 e

Note we apply this rotation conditionally on whether or not j i is equal to 1. We do this by focusing
on the least significant digit first. We want to achieve:

0 e2πi0 j1 j2 jn 1

Start with j1 j2 jn

37
Apply H to obtain:

1
0 e2πi0 j1 1 j2 jn
2

Apply a controlled R2 rotation to obtain:

1
0 e2πi0 j1 j2 1 j2 jn
2

Apply controlled R3 :

1
2
0 e2πi0 j1 j2 j3 1 j2 jn

And so on to obtain:

1
0 e2πi0 j1 j2 jn 1 j2 jn
2

This is done similarly for the other bits j 2 then j3 , etc, and that’s it. The result ends up with the
bits in reverse order, but simply swap them and you have the QFT!

H R2 R3 Rn

H R2 R n−1

Figure 15: The above circuit implements the Quantum Fourier Transform (QFT). Note the outputs
are reversed in their bit-significance.

9.3 Shor’s Algorithm – the easy way

A less rigorous, but more intuitive way to think of Shor’s algorithm is that you simply compute
the function yx j modN for all j. One wonders what value of y should be chosen, but an easy value,
and one that makes y disappear is to choose the number 1. Then, simply fourier transform the
solution space and measure the period, which is the number we are looking for. In some respects,
this is exactly how Shor’s algorithm works and we give that derivation here. However, a deeper
understanding of Shor’s algorithm comes from Phase estimation, which we’ll get to next. For now,
here is the straightforward description of Shor’s algorithm:

38
ψ1 0 t 00 1

1
ψ2 ∑ j 00 1
2t
j

1
ψ3 ∑ j x j modN
2t
j

r
ψ4 ∑ j xk modN k 0r 1
2t
j k k r k r2

r 1
1
ψ5 r ∑ s r xk modN
s 0

ψ6 s r xk modN

9.4 Phase estimation

2t |j>
|0> !QFT
H

|u> j |u>
U

Figure 16: Phase estimation estimates the phase of a particularly formed eigenvalue of the eign-
vector to a matrix (in the case depicted, U ).

Suppose u is an eigenvector of U with eigenvalue e2πiϕ

This means:

e2πiϕ I U u 0 from λI A x 0

e2πiϕ I u Uu

Or more generally
t t
e2πi2 ϕ I u U2 u
k
The idea with phase estimation is to apply the controlled U 2 operation with 12 0 1 as the
control, for k 01 n . Then apply inverse QFT to n qubits and obtain ϕ̃ , an estimate of ϕ.
In summary:

39
Start with: 0 t u

Apply H t to get:

1
∑ j u
2t
j

k
Apply controlled-U 2 operation for each of the k qubits of j

1
2t ∑ e2πi jϕu j u
j

Apply inverse QFT:

ϕ̃ u

9.5 Shor’s Algorithm – Phase estimation method

Use phase estimation on U where U y xy modN


find us
Estimate phase s r
Use continued fraction expansion to find r

Given U y xy modN claim that us , the eigenvectors of U are:

r 1
2πi rs k
us 1
r ∑e xk modN
k 0

s
Suppose e2πi r for 0 s r 1 are eigenvalues, then:
s
U us e2πi r us

r 1
s 2πi sr k
e2πi r 1r ∑e xk modN
k 0

r 1
2πi sr k 1
1
r ∑e xk modN
k 0

r 1
2πi sr k
1
r ∑e xk 1
modN
k 0

40
r 1
2πi sr k
1
r ∑e xk modN
k 0

r 1
2πi rs k
U us 1
r ∑e U xk modN
k 0

r 1
2πi sr k
1
r ∑e xk 1
modN
k 0

r 1
2πi sr k
1
r ∑e xk modN
k 0

So how to prepare us for Shor’s algorithm? We can’t for a single eigenvalue, but note, we can for
a superposition of them!

r 1
1
r ∑ us
s 0

r 1r 1
2πi rs k
1 1
r r ∑ ∑e xk modN
s 0k 0

Look carefully at k 0

r 1
1
r ∑ e0 x0 modN r
r 00 1 00 1
s 0

So, Shor’s algorithm starts out with the state:

r 1r 1
2πi sr k
0 t 1 1
r r ∑ ∑e xk modN 0 t 00 1
s 0k 0

The H t transform is applied:

r 1r 1
2πi sr k
1
∑ j 1 1
r r ∑ ∑e xk modN
2t
j s 0k 0

Modular exponentiation is applied:

r 1r 1
2πi sr j 2πi rs k
1
∑ j 1 1
r r ∑ ∑e xk modN
2t
j s 0k 0

41
Measure the second register to obtain some k

r 1
2πi sr j k
1
∑ j 1
r ∑e xk modN
2t
j s 0

1 r 1 2πi sr j k
1
∑ e j xk modN
2t
j r s∑0

Inverse QFT to obtain:

r 1
1
r ∑ s r xk modN
s 0

Measure first register to obtain a particular s r, and then use continued fraction expansion to find
r.

9.6 Continuous fraction expansion

(See page 230 from the book)

1
a0 a1 am a0 a1 1
a2 1

Examples:

13 1 1 1 1 1
64 64 12 1 1 5
13 4 13 4 13 4 1
12 1 12

18 1 1 1 1 1 1 2
64 64 3 10 3 1 3 1 3 1 3 1 7
18 18 18 8
1 10 1 1 1 1
10 10 1 28
8

9.7 Modular Exponentiation

z y z xz ymodN

Note that:

Z zt 2t 1 zt 12
t 2 z 1 20
t 1 t 2 0
xZ xzt 2 xzt 12 xZ xz1 2

42
t 1 zt t 2 zt 1 0 z0
x2 x2 x2

i
Can compute x2 classically. Note that zi is binary, hence this is really a sequence of conditional
multiplies, almost. The tricky bit is mod, but that distributes, i.e.:

iN α k modN iN k α k modN αk modN

Thus, compute:

t 1 zt t 2 zt 1 0 z0
x2 modN x2 modN x2 modN modN

Note that this is only t conditional modular multiplications.

10 Grover’s Algorithm

sqrt{2^n} times

n n
|0> H

G G G

|1> H

Figure 17: Grover’s algorithm

n n n n
H x H |0> to |0> H
x

|x> to −|x>
f(x)

y (y + f(x)) mod 2

Figure 18: A Grover iteration

X X
X X
X X
X X
X H H X

Figure 19: A Grover operator taking 0 0 and x x for x 0. Note, this actually
does the reverse, but that is the same up to a global phase of 1, which isn’t observable.

43
Examine the first iteration of Grover’s algorithm:

Apply H gates:

n 1 0 1
0 1 2n ∑ j 1
j 2

Apply oracle:

1 f j 0 1
2n ∑ 1 j 1
j 2

1 0 1
2n ∑ j m 1
j m 2

1 0 1
2n ∑ j 2m 1
j 2

Apply H n

n 1 1 m j 0 1
0 2 ∑ 1 j 1
2n 2n
j 2

2 n 2 m j 0 1
1 2n 0 2n ∑ 1 j 1
j 0 2

Apply Grover operator transforming 0 0 and x x

2 n 2 m j 0 1
1 2n 0 2n ∑ 1 j 1
j 0 2

2n 4 n 2 m j 0 1
2n 0 2n ∑ 1 j 1
j 2

Apply H n

2n 4 2 0 1
2n ∑ j 2n m 1
j 2

So observe that the “other” part has a slightly lower probability, and the correct answer (m) has a
slightly more likely chance of being measured. Lets generalize this for an arbitrary iteration.

44
W R
2n ∑ j 2n
m
j

Apply oracle:

W f j R
∑ 1 j m
2n 2n
j

W R 2W
∑ j m
2n 2n
j

Apply H n

R 2W 1 jm
W 0 ∑ 1 j
2n 2n
j

Apply Grover operator:

R 2W R 2W 1 jm
W 1 2n 0 ∑ 1 j
2n 2n
j 0

R 2W R 2W 1 jm
W 2 2n 0 ∑ 1 j
2n 2n
j

Apply H n

R 2W 1 R 2W
W 2 2n ∑ j 2n m
2n
j

Thus, for each iteration the probability of obtaining a random answer “W” changes from:

Ri 2Wi
Wi Wi 1 2 1
2n
1

and the probability of obtaining the correct answer changes from:

Ri Ri 1 2Wi 1

(these probability amplitudes are all over 2n

Note that the sequence W1 W2 Wn is non-increasing and the seqeuence R1 R2 Rn is


non-decreasing. This (and the above equation) implies that the sequence R 1 R2 R1 Rn
Rn 1 is non-increasing. We can use this fact to prove the correctness of Grover’s algorithm.

Suppose that Wi 1 1 2 after 2n iterations. Then:

Ri Ri 1 2 Wi 1 2 1 2 1

45
Hence, W 2n 2n , hence we must measure the correct answer, which is a direct contradiction to
Wi 1 1 2 ! Therefore after 2n iterations Wi 1 1 2. This means that probability of obtaining
the wrong answer is less than 1 4, which means with 75% chance we will measure the correct
answer m after 2n iterations.

11 Error Correction

Let’s suppose there was no theory of error correction for quantum computers. Then a single quan-
tum bit de-coheres (randomizes) at the same rate as a classical bit: e λt , except for quantum
systems they tend to be so error prone that λ is quite large.

Given a system if n qubits the probability that there is no error in the entire system is the probability
of no-error on each qubit multiplied together. That is:

e λt e λt e λt e λt n

As an example of how faulty quantum systems are, lets compute the largest number of bits we can
factor using Shor’s algorithm without error correction.

Discounting the inverse QFT, Shor’s algorithm is roughly t 65n 3 complexity, when factoring n
qubits. Suppose ε 0 05 is the probability of failure that we want (this says that with 5% chance
we will fail, but that is acceptable since if we fail we will just measure random data, which we can
check and then re-run the algorithm anew). This implies that:

1 ε e λt n

Let p n t n (p n is the space-time complexity of an algorithm)

1 ε e λpn

An appropriate value of λ is 10 6 , this is far to aggressive for current demonstration systems (which
are more like 10 3 ), but is around what we expect future quantum systems to be. Furthermore, it
is above a critical threshold – more on this later. So for λ 10 6 , how many bits can we factor
with Shor’s algorithm?

1 ε e λpn

log 1 ε λp n

65n3 n pn log 1 ε λ

46
1 1
n log 1 0 05 10 6 65 4
342 4 4 qubits!

Clearly, this is not good. Fortunately, there are methods to apply essentially classical error correc-
tion techniques to quantum systems.

Error correction overview:

Errors are caused by decoherence (entanglement with the environment).

We “fight” this entanglement with more entanglement.

Create codes that allow for the measurement of error, without the measurement of the value.
I view this as information loss, we create codes whereby we can gain knowledge about the
error, but not the state, and thereby we “leak” the knowledge about the errors out of the
system.

Based on the ideas of classical codes (well almost). Classical codes such as TMR, i.e.,
0 000 and 1 111. Just repeat the classical bit and then take a majority vote.

11.1 Shor’s 3 qubit bit-flip code

Shor’s code for protecting against bit-flip errors is the most basic of quantum codes and is a direct
translation of TMR. That is, given a qubit:

ψ a0 b1

encode it to be:

ψc a 000 b 111

To see how to correct errors on this code, lets write it as:

ψc a z 1 z2 z3 b z¯1z¯2 z¯3

|0> z1 xor z2 |0> z2 xor z3

|z1>

|z2>

|z3>

Figure 20: Measurement of errors in the 3 qubit bit flip code.

47
Error correction is based around the idea of using an ancilla set of qubit(s) that are entangled with
the code word. The ancilla is carefully entangled in such a way that it’s state is entangled with
the error on the qubits (if there is any) and not the state. To see how to do this, lets return to the
classical TMR codes again.

Suppose we have a classical code 010. Clearly majority voting would lead us to conclude that the
code should really be 000. However, lets arrive at this result using the restriction that we cannot
gain knowledge about the logical state of the code. That is, lets arrive not at the knowledge that the
code should be 000, but that only there is a bit-flip error on the 2nd qubit. Thus we won’t be able
to know whether it is 010 or 101. This knowledge, while incomplete, does tell us where the error
is and how to correct it. We can use it to know whether to apply a NOT gate to the 2nd’s qubit. To
gain this knowledge (and this knowledge only!), measure the following:

s1 z1 z2 (that is s1 z1 xor z2 )

s2 z2 z3

Lets examine the outcome possibilities:

code-word s1 s2
000 0 0
001 0 1
010 1 1
011 1 0
100 1 0
101 1 1
110 0 1
111 0 0

Focus in on the 010 and 101 code words:

code-word s1 s2
010 1 1
101 1 1

There in lies the key: s1 and s2 do not tell us whether the code word should be 000 or 111, but they
do tell us that the 2nd bit has been flipped.

This is the key concept behind quantum error correction (one of two). We devise a measurement
that gives us partial knowledge, chiefly in this case, the xor. Here is how to do this in the quantum
world:

Start with a code word:

ψc a z 1 z2 z3 b z¯1z¯2 z¯3

48
And use an ancilla qubit:

a z 1 z2 z3 b z¯1z¯2 z¯3 0 a z 1 z2 z3 0 b z¯1z¯2 z¯3 0

Apply a CNot with the code-word bit 1 as the control and the ancilla the target.

a z 1 z2 z3 z1 b z¯1 z¯2 z¯3 z¯1

Apply a 2nd CNot with the code-word bit 2 as the control and the ancilla the target.

a z 1 z2 z3 z1 z2 b z¯1z¯2 z¯3 z¯1 z¯2

Suppose that z1 z2 (thus z¯1 z¯2 ), then:

z1 z2 0 and z¯1 z¯2 0

Suppose that z1 z2 (thus, z¯1 z¯2 ), then:

z1 z2 1 and z¯1 z¯2 1

Hence, the ancilla qubit above does not gain knowledge on whether z 1 or z2 is equal to 1 or 0, but
it does gain knowledge about the parity of z 1 and z2 . Doing the same for bits z2 and z3 we have:

z1 z2 z2 z3 error ?
0 0 None
0 1 qubit 3 has flipped
1 0 qubit 1 has flipped
1 1 qubit 2 has flipped

This is understating the power of quantum error correction. Unlike classical bits, quantum bits
can be in a continuous range between 0 and 1. Furthermore, so are the errors! The true power of
quantum error correction is that it transform continuous errors to either no error at all, or a discrete
error. Here’s an example of how:

Suppose ψc a 000 b 111 and some random rotation about the x-axis R x θ occurs on the
third qubit. This is expressed as:

a 0 0 Rx θ 0 b 1 1 Rx θ 1

Recall that:

cos θ2 i sin θ2
Rx θ
i sin θ2 cos θ2

Thus,

49
a 0 0 cos θ2 0 i sin θ2 1 b1 1 i sin θ2 0 cos θ2 1

Now parity check the 2nd and 3rd qubits. First add the ancilla qubit:

a 0 0 cos θ2 0 0 i sin θ2 1 0 b1 1 i sin θ2 0 0 cos θ2 1 0

Apply the first CNot:

a 0 0 cos θ2 0 0 i sin θ2 1 0 b1 1 i sin θ2 0 1 cos θ2 1 1

Apply the 2nd CNot:

a 0 0 cos θ2 0 0 i sin θ2 1 1 b1 1 i sin θ2 0 1 cos θ2 1 0

Measure the ancilla qubit. What is the probability of measuring 0?

p0 a2 cos2 θ2 b2 cos2 θ2 a2 b2 cos2 θ2 cos2 θ2

Similarly for 1:

p1 a2 sin2 θ2 b2 sin2 θ2 a2 b2 sin2 θ2 sin2 θ2

It doesn’t matter which one we pick, but lets choose 0, after measurement the qubits are re-
normalized to become:
a cos θ2 000 0 b cos θ2 111 0
a 000 b 111 0
cos2 θ2

Key:
The very fact of measuring a continuous error has made it discrete, and in this case
has made the error go away! Why did it go away? Think of it this way, the error
was some superposition / entanglement with the environment, and measurement has
clasped that entanglement and superposition. Alternatively, just think of the error
as additional “information” in the state vector and measurement has observed (and
made classical) that information. The fact that that information was not in a single
qubit, but in a joint system of the two qubits is subtle.

11.2 Protecting phase

Quantum bits have a phase as well as an amplitude. This too must be protected. However, recall
that the phase flip Z surrounded by two H gates is a bit flip X. More generally, a phase rotation
surrounded by two H gates is an amplitude rotation. Thus a phase error is just a bit-flip error if the
code is setup to protect for bit flips but then the qubits of the code are passed through H gates prior

50
to use. Starting with the 3 bit Shor bit flip code we can derive the 3 bit Shor phase flip code in this
way. The encoder is shown in Figure 21

|y> H

|0> H

|0> H

Figure 21: Encoder that takes an arbitrary state ψ and encodes it in the 3 qubit Shor phase-flip
protecting code

However we need to correct for both phase and amplitude to be fully fault tolerant. For this, we
need an additional tool. The tool we use is concatenation. This is exactly like the classical use of
concatenation. For example, suppose we have the classical bit “1”, and we TMR encode this to be
“111”. This can protect for one of the bits being in error. However, suppose the error rate is so
high that it is possible for two bits to be in error. What we can do is take each bit of the “1-1-1”
and re-encode that with TMR to obtain: “111-111-111”. Then suppose we have the value “111-
001-111”. We first perform error correction on the lowest layer to obtain “111-000-111”. Next we
perform error correction on the upper layer (in logical space) to obtain “111-111-111”. This is not
the most efficient classical code, but it is easy to reason and work with. It can also be translated
directly into quantum codes.

To protect for both phase and amplitude on a qubit we first encode it with a bit-flip code, and pass
those qubits through H gates. This protects the upper layer for phase. We then re-encode each of
those qubits again with a bit flip code. This protects the lower layer for amplitude. All told, the
entire code (known as the Shor 9 qubit code, shown in Figure 22) protects for a single phase or
a single amplitude error on any of the 9 qubits and logically holds one 1 quantum bit. Figure 23
illustrates how to measure the error in a phase.

11.3 7 Qubit Steane code

Now that we have the 9 qubit Shor code we can protect quantum state. But we also want compute
on it. To compute in a fault tolerant manner we cannot decode the code word (which we’ll call
the logical qubit) into a single qubit (which we’ll call a physical qubit), transform it, and then
re-encode it. The reason is the physical qubit is susceptible to errors, and if an error does occur
to it, in this unencoded state, then the computation is lost. The solution is to transform a basic set
of quantum operations that would ordinarily be applied to physical qubits such that they can be
applied to logical qubits in a fault tolerant manner.

Doing this for the Shor code is not easy. Logical X and Z operations can be performed simply

51
|y> H

|0>

|0>

|0> H

|0>

|0>

|0> H

|0>

|0>

Figure 22: Encoder that takes an arbitrary state ψ and encodes it in the 9 qubit Shor code.

(challenge: what are the logical implementations of these?), but logical H, CNOT, and T cannot. A
vast amount of quantum coding research is out there, but one of the easiest to transform codes is
the 7 qubit Steane code.

To introduce the 7 qubit Steane code we’ll take a brief detour into stabilizer codes. Stabilizer codes
and their associated stabilizers is a neat compact theory useful for describing quantum codes.

Here is the idea with stabilizer codes. Suppose:

00 11
ψ 1
2

Then X1 X2 ψ ψ and Z1 Z2 ψ ψ . Thus we say that ψ is stabilized by X1 X2 and Z1 Z2 (here


X1 means the X gate applied to the first qubit). Note that X1 X2 is only a stabilizer for this particular
ψ , and does not generalize to arbitrary a 00 b 11 .

Thus, the 3 qubit bit-flip Shor code is stabilized by Z 1 Z2 and Z2 Z3 . The 3 qubit phase-flip code
is stabilized by X1X2 and X2 X3 . What is nifty about the stabilizer formalism is that they indicate
precisely how to measure the error. To measure the error in a logical quantum bit one measures the
stabilizers.

The stabilizers for the 7 qubit Steane code are:

52
Think about bit−flip error measure this way Implement it like this Formalize it like this:

|0> |0> H H |0> H H

H H Z

Thus for phase−flip measurement just:

|0> H H

Figure 23: Recall that to measure the amplitude error we performed two CNOT operations on an
ancilla qubit initially in the 0 state. To implement this, however, we surrounded both the ancilla
and the code bits with H gates and inverted the direction of the CNOT gate. This was so that an
phase error on the ancilla did not pollute the qubits in the code word. To formalize this thinking
we thought of this as a controlled Z operation with the ancilla as the control. To measure the phase
error we just directly implement the formalism, which is to perform a controlled X (i.e. CNOT)
operation.

g1 I1 I2 I3 X4 X5 X6 X7
g2 I1 X2 X3 I4 I5 X6 X7
g3 X1 I2 X3 I4 X5 I6 X7
g4 I1 I2 I3 Z4 Z5 Z6 Z7
g5 I1 Z2 Z3 I4 I5 Z6 Z7
g6 Z1 I2 Z3 I4 Z5 I6 Z7

The Steane code is particularly nice because once we measure these stabilizers if any stabilizer
g1 g2 g3 is non-zero then a phase error has occurred on the physical qubit that is part of the
logical qubit at position g 1 22 g2 21 g3 20 1 and if any stabilizer g4 g5 g6 is non-zero then a
bit-flip error has occurred on the physical qubit g4 22 g5 21 g6 20 1.

Figure 24 depicts how to (non-fault tolerantly) encode a physical qubit into the Steane code. This
figure is from John Preskill at Caltech and is not in your book.

The important part about the 7 qubit Steane code is that the H, X, Z, and CNOT gates can be applied
in logical form transversally. That is, bit-wise across the qubits of the code. Unfortunately, T
cannot. See pages 485-491 of the book for details on how to implement T.

11.4 Recursive error correction and the threshold theorem

How fault tolerant is the Steane code? For this lets perform a calculation. Assume the following:

53
bit 7 |0> H

|0> H

|0> H

|0>

|0>

|0>

bit 1 |y>

Figure 24: Non-fault tolerant encoder for the 7 Qubit Steane code. This figure is from John Preskill
at Caltech.

On average, no fixup is required (the likely case) after each logical operation and error cor-
rection step.
Failure occurs when two or more errors show up in a code word.

In general, error correction takes an error rate of p 1 e λ to cp2 . The constant c is the
number of double-points of failure in the logical operation and error correction step (i.e. the
number of places that can both fail to produce two errors in a code word). It is about 21,942
for a straightforward implementation of stabilizer measurement for the 7 qubit Steane code.

Fault tolerant operation transforms:

1 ε eλp n

into:
pn
1 ε 1 cp2

1 ε 1 cp2 p n

ε
pn cp2

Assuming we want a 95% chance of obtaining the correct answer and the same error rate as before
(λ 10 6 ) we have that:

6 2
0 05 10
65n3 n
21 942 1 e

n 35 057 1 4

54
|0> H H g1 |0> H H g6

b7 X H X H

b6 X H H

b5 X H X H

b4 X H H

b3 H X H

b2 H H

b1 H X H

Figure 25: Almost fault-tolerant measurement of the stabilizers g 1 and g6 . To make this circuit
fault tolerant, the ancilla must be a checked CAT state, and the measurement must be repeated at
least two times.

n 13 qubits

Clearly we have to do better, and for this we turn to recursive error correction. Similar to the
concatenation we used to combine the bit and phase flip codes we can concatenate a quantum code
with another quantum code. For our example, we are going to concatenate the 7 qubit Steane code
with itself. The idea is to take a qubit and encode it in the 7 qubit Steane code. Then take each
physical qubit that is part of that single logical qubit and re-encode it again in the 7 qubit Steane
code. Repeat this procedure until we have a sufficiently strong error correcting code.

Note that this repetition would seem to imply an exponential blowup in resources – and it does, but
it also creates an exponentially strong error correcting code. Thus the overhead is polynomial to
perform computation. As we will see, however, just being polynomial doesn’t make the overhead
insignificant.

Key:
Concatenating codes recursively works so long as the underlying decoherence rate
p 1 e λ is less than 1 c, the unit of complexity of the error correction step. This
is the result of the threshold theorem which underpins fault tolerant computation.
The concept is straightforward: we have to be able to correct fast enough such that
any decoherence that occurs while we are correcting can be corrected away. If error
correction takes so long that it would do more harm than good, then arbitrarily long
quantum computation cannot be sustained.

Applying error correction recursively we obtain the following equation:

55
Basic measurement is not fault tolerant:

Measurement needs to be p^2 accurate and this is only p


|0> H H

Phase errors can travel up to control and polute bits

Solution is to use a checked CAT state:

Create CAT Check the CAT for errors use it un−create CAT

|0> H H
|0>
|0>
|0>

|0> =0? |0> =0?

check check

Discard if check != 0

Do this at least 2X for each stabilizer


This will increase the measurement reliability from p to p^2

Figure 26: Making measurement of stabilizers fault-tolerant is an arduous task. First, a CAT state
must be used in order to prevent errors in one qubit of the code word from polluting other qubits
via the ancilla qubit. This CAT state must be checked to make sure it is reliable. Furthermore, the
whole process must be repeated at least twice for each stabilizer since the measurement must be
p2 reliable.

k
c ṗ 2 ε
c pn

Here, k 1 is the number of recursive levels of error correction. Note the 2k in the equation, this
is where the exponential improvement in tolerance to errors comes from.

Lets examine what happens when we apply 5 layers of error correction:

10 6
k 5, c 21 942, p 1 e ,ε 0 05, p n 65n3 n

25
21 942 1 e 10 6
0 05
21 942 65n3 n

n 37 1013 qubits.

Now we can factor large numbers. However, there is a down side. The overhead for each qubit
is 75 16 807 physical qubits. Worse still 1 logical gate requires about 153 5 83 841 135 993
physical gates. At 1Mhz operation 1 logical gate takes 23 hours to do (serially), so at k 5,
factoring a 1024 bit number takes 200 million years!

56
g1, g2, g3, g4, g5, g6

Logical gate Syndrome measurement Recover

g1, g2, g3, g4, g5, g6

Syndrome measurement Recover

Logical g1, g2, g3, g4, g5, g6


2 qubit
gate
Syndrome measurement Recover

H X Z

H X Z

H X Z

H X Z

H X Z

H X Z

H X Z

Figure 27: Fault tolerant computation proceeds by performing the coded operation, measuring
the stabilizers (syndrome measurement), and then possibly recovering from an error. For the
Steane code, the X, Z, H, and CNOT operations are easily applied in code-space, simply apply
them transversally. Note this is not the case for T.

The solution: parallelism and quantum architecture.

Really only need k 3 for 1024 bits, so only 343 qubits of overhead, and 3,581,577 ops/logical
op. This requires only 8000 years serially. Hence, still need quantum architecture.

k 2, p 10 8 , 51 years

k 2, p 10 9 , 1 Ghz operation (electron state), optmized error correction, clustering, 31


hours!

57

You might also like