+ All Categories
Home > Documents > C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07...

C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07...

Date post: 18-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
9
C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 Fall 2007 Lecture 21 1 Readings Benenti et al., Ch. 3.10 Stolze and Suter, Quantum Computing, Ch. 8.4 Nielsen and Chuang, Quantum Computation and Quantum Information, Ch. 6 Literature: Grover, quant-ph/9605043, quant-ph/9706033; diffusion transform and other motivations from physics, quant-ph/0109116 2 Introduction The problem is to search for an item in an unstructured database. For example, suppose you are given a telephone number in LA and need to find out who it belongs to. You will have to go through all the phone numbers and check the names of the registered owners in each case... Searching an item in an unsorted database with size N costs a classical computer O(N ) running time, since on average N /2 entries need to be checked. Can a quantum computer search for a needle in a haystack much more efficiently than its classical counterpart? Grover, in 1996, affirmatively answered this question by proposing a search algorithm that consults the database only O( N) times. In contrast to algorithms based on the quantum Fourier transform, with exponential speedups, the search algorithm only provides a quadratic improvement. However, the algorithm is quite important because it has broad applications, and because the same technique can in principle be used to improve solutions of NP-complete problems. One might think of having better improvements over the search algorithm. However, it turns out that Grover’s search algorithm is optimal. At least ( N) queries are needed to solve the problem. Grover’s algorithm uses parallelism and amplitude amplification. We will discuss the amplitude amplifica- tion aspect in detail in the next lecture. In the current lecture we will present a geometrical analysis of the quantum search algorithm. 2.1 The quantum oracle Here’s the search problem: You are given a boolean function f : {1,..., N }→{0, 1}, and are promised that for exactly one a ∈{1,..., N }, f (a)= 1. Think of this as a table of size N , where exactly one element has value 1, and all the others are 0. f is effectively an oracle that can check/recognize the solution when this is given it as input. So f acts like a detector of the target solution. In the current analysis we shall assume that there is only 1 solution, but the arguments can be generalized to a finite number of solutions. We construct a two register state, with the database register first and the oracle register second. Then our oracle acts as follows (cf. the Deutsch-Jozsa algorithm) O x q = x q f (x) , where we assume f can be computed classically in polynomial time. Then we can also apply the oracle with C/CS/Phys C191, Fall 2007, Lecture 21 1
Transcript
Page 1: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07Fall 2007 Lecture 21

1 ReadingsBenenti et al., Ch. 3.10

Stolze and Suter, Quantum Computing, Ch. 8.4

Nielsen and Chuang, Quantum Computation and Quantum Information, Ch. 6

Literature: Grover, quant-ph/9605043, quant-ph/9706033; diffusion transform and other motivations fromphysics, quant-ph/0109116

2 IntroductionThe problem is to search for an item in an unstructured database. For example, suppose you are given atelephone number in LA and need to find out who it belongs to. You will have to go through all the phonenumbers and check the names of the registered owners in each case...

Searching an item in an unsorted database with sizeN costs a classical computerO(N) running time, sinceon averageN/2 entries need to be checked. Can a quantum computer search for a needle in a haystackmuch more efficiently than its classical counterpart? Grover, in 1996, affirmatively answered this questionby proposing a search algorithm that consults the database only O(

√N) times. In contrast to algorithms

based on the quantum Fourier transform, with exponential speedups, the search algorithm only provides aquadratic improvement. However, the algorithm is quite important because it has broad applications, andbecause the same technique can in principle be used to improve solutions of NP-complete problems.

One might think of having better improvements over the search algorithm. However, it turns out thatGrover’s search algorithm is optimal. At leastΩ(

√N) queries are needed to solve the problem.

Grover’s algorithm uses parallelism and amplitude amplification. We will discuss the amplitude amplifica-tion aspect in detail in the next lecture. In the current lecture we will present a geometrical analysis of thequantum search algorithm.

