You are on page 1of 4

NUROP – Overview, Analysis and Simulation of Grover's Quantum Database Search Algorithm

NUROP CONGRESS PAPER


Overview, Analysis and Simulation of
Grover’s Quantum Database Search Algorithm
RAMEEZ ANSAR1 AND KULDIP SINGH2
School of Computing, National University of Singapore
3 Science Drive 2, Singapore 117543

ABSTRACT

Lov. K. Grover formulated a quantum search algorithm that provides a


polynomial (quadratic) speedup over the best classical counterpart. This
paper presents an in-depth look at the Grover’s algorithm and how it
searches for a marked state within a N element unstructured database in
only O(√N) steps. First, the problem of unstructured database searching is
introduced. The mathematical formalism required to understand the
Grover’s algorithm is discussed next. Finally, the actual algorithm is
presented together with a discussion of its mathematical and geometrical
proofs of correctness. Errors in quantum computations are also briefly
mentioned. In particular, a naïve form of decoherence is discussed to
appreciate the limitations in actually realizing the Grover’s algorithm. A C
language based simulation is also desgined to study the correlations
between the success probability and noise, the admissible noise levels and
the bounds on the optimal number of iterations of the algorithm.

1 INTRODUCTION
According to Moore’s law, the accelerated trend toward miniaturization in
microelectronics would soon reach a road block as we reach sizes of the order of atoms.
At this size, the quantum mechanical effects would become highly relevant in handling
information. On the other hand, Richard Feynman (Feynman, 1982) first observed in
1982 that quantum-mechanical systems could be utilized as information-processors with
capabilities much greater than that of corresponding classical systems. These
developments necessitated study into the theory of quantum computation.
Quantum Computers would rely on a superposition of classical bits, allowing them to
store an infinite amount of information. Further, it was shown that using quantum
parallelism, there was at least some problems that could be significantly sped up using
quantum computers. In 1996, Lov K. Grover (Grover, 1996) formulated his algorithm for
searching large unstructured databases. It was polynomially (quadratic speedup) faster
than any known classical algorithm and takes only O(√N) to complete the computation.
What is also significant about the development of Grover’s algorithm is that, Grover
devised a neat trick that could be used as a way to solve a complete host of hard problems
1
Student
2
Supervisor

1
NUROP – Overview, Analysis and Simulation of Grover's Quantum Database Search Algorithm

like quantum counting and graph coloring. Given a number of choices, Grover’s trick
increased the amplitude of the solution(s) at the expense of the non solutions. This trick is
called amplitude amplification and causes the solutions to be read apart.

2 THE UNSTRUCTURED DATABASE SEARCH PROBLEM


Let a system have unordered states that are labeled x1, x 2,...,xN. Let n be such that 2n
≥ N. Let there be a unique state, say x0, that satisfies the condition C(x0) =1, whereas for
all other states x, C(x) = 0 (assume that for any state x, the condition C(x) can be
evaluated in unit time). The problem is to identify the state x0.

3 ANALYSIS OF THE CLASSICAL SEARCH ALGORITHM


For an unstructured database, there does not exist any sorting on the database that
would aid its selection. While Grover proposes to solve this problem with a solution of
the order of √N, the most efficient classical algorithm for this is to examine the items in
the database linearly and thus have an average order of O (N).

4 FORMALIZATION OF QUANTUM COMPUTATION


Since the study of the theory of quantum computation is mostly theoretical,
considerable depth in linear algebra, vector spaces and complex numbers is required
before one can start to analyze quantum algorithms. Thus, there is a need to study the
mathematical and logical constructs involved in the algorithm and quantum computation.
Briefly these areas would cover the following;

4.1 SUPERPOSITION
While we talk about of the state when refereeing to a physical system in the
classical sense, such a notion of mutually exclusive states does not necessarily exist
in quantum mechanics. Briefly, a quantum state, (a qubit in this case) is actually a
superposition of classical states that lies in a complex Hilbert space and where a
qubit S, can be represented using the Dirac ‘bra’ and ‘ket’ notation by,
| S 〉 = α1 | 0〉 + α 2 |1〉 , where α1 and α 2 ∈ C (1)
To state S, we can apply either a measurement or a unitary operation (Wolf, 1999).

4.2 MEASUREMENT (Singh, 2003)


Suppose we observe state S. We cannot “see” a superposition itself, but
only classical states. Accordingly, if we observe sate S we will see one and only
one classical state, |0> or |1>. We cannot determine in advance which specific state
is observed; but we can predict with a certain probability, i.e., we can say that we
will observe the state |0> with probability | α 0 | (square of the amplitude vector).
2

We must have sum of all probabilities, |αN|2 =1, to ensure that (Euclidean) norm is 1.

4.3 UNITARY EVOLUTION


Instead of measuring |S>, we can also apply some operation on it, U, to
change the state to another, |S1> that still lies in the Hilbert space. Quantum
mechanics only allows linear operations to be applied to quantum states and they

2
NUROP – Overview, Analysis and Simulation of Grover's Quantum Database Search Algorithm

