You are on page 1of 5

Quantum Algorithms

Shor-type Grover-type
Grover’s Algorithm Algorithms
Quantum Algorithms
Counting
•Searching
•Factoring
•Marked state
•Discrete log •Minimum
•Abelian stabilizer •Median

Speed-up:
Speed-up:
Exponential?
quadratic
Quantum
Simulations
Lov K. Grover Grover
Bell Labs Sesame Street

Unsorted Database Unsorted Database


• Example: Telephone Book • Example: Telephone Book

Find the name of the person Find the name of the person
with phone number: 3397 0454 with phone number: 3397 0454

• Very difficult task! • This is not such a good example


• If there are N entries in the phone book, it • There exists a more efficient solution
will take an average of N/2 queries to find
• The search time is linear with respect to
the name
the size of the problem
• That is because the number of possible
inputs scales linearly with the size of the
problem

Traveling salesman Problem Traveling salesman Problem


22 km 23 km 22 km 23 km
Given a network and a Given a network and a
number, k, is there a tour 15 km
12 km number, k, is there a tour 15 km
12 km

through all the cities of 19 km 14 km through all the cities of 19 km 14 km

length less than k? 16 km


length less than k? 16 km

• What is the size of this problem? • The size of the problem is O(c2 log k),
• The network might be directed (It could take • How many possible tours are there?
longer to get from A to B than from B to A) • Equal to the number of permutations of cities
• Each city could be connected to every other city • There are c! possible tours
• Therefore if there are c cities, there could be • c! ~ O(exp(c log c))
c(c-1) edges
• Therefore the number of possible inputs scales
• Each edge requires log k bits to store exponentially with the size of the problem

1
Traveling salesman Problem Traveling salesman Problem
22 km 23 km 22 km 23 km
Given a network and a Given a network and a
number, k, is there a tour 15 km
12 km number, k, is there a tour 15 km
12 km

through all the cities of 19 km 14 km through all the cities of 19 km 14 km

length less than k? 16 km


length less than k? 16 km

• Suppose there is exactly one solution • O ( c ! ) is still exponential


• We could try to solve the problem by • We haven’t made the problem “tractable”
choosing a tour and testing if it is less than k • Suppose there are 10 billion permutations
• It would take on average c!/2 attempts to • Grover’s algorithm would only require one
find the solution hundred thousand queries
• Grover’s algorithm allows us to find a solution • Classically we would require an average of 5
by using only O ( c ! ) attempts billion queries

The Quantum Oracle The Quantum Oracle


22 km 23 km
oracle [or’a-kl] n a medium or agency, especially Given a network and a
in ancient Greece, of divine revelation; a person of number, k, is there a tour 15 km
12 km

great wisdom; a wise utterance through all the cities of 19 km 14 km

length less than k? 16 km


• Not an all-knowing device
• Simple a device which can efficiently – We could write a computer program to
check whether a given solution is check whether a tour is a valid solution
correct – We could make it reversible
• A witness – Therefore, we could implement it on a
• Telephone book: quantum computer
– Is Jones the name of the person with
phone number 3397 0454?

The Quantum Oracle The Quantum Oracle


