Download Quantum Computation and Algorithms

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Topological quantum field theory wikipedia , lookup

Renormalization group wikipedia , lookup

Renormalization wikipedia , lookup

Instanton wikipedia , lookup

Bell test experiments wikipedia , lookup

Basil Hiley wikipedia , lookup

Quantum dot cellular automaton wikipedia , lookup

Bohr–Einstein debates wikipedia , lookup

Relativistic quantum mechanics wikipedia , lookup

Double-slit experiment wikipedia , lookup

Delayed choice quantum eraser wikipedia , lookup

Particle in a box wikipedia , lookup

Scalar field theory wikipedia , lookup

Theoretical and experimental justification for the Schrödinger equation wikipedia , lookup

Quantum decoherence wikipedia , lookup

Max Born wikipedia , lookup

Quantum field theory wikipedia , lookup

Copenhagen interpretation wikipedia , lookup

Measurement in quantum mechanics wikipedia , lookup

Quantum dot wikipedia , lookup

Bell's theorem wikipedia , lookup

Hydrogen atom wikipedia , lookup

Quantum entanglement wikipedia , lookup

Density matrix wikipedia , lookup

Coherent states wikipedia , lookup

Quantum fiction wikipedia , lookup

Path integral formulation wikipedia , lookup

Many-worlds interpretation wikipedia , lookup

Probability amplitude wikipedia , lookup

Orchestrated objective reduction wikipedia , lookup

Symmetry in quantum mechanics wikipedia , lookup

History of quantum field theory wikipedia , lookup

Quantum electrodynamics wikipedia , lookup

EPR paradox wikipedia , lookup

Interpretations of quantum mechanics wikipedia , lookup

Quantum group wikipedia , lookup

Quantum machine learning wikipedia , lookup

Quantum key distribution wikipedia , lookup

Hidden variable theory wikipedia , lookup

Quantum cognition wikipedia , lookup

Quantum state wikipedia , lookup

Canonical quantization wikipedia , lookup

Quantum computing wikipedia , lookup

Quantum teleportation wikipedia , lookup

T-symmetry wikipedia , lookup

