mathematical_introduction_to_quantum_computation

66
T rinity College Dublin School of Maths Final Y ear T hesis Mathematical Introduction to Quantum Computation Author: Brian Flynn Supervisor: Professor Richard T imoney March 2015

Upload: brian-flynn

Post on 12-Apr-2017

35 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Mathematical_Introduction_to_Quantum_Computation

Trinity College Dublin

School of Maths

Final Year Thesis

Mathematical Introduction to QuantumComputation

Author:Brian Flynn

Supervisor:Professor Richard Timoney

March 2015

Page 2: Mathematical_Introduction_to_Quantum_Computation
Page 3: Mathematical_Introduction_to_Quantum_Computation

A B S T R A C T

The subject of Quantum Computing is one of great interest across industry and academiaat present. It is believed that by exploiting quantum properties of extremely small sys-tems, we may be able to build machines which utilise these unique properties in sucha way as to offer significant increase in computational power over even the strongest ofclassical super-computers currently.

The aim of this thesis is to consider and simplify the fundamental principles of thefield of quantum computing. In doing so, it is hoped to present the subject in accessibleand plain language so that the reader may understand some elements not explored ingreat depth in standard literature.

We first define the language with which we can explore the topic by recalling somelinear algebra to describe quantum mechanics. We then combine quantum physics withcomputer science to generate the fundamental unit of quantum communication, thequbit.

We build from the definition of the qubit to the declaration of quantum gates, whichact as logic gates, transforming the state of a qubit to a new state. By combining thesegates, then, we see how quantum circuits can be developed to perform useful schemes,which can themselves be put together to form quantum algorithms in order to achievecomputations which may not be possible through exploitation of solely classical technol-ogy.

We will conclude with a discussion of why quantum computing has been of suchinterest in recent decades. In particular, we will describe the process of the single mostfamous result of the field of study to date, Shor’s factoring algorithm. We will hereby seehow quantum methodology can solve a real problem, namely factorising large integers,which has been a difficult problem for classical computers historically. As such we willhave demonstrated clear motivation for the school of thought, as well as clarifying somefundamental mathematical concepts involved in its inception.

i

Page 4: Mathematical_Introduction_to_Quantum_Computation

A C K N O W L E D G E M E N T S

I would like to thank Prof. Timoney for his help and patience through-out this project. His guidance has been crucial to my progress at alltimes, and I am extremely grateful for his input.

D E C L A R AT I O N

I, Brian Flynn, hereby declare that this thesis, “A Mathematical Introduc-tion to Quantum Computation”, is of my own authorsip and comprisesentirely my own work, except where fully and properly referenced. Incases where the work resembles or derives from that of other authors,full citation is provided.

Signature :

Date:

Page 5: Mathematical_Introduction_to_Quantum_Computation

C O N T E N T S

1 introduction 2

1.1 Motivation 3

What 4

2 linear algebra 5

2.1 Recap of basics 5

2.2 Definitions 6

3 quantum mechanics 8

3.1 Postulates of Quantum Mechanics 8

3.2 Superpositions 9

4 quantum bits 10

4.1 Physical Realisation 10

4.2 Standard Notation 10

4.3 Multiple Qubits 11

5 acting on qubits 13

5.1 Entanglement 13

5.2 Unitary Transformations 14

5.3 Dirac Notation 14

How 19

6 gates and circuits 20

6.1 Gates 20

6.2 Circuits 25

6.3 Quantum Teleportation 27

7 computational techniques 31

7.1 Techniques 31

8 algorithms 35

8.1 Quantum Subroutines 35

8.2 Quantum Parallelism 38

Why 44

9 shor’s algorithm 45

9.1 Cryptography 45

9.2 Fourier Transformation 46

9.3 Factorisation by Period Finding 48

9.4 Steps of Shor’s Algorithm 50

9.5 Efficiency Improvement 56

10 conclusion 59

iii

Page 6: Mathematical_Introduction_to_Quantum_Computation
Page 7: Mathematical_Introduction_to_Quantum_Computation

1

I N T R O D U C T I O N

This thesis sets out to explain in clear detail the fundamentals of Quantum Computing.The aim herein is to bring a reader with little or no knowledge of the subject to a pointof understanding of the basic concepts and processes involved in quantum computation.

We will present the topic as a simple story:

• What are the processes and mathematical techniques that we are considering?

• How can they be used to construct quantum computers?

• Why do we think this to be worthwhile?

In doing so, we will explain the fundamental quantum mechanics at the heart ofthese machines. We will then discuss how these processes can be used to realise morepowerful computations than would be possible using classical techniques. And we willconclude by considering what potential applications the technology offers, and why it isof such interest to so many people to build a truly functional quantum computer.

This thesis will aim to follow a mathematical route rather than answer the more obvi-ous questions of how these devices could be engineered. A brief discussion will mentionsome of the methods of realising quantum bits, but overall, our aim is to demonstrateproof of concept mathematically. By and large we will assume the physics to be possible,and focus rather on what we need it to do: we prove their functionality and superiorityover classical machines by calculating efficiency and writing algorithms which can’t beimplemented classically.

The scope of this thesis, then, is to give some insight into how this can be achieved.We will discuss how it is possible to act on quantum bits analogously to classical bits,and how there exist considerably more powerful combinations of gates and circuits toachieve the same results as classical devices, but in significantly less steps. We willdiscuss the limits that today’s computers are subject to and we will show that quantumalgorithms can far exceed these limits, and we will provide strong motivation to do soby examining some of the uses this will allow for, such as high-level cryptography.

2

Page 8: Mathematical_Introduction_to_Quantum_Computation

1.1. MOTIVATION CHAPTER 1. introduction

1.1 motivation

Since the notion of a quantum computer was first suggested by Yuri Manin in 1980 [1],and seperately by Richard Feynman [2], many prominent mathematicians and physicistshave studied the topic in great depth. In 1982, the first potential framework of a quantumcomputer was proposed by Paul Benioff [3]. In the following years, it was proven thatthere were processes for which quantum computing could be shown to out-perform itsclassical counterpart, in particular by the work of David Deutsch, [4]. In 1992, Deutsch,together with Richard Josza released a paper entitled Rapid solution of problems by quan-tum computation, in which they showed how quantum machines could be used to achieveexponential speed-up in solving computational problems [5]. The problems that their al-gorithm was able to solve, however, were of little practical use, so there was no knownreason to actually invest in the construction of such potentially useless devices. In 1994,Peter Shor published a paper that became a turning point in the history of quantumcomputing: his now-famous algorithm used techniques only available to quantum com-puters to solve factorisation problems. He showed that a quantum computer would beable to factorise large numbers with significantly less computational expense than clas-sical machines will ever be capable of [6]. Following this milestone, it became clear thatquantum methods have the capacity to transcend classical machines, and so the field hasbeen growing steadily as a research topic since.

In the late 1990’s, the first quantum computer was built utilising 2 qubits. There havebeen significant strides every year since then towards a fully functional model.

Thus our motivation is clear: the entire quantum computing industry is built on thebelief that, quite soon, we will be able to build computers which operate at exponen-tially faster and more efficient rates than we will ever be able to achieve using classicalimplementations.

We endeavour to understand the building blocks which are at the centre of this po-tentially massive transition to a new kind of computation.

3

Page 9: Mathematical_Introduction_to_Quantum_Computation

W H AT

In order to describe quantum devices, we must first thinkabout what we’re talking about. We must recall the basicmaths involved in describing quantum mechanics, as well asremembering the cornerstones of quantum physics, before ex-tending these concepts to allow for the notion of exploitingtheir properties. In other words, we will consider What we’regoing to discuss henceforth.

4

Page 10: Mathematical_Introduction_to_Quantum_Computation

2

L I N E A R A L G E B R A

Before getting too involved in mechanical view points and quantum physics, it is im-portant to review the language with which these topics will be discussed: here we willrecap some basics of linear algebra and summarise the basic mathematical techniquesrequired to describe physics at a quantum scale.

2.1 recap of basics

Some algebraic knowledge is assumed of the reader. For further discussion and deriva-tion of some points, consult §2.1 of the standard text on the subject on quantum comput-ing and information processing, Nielsen and Chuang. [7]. We will briefly recall somedefinitions for reference.

• Notation

Definition of RepresentationVector (or ket) |ψ〉

Dual Vector (or bra) 〈ψ|Tensor Product |ψ〉 ⊗ |φ〉

Complex conjugate |ψ∗〉Transpose |ψ〉T

Adjoint |ψ〉† = (|ψ〉∗)T

Algebraic Definitions

The dual vector of a vector (ket) |ψ〉 is given by 〈ψ| = |ψ〉†. The adjoint of a matrixreplaces each matrix element with its own complex conjugate, and then switchesits columns with rows.

M† =

(M0,0 M0,1M1,0 M1,1

)†

=

(M∗0,0 M∗0,1M∗1,0 M∗1,1

)T

=

(M∗0,0 M∗1,0M∗0,1 M∗1,1

)(2.1)

5

Page 11: Mathematical_Introduction_to_Quantum_Computation

2.2. DEFINITIONS CHAPTER 2. linear algebra

The inner product of two vectors, |ψ〉 =

ψ1ψ2...

ψn

and |φ〉 =

φ1φ2...

φn

is given by

〈φ|ψ〉 = (|φ〉†)|ψ〉 = (φ∗1 φ∗2 . . . φ∗n)

ψ1ψ2...

ψn

= φ∗1 ψ1 + φ∗2 ψ2 + · · ·+ φ∗nψn (2.2)

|ψ〉i, |φ〉i are complex numbers, and therefore the above is simply a sum of productsof complex numbers. The inner product is often called the scalar product, which isin general complex.

2.2 definitions

For future reference, here is a list of definitions to be used throughout this thesis.

• Vector Space: A vector space is the region spanned by a set of basis vectors. As-signing a scalar multiple (which can be positive, negative, zero or complex) to eachbasis vector, it is possible to reach any point in the associated vector space.

• Hilbert Space: A Hilbert space is a generalised vector space which has an innerproduct. That is, it is possible to compute the inner product of any two vectors ina Hilbert space. It can be seen as a generalised Euclidean vector space, or a vectorspace of dimension n. It is the vector space associated with quantum mechanics.

• Operator: An operator, here denoted O, sometimes referred to as a transformation issomething which acts on an object, leaving the object in a new state. Operators arerepresented by matrices, which act on vectors, say v, by sending them to a differentvector, w, within the same vector space, V.

O(v) = w v, w ∈ V (2.3)

• Hermitian Operator: A Hermitian operator is one whose adjoint is equal to itself:

O† = O (2.4)

• Unitary Operator: A unitary operator is one whose inverse is equal to itself:

O−1 = O (2.5)

• Eigenfunctions and Eigenvalues: An eigenfunction is function which, when actedon by a linear operator, returns the same function as prior to operation, with someconstant factor, called its eigenvalue. If A is an operator, then an eigenfunction freturns an eigenvalue λ through the relation

A f = λ f (2.6)

6

Page 12: Mathematical_Introduction_to_Quantum_Computation

2.2. DEFINITIONS CHAPTER 2. linear algebra

• Tensor product: The tensor product of two vectors belonging to two vector spaces,is a new vector space. If we tensor product a vector v in some vector space V withanother vector w in a vector space W, the resultant v⊗w is in the newly generatedtensor space V⊗W. In general, the tensor product of two vectors generates anothervector with dimension equal to their individual dimensions multiplied together.

Example 2.1.

|a〉 =( a1

a2a3

)∈ A, |b〉 =

(b1b2

)∈ B⇒ |a〉 ⊗ |b〉 =

a1b1a1b2a2b1a2b2a3b1a3b2

We can also tensor product operators to form an operator which could act in thetensor space formed by the tensor product of two vectors. Suppose we tensorproduct an operator A, which sends vectors in a space V to other vectors in V, withanother, B, which acts in the space W. In doing so, we are generating an operatorwhich takes vectors in the space V ⊗W to other vectors in the same space.

A : V → V , B : W →W

A⊗ B : V ⊗W → V ⊗W

Example 2.2.

A =

(a0,0 a0,1a1,0 a1,1

)B =

(b0,0 b0,1b1,0 b1,1

)⇒ A⊗ B =

(a0,0B a0,1Ba1,0B a1,1B

)

=

a0,0b0,0 a0,0b0,1 a0,1b0,0 a0,1b0,1a0,0b1,0 a0,0b1,1 a0,1b1,0 a0,1b1,1a1,0b0,0 a1,0b0,1 a1,1b0,0 a1,1b0,1a1,0b1,0 a1,0b1,1 a1,1b1,0 a1,1b1,1

7

Page 13: Mathematical_Introduction_to_Quantum_Computation

3

Q U A N T U M M E C H A N I C S

In order to describe the universe at extremely small scales, we introduce a mathematicalframework called quantum mechanics. To build such a framework, there are severaluniversally accepted postulates that govern the language. It is expected that the readerhas a fair knowledge of basic quantum mechanics, so only the postulates are restatedhere for brevity.

3.1 postulates of quantum mechanics

There are many versions of statements of the postulates of quantum mechanics. Eachversion of the statements aims to achieve the same foundation, so we endeavour toexplain them in the simplest terms.

1. Every moving particle in a conservative force field has an associated wave-function,|ψ〉. From this wave-function, it is possible to determine all physical informationabout the system.

2. All particles have physical properties called observables (denoted q). In order todetermine a value, q, for a particular observable, there is an associated operatorQ, which, when acting on the particles wavefunction, yields the value times thewavefunction. The observable q is then the eigenvalue of the operator Q.

Q|ψ〉 = q|ψ〉 (3.1)

3. Any such operator Q is Hermitian

Q† = Q (3.2)

4. The set of eigenfunctions for any operator Q forms a complete set of linearly inde-pendent functions.

5. For a system with wavefunction |ψ〉, the expectation value of an observable q withrespect to an operator Q is denoted by 〈q〉 and is given by

〈q〉 = 〈ψ|Q|ψ〉 (3.3)

8

Page 14: Mathematical_Introduction_to_Quantum_Computation

3.2. SUPERPOSITIONS CHAPTER 3. quantum mechanics