• Imagine that the bit string, x, represents a tour of
the cities • The quantum oracle bit-flips the oracle
x x qubit if the input is a valid solution
q ⊕ f ( x)
• The inner workings of the oracle are
q
O by no means `magical’
w w • In the traveling salesman example, the
oracle qubit would be flipped if x
encoded a tour of the cities with a
x q w ⎯⎯→
O
x q ⊕ f ( x) w distance less than k.
• By abstracting the problem using an
⎧1, if x is a solution oracle, we can forget about the
f ( x) = ⎨
⎩ 0 , if x is not a solution specific problem we are trying to solve

2
The Quantum Oracle The Quantum Oracle
x q w ⎯⎯→
O
x q ⊕ f ( x) w • If x is not a solution, the oracle does nothing

• The work qubits are returned to their initial state,


x ( 1
2
0 − 1
2
1 ) ⎯⎯→
O
x ( 1
2
0 − 1
2
1)
so we will ignore them
• If x is a solution, the oracle qubit is flipped

x q ⎯⎯→ x q ⊕ f ( x )
O
x ( 1
2
0 − 1
2
1 ) ⎯⎯→
O
− x ( 1
2
0 − 1
2
1)
• We can write both of these as
• Suppose the oracle qubit is initially in the state
x ( 1
2
0 − 1
2
1 ) ⎯⎯→
O
( − 1) f ( x ) x ( 1
2
0 − 1
2
1)
q = 1
2
0 − 1
2
1 • Or simply as

x ⎯⎯→
O
(− 1) f ( x ) x

Hadamard gate Zero state phase shift


• Remembering the Hadamard gate, x ⎯⎯→
Z
( − 1) ∂ x 0 x
1 ⎛1 1 ⎞
H= ⎜ ⎟ • One way to implement Z:
2 ⎜⎝1 − 1⎟⎠
• In a slight abuse of notation,
x ( − 1) ∂ x 0 x
H
Will be written
H
⊗n simply as H
H =H 1
2
0 − 1
2
1 1
2
0 − 1
2
1
2 m −1
1
H
ψ ≡H 0 =
2m
∑x
x =0
• Flips the oracle qubit iff x = 0

Zero state phase shift Grover’s Algorithm


• The matrix representation of Z O( N )
644474448
⎡− 1
measure

0 0 0⎤
n qubits

⎢ 0 0⎥

1 0 L

0 H
Z =⎢ 0 0 1 0⎥ G G G
qubits

⎢ ⎥
Work

⎢ M O 0⎥
⎢⎣ 0 0 0 0 1 ⎥⎦
(1) Apply the oracle
(2) Apply the Hadamards
Z =20 0 −I
G = H Z HO (3) Apply the zero state
phase shift
(4) Apply the Hadamards

3
Grover Iterate Grover Iterate

G = HZHO HZH = 2 ψ ψ − I
• O: inverts the solution states ⎡1 1 1 1⎤ ⎡ α 0 ⎤ ⎡ ∑Nα n ⎤
⎢ ∑αn ⎥
• HZH: invert all states about the mean ⎢1 L 1⎥ ⎢ α1 ⎥
1 ⎢
1 1
⎥⎢ ⎥ ⎢ N ⎥
HZH (ψ ψ ) α = ⎢1 1 1 1⎥ ⎢ α 2 ⎥ = ⎢ ∑Nα n ⎥
H (2 0 0 − I ) H N ⎢
⎢ M O
⎥⎢ ⎥
⎥⎢ M ⎥
⎢ ⎥
2 H 0 0 H − HIH ⎢⎣ 1 1 1 1 ⎥⎦ ⎢⎣α N ⎥⎦ ⎢ M ⎥
⎢ ∑αn ⎥
2 ψ ψ − HIH ⎣ N ⎦
2ψ ψ − I

Grover Iterate Grover’s Algorithm


Amplitude

HZH = 2 ψ ψ − I 1 N −1
ψ ≡H 0 =
N
∑x
x =0
HZH α = ( 2 ψ ψ − I ) ∑ α n n 1
n
N
= ∑ 2α
n
− αn n 0 1 2 3
N −1
HZH: invert all states about the mean • The probability of measuring the marked
state, 1 1
P(m) = =
N 2n

Grover’s Algorithm Grover’s Algorithm


Amplitude

Amplitude

G = HZHO G = HZHO
1 1
N N

• The unmarked states decreased by a very


small amount
• O: invert the solution state • The marked state increased by O( 1 )
N
• To get P(m) = O(1), we need to apply the
• HZH: invert all states about the mean Grover iterate O( N ) times.

4
Grover’s Algorithm How many Grover iterates do we need?
Amplitude

• Initial amplitudes of the marked and


unmarked states:
m = 0
1
N
u =
0
1
N
1
N • After inverting the marked state, the
average amplitude is
Exercise: Suppose we apply Grover's algorithm ( N −1)ui−1 − mi−1
to a 4 qubit register, assuming exactly one of ai =
the states is marked. N
• Completing the Grover iterate
What is the probability of measuring the
marked state after applying the Grover iterate mi = 2ai + mi−1
0,1,2,3 times?
ui = 2ai − ui−1

How many Grover iterates do we need? Generalizations of Grover’s Algorithm


• Substituting ai in gives • What if we have more than one marked
mi = 2(1 − N1 )ui−1 + (1 − N2 )mi−1 state?
⎡4 N ⎤ • M: Number of solutions
ui = 2(1 − N2 )ui−1 − N2 mi−1 k =⎢ ⎥ • M < N/2
⎢π M ⎥
• We would like to find k, such that
• What if we use a different initial state?
mk ≥ 1
2
so that P(mk ) ≥ 12 • The algorithm still works
• Note that
k • What if we alter the Grover iterate?
⎡mk ⎤ ⎡1 − N2 2 − N2 ⎤ ⎡ N ⎤ ⎡π N ⎤
1
• The algorithm still works
= k =⎢ ⎥
⎢ u ⎥ ⎢ − 2 1− 2 ⎥ ⎢ 1 ⎥
⎣ k⎦ ⎣ N N⎦ ⎣ N⎦ ⎢ 4 ⎥

Optimality of search algorithm Summary


• Classically, if all you can do is ask • Used to solve a problem that you don’t
questions of the oracle know much about:
– The best you can do is O(N ) – Unsorted databases
– NP-complete problems
• Problems remain intractable
• Quantumly, if all you can do is ask
questions of the oracle • Square-root speed-up
– The best you can do is O( N)

You might also like