2.1 The quantum oracleHere’s the search problem: You are given a boolean functionf : 1, . . . ,N→ 0,1, and are promised thatfor exactly onea ∈ 1, . . . ,N, f (a) = 1. Think of this as a table of sizeN, where exactly one element hasvalue 1, and all the others are 0.f is effectively an oracle that can check/recognize the solution when this isgiven it as input. Sof acts like a detector of the target solution. In the current analysis we shall assume thatthere is only 1 solution, but the arguments can be generalized to a finite number of solutions.

We construct a two register state, with the database register first and the oracle register second. Then ouroracle acts as follows (cf. the Deutsch-Jozsa algorithm)

O∣

∣x⟩ ∣

∣q⟩

=∣

∣x⟩ ∣

∣q⊕ f (x)⟩

,

where we assumef can be computed classically in polynomial time. Then we can also apply the oracle with

C/CS/Phys C191, Fall 2007, Lecture 21 1

Page 2: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

1. the database register in superposition:

∑x

αx

∣x⟩ ∣

∣0⟩

→ ∑x

αx

∣x⟩ ∣

∣ f (x)⟩

and

2. with the oracle register in superposition:

∑x

αx∣

∣x⟩

(∣

∣0⟩

−∣

∣1⟩

√2

)

7→ ∑x

αx

(∣

∣x⟩ ∣

∣ f (x)⟩

−∣

∣x⟩ ∣

∣ f (x)⟩

√2

)

= ∑x

αx∣

∣x⟩

(∣

∣ f (x)⟩

−∣

∣ f (x)⟩

√2

)

= ∑x

αx

∣x⟩

(−1) f (x)

(∣

∣0⟩

−∣

∣1⟩

√2

)

Here f (x) means the binary complement off (x), i.e., if f (x) = 1, then f (x) = 0. Note that we have used thesame phase kick-back as in Deutsch-Jozsa to go from lines 2 to3. (Check: if f (x) = 0 the oracle qubit is∣

∣0⟩

−∣

∣1⟩

= (−1) f (0)(∣

∣0⟩

−∣

∣1⟩)

, while if f (x) = 1 the oracle qubit is∣

∣1⟩

−∣

∣0⟩

= (−1) f (1)(∣

∣0⟩

−∣

∣1⟩)

.)

So the oracle marks the solutions to the search problem by a minus sign, i.e., by a phase (note, no measure-ment).

While it is quite sloppy, we will follow many authors and summarize the action of the oracle on an arbitrarystate

∣ν⟩

= ∑x

αx∣

∣x⟩

as

O∣

∣ν⟩

≡ ∑x

(−1) f (x)αx∣

∣x⟩

,

where we have omitted the oracle register on both sides of theequation because it is in the same state. Butdon’t forget that the oracle register is essential for this action of O on the database register to be realized!

2.2 Geometric analysis of searchGrover’s algorithm findsa in O(

√N) steps. Consider the two dimensional subspace that consistsof two

states:∣

∣a⟩

and the uniform superposition∣

∣ψ0⟩

= ∑x1√N

∣x⟩

. Let θ be the angle between∣

∣ψ0⟩

and∣

∣e⟩

,

where∣

∣e⟩

is the vector that is orthogonal to∣

∣a⟩

(in the direction of∣

∣ψ0⟩

) in this subspace. See Figure 1.∣

∣a⟩

is the target and we can regard∣

∣ψ0⟩

as the least biased initial state. So we want to increaseθ to go from∣

∣ψ0⟩

to∣

∣a⟩

. How do we accomplish this?

One way to rotate a vector is to make two reflections. In particular, we can rotate a vector∣

∣v⟩

by 2θ tothe new vector

∣v1⟩

by first reflecting about∣

∣e⟩

and then reflecting about∣

∣ψ0⟩

. This transformation isalso illustrated in Figure 1. The first reflection transformsan arbitrary vector

∣v⟩

to∣

∣v2⟩

and the secondreflection transforms

∣v2⟩

to∣

∣v1⟩

.

C/CS/Phys C191, Fall 2007, Lecture 21 2

Page 3: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

Figure 1: To rotate∣

∣v⟩

by 2θ to∣

∣v1⟩

, we reflect around∣

∣e⟩

, reaching∣

∣v2⟩

, and then reflect around∣

∣ψ0⟩

.