6. The time evolution of |ψ〉 is given by the time dependent Schrodinger Equation

ih∂ψ

∂t= Hψ (3.4)

Using these building blocks, we can begin to construct a language to describe quan-tum systems.

3.2 superpositions

One of the most surprising and interesting results of quantum mechanics is that ofsuperposition. By this we mean the existence of a particle or body which is simultaneouslyin a number of states. A quantum state can be thought of as a value with respect to adefining property. A simple classical example of a state is on/off: we can say withcertainty whether a switch - say a light switch - is on or off. To build on this conceptthen, imagine instead a situation where the switch is both on and off simultaneously.Mathematically, say that |↑〉 represents the situation where a switch is “up” (or “on”).Then, |↓〉 will similarly represent the situation where the switch is “down”. Classically,we expect any switch, S - given by a state |S〉 - to take the value

|S〉 = |↑〉 or |S〉 = |↓〉

Then, in quantum mechanics, there exists a superposition state wherein it is both upand down:

|S〉 = a|↑〉+ b|↓〉where a, b are the amplitudes of the states up and down respectively. The amplitudes arewhat define to what extent the body can be seen to exist in the associated state. Uponmeasurement, the system will assume only one of its constituent quantum states: thesquare of the amplitudes indicate the probability that the system will be measured inthat state. i.e

P(|S〉 = |↑〉) = |a|2 ; P(|S〉 = |↓〉) = |b|2

and it is obvious then that for the probabilities to sum to 1,

|a|2 + |b|2 = 1

In general, if |x〉 is a possible state of a system, with complex amplitude ax, then thesystem can be said to be in the superposition

∑x

ax|x〉 ; ∑x|ax|2 = 1, ax ∈ C (3.5)

This is known as the State Vector for a quantum state. The state space of a physicalsystem (classical or quantum) is then the set of all possible states the system can exist in,i.e the set of all possible values for x such that 3.5 are satisfied.

9

Page 15: Mathematical_Introduction_to_Quantum_Computation

4

Q U A N T U M B I T S

We now look to what these operations actually act on. In classical circuitry, bits (binarydigits) are fundamental units of information which can occupy either the state 0 or 1.These bits are acted on by gates to achieve particular combinations to find an outputof some programme. In quantum computation, quantum bits, or qubits, are used incombination as input, and acted on by some quantum gates and circuits implementingsome quantum algorithm, to ultimately achieve an output that may not be possible toachieve using classical machines, or else is far more efficient through use of quantumcomputation.

4.1 physical realisation

As qubits are, by definition, systems subject to quantum mechanics, we must constructthem from two-state mechanical systems at this scale. Examples of feasible systemsinclude the energy levels of hydrogen atoms, electron spin and photon polarisation alongperpendicular directions. For our purposes, one qubit representation is equivalent toany other. It is simplest to think of electron spin as the quantum property that we willmanipulate because it can take the values up/down, analogous to the classical on/offswitch. For the simplicity of being able to transfer to an orthogonal basis intuitively,however, we will focus on photon polarisation for the next section. The remainder ofthis text does not refer to what physical realisation is being implemented.

4.2 standard notation

Take a 2-dimensional, x-y plane as our surface: photons can then be polarised along thex- or y- axis. A general state will be represented by a vector ( x

y ). These polarisations canthen be thought of as standard basis vectors in linear algebra. Denote them as |0〉 and|1〉

|→〉 = |0〉 =(

10)

A unit vector along x-axis (4.1)

|↑〉 = |1〉 =(

01

)A unit vector along y-axis (4.2)

10

Page 16: Mathematical_Introduction_to_Quantum_Computation

4.3. MULTIPLE QUBITS CHAPTER 4. quantum bits

Now, in relation to the concept of superposition, we can consider a photon, ψ whichtravels along a diagonal, evenly splitting the two basis vectors. As such, we wouldrequire that, upon measurement, it is equally likely that the photon will ”collapse” intothe polarised state along x as it is to collapse along y. That is, we want P(↑) = P(→) soassign equal modulus amplitudes to the two possibilities:

|ψ〉 = a| ↑〉+ b|→〉, with P(↑) = P(→)⇒ |a|2 = |b|2

We consider here a particular case, due to the significance of the resultant basis, whereup-polarisation and down-polarisation have real amplitudes a, b ∈ R.

⇒ a = ±b but also |a|2 + |b|2 = 1

⇒ a =1√2

; b = ± 1√2

⇒ ψ =1√2| →〉 ± 1√

2| ↑〉

⇒ ψ =1√2|0〉 ± 1√

2|1〉

These particular superpositions are of significance. We denote them

|+〉 = 1√2|0〉+ 1√

2|1〉 (4.3)

|−〉 = 1√2|0〉 − 1√

2|1〉 (4.4)

This is called the Hadamard basis and will be important for the remainder of thisdiscussion. It is an equally valid vector space as the standard basis which is spanned by(

10)

,(

01

). In the standard basis, the Hadamrad basis can be seen as being spanned by( 1√

21√2

),( 1√

2

− 1√2

)

4.3 multiple qubits

In reality, we will be dealing with systems of numerous qubits. Mathematically, weconsider the state vector of a system containing n qubits as being the tensor product ofthe n qubits’ individual state vectors. That is, for a 2-qubit system, |ψ〉 to be in somecombination of two qubits |A〉 and |B〉:

|ψ〉 = |A, B〉 = |AB〉 = |A〉 ⊗ |B〉

11

Page 17: Mathematical_Introduction_to_Quantum_Computation

4.3. MULTIPLE QUBITS CHAPTER 4. quantum bits

Consider first a simple system of 2 qubits. Measuring in the standard basis, thesequbits will have to collapse in to one of the basis states |0, 0〉, |0, 1〉, |1, 0〉, |1, 1〉. Thus, forsuch a 2-qubit system, we have the general superposition

|ψ〉 = α0,0|0, 0〉+ α0,1|0, 1〉+ α1,0|1, 0〉+ α1,1|1, 1〉

where αi,j is the amplitude for measuring the system as the state |i, j〉. This is perfectlyanalogous to a classical 2-bit system necessarily occupying one of the four possibilities(0, 0), (0, 1), (1, 0), (1, 1).

Hence, for example, if we wanted to concoct a two-qubit system composed of onequbit in the state |+〉 and one in |−〉

|ψ〉 = |+〉 ⊗ |−〉

|ψ〉 = (1√2|0〉+ 1√

2|1〉)⊗ (

1√2|0〉 − 1√

2|1〉)

=12[|00〉 − |01〉+ |10〉 − |11〉]

=12[(

10)⊗(

10)−(

10)⊗(

01

)+(

01

)⊗(

10)−(

01

)⊗(

01

)]=

12

[( 1000

)−( 0

100

)+

( 0010

)−( 0

001

)]

|ψ〉 = 12

( 1−1−11

)That is, the system is given by a linear combination of the four basis vectors( 1

000

),( 0

100

),( 0

010

),( 0

001

)We can notice that a single qubit system can be described by a linear combination of twobasis vectors, and that a two qubit system requires four basis vectors to describe it. Ingeneral we can say that an n-qubit system is represented by a linear combination of 2n

basis vectors.

4.3.1 Registers

A register is the name given to a system of multiple qubits. We may use the idea toconsider a system of n qubits as two sub systems. For instance, a register of ten qubitscan be denoted |x[10]〉, and we can think of the system as a register of six qubits togetherwith a register of three and another register of one qubit.

|x[10]〉 = |x1[6]〉 ⊗ |x2[3]〉 ⊗ |x3[1]〉

12

Page 18: Mathematical_Introduction_to_Quantum_Computation

5

A C T I N G O N Q U B I T S

5.1 entanglement

Another unique property of quantum systems is that of entanglement: ie when two ormore particles interact in such a way that their individual quantum states can not bedescribed independent of the other particles. A quantum state then exists for the systemas a whole instead.

Mathematically, we consider such entangled states as those whose state can not beexpressed as a tensor product of the states of the individual qubits it’s composed of: theyare dependent upon the other.

Example 5.1. Consider the state

|Φ+〉 = 1√2[|00〉+ |11〉]

If we measure this state, we expect that it will be observed either as |00〉 or |11〉, withequal probability due to their equal magnitudes. The bases for this state are simply thestandard bases, |0〉 and |1〉. Thus, according to our previous definition of systems ofmultiple qubits, we would say this state can be given as a combination of two states

|Φ+〉 = |ψ1〉 ⊗ |ψ2〉

= [a1|0〉+ b1|1〉]⊗ [a2|0〉+ b2|1〉]

= a1a2|00〉+ a1b2|01〉+ b1a2|10〉+ b1b2|11〉

However we require |Φ+〉 = 1√2[|00〉+ |11〉], which would imply a1b2 = 0 and b1a2 = 0.

These imply that either a1 = 0 or b2 = 0, and also that b1 = 0 or a2=0, which areobviously invalid since we require that a1a2 = b1b2 = 1√

2. Thus, we cannot express

|Φ+〉 = |ψ1〉 ⊗ |ψ2〉

and this is what we term an entangled state.

13

Page 19: Mathematical_Introduction_to_Quantum_Computation

5.2. UNITARY TRANSFORMATIONS CHAPTER 5. acting on qubits

5.2 unitary transformations

A fundamental concept in quantum mechanics is that of performing transformations onstates. Quantum transformations, otherwise known as quantum operators are those whichmap a quantum state into a new state within the same state space. There are certainrestrictions on a physically possible quantum transformation: in order that U is a validtransformation acting on some superposition |ψ〉 = a1|ψ1〉+ a2|ψ2〉+ . . . ak|ψk〉, U mustbe linear

U(a1|ψ1〉+ a2|ψ2〉+ . . . ak|ψk〉) = a1(U|ψ1〉) + a2(U|ψ2〉) + · · ·+ ak(U|ψk〉)

It is also necessary that the order of measurement and transformation do not affectthe system: to obtain |ψ0〉 with probability P0, it should be equally valid to first apply Uto |ψ〉 and then measuring, as it is to first measure and then transform the result.

To fulfil these properties, we require that U preserve the inner product:

〈ψ0|U†U|ψ〉 = 〈ψ0|ψ〉

That is, we require that any such transformation be unitary:

UU† = I ⇒ U† = U−1 (5.1)

Unitarity is a sufficient condition to describe any valid quantum operation: any quan-tum transformation can be described by a unitary quantum transformation, and anyunitary transformation corresponds to a physically possible quantum transformation.

Then, if U1 is a unitary transformation that acts on the space S1 and U2 acts on S2, theproduct of the two unitary transformations is also unitary. The tensor product U1 ⊗U2acts on the space S1 ⊗ S2. So, then, supposing a system of 2 qubits, |ψ1〉 and |ψ2〉 wherewe wish to act on |ψ1〉 with operator U1 and on |ψ2〉 with U2, we perform it as

(U1 ⊗U2) (|ψ1〉 ⊗ |ψ2〉) = (U1|ψ1〉)⊗ (U2|ψ2〉)

This idea will be built upon when we discuss quantum gates and circuits.

5.2.1 Reversibility

Quantum mechanics is by nature reversible in time: probability is conserved as a stateevolves in time. This can be seen from the Schrodinger equation, which approximatesthe time evolution of a quantum state. Then, to build a quantum computer, we mustinvolve only states that evolve in accordance with Schrodinger’s equation, and so wecan only build one using reversible circuits.

5.3 dirac notation

In keeping with standard practice, we will employ Dirac notation throughout this thesis.This will simplify calculations as they become progressively more difficult and standard

14

Page 20: Mathematical_Introduction_to_Quantum_Computation

5.3. DIRAC NOTATION CHAPTER 5. acting on qubits

matrix and vector calculation would become increasingly difficult too. Vectors will bedenoted by kets of the form |a〉. For example, the standard basis will be represented by,

|x〉 = |0〉 =(

10)

|y〉 = |1〉 =(

01

)We saw in §2 that, for every such ket |ψ〉, there exists a dual vector: its complex

conjugate transpose, called the bra of such a vector, denoted 〈ψ|. That is

〈ψ|† = |ψ〉 ; |ψ〉† = 〈ψ|

|ψ〉 =

ψ1ψ2...

ψn

⇒ 〈ψ| = ( ψ∗1 ψ∗2 ... ψ∗n )

Then if we have two vectors |ψ〉 and |φ〉, their inner product is given as 〈ψ|φ〉 = 〈φ|ψ〉.

Definition 5.2. Inner Product

|ψ〉 =

ψ1ψ2ψ3...

ψn

; |φ〉 =

φ1φ2φ3...

φn

⇒ 〈φ| = ( φ∗1 φ∗2 φ∗3 ... φ∗n )

⇒ 〈φ|ψ〉 = ( φ∗1 φ∗2 φ∗3 ... φ∗n )

ψ1ψ2ψ3...

ψn

⇒ 〈φ|ψ〉 = φ∗1 ψ1 + φ∗2 ψ2 + φ∗3 ψ3 + · · ·+ φ∗nψn

Example 5.3.|ψ〉 =

(123

); |φ〉 =

( 456

)⇒ 〈φ|ψ〉 = ( 4 5 6 )

(123

)= (4)(1) + (5)(2) + (6)(3) = 32

Similarly, their outer product is given as |φ〉〈ψ|. Multiplying a column vector by a rowvector thus gives a matrix. Matrices generated by a outer products then define operators:

Example 5.4. (12)( 3 4 ) =

(3 46 8

)

15

Page 21: Mathematical_Introduction_to_Quantum_Computation

5.3. DIRAC NOTATION CHAPTER 5. acting on qubits

Then we can say, for |0〉 =(

10)

and |1〉 =(

01

)|0〉〈0| =

(1 00 0

)(5.2a)

|0〉〈1| =(

0 10 0

)(5.2b)

|1〉〈0| =(

0 01 0

)(5.2c)

|1〉〈1| =(

0 00 1

)(5.2d)

And so any 2-dimensional linear transformation in the standard basis |0〉, |1〉 can begiven as a sum (

a bc d

)= a|0〉〈0|+ b|0〉〈1|+ c|1〉〈0|+ d|1〉〈1| (5.3)

