You are on page 1of 19

Emerging Systems

part 1: Quantum Computing

Lecture 3: Algorithms
Quantum Algorithms
• Simulation algorithms
– Simulation of quantum systems
– Tools for physicists
• Search algorithms
– Deutsch-Jozsa algorithm (1992)
– Grover’s algorithm (1996)
– Searching unstructured databases
• DFT-based algorithms
– Shor’s algorithm (1994)
– Discrete logarithms
– Factoring large integers
Grover’s Algorithm
 
On   O n

• Several applications of this algorithm were developed


• Quantum Counting
• Speedup for solving NP-complete problems
• Searching through unstructured databases
• Algorithm description
• We admit an n-element search space, labeled
• {0,1, …n-1} where n =2m => m-qubit label
Grover’s Algorithm
• We consider that the problem has k
solutions
1kn
• We can reduce his problem to a
decision problem, thus
0 if x is not the solution
f d ( x)  
1 if x is the solution
• In this context, we can define a
quantum oracle as U O : x u a x fd  x   u
Index quregister Oracle quregister
Grover’s Algorithm
The Oracle
1
• If u  0 1  “Marks the Solution”
2

• and because
1 1
NOT :  0  1  a (1)  0  1 
2 2

• We will have
1 1
UO : x  0  1 a  1
fd  x 
x 0 1 
2 2
Grover’s Algorithm
1 n 1

Initial state ?
 i  H  n 00...0 a n x
n 2 2 x 0
0

Oracle
Workspace
 ( m 1)
0 1
Grover’s Algorithm
Hadamard
• The “Gro” circuit transform
Oracle
levels

Phase shift  0 if x  0
Ph : x  
circuit  x if x  0
Grover’s Algorithm

U Gro   2  i  i  I U O
Grover’s Algorithm
New basis:  ,  
1
 
nk
 x
xS

1
 
k
 x
xS

Iterations:  n
q 
4 k

 n
O  
 k
Grover’s Algorithm

Nielsen & Chuang example


Shor’s Algorithm
• Best classical factorization: Number Field
Sieve:  1
2 
exp (c  O(1))log n  3 (log log n) 3 
• NFS complexity: 



• Shor algorithm complexity: BQP  BPP
• Consequence: threatens RSA
cryptosystem
Exponential speedup impact
• Factor a 5000 digit number

– On a classical computer (1ns/instruction)


• The classical algorithm will require more than 5
trillion years
• The universe is ~10-16 billion years old

– On a quantum computer (1ns/instruction)


• Shor’s algorithm will require over 2 minutes
Exponential speedup impact
4
3 10

4
2 10
Poly ( x)

Exp( x)
4
1 10

0
0 5 10 15 20
x

Exponential vs. polynomial discrepancy


Shor’s Algorithm
2 L 2 L
• Step 1:

• Step 2:
1   i  o  0 0
• Step 3:
 1 2 2 L 1 
– f is periodic

– factors:
2  L
2  i 0

 i 0 
2 2 L 1
1
3 
2 L i
i 0
f (i )

f a , N x   a x mod N

 r 
gcd a 2  1, N , r mod N  1
 
 
fa,N(x)
Shor’s Algorithm
• Step 4: output register measurement
 22 L 
  1
 r 
 r 
4   2L 
2 
 r i  b
i 0
m

Result Post-measure state Offset


1   0  4  8   1 0
4   3  7  11   4 3
7   1  5  9   7 1
13   2  6  10   13 2
Shor’s Algorithm
• Step 5: offset removal
 5  U DFT  4

– input register measurement: h

– h/22L=a1/a2 is approximated with continued


fractions
Quantum DFT
r divides 22L, peak distance 22L/r
Quantum DFT
r is not dividing 22L, distinct peak distance 22L/r
0.5

0.4

0.3

0.2

0.1

50 100 150 200 250

You might also like