Each step of our algorithm is thus a rotation by 2θ (we discuss the implementation of the two rotationsinvolved in a step below). This means that we need at mostπ/2

2θ iterations for the algorithm to complete.Now, what isθ?

〈ψ0|a〉 = cos(π/2−θ) = sin(θ)

but

〈ψ0|a〉 =1√N

∑x

x∣

∣a⟩

=1√N

δxa =1√N

Then since sinθ ≈ θ , we know thatθ ≈ 1√N

. Thus, we needO( π/2

2/√

(N))= O(

√N) iterations for the algorithm

to complete. In the end, we get very close to∣

∣a⟩

, and then with high probability, a measurement of the statein the computational basis (all qubits) yieldsa.

Note that one must not iterate beyond this point. Subsequentiterations will rotate the vector∣

∣v⟩

away from∣

∣a⟩

again. For large N, we need to iterater = π√

N/4 times and the corresponding probability of error isO(1−cos2 θ) = O(sin2θ) = O(N−1).

How do we implement the two reflections?

1. Reflection about∣

∣e⟩

is easy.∣

∣e⟩

is the vector orthogonal to∣

∣a⟩

so all we need to do is flip the phaseof the component of the database wavefunction in the direction of

∣a⟩

, i.e., we send any component

C/CS/Phys C191, Fall 2007, Lecture 21 3

Page 4: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

∣a⟩

to−∣

∣a⟩

and leave all other components as is. To accomplish this, we just act with the oracle:

O∣

∣v⟩

= ∑x

(−1) f (x)αx∣

∣x⟩

= ∑x6=a

αx∣

∣x⟩

−αa∣

∣a⟩

= ∑x

αx∣

∣x⟩

−2αa∣

∣a⟩

⇒ Oa = I −2∣

∣a⟩⟨

a∣

∣= R∣∣e⟩

The notationR∣∣e⟩ means a reflection about the vector

∣e⟩

.

2. What about the reflection about∣

∣ψ0⟩

? This uniform superposition state is just the zero vector from thecomputational basis transformed to the Hadamard basis.So we first applyH2n , which maps

∣ψ0⟩

7→∣

∣00. . .0⟩

, then reflect around∣

∣00. . .0⟩

, and finally, applyH2n to return to the original basis. Thereflection about the zero vector in the computation basis caneasily be seen to be given by

−O0 = −I +2∣

∣0⟩⟨

0∣

using similar analysis to that above for reflection about∣

∣e⟩

. The overall reflection about∣

∣ψ0⟩

is thengiven by the product of the three transformations:

D = (H⊗n)†[−I +2∣

∣0⟩⟨

0∣

∣ ]H⊗n

= −I +2∣

∣ψ0⟩⟨

ψ0∣

= −R∣∣ψ0

where we have used the fact thatH is self-adjoint (H = H†) and that∣

∣ψ0⟩

= H⊗n∣

∣0⟩

. This operatoris referred to as the ’diffusion operator’ for reasons that will be explained below.

To make one iteration step we combine the two reflections, yielding the Grover operator

G = DOa = −R∣∣ψ0

⟩R∣∣a⟩ .

We apply this Grover operatorO(√

N) times to rotate from∣

∣ψ0⟩

to∣

∣a⟩

. Notice the difference between thetwo reflections which arises from the fact that we have written one in terms of the vector about which wereflect (R∣

∣ψ0

⟩ ) and the other in terms of the vector perpendicular to the vector about which we reflect (R∣∣a⟩ ).

What about efficiency of implementation? Observe thatD is expressed as the product of three unitarymatrices: two Hadamard matrices separated by a conditionalphase shift matrix (minus one times a diagonalmatrix with values everywhere one except for the uniform superposition state when the value gains a relativephase shifteiπ ). Therefore,D is also unitary. Regarding the implementation, both the Hadamard and theconditional phase shift transforms can be efficiently realized withinO(n) gates.

3 Amplitude amplification in Grover searchThe Diffusion operatorD has two properties:

C/CS/Phys C191, Fall 2007, Lecture 21 4

Page 5: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

1. It is unitary and can be efficiently realized.

2. It can be seen as an “inversion about the mean.”

We discussed the first property above. We now analyze the second property.