This method of representing operators as outer products of vectors will be useful through-out this text. A transformation that exchanges two particles, say |0〉 ↔ |1〉 is given by theoperation

Q :

{|0〉 → |1〉|1〉 → |0〉

Which is equivalent to the outer product representation

Q = |0〉〈1|+ |1〉〈0|

For clarity, here we will prove this operation

Example 5.5.Q = |0〉〈1|+ |1〉〈0|

=(

10) (

01

)+(

01

) (10)

=

(0 10 0

)+

(0 01 0

)=

(0 11 0

)So then, acting on |0〉 and |1〉 gives

Q|0〉 =(

0 11 0

) (10)=(

01

)= |1〉

Q|1〉 =(

0 11 0

) (01

)=(

10)= |0〉

16

Page 22: Mathematical_Introduction_to_Quantum_Computation

5.3. DIRAC NOTATION CHAPTER 5. acting on qubits

To demonstrate how Dirac notation simplifies this:

Q|0〉 = (|0〉〈1|+ |1〉〈0|)|0〉

= |0〉〈1||0〉+ |1〉〈0||0〉

= |0〉〈1|0〉+ |1〉〈0|0〉

Then, since |0〉 and |1〉 are orthogonal basis, their inner product is 0 and the innerproduct of a vector with itself is 1, ( 〈1|1〉 = 〈0|0〉 = 1, 〈0|1〉 = 〈1|0〉 = 0). So,

Q|0〉 = |0〉(0) + |1〉(1)

⇒ Q|0〉 = |1〉

And similarly for Q|1〉. This simple example then shows why Dirac notation can signif-icantly simplify calculations across quantum mechanics, compared to standard matrixand vector notation. To see this more clearly, we will examine a simple 2-qubit stateunder such operations. The method generalises to operating on two or more qubitsgenerically: we can define any operator which acts on two qubits as a sum of outer prod-ucts of the basis vectors |00〉, |01〉, |10〉 and |11〉. We can similarly define any operatorwhich acts on an n qubit state as a linear combination of the 2n basis states generated bythe n qubits.

Example 5.6. To define a transformation that will exchange basis vectors |00〉 and |11〉,while leaving |01〉 and |10〉 unchanged (ie exchanging |01〉 ↔ |01〉, |10〉 ↔ |10〉) wedefine an operator

Q = |00〉〈11|+ |11〉〈00|+ |10〉〈10|+ |01〉〈01|

Then, using matrix calculations this would require separately calculating the four outerproducts in the above sum and adding them to find a 4× 4 matrix to represent Q, whichthen acts on a state |ψ〉. Instead, consider first that |ψ〉 = |00〉, ie one of the basis vectorsour transformation is to change:

Q|00〉 = (|00〉〈11|+ |11〉〈00|+ |10〉〈10|+ |01〉〈01|) |00〉

And as before, only the inner products of a vector with itself remains:

= |00〉〈11|00〉+ |11〉〈00|00〉+ |10〉〈10|00〉+ |01〉〈01|00〉

= |00〉(0) + |11〉(1) + |10〉(0) + |01〉(0)

⇒ Q|00〉 = |11〉

i.e the transformation has performed Q : |00〉 → |11〉 as expected. Then, if we applythe same transformation to a state which does not depend on one of the target states, eg,

|ψ〉 = a|10〉+ b|01〉

17

Page 23: Mathematical_Introduction_to_Quantum_Computation

5.3. DIRAC NOTATION CHAPTER 5. acting on qubits

Q|ψ〉 =(|00〉〈11|+ |11〉〈00|+ |10〉〈10|+ |01〉〈01|

)(a|10〉+ b|01〉

)= a

(|00〉〈11||10〉+ |11〉〈00||10〉+ |10〉〈10||10〉+ |01〉〈01||10〉

)+b(|00〉〈11||01〉+ |11〉〈00||01〉+ |10〉〈10||01〉+ |01〉〈01||01〉

)And since the inner product is a scalar, we can factor terms such as 〈11|10〉 to the

beginning of expressions, eg |00〉〈11||10〉 = 〈11|10〉|00〉, and we also know

〈11|10〉 = 〈00|10〉 = 〈01|10〉 = 〈11|01〉 = 〈00|01〉 = 〈10|01〉 = 0 and 〈10|10〉 = 〈01|01〉 = 1

We can express the above as

Q|ψ〉 = a((0)|00〉+ (0)|11〉+ (1)|10〉+ (0)|01〉

)+b((0)|00〉+ (0)|11〉+ (0)|10〉+ (1)|01〉

)= a|10〉|+ b|01〉

= |ψ〉

Then it is clear that, when |ψ〉 is a superposition of states unaffected by transformationQ, then Q|ψ〉 = |ψ〉.

This method generalises to systems with greater numbers of particles (qubits). If webriefly consider a 3 qubit system - and initialise all qubits in the standard basis state|0〉 - then the system is represented by |000〉 = |0〉 ⊗ |0〉 ⊗ |0〉 =

(01

)⊗(

01

)⊗(

01

). This

quantity is an 8-row vector. To calculate the outer product 〈000|000〉, we would be multi-plying an 8-column bra 〈000| by an 8-row ket |000〉. Clearly then we will be working with8× 8 matrices, which will become quite difficult to maintain effectively and efficientlyquite fast. As we move to systems of larger size, standard matrix multiplication willbecome unfeasible. Then it is obvious that Dirac’s bra/ket notation can be consideredbest practice for the scope of this subject and quantum mechanics in general.

18

Page 24: Mathematical_Introduction_to_Quantum_Computation

H O W

We may now try to answer the question of How actions onsuch qubits can represent computation, and outline proofsthat such computations operate at improved efficiency com-pared with classical computers.

19

Page 25: Mathematical_Introduction_to_Quantum_Computation

6

G AT E S A N D C I R C U I T S

In analogy with classical computers, in order to operate on qubits, we need to devisegates to achieve desired effects when qubits “pass” through them. These simple gatesmay then be combined into circuits of varying complexity, and it is by arranging suchcircuits in particular orders that we may input a number of qubits and produce an outputcorresponding to a function we want to be evaluated.

6.1 gates

Classically, a gate takes an input of a number of bits and produces a defined output basedon the value(s) of the input bits. For example, a simple NOT gate, N, has the effect:

N :

{1→ 00→ 1

There are a number of such simple gates, such as AND, OR and XOR, which can beused to build arbitrarily complex circuits, and thus achieve any computation. To have aquantum gate, we require a process which takes an input state, and alters it in a definedway to produce an output state. That is, a quantum gate is simply a transformation oroperation acting on input qubits.

6.1.1 Single Qubit Gates

The simplest such gate is one which would act only on one qubit and change its value.For instance, suppose we wanted to define an operator which would change a |0〉 to|1〉 and vice versa. This can be seen mathematically as transforming one basis vectorto another. Let us call this operation a quantum NOT-gate. As above, to generate anoperator that exchanges basis vectors, we include the outer product of the vectors to betransformed:

QNOT = |1〉〈0|+ |0〉〈1|Then if we apply this operation to |0〉 for example

QNOT|0〉 =(|1〉〈0|+ |0〉〈1|

)|0〉 = |1〉〈0|0〉+ |0〉〈1|0〉

20

Page 26: Mathematical_Introduction_to_Quantum_Computation

6.1. GATES CHAPTER 6. gates and circuits

= |1〉(1) + |0〉(0)

⇒ QNOT|0〉 = |1〉

Single qubit gates may be applied simultaneously, which we call multiple qubit gates,which we discuss shortly.

6.1.1.1 Diagrammatic Representation of Gates

Before proceeding we will define how we will present gates pictorally from here on. Aqubit will be represented by a wire - a straight line - and an operator will be shown by abox.

Example 6.1. A qubit, |ψ〉 operated on by Q, finishing in the state |ψ′〉

|ψ〉 Q |ψ′〉

6.1.1.2 Pauli Matrices

There are some basic quantum operations that are extremely useful and form the basisof a great number of gates, called the Pauli matrices, which we define here

I =(

1 00 1

)= |0〉〈0|+ |1〉〈1| (6.1a)

X =

(0 11 0

)= |1〉〈0|+ |0〉〈1| (6.1b)

Y = i(

0 1−1 0

)= i(−|1〉〈0|+ |0〉〈1|) (6.1c)

Z =

(1 00 −1

)= |1〉〈1| − |0〉〈0| (6.1d)

We can see that the Pauli-X gate is the same as the quantum not gate above. Werepresent this operation on a diagram (acting on |0〉) thus:

|0〉 X |1〉

21

Page 27: Mathematical_Introduction_to_Quantum_Computation

6.1. GATES CHAPTER 6. gates and circuits

6.1.1.3 Hadamard Gate

If we now wish to take advantage of the quantum properties of qubits, we need togenerate and act on superpositions. The Hadamard gate, H, takes a single basis state |0〉or |1〉, and turns it into an even superposition of basis states:

H : |a〉 → 1√2

(|0〉+ (−1)a|1〉

)That is

H|0〉 = 1√2

(|0〉+ 1|1〉

)= |+〉

H|1〉 = 1√2

(|0〉 − 1|1〉

)= |−〉

These are the two orthogonal basis vectors which span the Hadamard basis of 4.2. Forreference, the Hadamard gate can be represented as the matrix operator

H =1√2

(1 11 −1

)=

1√2

(|0〉〈0|+ |1〉〈0|+ |0〉〈1| − |1〉〈1|

)(6.2)

Upon measurement then it is equally likely that a state generated by a Hadamardgate will be observed in the basis |0〉 or |1〉.

6.1.1.4 Linearity of quantum gates

We should note that quantum gates act linearly. That is, when acting on a superposition,the gate will take action separately on each basis state as it would individually.

Example 6.2.

QNOT

(a0|0〉+ a1|1〉

)=(

a0(QNOT|0〉) + a1(QNOT|1〉))= a0|1〉+ a1|0〉

So to see how this might apply to more complicated systems, consider a Hadamardgate acting on the superposition state |ψ〉 = a0|0〉+ a1|1〉,

Example 6.3.H|ψ〉 = H

(a0|0〉

)+ H

(a1|1〉

)a0(

H|0〉)+ a1

(H|1〉

)a0

( 1√2

(|0〉+ |1〉

))+ a1

( 1√2

(|0〉 − |1〉

))=

1√2

((a0 + a1

)|0〉+

(a0 − a1

)|1〉)

22

Page 28: Mathematical_Introduction_to_Quantum_Computation

6.1. GATES CHAPTER 6. gates and circuits

6.1.2 Multiple Qubit Gates

Single qubit gates may be applied simultaneously, which we call multiple qubit gates.Consider first a gate to act on 2 qubits, |ψ1〉 and |ψ2〉. Suppose we want to performseparate operations, say Q1 and Q2, on the two qubits at the same time, as part of somelarger scheme. The system is represented by |ψ1〉 ⊗ |ψ2〉, so we represent the operator toperform both Q1 and Q2 as Q1 ⊗Q2. So(

Q1 ⊗Q2)(|ψ1〉 ⊗ |ψ2〉

)= Q1|ψ1〉 ⊗Q2|ψ2〉

)If we wish to perform an operator Q on the ith qubit of an n-qubit system, we must

simultaneously act on the other (n− 1) qubits by the Identity operator, given by the Paulimatrix 6.1a, which has no effect on a state. So we have

(I ⊗ · · · ⊗ I ⊗Q⊗ I · · · ⊗ I

)(|ψ1〉 ⊗ · · · ⊗ |ψi−1〉 ⊗ |ψi〉 ⊗ |ψi+1〉 ⊗ · · · ⊗ |ψn〉

)= (I|ψ1〉)⊗ . . . (Q|ψi〉)⊗ . . . (I|ψn〉) (6.3)

And this behaviour extends generically to applying specific operations Qi on partic-ular qubits |ψi〉.(

Q1 ⊗ · · · ⊗Qn

)(|ψ1〉 ⊗ · · · ⊗ |ψn〉

)= (Q1|ψ1〉 ⊗ · · · ⊗ (Qn|ψn〉) (6.4)

6.1.2.1 Controlled Operations

An important multiple qubit gate is the Controlled-NOT gate, CNOT. This gate performsa NOT-operation on a target qubit, if and only if a control qubit is in the standard basisstate |1〉, and leaves the control bit unchanged.

Definition 6.4.CNOT|A⊗ B〉 = |A⊗ (B⊕ A)〉

Where A is the control-qubit, B is the target-qubit, and⊕ denotes modulus-2 addition:

0⊕ 0 = 0 ; 1⊕ 1 = 2mod2 = 0 ; 0⊕ 1 = 1⊕ 0 = 1 (6.5)

such that

CNOT|00〉 = |00〉 (6.6a)

CNOT|01〉 = |01〉 (6.6b)

CNOT|10〉 = |11〉 (6.6c)

23

Page 29: Mathematical_Introduction_to_Quantum_Computation

6.1. GATES CHAPTER 6. gates and circuits

CNOT|11〉 = |10〉 (6.6d)

This concept of control then generalises simply: we can define multiply-controlled singlequbit transformations which change a solitary target qubit if every control-qubit satisfiesthe control condition, which is usually simply to be in the state |1〉. We can also definea controlled operation other than a NOT gate, to allow us to perform an operation uponone or multiple qubits when some criteria are met by other qubits.

A simple extension of the controlled-NOT gate is the controlled-controlled-NOT gate,or the Toffoli gate, T, which flips a third qubit if both other input qubits are in the state|1〉.

T|A⊗ B⊗ C〉 = |A⊗ B⊗ C⊕ AB〉

Example 6.5.T|111〉 = |110〉 ; T|101〉 = |101〉 ; T|001〉 = |001〉

6.1.2.2 Diagram Representation

Intuitively, diagrams expand generically: one wire per qubit and boxes for each opera-tion. Acting on multiple qubits then requires diagrams for multiple-qubit gates. Controlbits are represented by black dots, and target bits are given by open circle. When agate acts on a qubit conditional on another, as in the CNOT and Toffoli gates, they areconnected by a vertical wire, so the CNOT and Toffoli gates are given by

|A〉 • |A〉|B〉 |B⊕ A〉

|A〉 • |A〉|B〉 • |B〉|C〉 |C⊕ A× B〉

6.1.3 Black Box problems

We will define a black box which will calculate a function f . We are unconcerned withwhat goes on inside this box - we assume the same computation as such a black boxwould perform classically. We assume that we cannot improve on the internal efficiencyof the calculation of f , so we aim to minimise how many times we must call on this blackbox. Consider a gate which takes an input |x, y〉 and outputs the result of the functionin the second qubit, as seen here.

|x〉U

|x〉

|y〉 |y⊕ f (x)〉

So then, if we set the second qubit to be 0, upon input |x, 0〉 we retrieve the output|x, f (x)〉, so we have both the input and the output of the function contained within the

24

Page 30: Mathematical_Introduction_to_Quantum_Computation

6.2. CIRCUITS CHAPTER 6. gates and circuits

2-qubit register after a call to the black box. As such, we are dealing with a reversiblecircuit in that we can determine the input, |x〉 by observation of the output, |x〉| f (x)〉.This is important in quantum information processing as we saw in 5.2.1 that we canonly build a quantum computer if its processes are reversible in time.

6.2 circuits

Quantum circuits then, are simply the combination of a number of gates acting on thesame set of qubits sequentially. This is in obvious analogy with classical circuitry,whereby an output is found for a particular set of input bits by acting on the bits ina particular order to achieve calculations. Circuits build on the effects of single gates: byperforming one gate, and inputting the result obtained into another gate, we may beginto construct more complicated devices, which are arranged to the specific requirementsof the process to be computed.

6.2.1 Single Qubit Circuits

The simplest possible circuit is to act on a qubit by one gate, and then to act on theresultant qubit by another gate. For example, first performing a quantum NOT-gate ona qubit in state |0〉, and then performing a Hadamard gate upon the result. We expect tofirst obtain QNOT|0〉 = |1〉, and thereafter compute H(|1〉). For mathematical consistencythen, we will write the first-in-time operation as the operator left-most closest to the statebeing acted upon:

H(QNOT|0〉

)= H

(|1〉)= |−〉

|0〉 X H |−〉

Now consider twice applying a Hadamard gate to any qubit

H(H|a〉) = H( 1√

2

(|0〉+ (−1)a|1〉

))=

1√2

(H|0〉+ (−1)aH|1〉

)=

1√2

( 1√2

(|0〉+ 1|1〉

)+ (−1)a 1√

2

(|0〉 − 1|1〉

))=

1√2

1√2

((1 + (−1)a)|0〉+ (1− (−1)a)|1〉)

So if a = 0, (1+(−1)a) = 2, (1− (−1)a) = 0, and if a = 1, (1+(−1)a) = 0, (1− (−1)a) =2

H(H|0〉) = 12((2)|0〉+ (0)|1〉

)= |0〉

25

Page 31: Mathematical_Introduction_to_Quantum_Computation

6.2. CIRCUITS CHAPTER 6. gates and circuits

H(H|0〉) = 12((0)|0〉+ (2)|1〉

)= |1〉

Otherwise, if |a〉 had been a superposition state, due to linearity, § 6.1.1.4, this princi-ple would remain and the superposition would be preserved under a double Hadamardgate. It is clear then that HH = I. This property does not hold for all quantum gates butthe Hadamard gate is of such importance that it is worth noting this relation.

6.2.2 Multiple Qubit Circuits

Of more practical interest is the concept of defining a circuit to process multiple qubits.The goal here is to design circuits that will be used to construct relatively simple quantumalgorithms, chapter 8 . These algorithms will form the basis of quantum subroutines § 8.1 ,which will in turn become the basis for involved routines which implement calculationsat a user’s level.

Example 6.6. Alternative CNOT GateTo gain an initial understanding of how such circuits can be formed, let us consider theprocess of altering the criteria of a controlled-NOT gate, described in § 6.1.2.1. We wantto make it that the gate performs the NOT operation when the control-qubit registersthe state |0〉 as opposed to |1〉. We will consider a 2-qubit state, |A⊗ B〉. The circuit isdescribed by the following series of operations

1. QNOT on |A〉 , I on |B〉

2. CNOT on |AB〉

3. QNOT on |A〉 , I on |B〉

Then the effects of this circuit are:

1.(QNOT ⊗ I

)(|A〉 ⊗ |B〉

)=(QNOT|A〉

)⊗(

I|B〉)

= |A⊕ 1〉 ⊗ |B〉 = |(A⊕ 1), B〉

2. CNOT|(A⊕ 1), B〉= |(A⊕ 1)〉 ⊗ |(B⊕ (A⊕ 1))〉= |A⊕ 1〉 ⊗ |B⊕ A⊕ 1〉

3.(

QNOT ⊗ I)(|A⊕ 1〉 ⊗ |B⊕ A⊕ 1〉

)=(QNOT|A⊕ 1〉

)⊗ (I|B⊕ A⊕ 1〉)

= |A⊕ 1⊕ 1〉 ⊗ |B⊕ A⊕ 1〉 Note : 1⊕ 1 = 0= |A, B⊕ A⊕ 1〉

That is, if |A〉 is initially |0〉, then after step 1 it becomes |1〉. The controlled-NOT gatenow uses this transformed A to determine whether it will perform a QNOT on qubit |B〉.

26

Page 32: Mathematical_Introduction_to_Quantum_Computation

6.3. QUANTUM TELEPORTATION CHAPTER 6. gates and circuits

So if A had been |0〉 and is now |1〉, B gets flipped. If A had been |1〉 and is therefore now|0〉, B does not get flipped. Finally, step 3 returns A to its original value by performinganother NOT operation only on the first qubit. This is equivalent to a controlled-NOTgate whose criteria is the control-bit being in state |0〉 initially.

So we can show this on a diagram as below. In diagrams such as this, a wire (qubit)without any operation acting directly on it indicates the identity operator being imposedon that qubit at that juncture. That is, it is equivalent to have an identity gate, I, as belowthe first X-gate, as it is to have no gate there at all, as below the second X-gate here:

A X • X A

B I B⊕ A⊕ 1

6.2.3 Universal Gate Set

While this example is trivial, the principle is the same as it would be for any quantumcircuit. We can build circuits of arbitrary complexity using the ideas described so far. Itremains to define a set of gates which may be used to construct any circuit. We may doso by recalling from § 5.2 that any quantum operation can be achieved by some unitarytransformation. Then, any unitary transformation may be achieved by a sequence ofsimple quantum gates and quantum controlled-NOT gates. We will therefore take as auniversally approximating gate set, the generic set below, with U any unitary operation.

UG = {CNOT , U | U = U†}

We will therefore proceed by constructing any operation we require provided theyare achievable by some combination of operations Oi,

O1O2 . . . On ; Oi ∈ UG

In most cases, circuits will be composed of the simple single qubit gates described al-ready, put together to become multiple-qubit circuits, then used within quantum sub-routines and algorithms.

6.3 quantum teleportation

We will now pause for a brief aside, in order to explore a more general concept of inter-est in Quantum Information Theory, to appreciate the power of quantum mechanics. It canbe proven using only knowledge described so far, that it is possible to regenerate a quan-tum state by transferring only classical information about the state [8]. An importantprinciple in quantum mechanics is that an unknown quantum state cannot be copied orcloned [9]. Thus if we have an unkown superposition state |ψ〉 = a0|0〉+ b0|1〉, and anauxiliary qubit |0〉, onto which we hope to create a qubit, measurement upon which will

27

Page 33: Mathematical_Introduction_to_Quantum_Computation

6.3. QUANTUM TELEPORTATION CHAPTER 6. gates and circuits

yield |0〉 or |1〉 with the same probability as it would from measuring |ψ〉, we see thatit is impossible. That is, it is impossible to begin with the system |ψ, 0〉 and finish withthe state |ψ, ψ〉. It is however possible to destroy the initial state, and regenerate it at anarbitrarily far away point.

Consider some observer Alice, who possesses some qubit |ψ〉 = a|0〉+ b|1〉. Supposethere is another observer, Bob, arbitrarily1 far away, and Alice wishes to “send” her qubitto Bob. We initialise a Bell state,

∣∣Φ+⟩=

1√2

(|00〉+ |11〉

)(6.7)

It is possible for this entangled state to exist with one constituent qubit at a largedistance away from the other. Suppose then, that the first state is in Alice’s possession,while Bob holds the second. Denote this possession with a subscript; our system is nowdescribed as

|ψ〉A = a|0〉A + b|1〉A (6.8a)

∣∣Φ+⟩

AB =1√2

(|0〉A|0〉B + |1〉A|1〉B

)(6.8b)

⇒ |ψ〉A ⊗∣∣Φ+

⟩AB =

1√2

(a|0〉A + b|1〉A

)⊗(|0〉A|0〉B + |1〉B|1〉B

)(6.8c)

So we view our total initial state, denoted now by |S〉 as

|S〉AB =1√2

(a|0〉A|0〉A|0〉B + a|0〉A|1〉A|1〉B + b|1〉A|0〉A|0〉B + b|1〉A|1〉A|1〉B

)(6.9)

Now, Alice has control over the first two qubits and can act on them. Her operationscan not act directly on Bob’s state. If she performs a CNOT with the first state as thecontrol and the second as the target, followed by Hadamard gate on the first state andno action on the others, we may represent this as(

HA ⊗ IA ⊗ IB

)((CNOT)AA ⊗ I B)|S〉AAB (6.10)

This will act linearly: the same circuit will act on each of the basis states

|000〉, |011〉, |001〉, |111〉

Consider the second such basis state, |0〉A|1〉A|1〉B to show on a diagram as below.

1 Arbitrary distance between sender and receiver may seem to imply that the two could be sufficiently apartthat this would constitute the quantum information travelling faster than the speed of light. However, theteleportation relies on the exchange of classical information, which is strictly slower than the speed oflight, so the entire process is not as instantaneous as it would need to be to violate relativity in this way.

28

Page 34: Mathematical_Introduction_to_Quantum_Computation

6.3. QUANTUM TELEPORTATION CHAPTER 6. gates and circuits

|0〉A • |0〉A H |+〉A

|1〉A |1〉A |1〉A

|1〉B |1〉B |1〉B

For clarity, the circuit acts in the following steps

1.(

CNOT⊗ I)( 1√

2)

(a|0〉A|0〉A|0〉B + a|0〉A|1〉A|1〉B + b|1〉A|0〉A|0〉B + b|1〉A|1〉A|1〉B

)

=1√2

(a|0A0A0B〉+ a|0A1A1B〉+ b|1A1A0B〉+ b|1A0A1B〉

)

2.(

H ⊗ I ⊗ I)

1√2

(a|0A0A0B〉+ a|0A1A1B〉+ b|1A1A0B〉+ b|1A0A1B〉

)

=1√2

[a

1√2(|0〉+ |1〉)A|0A0B〉+ a

1√2(|0〉+ |1〉)A|1A1B〉

+b1√2(|0〉 − |1〉)A|1A0B〉+ b

1√2(|0〉 − |1〉)A|0A1B〉

]

=12

[a(|0A0A0B〉+ |1A0A0B〉+ |0A1A1B〉+ |1A1A1B〉

)+b(|0A1A0B〉 − |1A1A0B〉+ |0A0A1B〉 − |1A0A1B〉

)]

=12

[|0A0A〉

(a|0〉B + b|1〉B

)+ |0A1A〉

(a|1〉B + b|0〉B

)+|1A0A〉

(a|0〉B − b|1〉B

)+ |1A1A〉

(a|1〉B − b|0〉B

)]So now, after Alice has performed her circuit on the two states she possesses, her

system is left in a superposition of basis states |00〉, |01〉, |10〉and|11〉, and she can observethem to collapse into one of these. Bob’s qubit is now in some state |ψ′〉. Each possiblestate of Alice’s qubit after the procedure corresponds to a particular state which Bob’squbit is now in: if Alice classically communicates to him that her system, for instance,was observed in |00〉, then Bob now knows that his qubit is in the state∣∣ψ′⟩ = a|0〉+ b|1〉

This is the initial state of Alice’s qubit! Hence Alice has transported an unkown quantumstate an arbitrary distance by only acting on the qubits in her possession.

29

Page 35: Mathematical_Introduction_to_Quantum_Computation

6.3. QUANTUM TELEPORTATION CHAPTER 6. gates and circuits

There remains the cases where Alice observes her system in the other basis states,however. Bob is still able to obtain the unkown state |ψ〉 regardless of what measurementAlice sees, by means of decoding his qubit. For example, had Alice measured |01〉, thenBob would know his qubit to be in the state a|1〉+ b|0〉. To restore the initial amplitudes,he must simply “swap” the states |0〉 ↔ |1〉, which we know to be possible by thequantum not gate, 6.1b. Likewise, he can restore |ψ〉 by performing the Pauli-Y gate,6.1c if Alice’s qubits had been in |11〉, and by a Pauli-Z gate, 6.1d, if Alice’s is in |10〉.

Example 6.7 (Decoding). If Alice had observed |10〉, Bob then knows he has the state|ψ′〉 = a|0〉 − b|1〉. Bob would find the original qubit |ψ〉 by implementing a Pauli-Zgate:

Z∣∣ψ′⟩ = (|0〉〈0| − |1〉〈1|)(a|0〉 − b|1〉

)= a|0〉(〈0|0〉)− a|0〉(〈0|1〉)− b|1〉(〈1|0〉) + b|1〉(〈1|1〉)

= a|0〉(1)− a|0〉(0)− b|1〉(0) + b|1〉(1)

= a|0〉+ b|1〉

= |ψ〉

This is a simple of example of encrypting and decrypting messages. Quantum Infor-mation theory builds on these ideas to consider how communication can be achievedthrough quantum methods. Improvements offered over classical communication chan-nels are of the same magnitude as the improvements quantum computation offers overclassical. This is explored in depth in a huge amount of literature on the subject, includ-ing [7] and [10].

30

Page 36: Mathematical_Introduction_to_Quantum_Computation

7

C O M P U TAT I O N A L T E C H N I Q U E S

We have seen the equivalence of quantum gates and unitary operations, and we haveseen that any unitary operation is reversible in § 5.2. Thus any reversible gate is unitary.We have also seen that it is possible to construct any unitary transformation using onlysimple quantum gates, § 5.2.1. However, in general, such constructions are inefficient.Quantum versions of classical computations are where efficiency may be improved uponbetween the two cases: if we can define an efficient classical circuit, then build thequantum version of this circuit by replacing all classical logic gates with simple quantumgates, then we may begin to see where the power of quantum computation comes from.Since we know we can build any unitary transformation using quantum gates, we canreplace any classical gate with a quantum analogue. However, classical circuits are not ingeneral reversible, so our problem is reduced to constructing reversible classical circuits,but we also require that such gates be efficient, or else the procedure is redundant. Anin depth discussion of how this can be achieved is given in §6 of [11]. It will suffice forour purposes to infer that if a reversible, classical gate can be achieved efficiently, then aquantum analogue can be achieved trivially by replacing logic gates with their quantumcounterparts, which we have seen to exist already. We will instead explore algorithmswhich make use of strictly quantum processes in order to achieve greater efficiency, andcompare such constructions with classical circuits that aim to do the same thing, so thatwe can see the improvement offered.

7.1 techniques

With an understanding of how quantum circuits are constructed, we may now turnto how their implementation can offer computational power. We will demonstrate asimple proof of principle to see how quantum methods can achieve definitively superiorcomputational power, and we will outline some simple quantum subroutines which formthe basis of more complicated algorithms examined in the next chapter.

In doing so we will see the fundamental difference between classical and quantumcomputation: it is by finding a global property of a function that we may solve it inexponentially less steps. Quantum computers are uniquely capable of finding theseproperties by working on superpositions to uncover information about a function, ratherthan simply evaluating the function. This concept will become clearer in later quantumcomputations, especially the algorithms for Simon’s problem, § 8.2.2, which finds the

31

Page 37: Mathematical_Introduction_to_Quantum_Computation

7.1. TECHNIQUES CHAPTER 7. computational techniques

hidden variable of a function. It exploits the periodicity of a function, which Shor thenshows can be used to factor large integers, § 9. In doing so, these methods take aproperty of the function, here the period, and use it to determine evaluations whichwould be more difficult to achieve without knowing these properties.

We now consider the inapplicable problem designed by Deutsch to demonstratehow properties of functions are achievable through quantum devices, in order to show,through a simple example, the power of this idea.

7.1.1 Deutsch’s Problem

This proof by David Deutsch was the first concrete evidence that quantum methodologycan yield a result that would take a classical computer more steps [4]. The problemaddressed is of little practicality, though it is the conceptual proof we are interested inhere.

Recalling the black box (often referred to as an oracle) of § 6.1.3, we suppose that weare interested in a function f : {0, 1} → {0, 1}. So our oracle now,

U f : |x, y〉 → |x, y⊕ f (x)〉

We want to know if f (0) = f (1) or not. That is, whether the function returns a constantanswer for x ∈ {0, 1} or not. Define an system |+〉|−〉 by performing a Hadamard gateon both qubits of the system |0〉|1〉, and use this as input to our oracle.

U f(|+〉|−〉

)= U f

[12(|0〉+ |1〉)(|0〉 − |1〉)

]=

12

U f

[|00〉 − |01〉+ |10〉 − |11〉

]=

12

[|0〉|0⊕ f (0)〉 − |0〉|1⊕ f (0)〉+ |1〉|0⊕ f (1)〉 − |1〉|1⊕ f (1)〉

]

=12

[|0〉(| f (0)〉 − |1⊕ f (1)〉

)+ |1〉

(| f (1)〉 − |1⊕ f (1)〉

)](7.1)

=12

1

∑x=0|x〉(|0⊕ f (x)〉 − |1⊕ f (x)〉

)So now consider the quantity |0⊕ f (x)〉 − |1⊕ f (x)〉.

|0⊕ f (x)〉 − |1⊕ f (x)〉 ={|0⊕ 0〉 − |1⊕ 0〉 = |0〉 − |1〉 =

√2|−〉 f (x) = 0

|0⊕ 1〉 − |1⊕ 1〉 = |1〉 − |0〉 = −√

2|−〉 f (x) = 1

= (−1) f (x)√

2|−〉

32

Page 38: Mathematical_Introduction_to_Quantum_Computation

7.1. TECHNIQUES CHAPTER 7. computational techniques

and the sum becomes

1√2

1

∑x=0

(−1) f (x)|x〉|−〉 = 1√2

((−1) f (0)|0〉|−〉+ (−1) f (1)|1〉|−〉

)(7.2)

Recall our objective is to determine whether f (x) is constant or not. In the case that f isconstant, then either f (0) = f (1) = 0 or f (0) = f (1) = 1 Then

1

∑x=0

(−1) f (x)|x〉 = (−1) f (0)|0〉+ (−1) f (1)|1〉

=

{1|0〉+ 1|1〉 =

√2|+〉 f (0) = f (1) = 0

(−1)|0〉+ (−1)|1〉 = −√

2|+〉 f (0) = f (1) = 1

⇒ 1√2

1

∑x=0

(−1) f (x)|x〉− = ± 1√2

√2|+〉 = ±|+〉

A constant (−1) can be interpreted as a phase factor which is physically meaningless;we can safely ignore it. The total system then is in the state |+〉|−〉 = 1√

2|0〉|−〉+ |1〉|−〉.

Next apply a Hadamard gate to the first qubit

⇒(

H ⊗ I)1√2

(|0〉|−〉+ |1〉|−〉

)=

1√2

[( 1√2(|0〉+ |1〉) 1√

2(|0〉 − |1〉)

)+( 1√

2(|0〉 − |1〉) 1√

2(|0〉 − |1〉)

)]=

12√

2

[(|00〉 − |01〉+ |10〉 − |11〉

)+(|00〉 − |01〉 − |10〉+ |11〉

))=

12√

2

[2|00〉 − 2|01〉

]=[|0〉][ 1√

2|0〉 − 1√

2|1〉]

= |0〉|−〉

Or simply (H ⊗ I)

(|+〉|−〉

)= |0〉|−〉

Then, if the first qubit is measured in the case where f (0) = f (1), then it will be observedas |0〉. This is not a probabilistic result: there is no amplitude attached to the state |1〉that would enable us to measure our qubit after the transformation, using the standardbasis, and find anything other than |0〉. This serves also to demonstrate that definiteresults can be obtained using quantum mechanics, which may seem to oppose commonperception.

A similar argument holds for when f is not constant. In this case, we return toequation 7.2:

1√2

((−1) f (0)|0〉|−〉+ (−1) f (1)|1〉|−〉

)

33

Page 39: Mathematical_Introduction_to_Quantum_Computation

7.1. TECHNIQUES CHAPTER 7. computational techniques

We have either {f (0) = 0 ; f (1) = 1f (0) = 1 ; f (1) = 0

⇒ 1√2

((−1) f (0)|0〉|−〉+(−1) f (1)|1〉|−〉

)=

1√2

((−1)0)|0〉+ (−1)1|1〉

)|−〉 = +1|−〉|−〉

1√2

((−1)1|0〉+ (−1)0|1〉

)|−〉 = −1|−〉|−〉

Again, the phase factor of (−1) is physically meaningless: what matters is that the firstqubit is now in the state |−〉. A Hadamard gate on only the first qubit will then return|1〉 with probability 1.

We may also note that{f (0)⊕ f (1) = 0 f (0) = f (1), f constantf (0)⊕ f (1) = 1 f (0) 6= f (1), f not constant

We have found generally that the output state after this algorithm is

| f (0)⊕ f (1)〉|−〉 (7.3)

We know the value f (0)⊕ f (1) from the measurement of this first qubit after the algo-rithm, which also determines that f was constant if it measures |0〉 and that f was notconstant if it measures |1〉.

Thus, with only a single call to the oracle, we have found a global property of thefunction f , ie the value f (0)⊕ f (1). This is an important principle that will be utilisedin subsequent quantum routines.

Consider now a classical routine to find out the same information about f . It wouldtake at least two calls to the function in order to know f (0) and f (1), whereas theDeutsch Algorithm, rather than finding both, finds a property f (0) ⊕ f (1) in a singlecall to the oracle, which provides sufficient information to answer our query. This is aprimitive example meant only to illustrate how a quantum regime can achieve the samegoal as a classical regime, but in less steps.

34

Page 40: Mathematical_Introduction_to_Quantum_Computation

8

A L G O R I T H M S

8.1 quantum subroutines

The idea of subroutines within quantum algorithms is important: by defining simplemanipulations, we may construct larger algorithms from a stronger starting point than ifwe had to define all operations of an algorithm. This can be seen as similar to declaringthe function of gates, and then using those gates to build circuits: here we will composea series of circuits to define subroutines, and combine numerous subroutines and otheroperations to achieve what we wish our quantum procedure to do.

8.1.1 Walsh-Hadamard Transformation

An important but simple subroutine in the generalisation of the Hadamard gate to morethan one qubit. We wish to take a sequence of qubits |ψ1 . . . ψn〉, and place the system inan even superposition of all the possible basis vectors. For instance, a three qubit systemhas basis vectors given by |000〉, |001〉, |010〉, |011〉, |100〉, |101〉, |110〉, |111〉. Here we haven = 3 qubits, and therefore 2n = 8 basis vectors. The vectors given above can be seen tocorrespond to binary notation

0 → 000

1 → 001

2 → 010

3 → 011

4 → 100

5 → 101

6 → 110

7 → 111

Binary Representation

And so, any 3-qubit state can be given by the superposition

7

∑x=0

ax|x〉 (8.1)

35

Page 41: Mathematical_Introduction_to_Quantum_Computation

8.1. QUANTUM SUBROUTINES CHAPTER 8. algorithms

where ax is the amplitude of |x〉. In general, for an n-qubit system, there are N = 2n

basis states, and the system may be represented

1√N

N−1

∑x=0|x〉 (8.2)

Now, if we had a system with, say, 3 qubits, all initialised in the state |0〉, i.e. |000〉,and we wised to place the system into an equal superposition of all possible basis states,we would do so by applying Hadamard gates to each qubit individually, as seen below.Recall the operation of a Hadamard gate: H : |0〉 → 1√

2

(|0〉+ |1〉

)|0〉 H 1√

2

(|0〉+ |1〉

)|0〉 H 1√

2

(|0〉+ |1〉

)|0〉 H 1√

2

(|0〉+ |1〉

)In other words, upon input |0〉 ⊗ |0〉 ⊗ |0〉 this combination gives the output

1√2

(|0〉+ |1〉

)⊗ 1√

2

(|0〉+ |1〉

)⊗ 1√

2

(|0〉+ |1〉

)=

1√23

(|000〉+ |001〉+ |010〉+ |011〉+ |100〉+ |101〉+ |110〉+ |111〉

)=

1√8

7

∑x=0|x〉

The amplitude for each of these basis vectors is 1√8, meaning they each have equal prob-

ability of being observed, 18 , i.e there is a one in eight chance or observing each of the

eight basis states, so we have achieved our goal of an even distribution across basis states.Now, consider the same method applied to an n-qubit system.

|0〉 H 1√2

(|0〉+ |1〉

)|0〉 H 1√

2

(|0〉+ |1〉

)......

|0〉 H 1√2

(|0〉+ |1〉

)The output state here is

1√2

(|0〉+ |1〉

)⊗ 1√

2

(|0〉+ |1〉

)⊗ · · · ⊗ 1√

2

(|0〉+ |1〉

)=

1√N

[|00 . . . 00〉+ |00 . . . 01〉+ |00 . . . 10〉+ |00 . . . 11〉+ . . .

36

Page 42: Mathematical_Introduction_to_Quantum_Computation

8.1. QUANTUM SUBROUTINES CHAPTER 8. algorithms

+|01 . . . 00〉+ |01 . . . 10〉+ |01 . . . 01〉+ |01 . . . 11〉+ . . .

+|10 . . . 00〉+ |10 . . . 01〉+ |10 . . . 10〉+ |10 . . . 11〉+ . . .

+|11 . . . 00〉+ |11 . . . 01〉+ |11 . . . 10〉+ · · ·+ |11 . . . 11〉]

Again, let the above basis states be considered binary for the numbers ( 0→ N− 1), andthis can be described by

1√N

N−1

∑y=0|y〉

We call this general operation the Walsh-Hadamard transformation [12]. When it actson on a system of n unentangled qubits, all initialised to |0〉 and therefore denoted |0〉⊗n,

W(|0〉⊗n) =1√2n

2n−1

∑y=0|y〉 (8.3)

More generally, consider the case where not all qubits in a system are initially |0〉.Suppose we have |z〉 = |z0, z1, z2, ..., zn〉, then there exists |y〉 = |y0, y1, ..., yn〉. Then z · yis the number of common bits in z and y. For example, if |z〉 = |0011〉 and |y〉 = |1110〉,then only the third entry is the same in both, so z · y = 1. Now, |z〉 is a representation of

|z〉 = |z0〉 ⊗ |z1〉 ⊗ ...⊗ |zn〉

So let zi ∈ {0, 1} and compute

W|z〉 = (H ⊗ H ⊗ H ⊗ · · · ⊗ H)(|z0〉 ⊗ |z1〉 ⊗ ...⊗ |zn〉)

= (H|z0〉)⊗ (H|z1〉)⊗ · · · ⊗ (H|zn〉)

=1√2n

(|0〉+ (−1)z0 |1〉)⊗ (|0〉+ (−1)z1 |1〉 ⊗ · · · ⊗ (|0〉+ (−1)zn |1〉)

Again we will prove a simplified case and assume the generalisation as trivial. Considern = 3.

=1√8

[(|0〉+(−1)z0 |1〉

)⊗(|0〉+(−1)z1 |1〉

)⊗(|0〉+(−1)z2 |1〉

)]= |000〉+(−1)z2 |001〉+(−1)z1 |010〉+(−1)(z1+z2)|011〉

+(−1)z0 |100〉+ (−1)(z0+z2)|101〉+ (−1)(z0+z1)|110〉+ (−1)(z0+z1+z3)|111〉 (8.4)

And as this is an evenly distributed three-qubit state, we can represent it as a sumover basis states, given by

1√8

8

∑y=0|y〉 = 1√

8

[|000〉 ± |001〉 ± |010〉 ± |011〉 ± |100〉 ± |101〉 ± |110〉 ± |111〉

](8.5)

37

Page 43: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

It will help clarify this point if we take an explicit value for the initial |z〉, say |z〉 =|011〉 Then, for instance (−1)(z0+z2)|101〉 = (−1)(0+1)|101〉 = −|101〉, so we know thesign in 8.5 is negative for y = |101〉. Consider, then, the value z · y = |011〉 · |101〉 = 1as they share only the third qubit value. We can then express the |101〉 term as beinggenerated by (−1)z·y, and so the entire sum given by 8.5 become

18

8

∑y=0

(−1)z·y|y〉

And so in general, we have the Walsh Hadamard Transformation, or simply the Walshtransformation, described by

W(|z〉) = 1√2n

2n−1

∑y=0

(−1)(z·y)|y〉 (8.6)

This transformation is often applied at the outset of quantum algorithms, or within alarger scheme, so that the generated superposition may be exploited throughout, as wewill see.

8.2 quantum parallelism

The concept of generating a state which spans many or all solutions of a function isreferred to as quantum parallelism. That is, rather than finding a specific f (x0), generatingthe superposition

1√N

N−1

∑x=0|x〉| f (x)〉

which contains the value of f for the n x’s under consideration. Here, N = 2n. Thisrequires the use of auxiliary qubits: these are additional qubits initially in the state |0〉.These auxiliary qubits are passed through some black box, U f , and then hold f (x). Thiscan be visualised by the circuit diagram

|x1〉

U

|x0〉

|x2〉 |x1〉...

...|x2n−1〉 |x2n−1〉

|0〉 | f (x0)〉

|0〉 | f (x1)〉...

...|0〉 | f (x2n−1)〉

38

Page 44: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

It is incorrect to think that, because a quantum process generates and works on thesuperposition 1√

N ∑Nx=0 |x, f (x)〉, that a quantum computer can simply calculate and out-

put all possible results in one step. While it works on the superposition across the statespace of solutions of f (x), we must note that measurement of an n-qubit system willonly give one result. This is the same level of efficiency as a classical algorithm whichsimply calculates f (x) for one x at a time. It is through methods as outlined above,§ 7.1.1, that we may exploit quantum mechanics: rather than compute all solutions invery few steps and then measure them, we must find a property common to all valuesof f (x), and use it to work our way backwards to find a solution. This idea is utilisedin many quantum subroutines, including Simon’s Problem, which finds the period of afunction, and in more applicable complete algorithms, most famously Shor’s Algorithm,which uses the period of a generated function to obtain prime factors of a number. Wewill explore this algorithm fully in § 9.

8.2.1 Deutsch-Jozsa Problem

As another demonstration of generalising specific problems addressed, we will composea multiple qubit generalisation of Deutsch’s Problem, § 7.1.1. This is an improved versionof the above process, given 7 years later by [5]. We again consider a function f : Z2n 7→ Z2i.e that x ∈ X = {0, ..., 2n − 1} and f (x) ∈ {0, 1}.The function is known to be one of twotypes: it will either be constant, always returns 0 or 1, or balanced, returns 0 exactly halfthe time and 1 the other half. Our aim is to determine which of these types of function fis. Again we have a quantum oracle U f : |x〉|y〉 → |x〉|y⊕ f (x)〉. Through parallelisation,we are working with the superposition

|ψ〉 = 1√N

N

∑x=0|x〉 (8.7)

We must note that it is possible to change the phase of a basis state depending onsome criteria of our choosing (see §7.4.2 of [11]). For our purpose, suppose there is asubset X0 ∈ X, such that { f (xi) = 1|xi ∈ X0}. We change the phase for such vectors by aglobal phase, a physically meaningless constant. In this case, the phase change we chooseis (−1). In other words, we have sent

|xi〉 → −|xi〉 = (−1) f (xi)|xi〉

And applying this phase change throughout, 8.7 becomes

|ψ〉 = 1√N

N

∑x=0

(−1) f (x)|x〉 (8.8)

So for this problem then, we start with n qubits in the state |0〉, and one in the state|1〉.

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

39

Page 45: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

We perform a Walsh transformation on this state. Say

W = H ⊗ H · · · ⊗ H = H⊗n ⊗ H

⇒W(|ψ〉) =(

H⊗n|0〉⊗n)(H|1〉)

=( 1√

2n

2n−1

∑x=0|x〉)⊗ 1√

2

(|0〉 − |1〉

)W|ψ〉 = 1√

2n+1

2n−1

∑x=0|x〉 ⊗

(|0〉 − |1〉

)(8.9)

Then perform the subroutine outlined above to send |x〉 → (−1) f (x)|x〉

⇒ 1√2n+1

2n−1

∑x=0

(−1) f (x)|x〉(|0〉 − |1〉

)(8.10)

Now we can show that for f (x) constant, reperforming a Walsh transform on the first nqubits will allow us to measure, with certainty, |0〉 if f (0) = f (1), and |1〉 for f (0) 6= f (1).We will show this explicitly for the simplest case of a single qubit, and the result extendsgenerically to higher n.

n = 1⇒ 2n − 1 = 1⇒2n−1

∑x=0→

1

∑x=0

⇒ 1√22−1

1

∑x=0

(−1) f (x)(|x, 0〉 − |x, 1〉)

=12((−1) f (0)|0, 0〉 − (−1) f (0)|0, 1〉+ (−1) f (1)|1, 0〉 − (−1) f (1)|1, 1〉

)(8.11)

Now we consider two cases: firstly, that f (x) is constant, and we can therefore factorout the (−1) f (x) terms as (−1) f (0)

(−1) f (0)

2(|0, 0〉 − |0, 1〉+ |1, 0〉 − |1, 1〉

)=

(−1) f (0)√

2

(|0〉( |0〉 − |1〉√

2) + |1〉( |0〉 − |1〉√

2))

= (−1) f (0)( |0〉+ |1〉√2

)( |0〉 − |1〉√2

)= (−1) f (0)|+〉|−〉

At this point, we perform another Walsh transformation on this system, which willreturn |0〉 in the first qubit (recall n = 1 and that all n qubits would be found in |0〉 inthe general case). The (−1) f (0) is a global phase, which carries no physical meaning.

W(|+〉|−〉) = |0〉|1〉 (8.12)

40

Page 46: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

So with probability 1, if f (x) is constant, |0〉 will be measured in the first n qubitsfollowing this procedure. Otherwise, in the case f (0) 6= f (1), the logic would change at8.11:

12

((−1) f (0)(|0, 0〉 − |0, 1〉) + (−1) f (1)(|1, 0〉 − |1, 1〉)

)=

1√2

((−1) f (0)|0〉|−〉+ (−1) f (1)|1〉|−〉

)However, we know that either ( f (0) = 0; f (1) = 1) or ( f (0) = 1; f (1) = 0), andsubstituting these would differ only by a constant, −1, so we can use the substitutionf (0) = 0; f (1) = 1, giving

(−1) f (0) = (−1)0 = +1, (−1) f (1) = (−1)1 = −1

⇒ 1√2

(|0〉|−〉+ (−1)|1〉|−〉

)=( |0〉 − |1〉√

2

)|−〉 = |−〉|−〉 (8.13)

And again we apply the Walsh tranform

W(|−〉|−〉) = |1〉|1〉

And so we can see clearly that, if f (0) 6= f (1), that, with probability 1, following theDeutsch-Josza algorithm the first n qubits will be observed in the state |1〉.

This algorithm has solved a problem with effectively no application, but it has proventhat there is a solution to this problem which requires only a single call to the oracle.Comparatively, for a classical machine to find this result deterministically, it would requireat least 2n−1 + 1 calls to find the same result with certainty.

8.2.2 Simon’s Problem

Simon’s Problem addresses a function f with f (x) = f (x⊕ a), (here ⊕ denotes modulus-a addition), and aims to determine what value of a satisfies this [13]. In other words,Simon’s Algorithm find the period of a function f . We focus on this particular subroutinerather than the many others because it was this routine which suggested to Shor thatfactorisation of large integers could be achieved by quantum computers in reasonabletime limits.

An initial state is generated by quantum parallelisation

2n−1

∑x=0|x〉| f (x)〉 = ∑ |ψ〉|φ〉

Where we have denoted the register of qubits holding initial values x as |ψ〉 and theregister holding the values after evaluation in f as |φ〉. We know that f (x) = f (x ⊕ a)

41

Page 47: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

where a is the period. Then, if the register |φ〉 is measured, it will return some f (x0),and we can deduce that the input required to return this value must have been either x0or x0 ⊕ a, and that there is an equal probability that it was either of these cases. Fromthis we infer that |ψ〉 is in an even superposition of the states |x0〉 and |x0 ⊕ a〉 after thesecond register is measured. ∣∣ψ′⟩ = 1√

2

[|x0〉+ |x0 ⊕ a〉

]Then consider applying the Walsh transformation to this state. Recall 8.6

W|z〉 = (−1)z·y|y〉

⇒W(∣∣ψ′⟩) = W

(1√2

[|x0〉+ |x0 ⊕ a〉

])=

1√2

[W(|x0〉) + W(|x0 ⊕ a〉)

]=

1√2

[( 1√2n

2n−1

∑y=0

(−1)(x0·y)|y〉)+( 1√

2

2n−1

∑y=0

(−1)(x0⊕a)·y|y〉)]

=1√

2n+1

2n−1

∑y=0

[(−1)x0·y

(1 + (−1)a·y)]|y〉

In the case where a · y is an odd number, 1 + (−1)a·y = 1 + (−1) = 0, and thesum disappears. Thus we may only consider the case where a · y is even from now on,1 + (−1)a·y = 2. This is equivalent to the requirement a · y = 0 mod 2, so the system isnow in the state

2√2n+1 ∑

a·y=0 mod 2(−1)x0·y|y〉 (8.14)

Adding even numbers always returns an even number, but if we use modulo-2 addition,then adding even numbers always gives 0. For instance

2 + 6 + 10 = 18⇒ 18 mod 2 = 0

⇒ a0 · y0 ⊕ a1 · y1 ⊕ · · · ⊕ an · yn = 0 (8.15)

Measuring when the system is in 8.14 will result in a value for y for which we knowthat y · a = 0 mod 2. Then each iteration, i of this procedure produces a linear equationyi · ai = 0.

y0 · a0 = 0y1 · a1 = 0

...yn · an = 0

(8.16)

42

Page 48: Mathematical_Introduction_to_Quantum_Computation

8.2. QUANTUM PARALLELISM CHAPTER 8. algorithms

To solve for a, we need n linearly independent equations of this form. The equationproduced upon iteration is not necessarily linearly independent: there is a probability(< 0.5) that the new equation is not independent from the previous ones. Computing thevalue of (yi · ai) a total of 2n times will therefore produce a set of n linearly independentequations with a probability of 50%. It may take more computations to obtain the set ofequations, but there is an extremely high probability that the set can be found in O(n)calls to U f . Such a system can then be used to solve for a in O(n2) steps. So, overall theperiod a of a 2-to-1 function f can be found in O(n) + O(n2) steps. Classically, it wouldrequire O(2n/2) calls to the function to achieve this result.

43

Page 49: Mathematical_Introduction_to_Quantum_Computation

W H Y

Now that we have seen what properties quantum computersexploit, and how they can be used to achieve circuits and al-gorithms, we may finally address the real question of Whywe should be interested to do so in the first place. Concep-tual mathematical physics aside, this topic has the potentialto propel the already fast expanding field of computer science.We will provide instances where quantum computers can of-fer substantial computational advances, and examine in detailthe most famous result of the field to date, Shor’s FactoringAlgorithm, so that we can understand a true application ofthe subject.

44

Page 50: Mathematical_Introduction_to_Quantum_Computation

9

S H O R ’ S A L G O R I T H M

Providing concrete examples of what only quantum machines can achieve is pivotal tojustifying funding research into their construction. We will outline the major drivingfactor to date in quantum computation, factorisation of large numbers, described byShor’s Algorithm, to see one such example.

The aim of the algorithm is to factor large numbers, which is known to be extremelydifficult to achieve classically, [14]. To do so, we describe first the reasons that this can beseen as a worthwhile driving force for research into quantum computation by outlininghow cryptography currently works. To describe mathematically how quantum methodscan uniquely be used in this area, we briefly discuss Fourier transforms and how theycan be translated into Quantum Fourier Transforms. To realise the potential applicationof quantum mechanics, we will reduce the problem of factoring a large number to thatof finding the period of a function we can generate based on the number we wish tofactorise, and then show how we may find such a period only through manipulationof quantum states. True quantum mechanics will play only a minor role insofar as itwill be used in very few steps of the algorithm, but by doing so we will see how andwhy classical computation could never achieve the same efficiency as we will find forquantum computation.

9.1 cryptography

Current encryption relies on the principle that it is very easy to multiply two large primestogether to form a semi-prime number, while it is extremely difficult to factor a semiprime into its two factors. Multiplying two prime numbers of the order 10100 will resultin a number of order 10200, which is extremely hard to factor classically. Encryptiontherefore generates a public key, the product of the primes, and a private key, the numbersused to generate it, known only to those who need to know how to decrypt the message.For this reason, Shor’s factoring algorithm poses a threat to standard cryptography atpresent, as it would drastically simplify the process of decoding the secret key, andwould thus render currently secure communications as potentially insecure, [15]. Thisis a detractor for the field of study, though it is seen as a turning point in quantumcomputing insofar as it sparked huge interest in the subject immediately following thepublication of the original paper, [6]. It is a fundamental concept to the subject, so

45

Page 51: Mathematical_Introduction_to_Quantum_Computation

9.2. FOURIER TRANSFORMATION CHAPTER 9. shor’s algorithm

we examine the entire process to understand how quantum computers can solve a realproblem, factorisation, significantly faster than classical machines.

9.2 fourier transformation

9.2.1 Classical Fourier Transform

Recall the classical Discrete Fourier Transformation, a classical transformation which takesa discrete complex valued function, f (x), to another discrete complex valued function,F(x), given by

F(x) =1√N

N−1

∑k=0

f (k) exp(2πikxN) (9.1)

The values F(0), F(1), ..., F(N − 1) are called the Fourier coefficients of the function f .

9.2.1.1 Fast Fourier Transform

There exists a particularly efficient implementation for the Fourier Transform for thespecial case when the number of values f acts on is a power of two. That is, N = 2n. TheFast Fourier Transform, FFT, exploits the periodicity of such functions by decomposingthe transformation recursively.

9.2.2 Quantum Fourier Transform

A variation of the discrete Fourier Transform is the Quantum Fourier Transform, QFT. Aswith the FFT, the QFT considers the case N = 2n. If we consider the quantum state

N−1

∑x

fx|x〉

where fx = f (x) is the amplitude for the basis state |x〉, then the Fourier coefficients F(x)represent the amplitude of the basis states of the quantum Fourier transformed state

N−1

∑x

F(x)|x〉

Then if we consider the Fourier coefficients F(x) which now represent the probabilityamplitude of measuring a state |x〉 after performing the transformation, we can observethat only certain values for x result in non-zero values for F(x).

Recall that we have defined N = 2n. We also impose that the period of f (x) is apower of two:

f (x) = f (x + r) , r = 2R

We also have

F(x) =1√N

N−1

∑k=0

f (k) exp(2πikxN)

46

Page 52: Mathematical_Introduction_to_Quantum_Computation

9.2. FOURIER TRANSFORMATION CHAPTER 9. shor’s algorithm

As previously, we will consider a specific case in order to understand the generalconcepts involved. Here, take N = 23 = 8 and r = 21 = 2, so N

r = 4 .

⇒ F(x) =1√8

7

∑k=0

f (k) exp(2πikx8)

=1√8

7

∑k=0

f (k)((eiπ)

kx4)

=1√8

7

∑k=0

f (k)((−1)

kx4)

=1√8

(f (0)(−1)(0) + f (1)(−1)

x4 + f (2)(−1)

2x4 + f (3)(−1)

3x4

+ f (4)(−1)4x4 + f (5)(−1)

5x4 + f (6)(−1)

6x4 + f (7)(−1)

7x4

)And now recall that due to the periodicity of f (x) = f (x + 2)

f (0) = f (2) = f (4) = f (6) , f (1) = f (3) = f (5) = f (7)

⇒ 1√8

(f (0)

[(1+(−1)

x2 +(−1)x +(−1)

3x2]+ f (1)

[(−1)

x4 +(−1)

3x4 +(−1)

5x4 +(−1)

7x4])

=1√8

(f (0)

[(1+(−1)

x2 +(−1)x +(−1)

3x2]+(−1)

x4 f (1)

[(1+(−1)

x2 +(−1)x +(−1)

3x2])

F(x) =1√8

(f (0) + (−1)

x4 f (1)

)(1 + (−1)

x2 + (−1)x + (−1)

3x2

)(9.2)

We focus on the term [1 + (−1)

x2 + (−1)x + (−1)

3x2]

(9.3)

Now consider that x ∈ {0, ..., N− 1} = {0, 1, 2, 3, 4, 5, 6, 7}. Also recall that Nr = 8

2 = 4.In cases where x is an integer multiple of N

r , in this case x = 0, 4, 9.3 becomes{x = 0⇒ 1 + (−1)0 + (−1)0 + (−1)0 = 4x = 4⇒ 1 + (−1)2 + (−1)4 + (−1)6 = 4

So clearly, when x is a multiple of Nr , the Fourier coefficient is nonzero. Otherwise,

however, say for instance x = 3:

Eqn.( 9.3) = 1 + (−1)32 + (−1)3 + (−1)

92

47

Page 53: Mathematical_Introduction_to_Quantum_Computation

9.3. FACTORISATION BY PERIOD FINDING CHAPTER 9. shor’s algorithm

= 1 + (−1)(−1)12 + (−1) + (−1)4(−1)

12

= 1− i− 1 + i = 0

Any other value of x that isn’t an integer multiple of Nr will demonstrate this behaviour

and sum to zero. This behaviour extends to larger values of n and R such that we cansay that the only Fourier coefficients which are non zero are F(x = k N

r ), k ∈ N. In thiscase, the state after QFT is a superposition of |0〉 and |4〉:

F(0)|0〉+ F(1)|4〉 = F(0)∣∣∣∣0(N

r)

⟩+ F(1)

∣∣∣∣1(Nr)

⟩Now that we know that the only nonzero Fourier coefficients correspond to x being

a multiple of Nr we can say that the state after Fourier transformation

F(x)|x〉

can only be measured to exist for such values of x. So then, if measured, the observedvalue would be some

∣∣k Nr⟩. The state after performing the QFT is given by

QFT( f (x)) =r−1

∑k=0

F(k)∣∣∣∣k(N

r)

⟩(9.4)

Producing this state is the most important quantum subroutine used in quantumcomputation, and we will see its use in Shor’s Algorithm. The realisation of the QFT isexplained in §7.8 of [11], which builds on the earlier idea of defining relatively simplegates and combining them recursively.

9.3 factorisation by period finding

Recall our overall aim here: we wish to factor an integer, M, into its prime factors, mi.For example, M = 21 = m1 × m2 = 7 × 3. Using modular addition, we define anyinteger as a mod M, e.g to define 30, we say 30mod21 ≡ 9mod21. We define the order ofsuch an integer as the first r which satisfies

ar − 1 ≡ 0mod M (9.5)

Example 9.1. If we consider M = 7 and we wish to find the order of a = 2, we areconsidering integers

a mod M ≡ 2mod 7, 9mod 7, 16 mod 7, ...

. We have

p mod 7 ≡ 0 for p = 7, 14, 21, 28, ...

So we are looking for the lowest value of r for each a to give ar − 1 = 7k where k ∈N.

48

Page 54: Mathematical_Introduction_to_Quantum_Computation

9.3. FACTORISATION BY PERIOD FINDING CHAPTER 9. shor’s algorithm

a r ar − 12 1 1 6≡ 0 mod 72 2 3 6≡ 0 mod 72 3 7 ≡ 0 mod 7

So for a mod M ≡ 2mod7, the order r = 3.So now if we can find the order of a mod M, we have

ar − 1 ≡ 0 modM

⇒ (ar2 + 1)(a

r2 − 1) ≡ 0 mod M

In general, both (ar2 + 1) and (a

r2 − 1) will share common factors with M. Then, if r

is even, we have found two numbers which share non-trivial factors with M. We canfactor by simply using a Euclidean algorithm to find the greatest common divisor of(M, a

r2 ± 1). By repeating, the prime factors of M can be found. So, if we are trying to

find factors of M, we must choose some random a, and use it to determine the order of(a mod M), and call it r.

Example 9.2. Take a simple example M = 15. We now must choose a random a, andfind the order of amod15. Suppose we considered a = 7, to find r:

a r ar − 17 1 6 6≡ 0mod 157 2 48 6≡ 0mod 157 3 342 6≡ 0mod 157 4 2400 (60 ×15) ≡ 0 mod 15

So we have that the order (period) of our function is r = 4. Then compute

(ar2 + 1) = (72 + 1) = 50

(ar2 − 1) = (72 − 1) = 48

So to find the prime factors of M = 15, we use a Euclidean algorithm to determine

m1 = gcd(50, 15) : 5

m2 = gcd(48, 15) = 3

And we can easily confirm that this simple case is correct.In other words, we started with wanting to factor M into prime factors. To do so, it

is necessary to find the period of a function given by ( f (x) = f (x + r) = ax mod M).We have reduced the problem to period-finding. In general, it may be more difficultto determine the period than simply finding the order as outlined here, but we canproceed with the knowledge that, if we can find the period, the rest of the problembecomes achievable classically, as we did not employ any quantum techniques in thisargument.

49

Page 55: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

9.4 steps of shor’s algorithm

We are now in a position to describe the steps taken in Shor’s Algorithm to factor aninteger M into its prime factors. A preliminary to the algorithms is deciding how manyqubits to compose the system of. It can be shown (§8.3, [11]) that the number of qubits,n, should be chosen to satisfy

M2 ≤ 2n ≤ 2M2 (9.6)

We will do so a number of times. First, we will go through each step in explicit detailand explain the concepts involved. Then, we will succinctly summarise the steps. Finally,we will walk through the programme precisely for a specific value to be factorised.

9.4.1 Detailed Description of Steps

1. Randomly choose a value for a that is relatively prime to M. (If they are notrelatively prime then a is a factor and the rest of the algorithm is redundant, so itis necessary to check this condition early by a simple Euclidean algorithm).

2. Since we are interested in the function f (x) = ax mod M, we generate it within thesuperposition of an n-qubit state obtained through quantum parallelisation (recall§ 8.2), by passing a register of qubits |x〉 together with a register of |0〉’s through aparallelisation scheme, giving the output

1√2n

2n−1

∑x=0|x〉| f (x)〉 = 1√

2n

2n−1

∑x=0|x〉|ax modM 〉 (9.7)

Since our function is periodic in r, f (x) = f (x + r), we saw in 8.2.2 that measuringonly the second register would place the first register into a superposition oversome x0 and x0 + l.r, l ∈ Z, where the second register was observed in | f (x0)〉. Weintroduce a function, g(x), to determine whether each x is separated from x0 bythe period or not:

g(x) =

{1 f (x) = f (x0) , (x = x0 + l.r)0 f (x) 6= f (x0) , (x 6= x0 + l.r)

After measurement of the second qubit, our system is in the state

C ∑x

g(x) |x〉 | f (x0)〉 (9.8)

Where C is a scaling factor.

3. Since the two registers are not entangled, we can safely ignore the register thatholds f (x), and focus solely on the state

C ∑x

g(x) |x〉 (9.9)

50

Page 56: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

Applying the Quantum Fourier Transform, 9.4:

QFT(

C ∑x

g(x)|x〉)= C2

r−1

∑k=0

G(k)∣∣∣∣k(N

r)

⟩(9.10)

Where C2 is another scaling constant. g(x) has the same period, r, as f (x) and G(x)is the Fourier coefficient for g(x), given by 9.1.

4. The above assumes that N = 2n and r = 2R. In the case that r 6= 2R, the transformapproximates the exact case: most of the amplitude is associated with integersequal to or near a multiple of the ratio N

r . In this way, following this procedure,were we to measure the system, with high probability we can say that the observedvalue for x is a multiple of N

r , or else a value very near to it. Assign the measure-ment found in this step the label β.

5. Having obtained a β, use the purely classical procedure of continued fractions todeduce the period r. We have obtained a measurement from step 4 which we areconfident generates an integer near to a multiple of N

r , (given by β = j Nr + ε, where

ε is small compared with N). We are interested in finding r. We know N = 2n, soif we consider the fraction

β

N= j

Nr

1N

N

=jr+

ε

NIn the simplest case, r = 2R, so ε = 0, and this means that simply reducing thefraction β

N yields a fraction which we can see as being jr , and we can read the

denominator as the period r we’re interested in. In general, this is not the case,so we must consider ε 6= 0. In this case we apply the method of continuouslyexpanding fractions. This is a purely classical mathematical argument, examinedwell by much of the literature on this topic, for instance in [16].

β

N=

jr+

ε

N

By fraction expansion, we may continuously change the fraction βN to reflect a

significant fraction, jr with some small correction, ε

N . We aim to calculate the signif-icant fraction and use it to read the denominator as the period r. We require thatr < M, so we terminate the procedure when the denominator of our ”significant”fraction exceeds M.

A general fraction expansion is given by

AB

= a0 +1

a1 +1

a2+1

...+ 1ap

(9.11)

51

Page 57: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

This is represented by AB = [a0; a1, a2, ..., ap]. The the qth convergent is an approxima-

tion for AB given by [a0, a1, ..., aq] for any 0 ≤ q ≤ p. For instance,

8570

= [1; 4, 1, 2] = 1 +1

4 + 11+ 1

1+ 12

= 1.214286

And if we take q1 corresponding to approximation using only one fraction, q1 =[1; 4], we would find

8370≈ q1 = [1; 4] = 1 +

14=

54=

q1,num

q1,den

Which is a fair approximation.

⇒ 8570

= 1.214286 =54− 0.035714

If we consider q2 = [1; 4, 1]

q2 = 1 +1

4 + 11

= 1 +15=

65= 1.2

⇒ 1.214286 =65+ 0.014286

So we can see that every time we boil the fraction down to the next value of q, thedominant fraction gets closer to the actual value and the correction becomes verysmall.

We are trying to generate a guess for our period r, but r < M, so we are onlyinterested in denominators of qi which are less than M. If we say qi =

qi,numqi,den

, welook for the first such qi,den to satisfy (qi,den < M < qi+1,den), and we try to completethe algorithm using r = qi,den.

Now, if we apply this to our situation: we have measured a β which we know tobe near a multiple of N

r . Take an explicit example, say N = 512 = 210, and that weare trying to factor M = 21. Suppose the output of the quantum implementationis β = 89.

β

N=

89512

= 0.173823 = [0; 5, 1, 3, 22]

= 0 +1

5 + 11+ 1

3+ 122

We calculate the values for qi

q0 = [0] = 0

52

Page 58: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

q1 = [0; 5] = 0 +15= 0.2

q2 = [0; 5, 1] = 0 +1

5 + 11

=16= 0.16667

q3 = [0; 5, 1, 3] = 0 +1

5 + 11+ 1

3

=1

5 + 43

=1234

=4

23= 0.173913

q4 = [0; 5, 1, 3, 22] = 0 +1

5 + 11+ 1

3+ 122

=89

512= 0.173823

Clearly, the highest qi,den < M is

(q2,den = 6) < (M = 21) < (23 = q3,den)

Thus we take r = 6 as our period and try to complete the algorithm using this.

One way to think of this is as

β =jr+

ε

N= α

jr

In our particular example, r = 6 and

β = 89 = 1(5126

) + 3.67

so j = 1.β

N=

89512

= 0.173828 = α016⇒ α0 = 1.042969

After the first expanded fraction we said that q1 = [0; 5]

⇒ 89512

= 0 +15= 0.2 = α1

jr= α1

16⇒ α1 = 1.2

Taking q2 = [0; 5, 1]

89512

= 0 +1

5 + 11

=16= α2

16⇒ α2 = 1

Note this is the case we’re looking for; we’ve boiled βN down to j

r . We now need toknow when we’ve gotten to this point in general.

q3 = [0; 5, 1, 3] = 0 +1

5 + 11+ 1

3

=4

23= α3

16⇒ α3 =

2423

At the point where the denominator of qi exceeds M, we must have passed the casewhere the denominator was the period r, since r < M, so we can read r from thedenominator of qi.

6. When r is odd, return to the start of the procedure using a different value for a.

7. When r is even, use a Euclidean algorithm to determine whether either of (ar2 + 1)

or (ar2 − 1) share a non-trivial factor with M. If so, we have found a factor of M.

53

Page 59: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

9.4.2 Summary of Shor’s Algorithm

In order to factorise an integer M, using n qubits where M2 ≤ 2n < 2 < M2:

1. Choose some random a, where 0 < a < M.

2. Generate a superposition1√2

N−1

∑x=0|x〉| f (x)〉

Where f (x) = axmod M. f (x) is periodic in r: f (x) = f (x + r).

3. Perform the quantum Fourier Transformation on the superposition.

4. Measure the system to obtain β = j Nr + ε, where we know that ε is either zero

or small compared to N. This concludes the quantum core of this algorithm, andfrom here onwards everything done is classical.

5. Use the continued fraction expansion on the value βN to determine a possible value

for the period r of f (x).

6. If r is odd, restart the algorithm with a new initial a.

7. If r is even, use the Euclidean algorithm to find common factors between (ar2 ± 1)

and M. If no nontrivial factor is found, return to the start of the algorithm.

9.4.3 Complete Example of Shor’s Algorithm

Let us demonstrate a complete run of Shor’s Algorithm for M = 35. To determine n:

M2 = 1225 < 2n < 2(1225)

is satisfied only for n = 11 : 1225 < 2048 < 2450. Then we have N = 2n = 2048.

1. Choose a = 6, and check that this is relatively prime to M:

gcd(35, 6) = 1

So we can continue with this choice.

2. f (x) = axmodM = 6xmod35. We now try to determine the period of f (x). Gener-ate the superposition

1√2048

2047

∑x=0|x〉| f (x)〉

Measurement on only the second register only forces the x values in the first regis-ter to become x + l.r, l ∈N:

C2047

∑x=0

g(x)|x〉| f (x)〉

54

Page 60: Mathematical_Introduction_to_Quantum_Computation

9.4. STEPS OF SHOR’S ALGORITHM CHAPTER 9. shor’s algorithm

with

g(x) =

{1 x = x0 + l.r0 x 6= x0 + l.r

We can now ignore the second register and focus only on the superposition

C2047

∑x=0

g(x)|x〉

3. Perform the quantum Fourier Transformation, yielding

QFT(C2047

∑x=0

g(x)|x〉) = C2

r−1

∑k=0

G(k)|k〉

4. Measure the system after this transformation. This will result in some β. Supposewe measure β = 206.

5. Computeβ

N=

2062048

=103

1024By continued fraction expansion this can be represented by

1031024

= 0 +1

9 + 11+ 1

16+ 16

We calculate the values of q for this fraction

q0 = [0] = 0

q1 = [0; 9] =19

q2 = [0; 9, 1] =1

10

q3 = [0; 9, 1, 16] =17

169

q4 = [0; 9, 1, 16, 6] =103

1024Considering the denominators of these shows that q2,den < M < q3,den holds:

10 < 35 < 169

So we proceed using r = q2,den = 10.

6. r is not odd, so we move to the next step.

55

Page 61: Mathematical_Introduction_to_Quantum_Computation

9.5. EFFICIENCY IMPROVEMENT CHAPTER 9. shor’s algorithm

7. r is even, so we compute (ar2 ± 1)

(6102 + 1) = (65 + 1) = 7777

(6102 − 1) = (65 − 1) = 7775

Then use the Euclidean algorithm to show that

m1 = gcd(7777, 35) = 7

m2 = gcd(7775, 35) = 5

Thus we have found 35 = m1.m2 = 7× 5, and we can verify that, for this simplecase, the algorithm works.

It is worth noting here that the period of ( f (x) = 6x mod 35) is in fact 2:

62 mod 35 ≡ 1

64 mod 35 ≡ 1...

610 mod 35 ≡ 1

Yet the algorithm still worked and found the correct factorisation for 35.

9.5 efficiency improvement

In order that we can understand the improvement offered by Shor’s factoring algo-rithm, we must consider how many steps it requires for its implementation, andcompare this with the number of steps a classical algorithm would take

9.5.1 Classical Factorisation

The general approach, [14], to finding a factor of M is to sequentially compute

M1

,M2

,M3

, ... ,M√M

In some cases, a suitable factor will appear very early in this procedure, but insome cases it could take all

√M attempts. On average, it is fair to say that it will

take√

M2 trials to identify a factor. Each iteration will have some time expense, we

will say as small as 10−12 seconds, so let us consider how many trials a realisticproblem would require and find how long it would take a classical computer tosolve this.

56

Page 62: Mathematical_Introduction_to_Quantum_Computation

9.5. EFFICIENCY IMPROVEMENT CHAPTER 9. shor’s algorithm

Example 9.3. If the number we wish to factorise, M, has, for instance, 77 digits, wecan sat that is of the order 2256 since 2256 = 1.15× 1077. Then

√M ∼ (2256)

12 = 2128

⇒√

M2∼ (2128)−1 = 2127Trials

In time, this will take

2127Trials× 10−12seconds per Trial

∼ 1026seconds

The universe is approximately 4× 1017 seconds old, so obviously trying to factorsuch a number is not achievable classically. The best known factoring algorithm,the number field sieve, [17] offers an improvement over this time scale, but not bynearly the same amount as the improvement offered by quantum computing, [18].

9.5.2 Quantum Factoring Algorithm

The most demanding part of the algorithm is the modular exponentiation required togenerate the calculation of f (x) = ax mod M inside the state. §6.4 of [11] discussesthis generation in detail, and Shor shows that it can be most efficiently achieved inO(n2 log2 n log2 log2 n) time steps, where n is the number of qubits involved inthe system [19]. (Recall N = 2n)

Rieffel and Polak also discuss the number of steps required of each section ofthe algorithm as outlined here, §8.4 of [11]. Clearly the most computationallyexpensive calculation is that of modular exponentiation, which we have seen tocost of the order (n2 log2 n log2 log2 n) in time.

Again aiming to factorise a number of the order 2256, we must first find what sizeof a system (number of qubits) would be required. This is determined by

M2 ≤ 2n ≤ 2M2

⇒ 2512 ≤ 2n ≤ 2513

In general M will not be a power of two, and there will be only one such n to satisfythis condition. It suffices here to choose n = 512. The majority of the computationis due to the modular exponentiation, so we must calculate O(n2 log2 nlog2log2 n)to get an idea of how many steps are needed.

n = 512⇒ log2n = log2(29)

⇒ log2 n = 9

57

Page 63: Mathematical_Introduction_to_Quantum_Computation

9.5. EFFICIENCY IMPROVEMENT CHAPTER 9. shor’s algorithm

⇒ log2 log2 n = log2(9) ≈ 3

⇒ n2 log2 n log2 log2 n = (512)2 × 9× 3

= 7, 077, 888 Trials

⇒ Time = (7, 077, 888 Trials)× (10−12 seconds per Trial)

= 7× 10−6seconds

This is clear evidence that Shor’s Algorithm is definitively faster than any classicalalgorithm can ever achieve.

Thus, we have given a concrete example of a case where quantum computing canbe implemented to solve a real problem which cannot be efficiently dealt withby a classical computer. There are, however, many other promising applications,such as the needle-in-the-haystack problem addressed by Grover’s Algorithm, [20].There is potential to model quantum chemistry far more accurately than is done atpresent by modelling chemical bonds at quantum levels through use of quantumcomputation, [21]. Such modelling currently occupies a huge amount of computa-tional resources worldwide in trying to achieve accurate models at quantum scales.It is thought that quantum computers may be able to save resources and help inthe modelling of specific chemical bonds at quantum levels, [22], and thereforehelp in the development of more effective medicines. These are only some of thevast possible applications of the technology, and so it is clear that there is suffi-cient motivation for the field to develop and to potentially shape the technologicallandscape over the coming years and decades.

58

Page 64: Mathematical_Introduction_to_Quantum_Computation

10

C O N C L U S I O N

The aim of this thesis was to bring the reader from little or no knowledge of quantumcomputation to a point of understanding of the fundamental mathematics and quantummechanics involved in describing the subject.

To achieve this, we examined What the subject considers: the use of linear algebrato describe physics at the smallest possible scales through the formulation of quantummechanics. The combination of this quantum mechanics with a basic concept in com-puter science, the unit of communication, the bit, lead us to a new building block forcomputation, the qubit.

We considered How qubits could be manipulated uniquely to achieve computationalresults not available to classical bits. This involved equating quantum operations withquantum analogues to logic gates, which were then combined to form quantum circuits.We then discussed the uniquely quantum property of parallelism to examine how wemay take advantage of the superposition of states inherent to quantum mechanics, andhow we can build useful subroutines to simplify larger algorithms.

Finally we thought about Why this is such an area of interest at present by consideringwhat real-world application can be achieved by a quantum computer that would notbe as easily or efficiently achievable using only classical technology. Shor’s Algorithmprovided a clear mathematical problem, of factorising large numbers, which has beenpuzzling mathematicians for decades, and which can be handled by a quantum machinein significantly less time than it can be on a standard computer.

Overall then, we have provided motivation and means for why quantum computa-tion is well placed to be a driving force in research in the coming decades. Our focushere has been on conceptual mathematical proofs rather than physical challenges to theconstruction of such machines, or of approaching the topic from a computer science per-spective and rigorously calculating efficiency in the number of space and time requiredto carry out computations. This has lead us to an understanding of why, mathematicallyat least, quantum computation holds huge promise for the future.

59

Page 65: Mathematical_Introduction_to_Quantum_Computation

B I B L I O G R A P H Y

[1] Yu I Manin. Vychislimoe i nevychislimoe (computable and noncomputable),moscow: Sov, 1980.

[2] Richard P Feynman. Simulating physics with computers. International journal oftheoretical physics, 21(6):467–488, 1982.

[3] Paul Benioff. Quantum mechanical hamiltonian models of turing machines. Journalof Statistical Physics, 29(3):515–546, 1982.

[4] David Deutsch. Quantum theory, the church-turing principle and the universalquantum computer. In Proceedings of the Royal Society of London A: Mathematical,Physical and Engineering Sciences, volume 400, pages 97–117. The Royal Society, 1985.

[5] David Deutsch and Richard Jozsa. Rapid solution of problems by quantum compu-tation. Proceedings of the Royal Society of London. Series A: Mathematical and PhysicalSciences, 439(1907):553–558, 1992.

[6] Peter W Shor. Algorithms for quantum computation: Discrete logarithms and fac-toring. In Foundations of Computer Science, 1994 Proceedings., 35th Annual Symposiumon, pages 124–134. IEEE, 1994.

[7] Michael A Nielsen and Isaac L Chuang. Quantum computation and quantum informa-tion. Cambridge university press, 2010.

[8] Charles H Bennett, Gilles Brassard, Claude Crepeau, Richard Jozsa, Asher Peres,and William K Wootters. Teleporting an unknown quantum state via dual classicaland einstein-podolsky-rosen channels. Physical review letters, 70(13):1895, 1993.

[9] WK Wooters and WK Zurek. Quantum no-cloning theorem. Nature, 299:802, 1982.

[10] Mark M Wilde. Quantum information theory. Cambridge University Press, 2013.

[11] Eleanor G Rieffel and Wolfgang H Polak. Quantum computing: A gentle introduction.MIT Press, 2011.

[12] Bernard J. Fino and V. Ralph Algazi. Unified matrix treatment of the fast walsh-hadamard transform. IEEE Transactions on Computers, 25(11):1142–1146, 1976.

[13] Daniel R Simon. On the power of quantum computation. SIAM journal on computing,26(5):1474–1483, 1997.

[14] John M Pollard. A monte carlo method for factorization. BIT Numerical Mathematics,15(3):331–334, 1975.

[15] Isaac Chuang, Raymond Laflamme, P Shor, and W Zurek. Quantum computers,factoring, and decoherence. arXiv preprint quant-ph/9503007, 1995.

[16] C Lavor, LRU Manssur, and R Portugal. Shor’s algorithm for factoring large integers.arXiv preprint quant-ph/0303175, 2003.

60

Page 66: Mathematical_Introduction_to_Quantum_Computation

BIBLIOGRAPHY BIBLIOGRAPHY

[17] Arjen K Lenstra, Hendrik W Lenstra Jr, Mark S Manasse, and John M Pollard. Thenumber field sieve. Springer, 1993.

[18] Shah Muhammad Hamdi, Syed Tauhid Zuhori, Firoz Mahmud, and Biprodip Pal.A compare between shor’s quantum factoring algorithm and general number fieldsieve. In Electrical Engineering and Information & Communication Technology (ICEEICT),2014 International Conference on, pages 1–6. IEEE, 2014.

[19] Peter W Shor. Polynomial-time algorithms for prime factorization and discrete log-arithms on a quantum computer. SIAM journal on computing, 26(5):1484–1509, 1997.

[20] Lov K Grover. A fast quantum mechanical algorithm for database search. In Pro-ceedings of the twenty-eighth annual ACM symposium on Theory of computing, pages212–219. ACM, 1996.

[21] Benjamin P Lanyon, James D Whitfield, GG Gillett, Michael E Goggin, Marcelo PAlmeida, Ivan Kassal, Jacob D Biamonte, Masoud Mohseni, Ben J Powell, Marco Bar-bieri, et al. Towards quantum chemistry on a quantum computer. Nature Chemistry,2(2):106–111, 2010.

[22] Christof Zalka. Simulating quantum systems on a quantum computer. Proceedingsof the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences,454(1969):313–322, 1998.

61