map the state back to a Hilbert space. Because measuring |S1> should also give a
probability distribution, we still need to have the total probability = 1. This implies
that the operation U must preserve the norm of vectors, and hence must be a unitary
transformation.

Using these basic postulates of quantum mechanics, we can model qubits to store
information and to apply transformations on them to model quantum gates and circuits to
first evolve superpositions into a state where desirable results are more probable.

5 GROVER’S ALGORITHM
The basic idea behind the Grover’s algorithm is that you want to start off with a
superposition of all possible database elements. The encoding space for these elements
would only be (log2 N) qubits but more importantly a quantum register (or a group of
qubits) would be able to hold all possibilities at the same time. This would mean that any
operation on the memory would in fact act on all possible elements of the database, in
unit time. This consequence is indeed astonishing.
The core of the algorithm then revolves around changing the amplitudes vectors
(amplitudes dictate the probability of each state being observed upon measurement) of
the superposed states such that the amplitude vectors of the solutions get magnified at the
expense of the non solutions. Grover implemented this using a combination of two
transformations performed iteratively for an optimal number of iterations. These are the
selective phase inversion operation and the inversion about the mean operation.

5.1 THE STEPS


(i) Initialize the quantum memory register to state {|0>}
(ii) Initialize the system to the superposition:
⎛ 1 1 1 1 ⎞
⎜⎜ , , , ... , ⎟⎟
⎝ N N N N⎠
i.e. there is the same amplitude to be in each of the N states.
(iii) Repeat the following unitary operations O ( N) times
(a) Let the system be in any state x: change the amplitude aj to –aj for x0 such that
f(x0) = 1, for all other states, leave the amplitude unaltered.
(b) Apply inversion about the average to increase amplitude of x with f(x0)= 1.
This transformation can be implemented by a matrix D, the diffusion op.
(iv) Measure the first register state which should give you the state xn where xn is in
{0,…2n-1}. Check f(xn).This will be the state x0 (i.e. the desired state that
satisfies the condition P(x0) = 1) with a probability of at least 0.5.
(v) If xn does not satisfy f(xn) =1, then goto (i). This would be in case the algorithm
fails to measure the correct marked state. This is a low probability event while
still possible.

5.2 OUTLINE OF THE PROOF OF CORRECTNESS (Hayward 2002)


To prove that Grover’s algorithm successfully finds the unique marked state
in O(√N) steps, the following can be shown mathematically and geometrically;
(1) There is an operator to produce an equal superposition of states of part 1 of the
algorithm. (2) There is an operator to rotate the phase of a given state. (3) The

3
NUROP – Overview, Analysis and Simulation of Grover's Quantum Database Search Algorithm

definition of the matrix D: Dij =2/N if i ≠ j and Dij = -1 +2/N is an inversion about
the average operator. (4) The matrix representations of all operators used are
unitary to preserve the normalization constraint. (5) The repeated applications of
step 2 of the algorithm increase the amplitude of the marked state, such that after O
(√N) iterations the probability of measuring the marked state is at least ½.

6 SIMLUATION OF GROVER’S ALGORITHM


Using a C language based simulation, we were able to analyze the quantum algorithm
and look at its various aspects. We also introduced operational errors that would be
involved in a real implementation of the algorithm. In the simulation itself, decoherence
as a form of stochastic noise (defined by the decoherence factor, λ, the variance of a
Gaussian distribution) is modeled that brings about random errors in to the system. In
particular, we looked at the following;
1. The relation between the probability of the correct solution and the no. of iterations.
2. The effect of stochastic noise on the probability of the correct solution.
3. The relation between N, the number of elements in the database and λ.

7 CONCLUSION
Our results showed that the there is an optimal number of iterations for the algorithm
π
i= ( N ) . After i iterations, the amplitude amplification process has magnified the
4
probability of observing the answer to a maximum. More iterations of the algorithm will
in fact decrease the amplitude again. The probabilities of the solutions show a periodic
behavior with a change in the number of iterations. On the other hand, introduction of
noise into the system was analyzed and it was found that smaller qubit systems are much
more tolerant to noise than higher order qubit systems. This seems logical as it would be
more difficult to maintain coherence in more qubits. Interestingly, we are also able to find
a relation between N, the no of elements in the database and λadmissible, the amount of
noise that would just prevent the Grover’s algorithm from failing. This was,
−2
Lambda, λadmissible = f (N) = 1.20595*N^(-1.98609), ≈ f ( N ) ∝ N (2)

8 REFERENCES
[1] Feynman, R. P. (1982). “Simulating Physics with Computers”. Int. J. Theor.
Phys. 21, pp. 467-488.
[2] Grover L. K.. (1996). “A fast quantum mechanical algorithm for database
search.” Proceedings for the 28th annual ACM symposium on the theory of
Computing. pg. 212-219.
[3] Hayward, Matthew (2002). “Quantum Computing and Grover’s Algorithm.”
January 23, 2002.
[4] Ronald de Wolf. (1999). “Quantum Computation and Shor’s Factoring
Algorithm.” Lectures at University of Amsterdam. Fall 1999.
[5] Singh, Kuldip (2003). Lectures on “Quantum Computing and Information.”
National University of Singapore. Spring 2003.

You might also like