For N = 2n, we can explicitly evaluate

D = −I +2∣

∣ψ0⟩⟨

ψ0∣

= (H⊗n)†[−I +2∣

∣0⟩⟨

0∣

∣ ]H⊗n

as:

D = HN

+1 0 · · · 00 −1 · · · 0...

.... . .

...0 0 · · · −1

HN

= HN

+2 0 · · · 00 0 · · · 0...

.... . .

...0 0 · · · 0

+ I

HN

= HN

+2 0 · · · 00 0 · · · 0...

.... . .

...0 0 · · · 0

HN − I

=

−2/N −2/N · · · −2/N−2/N −2/N · · · −2/N

......

. .....

−2/N −2/N · · · −2/N

− I

=

+2/N −1 +2/N · · · +2/N+2/N +2/N −1 · · · +2/N

......

. . ....

+2/N +2/N · · · +2/N −1

The indexing here is such that the first state (top left hand corner of the matrices) is the uniform superpositionstate

∣ψ0⟩

. Recall that the central matrix inD is a conditional phase shift matrix, i.e., it puts a phase shiftin front of all states except the target. Now for largeN, the matrixD has diagonal elements approx equal to(1−2/N) and very small, positive and constant off-diagonal elements (2/N). So in each step the amplitudeof every basis state contributes by a small amount to all other basis states. This is a generalization of thephenomenon of diffusion on a lattice.

Consider the action ofD on a vector∣

∣α⟩

to generate another vector∣

∣β⟩

:

C/CS/Phys C191, Fall 2007, Lecture 21 5

Page 6: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

Figure 2: Inversion of amplitudesαi about their mean valueµ .

D

α1...

αi...

αN

=

β1...

βi...

βN

Defineµ = ∑i αi/N as the mean amplitude Then

βi =2N ∑

j

α j −αi

= 2(µ −αi)

= µ +(µ −αi)

which corresponds to a reflection ofαi about the mean valueµ . This is illustrated in Figure 1 below (notethat if we start from the uniform superposition, the non-target states will have equal amplitude, we havejust illustrated the principle for a general state here). Thus, the amplitude ofβi = 2

N ∑ j α j −αi = 2µ −αi

can be considered an “inversion about the mean” with respectto αi. Now if we first change the sign ofthe amplitude of the target state, by applying the oracle as in the previous lecture, the target state is nowsignificantly further away from the mean. The inversion about the mean further amplifies this, as shown inFigure 2 below.

This shows how quantum search algorithm iteratively improves the probability of measuring a solutionby increasing the component of the target state at each iteration. The overall procedure is summarized asfollows

1. Start state is∣

∣ψ0⟩

= ∑x1√N

∣x⟩

2. Invert the phase of∣

∣a⟩

using f

3. Then invert about the mean usingD

C/CS/Phys C191, Fall 2007, Lecture 21 6

Page 7: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

Figure 3: Application of oracle to invert sign of target state followed by Inversion of amplitudesαi abouttheir mean valueµ gives rise to amplification of the target component.

C/CS/Phys C191, Fall 2007, Lecture 21 7

Page 8: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

Figure 4: The first three steps of Grover’s algorithm. We start with a uniform superposition of all basisvectors in the top panel. In the middle panel we have used the function f to invert the phase ofαk. Afterrunning the diffusion operatorD in the bottom panel, we have amplifiedαk while decreasing all otheramplitudes.

C/CS/Phys C191, Fall 2007, Lecture 21 8

Page 9: C/CS/Phys C191 Grover’s Quantum Search Algorithm 11/06/07 ...cs191/fa07/lectures/lecture21_fa07.pdf2 Introduction The problem is to search for an item in an unstructured database.

4. Repeat steps 2 and 3O(√

N) times, so in each iterationαa increases by2√N

Suppose we just want to finda with probability 12. Until this point, the rest of the basis vectors will have

amplitude at least 1√2N

. In each iteration of the algorithm,αa increases by at least2√2N

=√

2N . Eventually,

αa = 1√2. The number of iterations to get to thisαa is ≤

√N.

C/CS/Phys C191, Fall 2007, Lecture 21 9


Recommended