Transcript
Quantum Computation and Algorithms
M.Sc. Project Report
Submitted in partial fulfillment
of the requirements of
the degree Master of Science
By
Debasis Sadhukhan
Student (M.Sc. 2nd year)
Roll no.: 10512029
Under The Guidance of:
Prof. T. A. Tulsi
DEPARTMENT OF PHYSICS
INDIAN INSTITUTE OF TECHNOLOGY, BOMBAY
AUTUMN SEMESTER
NOVEMBER, 2011
PROJECT CERTIFICATE
…………………………………………………………………………………………………..
Department of Physics, Indian Institute of Technology, Bombay
This is to certify that the Project work ‘Quantum Computation and Algorithm’ is done
under my supervision at Dept. of Physics, IIT Bombay by Debasis Sadhukhan (Roll No.10512029) in Autumn Semester,2011 has been found satisfactory.
This report had not been submitted for any other examination and does not form a part
of any other course undergone by the candidate.
___________________________________
Date:
Signature
Project Guide
Acceptance Certificate
……………………………………………………………………………………………….
Department of Physics, Indian Institute of Technology, Bombay
This M.Sc. project report entitled “Quantum Computation and Algorithms” submitted by
Debasis Sadhukhan (Roll No-10512029) may be accepted.
___________________________________
Date:
Project Guide
_____________________________________
Date:
Examiner
___________________________________
Date:
Chairman
Declaration
……………………………………………………………………
I, hereby, declare that this written submission represents my ideas in my own words and where
other ideas and words have been included; I have adequately cited and referenced the original
sources. I also declare that I have adhered to all principles of academic honesty and integrity and
have not mispresented or fabricated or falsified any idea/data/fact/source in my submission. I
understand that any violation of the above will be cause for disciplinary action by the institute
and can also evoke penal action from the sources which have thus not been properly cited or
from whom proper permission has not been taken when needed.
________________________________________
Date:
Signature
(Name: Debasis Sadhukhan)
(Roll no.- 10512029)
Acknowledgement
At first and foremost I would like to express my sincere gratitude and humble respect to my
project guide Prof. T. A. Tulsi for his valuable guidance and encouragement throughout my
work. I also wish to acknowledge the helping hand of some of my friends Sudipto Singha Roy,
Sk Javed Rana and Ritwik Mondal.
________________________________________
Date:
Signature
(Name: Debasis Sadhukhan)
(Roll no.- 10512029)
Contents
1 Introduction and Background
1.1 Introduction . . . . . . . . . . . . .
1.2 Algorithms and their classes . . . .
1.3 Basics of Quantum Computation .
1.3.1 The Qubit . . . . . . . . . .
1.3.2 Bloch Sphere Representation
1.3.3 Multiple Qubit . . . . . . .
1.4 Entangled State and Product State
.
.
.
.
.
.
.
2
2
2
3
3
4
4
5
.
.
.
.
.
.
6
6
6
7
8
9
10
.
.
.
.
.
11
12
14
16
16
18
4 Quantum Search Algorithm
4.1 Unsorted Database Search Problem . . . . . . . . . . . . . . .
4.2 Grover’s Quantum Search Algorithm . . . . . . . . . . . . . .
4.2.1 Mathematical Description of the Search Problem . . .
19
19
21
21
2 Quantum Circuits
2.1 Quantum Algorithm . . . . . .
2.2 Operators: Quantum Gates . .
2.2.1 Single Qubit Operations
2.2.2 Controlled Operations .
2.3 Measurement . . . . . . . . . .
2.4 Universal Quantum Gates . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3 Shor’s Algorithm
3.1 The Quantum Fourier Transform(QFT) . .
3.2 Phase Estimation . . . . . . . . . . . . . .
3.3 Application . . . . . . . . . . . . . . . . .
3.3.1 Quantum Order-finding Algorithm
3.3.2 Quantum Factoring Algorithm . . .
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4.3
4.4
4.2.2 The Operations . . . . . . .
4.2.3 Geometric Visualization . .
4.2.4 Example: . . . . . . . . . .
4.2.5 Drawback . . . . . . . . . .
Quantum Counting . . . . . . . . .
Optimality of the Search Algorithm
2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
22
25
27
29
30
31
Abstract
In Quantum Algorithms, we use the mathematical framework of quantum
mechanics. It is a new paradigm created by reformulating information and
computation in a quantum mechanical framework. There are many problems
that are considered to be hard to solve with classical algorithm. As of now,
some of this problems has been demonstrated to have efficient solution in
quantum computer. In this report, we have studied the implementation and
applications of Shor’s prime factorization algorithm and Grover’s quantum
search algorithm.
Chapter 1
Introduction and Background
1.1
Introduction
Quantum Computation and Quantum Information is the study of information processing using quantum mechanical systems. In other words,
quantum computing is a new computational paradigm created by reformulating information and computation in a quantum mechanical framework[3].
Now, quantum mechanics is a mathematical framework or a set of rules
that helps us to construct physical theories. Here, we have used quantum
mechanics to build a physical theory that will be applicable for a quantum
computer. A quantum computer is a device that can perform quantum information processing. We can use a nice analogy to represent the relationship
between quantum mechanics and physical theories. The relationship between
quantum mechanics and specific physical theories is like the relationship of
a computer’s operating system to specific application software, where the
operating system sets certain basic rules and modes of operations and the
application uses those to perform specific tasks. Similarly, here we will develop basic framework or set of rules that will be applicable for Quantum
Computation.
1.2
Algorithms and their classes
A computer is a physical device that helps us to process information by
executing algorithm. And an algorithm is a well-defined procedure or a set of
2
instructions to perform a information processing task. According to strong
Turing-Church thesis:
Any algorithmic process can be simulated efficiently using a probabilistic
Turing machine.
Here, the word efficiently classified the algorithms into two main complexity classes i.e. P and NP, where P stands for polynomial type and NP for
non-deterministic polynomial type. An algorithm will fall in the polynomial
type class if it has an efficient solution or in other words, if it runs in time
polynomial in the size of the problem solved. On the other hand, a NP class
algorithm does not have an efficient solution or requires super-polynomial
(typically exponential) time. For example, prime factorization of an integer
is NP type because no efficient solution is known for solving this problem.
Here comes the power of quantum computers. Deutch first showed by a
simple example that there may exist efficient solution in quantum computer
for a classically classified NP problem. In 1994, Peter Shor demonstrated that
prime factorization have efficient solution in quantum computation. But only
a few NP class problems can be solved efficiently in a quantum computer.
There are plenty of NP class problem for which no efficient algorithm is
known even in quantum computation. We do not know whether we can find
out an efficient solution for them or not. So, though it is clear that P is a
subset of NP but whether P 6= NP or P = NP is still a question to many of
the computer scientists.
1.3
1.3.1
Basics of Quantum Computation
The Qubit
Qubit is the quantum mechanical version of a classical bit i.e. 0 and
1. In quantum computation we have described we describe the {0,1} with
{|0i , |1i}, which is called computational basis.
An arbitrary state in this computational basis will be:
|ψi = α |0i + β |1i
3
(1.1)
where, α, β are complex numbers, with |α|2 + |β|2 = 1
1.3.2
Bloch Sphere Representation
Bloch sphere representation is the geometric representation of an arbitrary
state |ψi in the computational basis. Notice that, every normalized state has
amplitude 1. So, all the normalized states can be represented as a point on
a Bloch Sphere of unit radius as shown in Figure 1.1.
Figure 1.1: Bloch Sphere Representation of Qubit.
We can rewrite Equation 1.1 as,
θ
θ
|ψi = eiγ cos |0i + eiφ sin
2
2
θ
θ
= cos |0i + eiφ sin
2
2
(1.2)
(1.3)
as the overall phase does not change anything.
1.3.3
Multiple Qubit
Like classical bits (00, 01, 10, 11), we have quantum bits |00i , |01i , |10i , |11i
to denote a two qubit system. Here, |abi denotes the tensor product (|ai⊗|bi)
4
The most important two qubit state is the Bell state:
|00i + |11i
√
;
2
|01i + |10i
√
;
|β01 i =
2
|00i − |11i
√
|β10 i =
;
2
|01i − |10i
√
|β00 i =
.
2
|β00 i =
1.4
(1.4)
(1.5)
(1.6)
(1.7)
Entangled State and Product State
The two qubit states can be classified in to two classes i.e. product states
and entangled state.
If a state α |abi+β |cdi can be written as α0 |ai+β 0 |bi ⊗ α00 |ci+β 00 |di
or any other combination (tensor product) of two such state, then the combine state is known as product state. Otherwise this is entangled state.
Entanglement play a very important role in quantum information theory.
With the help of entanglement we can achieve many goals in quantum information theory, like superdense coding, quantum teleportatation, which are
impossible classically.
5
Chapter 2
Quantum Circuits
2.1
Quantum Algorithm
In Quantum Algorithm, we developed some algorithms that uses quantum mechanical principles at the time of it’s execution1 . But, designing a
quantum algorithm is hard compared to a classical algorithm. Because our
intuition lies in the classical world. So, when we used our intuition to develop
an algorithm, then we come up with a classical idea. The second challenge
is our quantum algorithm has to be better than the best known algorithm
in classical world. That is why only a few number of algorithms has been
discovered so far.
2.2
Operators: Quantum Gates
The execution of an classical algorithm require hardware (basically classical computer) which is consist of many electrical circuits containing wires
and logic gates. These logic gates are the basic building block of classical
computer.
Similarly, to execute a quantum algorithm we must have a quantum computer where the building blocks are quantum gates. Now, what is special
about quantum gates that make it different from classical gates. Well, the
1
Note that for execution of an quantum algorithm, we must need a quantum computer
to execute the algorithm.
6
laws of quantum mechanics has to be applicable in quantum gates. That is
why the gates must be reversible. But we know that the classical gates e.g.
AND, OR, NAND, etc. are not in general reversible. So, these gates can not
be used in quantum circuitry. We will describe about the reversibility of the
quantum gates in Section 2.2.2
2.2.1
Single Qubit Operations
A single qubit can be represented as |ψi = a |0i + b |1i in the computational basis, that is parametrized by by two complex number satisfying
|a|2 + |b|2 = 1.. Operation on a qubit must preserve the norm the state as
per the requirement of quantum mechanics. This implies our operators must
be 2 × 2 unitary matrices.
The most important operators are Pauli matrices.
0 1
0 −i
1 0
1 0
X≡
;Y ≡
;Z ≡
;I ≡
1 0
i 0
0 −1
0 1
(2.1)
There are three other quantum gates (Hadamard(H), phase gate(S), and ( π8 )
gate (T)) which plays important role in quantum circuits.
1 1 1
1
0
1 0
H≡√
;S ≡
;T ≡
(2.2)
0 i
0 eiπ/4
2 1 −1
We can also generate rotation operators about the x̂, ŷ, ẑ using this Pauli
matrices.
θ
θ
cos 2θ
−i sin 2θ
−iθX/2
(2.3)
Rx (θ) ≡ e
= cos I − i sin X =
cos 2θ
−i sin 2θ
2
2
θ
θ
cos 2θ − sin 2θ
−iθY /2
Ry (θ) ≡ e
= cos I − i sin Y =
(2.4)
sin 2θ cos 2θ
2
2
" θ
#
−i
2
θ
θ
e
0
Rz (θ) ≡ e−iθZ/2 = cos I − i sin Z =
(2.5)
θ
2
2
0 ei 2
These are the elementary building blocks of a quantum circuit. With this
elementary gates we can produce any operator by using combination of these
gates.
7
2.2.2
Controlled Operations
But still we have a problem to use these gates can not be used in quantum
circuits. After applying this gate on a two qubit state we can not get back
our previous state. Here we use a simple trick to make this computation
reversible.
We introduced one extra qubit, known as control qubit to control our
operation2 . For example to execute the NOT gate operation, we add an
control bit to the Pauli X gate. We named it CNOT operation. CNOT is
a two qubit operation with one target qubit and one control qubit, resulting
|ci |ti → |ci |t ⊕ ci, as shown below:
Figure 2.1: Circuit representation of Controlled-NOT gate.
The matrix representation of CNOT is:


1 0 0 0
0 1 0 0


0 0 0 1
0 0 1 0
(2.6)
So, will introduce an ancilla qubit every time with any quantum operator
for reversible computing.
Note:
The target and control qubit are not basis independent i.e. our target and
control qubit may change if we use a different basis({|+i , |−i}, {|0i , |1i},
etc.)
2
‘If A is true then do B’ is a kind of controlled operation.
8
2.3
Measurement
Quantum Measurement is the last element we need in quantum circuits.
There are two main principle in Quantum Measurements.
The first one is that classically conditioned operation can be replaced by
quantum controlled operations:
Principle of deferred measurement: Measurements can always be
moved from an intermediate stage of a quantum circuit to the end of the
circuit; if the measurement results are used at any stage of the circuit then
the classically controlled operations can be replaced by conditional quantum
operations.
For example in the quantum teleportation circuit if we perform the measurements at the end , instead of middle in the circuit the overall action of
the quantum circuit will not change3 .
Figure 2.2: Quantum teleportation circuit where measure are done at the
end.
Principle of implicit measurement: Without loss of generality, any
unterminated quantum wires (qubits which are not measured) at the end of a
quantum circuit may be assumed to be measured.
3
Of course, the “teleportation” operation of the circuit is lost because no classical
information is transmitted from Alice to Bob.
9
Suppose we have two qubits and the first qubit is only measured at the
end. Here, the measurement statistic observed at this time will be determined
by the reduced density matrix of the first qubit. Now, it can be shown that
the measure on the second qubit will not affect the reduced density matrix
of the first qubit. So, we can assume that qubit to be measured.
2.4
Universal Quantum Gates
In classical computation, we have seen NAND and NOR gate as a universal gates. A similar universality is true for quantum computation also. As
described in this chapter, every classical gates can be created using unitary
quantum gates. In that sense quantum circuits include all the classical circuits. So, universality of quantum gates is obvious from this. The Hadamard
gate, phase gate, CNOT gate and π/8 gate are universal for quantum computation. So, any unitary operation on q qubits may be implemented exactly
by composing single qubit and controlled NOT gates.
10
Chapter 3
Shor’s Algorithm
Now a days, our everyday life is very deeply involved with the e-commerce
system. Now, when we transacting through Internet we may have seen the
connection is ‘SSL1 Certified’, written at the bottom of the website. This
provides the security of the Website.
Primarily, they have used prime factorization of a very large number
for encryption. Classically to find the prime factor of a very large number is considered to be very hard and this falls under NP complexity class.
For example, the best known classical algorithm(number field sieve) require
exp (Ω(n1/3 log2/3 n)) operation to find the prime factor of a n-bit integer.
In 1994, Peter Shor demonstrate a quantum algorithm that runs in polynomial time i.e exponentially faster than the best known classical algorithm.
This comes in the complexity class BQP.
With sufficient number of qubits, Shor’s prime factorization algorithm can
be used to break the RSA2 cryptosystem, that is based on the assumption
that factoring large numbers is computationally infeasible and this is true
for classical computer. But if Shor’s algorithm can be implemented we can
efficiently solve the prime factorization problem. So, we can break RSA!
1
Secure Sockets Layer (SSL) technology secures the Web site by encrypting information
and providing authentication. VeriSign is one of the provider of SSL Certificates.
2
RSA is a public key cryptography system named after Ronald Rivest, Adi Shamir and
Leonard Aldeman.
11
3.1
The Quantum Fourier Transform(QFT)
Classically, in a discrete Fourier transform with the input of a vector
of complex numbers x0 , · · · , xN −1 , we get a output of a vector of complex
numbers y0 , · · · , yN −1
N −1
1 X
yk ≡ √
xj e2πijk/N
N j
(3.1)
where N is the length of the vector.
Similarly, the Quantum Fourier transform on an orthonormal basis |0i , · · · , |N − 1i
defines as,
N −1
1 X 2πijk/N
e
|ki
|ji ≡ √
N j
(3.2)
Also, this action on arbitrary state may be written as,
N
−1
X
xj |ji →
j=0
N
−1
X
xk |ki
(3.3)
k=0
here, amplitude yk is the direct Fourier transform of xj .
Let us take N = 2n , where n is some integer, and the basis |0i , · · · , |2n − 1i
is the computational basis for an n-qubit quantum computer. We use the
binary representation j = j1 j2 · · · jn to represent |ji. We know that,
jl jl+1
jm
0.jl jl+1 · · · jm = +
+ · · · + m−l+1
(3.4)
2
4
2
Now,
n
|ji →
=
=
2 −1
1 X
2n/2
1
2n/2
1
2n/2
k=0
1
X
e2πijk/N |ki
···
k1 =0
1
X
k1 =0
1
X
e2πij(
(3.5)
Pn
l=1
kl 2−l )
|k1 k2 · · · kn i
(3.6)
kn =0
···
1
X
−l
⊗nl=0 e2πijkl 2 |kl i
kn =0
12
(3.7)
=
1
2n/2
⊗nl=0
1
hX
−l
e2πijkl 2 |kl i
i
kn =0
(3.8)
=
1
2n/2
h
i
−l
⊗nl=0 |0i + 22πij2
|0i + e2πi0.jn |1i
=
(3.9)
|0i + e2πi0.jn−1 jn |1i · · · |0i + e2πi0.j1 j2 ···jn |1i
2n/2
(3.10)
To design this QFT, we use the following circuit.
Figure 3.1: Schematic diagram of the QFT circuit.
Here, Rk denotes
1
0
Rk ≡
k
0 e2πi/2
(3.11)
Working Principles of QFT Circuit
After applying Hadamard to the first qubit |j1 j2 · · · jn i changes to √12 |0i +
e2πi0.j1 |1i |j2 · · · jn i. Now, after the controlled R2 operation the state becomes
1 √ |0i + e2πi0.j1 j2 |1i |j2 · · · jn i
(3.12)
2
13
Similarly, after the Rn gate this state becomes
1 2πi0.j1 j2 ···jn
√ |0i + e
|1i |j2 · · · jn i
2
(3.13)
We will do a similar operation on the second qubit. So after applying
Hadamard and the controlled R2 through Rn−1 , the state becomes
1 2πi0.j1 j2 ···jn
2πi0.j2 ···jn
|0i
+
e
|1i
|0i
+
e
|1i
|j3 · · · jn i
(3.14)
22/2
Similarly the final state will be
1 2πi0.j1 j2 ···jn
2πi0.j2 ···jn
2πi0.jn
|0i
+
e
|1i
|0i
+
e
|1i
·
·
·
|0i
+
e
|1i
2n/2
(3.15)
Now, we need a swap operation to get our desired output to perform QFT
as described in Equation 3.10. In this circuit, we have used a total of n gates
for the first qubit, (n-1) gates for the second qubit and so on. So, total gate
required is n + (n − 1) · · · + 1 = n(n − 1)/2. At most n/2 swap operation is
required and each swap need 3 CNOT gate. So, this circuit provide Θ(n2 )
algorithm to perform QFT which is exponentially faster than the best known
classical algorithm that require Θ(n2n ) gates.
3.2
Phase Estimation
The QFT, described above can be used to determine the unknown phase
of a eigenstate |ui of a unitary operator U , whose eigenvalue is e2πiφ . Let us
take b(0 ≤ b ≤ 2t − 1) such that b/2t = 0.b1 b2 · · · bt is the best t-bit approximation of φ. t mainly depends on our desired accuracy of φ and the desired
probability of success.
The procedure consist of two two registers: the first with t-qubit in |0i
state and the second is |ui The circuit is shown in Figure 3.2.
Similarly as QFT circuit, the final state of the first state will be:
1 2πi2t−1 φ
2πi2t−2 φ
2πi20 φ
|0i
+
e
|1i
|0i
+
e
|1i
·
·
·
|0i
+
e
|1i
2t/2
2t −1
1 X 2πiφk
= t/2
e
|ki (3.16)
2 k=0
14
Figure 3.2: Schematic diagram of the first stage Phase Estimation circuit.
Now, we need to apply a inverse Fourier transform on the first register to
produce the state
t
2 −1
1 X −2πikl/2l 2πiφk
e
e
|li
2t k,l=0
(3.17)
The entire circuit to perform phase estimation is shown in Figure 3.3
Figure 3.3: Schematic diagram of Phase Estimation procedure.
Here, we approximate φ to an accuracy 2−n . It can be shown that to successfully obtain φ accurate to n bits with probability of success at least (1 − )
15
we need to choose
3.3
3.3.1
l
1 m3
t = n + log 2 +
2
(3.18)
Application
Quantum Order-finding Algorithm
Order finding and factoring is the most useful aspect of QFT. The order
of a positive number x modulo N , is defined to be the least positive , r,
such that xr = 1. Now, Order-finding is believed to be a hard problem on
a classical computer, as no algorithm is known to solve the problem using
resources
polynomial
in the O(L) bits needed to specify the problem, where
l
m
L = log N is the number of bits needed to specify N .
We will apply phase estimation algorithm to the unitary operator U to
find the order,
U |yi ≡ |xy(
mod N )i
with
y {0, 1}L
(3.19)
We know that the eigenstate states of U are
r−1
1 X
exp − 2πisk/r xk
|us i ≡ √
r k=0
mod N
(3.20)
where 0 ≤ s ≤ r − 1
r−1
1 X
U |us i = √
exp − 2πisk/r xk+1
r k=0
h 2πis i
= exp
|us i
r
mod N
(3.21)
(3.22)
Now, using phase
procedure, we can determine the corresponding
h estimation
i
2πis
eigenvalues exp r , from which we can obtain the order r.
Now we need to implement the controlled-U operation for any integer j.
For this we use modular exponential4 procedure. We use the phase estimaj
tion procedure to implement the entire sequence of controlled-U 2 operations
3
4
Please refer Section 5.2.1 of Reference 1 for a detailed proof.
For detail, please refer Box 5.2 of Reference 1.
16
using O(L3 ) gates.
But phase estimation require that we should know r to prepare |us i. That
is the main problem in phase estimation. We can overcome that problem
using
r−1
1 X
√
|us i = |1i
(3.23)
r k=0
m
l
1
qubit for the first register and the
Choosing t = 2L + 1 + log 2 + 2
second register in state |1i, we can obtain an estimate of φ = s/r accurate
to 2L + 1 bits, with probability at least (1 − r)/r for each s. This is shown
in Figure 3.4
Figure 3.4: Schematic diagram of Order finding procedure.
With this we have found φ = s/r. But our desired answer is r. Note that
r is known up to 2L + 1 bits. But in general φ is a rational number-the ratio
of two bounded integer. We will try to compute the nearest such fraction to
compute φ using continued fraction algorithm5 .
If continued fraction algorithm produces s0 and r0 with no common factor.
0
Then s0 /r0 = s/r. Next we check whether xr mod N = 1 or not? If yes,
then we have found our desired no r.
Problem may arise if r0 and s0 have common factor. we have chosen r
randomly in 0 to r − 1.Then the number r0 returned by the continued frac5
Refer Box 5.3 of Reference 1.
17
tion algorithm be a factor of r. In that case we will not get the correct answer.
But, it can be shown that the no of prime numbers less than r is at least
r/2 log r. So the chance that s is prime is at least 1/2 log r > 1/2 log N .
Thus iterating the oracle 2 log N times we can get φ = s/r with very high
probability such that s and r are co prime.
3.3.2
Quantum Factoring Algorithm
We can find the prime factor of an integer N slightly modifying orderfinding algorithm. We can find a factor of N if we can find a non-trivial
solution (i.e. x 6= ±1( mod N )) to the equation x2 = 1( mod N ). Then,
we choose any y that is co-prime to N such that y r/2 6= ±1( mod N ). Thus
x ≡ y r/2 ( mod N ) is a non-trivial solution to x2 = 1( mod N ). We have
described the algorithmic process in the below:
First, we need to check whether N is even. If yes then return the factor
2. Now determine whether N = ab where a ≥ 1 and b ≥ 2. If so, return
the factor a. Next we need to check for any x (1 ≤ x ≤ N − 1), whether
gcd(x, N ) > 1. If yes return gcd(x,N). Up to this we can perform this efficiently in classical computer.
Next we need to find out the order (r) of x mod N. We use the orderfinding algorithm to estimate r. Now if r is even and xr/2 6= −1 mod N ,
then compute gcd(xr/2 − 1, N ) and gcd(xr/2 + 1, N ) and check if this is a
non-trivial factor, returning that factor if so. Otherwise the algorithm fails.
It can be shown that the prime factors of an L-bit integer can be determined in O(L3 ) operations. So, we can get our solution in polynomial time
which is exponentially faster than the best known classical algorithm.
With this tool we can break the RSA cryptosystem in which it is assumed
that prime factorization of a large number can not be done efficiently6 . So,
if Quantum Computer is discovered, then RSA cryptography will not work
anymore !
6
By this time, this is true for any classical computer.
18
Chapter 4
Quantum Search Algorithm
When we need some information about something that we do not know,
what do we do? The most obvious answer will be: Just search it in Google.
So, what is Google? Well, Google is a search engine that search for our
unknown word in their database and sort them according to relative importance with their PageRank algorithm. Their database consists of millions and
billions of information. So, primarily to search for a specific word in their
database, we need to go through every word in their database and check if
this is our required word or not?
4.1
Unsorted Database Search Problem
Now, let’s take a example that have relatively small database. Consider
a search engine within our IIT-B network.1 Suppose we have a database
consists of N words. Now, we want to search for a specific word say “Computation”. To do that we have to go through every word and check whether
this is “Computation” or not. For simplicity, let’s assume that the word
Computation occurs only once in the database of N words. So, if we are
lucky enough, we can find our solution i.e. the word Computation in the
very first chance. But for the worst case, we may find the word in the N th
chance. So, probabilistically we shall be able to find the solution in N2 no of
attempt.
1
We can always shorten the database using customized Google, by instructing Google
to search within “.iitb.ac.in” .
19
Now, we remove our assumption about non-degeneracy of our solution.
Now there are N words in our database out of which all the word Computation is our solution. Let’s say the word Computation occurs M times. So,
the size of the database is: N and out of which no of solution is: M .
So, probability of getting one of the M solution in one attempt is: p =
M
N
Notice that, in general M N , So, in this case p 1.
Now, let us find out: How many attempt we require to get the solution
with a very high probability?
N
), to get one
It turns out that we require no of chances of the order of ( M
of our solutions at least once in the entire attempts. We can prove this in
the following way:
Here, our probability of success is p. So, probability of failure is: (1 − p).
Let us assume we attempt n times to get the solution. So, probability of
failure in all the n attempt is : (1 − p)n .
Now, probability of success at least once in all the n attempt is: 1−(1−p)n
Now, for p 1, (1 − p) can be approximated as e−p .
So, Probability of success at least once is: P = 1 − (1 − p)n
= 1 − e−np
So, if np 1, i.e. n p1 , we can see, P ≈ 1.
N
Roughly speaking, if n ≈ O( p1 ) ≈ O( M
), we get our solution with sufficiently high probability.
N
So, approximately we require O( M
) trial to succeed with classical algo2
rithm . For M = 1, we require O(N ) trial to succeed.
2
With the best classical algorithm, to get a solution, we need at least O(N log N ) trials.
20
4.2
Grover’s Quantum Search Algorithm
Now, what we canqclaim from quantum mechanics is that we can get a
N
) trials. For example, if we have a database of one
solution with only O( M
6
million(10 ) words, out of which our solution is only one, then we require at
least one million trials to get the solution with high probability. But, with
quantum search algorithm we can get the solution in only thousand trials.
So, Grover’s algorithm performs the search quadratically faster than can be
done classically.
4.2.1
Mathematical Description of the Search Problem
Let us assume we have N words in our database. We named each of them
with a number which ranges from 0 to N − 1. For convenience we assume
N = 2n , so that the number can be written in n bits. For simplicity, we
assume that the database has M solution, where 1 ≤ M ≤ N . From now
and onwards we will call our solution to be target(t) and every element in
our database to be source(s)
Now we define a function corresponding to every word3 . Suppose for the
ith word, we define a function f (i), such that,
f (i) = 1
=0
f or
f or
i=t
i 6= t
(4.1)
Now, assume that we have a quantum oracle4 that will do the operation,
specified by the function f (i).
Now we know that to operate the function quantum mechanically, we
have to make reversible gates. That explains we must introduce some ancilla
3
Now, the n bit number, assigned to every word is the identity of the word.
Oracle is a black box that will perform some operation, but we don’t know it’s internal
hardware working principal.
4
21
bit. And also, the oracle must be a unitary operator as a prerequisite of a
quantum mechanical operator, whose action is described below:
Uf : |ii |qi → |ii |q ⊕ f (x)i
(4.2)
where, |ii is the index register, ⊕ denotes addition modulo 2, |qi is the ancilla
qubit, which is flipped if f (i) = 1 and is unchanged otherwise.
Figure 4.1: Schematic diagram of the operator Uf
Notice that, if we construct |qi such that |qif lipped = − |qi, then when
f (i) = 1, we can write |qi = (−1)f (i) |qi. An example of such |qi will be
|0i−|1i
√
. The action of the oracle is then:
2
Uf : |ii
|0i − |1i
|0i − |1i
√
= (−1)f (i) |ii √
2
2
(4.3)
Notice the ancilla bits remains unchanged. So, we can drop that part.
So, the oracle may be written as:
Uf : |ii = (−1)f (i) |ii
4.2.2
(4.4)
The Operations
To demonstrate the above operation, we begin our initial state with |0i⊗n .
Now we apply Hadamard gate5 on each state to get the uniform superposition
5
H
We know |0i −→
tion over all states.
|0i+|1i
√
.
2
⊗n
⊗n H
So, |0i
−−−→
22
|0i+|1i
√
2
⊗n
, which gives uniform superposi-
of all states.
n
|ψi =
2 −1
1 X
2n/2
|ii
(4.5)
i=0
Note that, here |ii is a n bit binary number, which corresponds to a decimal
number. For example for a three qubit state, possible |ii are |000i , |001i , |010i,
etc, which corresponds to |0i , |1i , |2i , etc.
Now, we will perform a conditional phase shift on every state, except our
target state |ti receiving a phase shift of −1. Firstly, let us assume that we
have only one solution i.e. only one target state |ti with no degeneracy. So,
our uniform superposition can be written as,
r
N −1
N −1
1
1 X
|ii = √ |ti +
|ψother i
(4.6)
|ψi = √
N
N i=0
N
We will now define a operator such that it will change the phase of |ti by
180◦ , leave all other state with no change. So, if the operator be It such that,
It : 1 − 2 |ti ht|
(4.7)
The operation of It on ψ is described below:
r
1
N −1
It |ψi = 1 − 2 |ti ht| √ |ti +
|ψother i
N
N
r
1
1
N −1
|ψother i − 2 √ |ti
= √ |ti +
N
N
N
Notice, ht| ψother i = 0, So, we can write |ψother i = |t⊥ i. So,
r
N −1
1
It |ψi = − √ |ti +
|t⊥ i
N
N
(4.8)
Now, if we have have M solution instead of one solution, the equation will
be,
r
r
M
N −M
It |ψi = −
|ti +
|t⊥ i
(4.9)
N
N
23
This action on each individual state can be described as:
I
t
→
−(−1)δi,t |ii
|ii −
(4.10)
Now, note that this is same as our required operator Uf as described in equation 4.4.
The action of It can be summarized as:
I
t
→
inverted.
Component parallel to |ti −
It
→
undisturbed.
Component perpendicular to |ti −
Now, we want another operator Is such that,
Is : 2 |si hs| − 1
(4.11)
where, |si denotes the source state, that can be written as H ⊗n |0i⊗n . The
action of the operator Is is described as,
Is |si = |si
Is |s⊥ i = − |s⊥ i
(4.12)
Now, Is can be written as,
Is = 2 |si hs| − 1
= 2H ⊗n |0 i⊗n h0 |⊗n H ⊗n − H ⊗n 1H ⊗n
= H ⊗n |0 i⊗n h0 |⊗n − 1 H ⊗n
= H ⊗n IOn H ⊗n
Now, we can write the Grover’s iteration operator as,
G = Is It
(4.13)
It = 1 − 2 |ti ht| ,
Is = 2 |si hs| − 1
(4.14)
(4.15)
Where,
24
Figure 4.2: Schematic diagram of the Grover’s operator G = Is It
Now, we need to operate the Grover’s operator many times to reach to
our target state. The number of iteration needed we will find out from the
geometric considerations.
4.2.3
Geometric Visualization
Let us start with the uniform superposition of all the n qubit states i.e. |si.
We will describe our two dimensional vector-space in terms of two orthogonal
basis out of which one is parallel to |ti and the other is perpendicular to |ti
i.e. along |t⊥ i.
Figure 4.3: Geometric visualization of the Grover’s operator G = Is It .
25
Let us assume |si makes angle θ with |t⊥ i. After operation of It , the
component of |si along |ti get flipped. So, It |si makes an angle 2θ with |si.
Now, Is will flip the component perpendicular to |si. So, Is It |si will now
make an angle 3θ with |t⊥ i.
Figure 4.4: The Grover iterate.
So, in one iteration we move an angle 2θ towards our desired state |ti.
Let’a say, after m iteration we will get our solution |ti, so
π
−θ
2
π
1
m=
−
4θ 2
m(2θ) =
So,
(4.16)
q
Now, from figure 4.2, we can see that , cos( π2 − θ) = sin θ = hs| ti = N1 for
q
one solution and M
for M solution. In general, N is very large compared
N
to M . So, we can assume that sin θ ≈ θ. Thus, no of iteration required is :
m=O
1
θ
=O
We can sumarize the search algorithm as,
26
r N M
(4.17)
Algorithm: Quantum Search Algorithm
1. Begin with the n-qubit state |000 · · · 0i.
2. Apply Hadamard on each state
prepare the uniform superposition of
PNto
−1
1
√
the n qubit states i.e. |ψi = N i=0 |ii .
3. Apply the Grover iterate G a total of π4 √1N times.
4. The resulting state will be our required solution state.
4.2.4
Example:
Let us start with the uniform superposition of all state say, |ψi =
P
N −1
Notice that H |00 · · · 0i has only real amplitudes and the
i=0 |ii.
Grover’s iterate does not introduce any complex phases, then the amplitudes
always remain real. So, we can represent the amplitude as lines above (for
positive amplitudes) or below (for negative amplitudes), as shown in figure
4.5. So, initially all the states has amplitude √1N . So, the mean value is √1N .
√1
N
So, our source state |si = √1N
P
|s0 i , where |s0 i = i ai |ii. So,
P
i
|ii upon action of It will produce It |si =
√
1 X
hs| s0 i = √
ai = N ā,
N i
as,
X
where, ā is the mean amplitude of |s0 i in {|ii}.
Now,
Is |si = 2 |si hs| − 1 |s0 i
= 2 |si hs| s0 i − |s0 i
√
= 2 N ā |si − |s0 i
X
=
2ā − ai |ii
ai = N ā
(4.18)
i
(4.19)
i
Let us take an example of this search algorithm. Suppose we have our
database consist of 8 words, out of which one is our solution. So, N = 8 and
M = 1. Let’s say 5th one is our solution. So, the amplitude of each source
state is 2√1 2 and the mean amplitude is also 2√1 2 .
27
Figure 4.5: Initial State
Figure 4.6: Example of It Operation
Figure 4.7: Example of Is Operation on It |si i.e. after one complete G
28
After the first operation by It , the amplitude of the target state will face
a 180o phase
shift. So,
it’s amplitude get reversed. So, the mean amplitude
7
1
1
√
√
become 8 2 2 − 2 2 = 8√3 2 as shown in figure 4.6.
The second operator Is will invert the |s0 i state about the mean position,
which nearly triples the size of the amplitude of our desired state and slightly
lowered the amplitudes of all other basis states, as illustrated in figure 4.7.
In our case, the new amplitude of Is |s0 i will be,
G |si = Is It |si = (2ā − ai )
3
1 =2 √ − − √
8 2
2 2
5
= √
4 2
So, in this way, after successive iterations, the amplitude of our desired
state get’s magnified and all other basis states get’s suppressed.
4.2.5
Drawback
We have described each source in our data base with a n bit binary number, where 2n = N. Now, for convenience, if we assume we have only one
solution, then we can guess the solution with probability 21n . That means we
will get the solution with a great probability if we take O(2n ) trials. For M
solutions also the number of trials will be of the same order.
But with the Quantum Searchq
we get
a quadratic speed up over the clasN
M
sical counterpart i.e. we need O
remains in NP class.
trials. But still the search problem
Notice that if we do not know the exact no of solutions i.e. M , we may
may not reach to our desired solution state as no of iteration explicitly depend
on M 6 .
6
No. of iteration required is O
q
N
M
.
29
4.3
Quantum Counting
To overcome this problem, we first need to estimate the no of solution
in our database. By combining the phase estimation technique with the
Grover’s algorithm we can count the no of solution state in our database. By
estimating the the eigenvalues of the Grover’s iteration G, we can determine
the no of solution M.
Let us assume |αi and |βi are the eigenvectors of the Grover’s iteration
operator in the space spanned by |ti and |t⊥ i . Now from figure 4.3, we can
express G |si in the {t, t⊥ } space as,
G |si = cos 3θ |t⊥ i + sin 3θ |ti
(4.20)
For the case of successive iteration,
Gk |si = cos (2k + 1)θ |t⊥ i + sin (2k + 1)θ) |ti
(4.21)
And the Grover’s iteration operator may be written as,
cos 2θ − sin 2θ
G=
sin 2θ cos 2θ
(4.22)
Figure 4.8: Circuit to perform quantum counting on a quantum computer.
30
e
i2θ
as G rotates 2θ in the {t, t⊥ } plane. The eigenvalues of this G is e±i2θ i.e.
.
& ei(2π−2θ) , where sin2 θ = M
N
The function of the of the circuit shown in figure 4.8 is to measure the
angle 2θ to m bits of accuracy, with probability of success at least 1 − .
Phase estimation algorithm suggested that the first register contains t ≡
m + [log(2 + 21 )] qubits. The second
Pregister is initialized with an uniform
superposition of all possible inputs i |ii by a Hadamard transform. Now,
the phase estimation algorithm tells us figure 4.8 will give us an estimate of
2θ or (2π − 2θ) accurate to within |∆θ| ≤ 2−m , with probability at least 1 − .
Also the estimate of angle (2π − 2θ) is equivalent to the estimate of angle 2θ
with same q
level of accuracy. So, the phase estimation algorithm determine
2θ i.e. ≈ 2
4.4
M
N
to an accuracy 2−m with probability 1 − .
Optimality of the Search Algorithm
We have proved that the Grover’s
√ algorithm can search N items an unstructured database with only O( N ) operation. Now, we will prove that
it is the best we can do i.e. any algorithm that accesses the database only
by using the operator Uω must apply Uω at least as many times as Grover’s
algorithm.
Suppose we start with the state |ψi. For simplicity, we assume there is
only one solution |ti in our database. We have applied It = 1 − 2 |ti ht|
to give a phase shift of -1 to |ti. Let us assume the algorithm starts in a
state |ψi and applies the oracle It exactly k times, with unitary operations
U1 , U2 , · · · , Uk interleaved between the oracle operations. Define
t
ψk ≡ Uk It Uk−1 It , · · · , U1 It |ψi
(4.23)
|ψk i ≡ Uk Uk−1 , · · · , U1 |ψi
(4.24)
Our aim is to bound the quantity
X
Dk ≡
kψkt − ψk k2
(4.25)
t
Now Dk is the measure of the deviation after k steps caused by the oracle.
If we prove the following:
31
1. Dk can not grow faster than O(k 2 );
2. Dk must be Ω(N ) if it is possible to distinguish N alternatives.
By combining this two, we prove the existence of the desired lower bound.
We will use method of induction to prove the first(Dk ≤ 4k 2 ).
For k = 0, this is true ( if k = 0, Dk = 0). Now,
X
Dk+1 =
kIt ψkt − ψk k2
(4.26)
t
=
X
kIt (ψkt − ψk ) + (It − 1)ψk k2
(4.27)
t
Now, kb + ck2 ≤ kbk2 + 2kbkkck + kck2 with b ≡ It (ψkt − ψk ) and c =
(It − 1)ψk = −2 ht| ψk i |ti. So,
X
Dk+1 ≤
kψkt − ψk k2 + 4kψkt − ψk k| ht| ψk i | + 4| ht| ψk i |2
(4.28)
t
Applying Caychy-Schwarz inequality in the second term in R.H.S.
Dk+1 ≤ Dk + 4
X
kψkt − ψk k2
21 X
| hψk | t0 i |2
21
+4
(4.29)
t0
t
!
p
≤ Dk + 4 Dk + 4.
as
X
| ht| ψk i |2 = 1
(4.30)
t
By the inductive hypothesis Dk ≤ 4k 2 . Now,
Dk+1 ≤ 4k 2 + 8k + 4 = 4(k + 1)2
(4.31)
To prove the second part, we assume | ht| ψkt i |2 ≥ 1/2 for all t i.e. an
observation yields a solution with probability at least one-half. Note that,
replacing |ti by eiθ |ti will not change the probability of success, so we may
assume ht| ψkt i = | ht| ψkt i |, so
√
kψkt − ψk k2 = 2 − 2 t ψkt ≤ 2 − 2
(4.32)
Define,
Ek =
X
kψkt − ψk k2 ≤ (2 −
√
2)N
&
Fk =
X
t
t
32
kt − ψk k2
(4.33)
So,
Dk =
X
k(ψkt − ψk ) + (t − ψk )k2
(4.34)
t
≥
X
kψkt − ψk k2 − 2
t
= Ek + Fk − 22
X
kψkt − ψk kkt − ψk )k +
t
X
X
kt − ψk )k2
(4.35)
t
kψkt − ψk kkt − ψk )k
(4.36)
t
√
P
From the Cauchy-Schwarz inequality, t kψkt − ψk kkt − ψk )k ≤ Ek Fk , so
p
p
p
Dk ≥ Ek + Fk − Ek Fk = ( Fk − Ek )2 .
(4.37)
√
P
From Cauchy-Schwarz inequality, Fk = t kt − ψk k2 = 2N − 2 N .
Combinng equation 4.33 and with this,
get D ≥ cN for sufficiently large
p we
√ 2 k
√
N , where c is a constant ≤ ( 2 − 2 − 2) ≈ 0.42.
Since Dk ≤ 4k 2 , this implies
p
(4.38)
k ≥ cN/4
So, we have proved to get a probability of success at least 21 for finding a
√
solution to the search problem, we must iterate the oracle Ω( N ) times.
So, Grover’s algorithm provides the fastest possible quantum search of
an unsorted database if time is measured according to the number of queries
of the oracle. One may feels a twinge of disappointment as no further improvement is possible. So, by the quadratic speed up we can see that the
search problem remain in the NP class. But this is true for an unstructured
database. But in our nature, we find that there is some sort structure. The
challenge to us is to use this structuring for further speed up.
Even the quadratic speedup may prove useful for a variety of NP complete optimization problems. Quantum computers may someday outperform
classical computers in performing exhaustive search, but only if the clock
speed of quantum devices does not lag too far behind that of their classical
counterparts.
33
References
[1] Michael A. Nielsen and Isaac I. Chuang, Quantum Computation
and Quantum Information, Cambridge University Press(2002).
[2] Phillip Kaye, Raymond Laflamme and Michele Mosca, An Introduction to Quantum Computing, Oxford University Press(2007).
[3] Jamie Smith and Michele Mosca, arXiv:1001.0767v2 [quant-ph]
[4] Lecture notes of John Preskill, California Institute of Technology:
http://theory.caltech.edu/~preskill/ph229/
1