groverʼs quantum search algorithm and a classical analogue · 2018. 9. 27. ·...
TRANSCRIPT
-
AbstractQuantum computation is currently a popular topic inphysics, not only because it may offer an improvementon classical computation, but also because it sheds lighton very fundamental issues in quantum mechanics. Inthis paper, we will explain Grover’s quantum searchalgorithm, which allows a quantum computer to perform
a database search of N elements in O N( ) operations.It is important to observe that Grover’s algorithmexploits the principle of superposition, but does notrequire quantum entanglement. Because superposition isa classical concept as well, there exists a classicalanalogue to quantum search involving a system ofcoupled oscillators.
I. Quantum Search of an Unstructured Database
Consider a database of N = 2n elements
(strings) of length l bits and suppose we wish to search
the database for a particular element, s . Assume we
have a simple classical computer consisting of a CPU
that manipulates data and a memory that stores the
database. The CPU contains an n bit index register that
refers to the individual elements in the database. One
iteration of a search algorithm might proceed as follows:
(1) Load the database entry corresponding to
the index value into the CPU
(2) Compare this string to s
(3) If they are the same, output the value of the
index and then stop. If not, increment the
index and begin again at step (1).
Evidently, this requires at most N −1 comparisons, i.e.
it takes O(N) operations to find the solution s . For
example, the database could consist of names in
alphabetical order with corresponding telephone
numbers. In this case, the database is unstructured with
respect to the telephone numbers. We might imagine
that we have a particular phone number but need to
match a name to that number. To do so it would be
necessary to search the database as described above.
The same task could be accomplished using a
quantum computer instead. The quantum computer will
also consist of a CPU and a Nl bit memory. Now
however, the CPU contains four registers: an n qubit
“index” register initialized to 0 ; an l qubit “compare”
register that always remains in the state s ; an l qubit
“data” register initialized to 0 ; and a 1 qubit register
initialized to the state 0 − 1( ) / 2 . Returning to our
example, each l qubit item corresponds to a telephone
number, and each n qubit item corresponds to a name.
The CPU performs a LOAD operation as follows. If the
index register is in state x and the data register is in
state d , then the contents of the xth memory cell, dx ,
are added (bitwise, modulo 2) to the data register:
d → d ⊕ dx . Suppose the CPU is in the state
xindex{ s
compare}0data{
0 − 12
.
Then, applying the LOAD operation, this becomes
Groverʼs Quantum Search Algorithm and A Classical AnalogueAARON J. AMSEL ʻ03
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE24 SPRING 2003 25
-
.
Next, the 2nd and 3rd registers are compared and if they
are the same, a bit flip is applied to the 4th register. The
result is
x s dx0 − 12
→− x s dx
0 − 12
if s = dx
x s dx0 − 12
if s ↑ dx
⎧
⎨⎪
⎩⎪
.
Since dx ⊕ dx = 0 , applying the LOAD operation again
resets the data register to 0 . So the net effect thus far
has been
x s 0 0 − 12
→− x s 0 0 − 1
2if s = dx
x s 0 0 − 12
if s ↑ dx
⎧
⎨⎪
⎩⎪
Now, defining the function
f (x) =1 if dx = s
0 if dx ↑ s⎧⎨⎩
the above operations can be written succinctly as
x Ô⎯ →⎯ (−1) f (x ) x .
The operator Ô represents the action of an “oracle,” a
black box that recognizes the solution and marks it with
a phase shift.
Now that the workings of the oracle have been
described, let us move on to the actual procedure of
Grover’s quantum search. The algorithm begins by
applying the Hadamard transform to the initial state
0 ⊗n . This puts the computer in the superposition state
ψ =1N
xx= 0
N −1
∑ .
Next we repeatedly apply the Grover operator Ĝ , which
consists of these steps:
(1) Apply the oracle Ô
(2) Apply the Hadamard transform Ĥ⊗n
(3) Perform a phase shift of –1 on every basis
state except 0 . (The corresponding
operator is given by 2 0 0 − Î )
(4) Apply the Hadamard transform Ĥ⊗n
From this definition it is straightforward to show that the
Grover operator may be written as
Ĝ = 2ψ ψ − Î( )Ô .
To interpret the action of the Grover operator, it is
helpful to define
x⊥ =1N −1
xx↑xo∑ ,
where xo is the solution to the search problem, i.e.
f (xo ) =1 . Then the initial state ψ may be rewritten
as
ψ =1N
xo +N −1N
x⊥ .
With the definition
cos θ2⎛⎝⎞⎠ =
N −1N
,
we can rewrite the initial state again as
ψ = sin θ2⎛⎝
⎞⎠ xo + cos
θ2⎛⎝
⎞⎠ x⊥ .
If the Grover operator Ĝ is then applied to ψ , some
simple algebra shows that
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE24 SPRING 2003 25
-
Ĝψ = sin 32θ
⎛⎝
⎞⎠ xo + cos
32θ
⎛⎝
⎞⎠ x⊥ .
Hence, in the xo , x⊥ basis, Ĝ rotates ψ by angle θ
toward xo . Applying the Grover operator repeatedly
brings the state vector closer to xo , and so an
observation in the xo , x⊥ basis produces the solution
to the search problem with high probability.
It is important to know how many calls to the
oracle are required to complete the search. To rotate the
state vector to approximately xo , ψ must be rotated
by angle π 2 − θ 2( ) . Given that each application of
the Grover operator rotates the state vector by angle θ ,
the total number of calls to the oracle, R , is given by
R =
π2−θ2
θ.
With the reasonable assumption that N >>1, we can
approximate 1/ N = sin θ / 2( ) ≈ θ / 2 . Using this in
the expression for R above and dropping a negligible
term, we obtain
R ≈ π4
N .
Therefore, Grover’s quantum search requires O N( )
oracle consultations, which is significantly more
efficient than the classical version. More generally, it
can be shown that for a search of N elements with M
solutions,
R ≈ π4
NM
.
Furthermore, it has been proven that the algorithm
described here is optimal, that is, no quantum algorithm
can perform a search in fewer than O N( ) calls to the
oracle. For those interested in more reading on quantum
search or on quantum computation in general, we
recommend the book by Nielsen and Chuang [1].
II. A Classical Analogue of Quantum Search
Now we will investigate a classical analogue of
quantum search involving a system of coupled
oscillators. Grover studied the system of coupled
pendulums shown in Figure 1 [2]. There are N small
pendulums whose motion is coupled by being attached
to a larger pendulum. One of these, which we will refer
to as the “marked” pendulum, is distinct from the rest in
that it has a different length and mass. Grover showed
that for appropriate parameters, most of the system’s
energy will be concentrated in the marked pendulum
after O N( ) cycles. The analogy to a search algorithm
is this: suppose that initially we do not know which
pendulum is marked. Then, if the system is set in
motion and the amplitudes of the small pendulums are
observed after O N( ) cycles, it should be possible to
identify the marked pendulum.
We will now discuss in detail a system almost
identical to this one. Our system has a large mass M
attached to a spring of constantK . Attached to the large
mass are N smaller oscillators each with spring constant
k . Of these, there is one marked oscillator with massDARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE26 SPRING 2003 27
-
m̃ , while the remaining N −1 have mass m . The
equations of motion for this system are
M ˙̇X = −KX + k xi − X( )i=1
N
∑
m˙̇xi = −k xi − X( ) i ↑ Nm ˜̇̇x = −k x̃ − X( )
where X is the position of the large mass, xi is the
position of the ith unmarked small mass, and x̃ is the
position of the marked mass. Note that since the N −1
unmarked small masses are completely identical, all the
xi are the same. In the future, we will just use the
coordinate x to denote the position of the unmarked
small masses. Now, defining a new time coordinate
τ =km̃t ⇒ d
2
dt 2=km̃
d2
dτ 2,
the equations of motion become
Mm̃˙̇X = − K
kX + (N −1)x + x̃ − NX
mm̃˙̇x = − x − X( )
˜̇̇x = − x̃ − X( )
Next it is useful to set M̃ = M / N , K̃ = K / N , and
x̃' = x̃ / N . Hence, we obtain
M̃m̃˙̇X = − K̃
k+1
⎛
⎝⎜ ⎞
⎠⎟ + (1 − 1
N)x + x̃'
Nmm̃˙̇x = − x − X( )
˜̇̇x' = − x̃' − XN
⎛⎝
⎞⎠
For notational convenience, let M̃→ M , K̃→ K ,
x̃'→ x̃ . The equations of motion can be written more
compactly in matrix form. To this end, introduce the
column vector
vx =
x̃
x
X
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
.
Then the equations of motion are
1 0 0
0 m m̃ 0
0 0 Mm̃
⎛
⎝
⎜⎜⎜
⎞
⎠
⎟⎟
d2
dτ 2
x̃
x
X
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟=
−1 0 1 N0 −1 11
N 1 −K k +1( )
⎛
⎝
⎜⎜⎜
⎞
⎠
⎟⎟⎟
x̃
x
X
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
,
where we have assumed N >>1 and dropped a term of
order 1/ N . To further simplify, define a new
coordinate
x̃'
x'
X'
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟=
1 0 0
0 m m̃ 0
0 0 M m̃
⎛
⎝
⎜⎜⎜
⎞
⎠
⎟⎟⎟
x̃
x
X
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
.
This transforms the equations of motion to
d2
dτ 2
x̃'
x'
X'
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟=
−1 0 β N0 −α αββN αβ − γ +1( )β
⎛
⎝
⎜⎜⎜
⎞
⎠
⎟⎟⎟
x̃'
x'
X'
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
where α = m̃ /m , β = m̃ /M , and γ = K / k . Thus, the
equation of motion for this system is of the form
v̇̇x(τ) = Avx(τ ) ,
where A is a real matrix. Assume a solution of the form
vx(τ) = Re civuie
iω iτ
i=1
3
∑⎡⎣⎢
⎤
⎦⎥,
where ci are complex coefficients,vui are the
eigenvectors of A , and −ω i2 are the eigenvalues of A .
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE26 SPRING 2003 27
-
It is then straightforward to show that the general
solution is
vx(τ) = Re UΛ(τ )U −1 vx (0)[ ] ,
where U is the matrix whose columns are the
eigenvectors of A and
Λ(τ ) =
eiω1τ 0 0
0 eiω2τ 0
0 0 eiω 3τ
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
.
This is actually the solution in the primed coordinate
system, so transforming back to the “real” coordinates
the solution is
vx(τ) = M Re UΛ(τ )U −1 vx ' (0)[ ] ,
where
M =
N 0 0
0 α 0
0 0 β
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
.
We will choose the initial condition
vx' (0) =
1/ N
α
0
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
,
which, in the actual coordinates, corresponds to
displacing all the small masses (including the marked
mass) a distance of 1 unit. Also, at this point we can
reverse the rescaling of the system parameters, so that
the “real” parameters are α = m̃ /m , β = Nm̃ /M , and
γ = K / Nk . Note that β and γ should be of order 1.
We can get an idea about how to specify the
parameters α , β , and γ by looking at the
eigenfrequencies of matrixA . To do this, we make the
large N approximation
A ≈
−1 0 0
0 −α αβ
0 αβ − γ +1( )β
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟
and set
det
ω2 − 1 0 0
0 ω 2 − α αβ
0 αβ ω 2 − γ + 1( )β
⎛
⎝
⎜⎜
⎞
⎠
⎟⎟= 0 .
First, it is clear that the x̃ mode has frequency ω̃ =1 ,
which makes sense given that the time coordinate is
scaled by the frequency of the marked mass. The
remaining two eigenfrequencies are given by
ω±2 =
12α + (1 +γ )β[ ] ± 12
α + (1 + γ )β[ ]2 − 4αβγ .
To ensure transfer of energy from the x , X system to
the x̃ system, we impose the resonance condition
ω+ = 1 or ω− = 1. Simple algebra will show
thatω− = 1 is obtained by setting
γ =1β+
1α − 1
.
The equations of motion were solved as
described above using Mathematica software. For
example, a plot of the three system coordinates vs. τ is
given in Figure 2. Clearly the amplitude of the marked
mass increases dramatically, while the amplitudes of the
other masses remain negligible in comparison. The total
energy of a simple harmonic oscillator is the sum of the
potential energy (kx 2 / 2) and the kinetic energy
(mẋ2 / 2 ). In our system then, the energies are given by
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE28 SPRING 2003 29
-
ε̃ = ˜̇x2 + ( x̃ − X)2 marked mass[ ]
ε = N −1( ) 1αẋ2 + (x − X)2⎛⎝
⎞⎠ N −1 unmarked masses[ ]
Ε = N 1βẊ2 + γX2
⎛
⎝⎜ ⎞
⎠large mass[ ]
where we have dropped the constant factor k / 2
common in each case. The total energy of the system is
ET = ε̃ + ε + Ε = constant . These energies have been
plotted in Figure 3. The plot demonstrates that a
significant portion (but not all) of the system’s energy is
transferred to the marked mass, as expected. Finally, it
is interesting to compare the number of periods required
for the marked mass to reach its peak amplitude with the
number of oscillators, N . We provide a log-log plot of
these quantities for three values of N in Figure 4. The
curve is a straight line with slope almost exactly 1/ 2 .
This implies that it would indeed take O N( ) cycles to
transfer most of the energy to the marked mass.
It is interesting to consider whether or not it is
possible to do better than O N( ) . The proof that the
quantum search is optimal assumes unitary (i.e. linear)
evolution. For the classical analogue though, it would
be conceivable to introduce nonlinearities, through
anharmonic springs or damping for example. Could this
be done in such a way as to speed up the energy
transfer? Could it even be possible to transfer all the
energy to the marked mass in one consultation of the
oracle, i.e. in a single oscillation of the marked mass?
These are questions for further investigation. We then
might relate insights gained from this study back to
quantum search, perhaps finding an improvement on
Grover’s algorithm through some form of nonlinear
quantum mechanics [3].
I am pleased to acknowledge Professor Miles
Blencowe, who proposed this research and guided my
work over the past two years. I greatly appreciate the
time and effort he devoted to this project.
REFERENCES
1. Nielsen, M. and Chuang, I. (2000), Quantum Computation andQuantum Information. (Cambridge, UK: Cambridge UniversityPress).
2. Grover, L. and Sengupta, A. (2001) A Classical Analog ofQuantum Search. http://lanl.arxiv.org/pdf/quant-ph/0109123
3. Abrams and Lloyd. (1998) Nonlinear Quantum MechanicsImplies Polynomial-time Solution for NP-complete and #PProblems. http://lanl.arxiv.org/abs/quant-ph/?9801041
FIGURES
Figure 1. The system of coupled pendulums studied by Grover is depicted here. There are small pendulums attached to a larger pendulum of mass M and length L. Of the small pendulums, have length and mass
, while the marked pendulum has length and mass .
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE28 SPRING 2003 29
-
Figure 2. A plot of the system coordinates vs. is given here for the parameters and . The curve with rapidly increasing amplitude is of
course , the marked mass. Curves for and are also shown, but are just barely visible due to their small amplitudes.
Figure 3. The total energies are given here for the parameters and . In this plot, is the thick black curve, is the thin black curve, is the thin
gray curve, and is the dashed line.
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE30 SPRING 2003 31
-
Figure 4. Given here is a log-log plot of , the number of periods for the marked mass to reach peak amplitude, vs. , the number of small oscillators. The slope of the line indicates that the exponent is 1/2.
Did a particular topic in class interest you that wasnʼt a major part of the syllabus? Explore it further and receive recognition for your
work. Weʼll work with you to bring it to print.
Thursdays at 9 PM, Collis 212
DARTMOUTH UNDERGRADUATE JOURNAL OF SCIENCE30 SPRING 2003 31