Simulation of Grover’s algorithm using MATLAB Kailiang Sun April, 2007

1 Introduction Classically, searching an unsorted database requires a linear search, which is O(N) in time. Grover's algorithm, which takes O(N1/2) time, is the fastest possible quantum algorithm for searching an unsorted database. It provides "only" a quadratic speedup, unlike other quantum algorithms, which can provide exponential speedup over their classical counterparts. However, even quadratic speedup is considerable when N is large. Like all quantum computer algorithms, Grover's algorithm is probabilistic, in the sense that it gives the correct answer with high probability. The probability of failure can be decreased by repeating the algorithm. Uses of Grover's algorithm Although the purpose of Grover's algorithm is usually described as "searching a database", it may be more accurate to describe it as "inverting a function". Roughly speaking, if we have a function y=f(x) that can be evaluated on a quantum computer, Grover's algorithm allows us to calculate x when given y. Inverting a function is related to the searching of a database because we could come up with a function that produces a particular value of y if x matches a desired entry in a database, and another value of y for other values of x.

2 Software Quantum computing uses unitary operators acting on discrete state vectors. Matlab is a well known (classical) matrix computing environment, which makes it well suited for simulating quantum algorithms. * Matlab is an interactive system for doing numerical computations. * A numerical analyst called Cleve Moler wrote the first version of Matlab in the 1970s. It has since evolved into a successful commercial software package. * Matlab relieves you of a lot of the mundane tasks associated with solving problems numerically. This allows you to spend more time thinking, and encourages you to experiment. * Matlab makes use of highly respected algorithms and hence you can be con_dent about your results. * Powerful operations can be performed using just one or two commands. * You can build up your own set of functions for a particular application. * Excellent graphics facilities are available, and the pictures can be inserted into LATEX and Word documents.

3 Method

1

Grover demonstrated that quantum computers can perform database search faster than their classical counterparts. In this simple example of Grover’s algorithm, a haystack function is used to represent the database. We are searching for a needle in the haystack., i.e. there is one element of the database that we require. 3.1 Steps of Grover's algorithm 1. Prepare a quantum register to be normalized and uniquely in the first state. Then place the register in an equal superposition of all states (

1 1 1 , ... ) by applying the N N N

Walsh-Hadamard operator Wˆ . This means simply the state vector will be in an equal superposition of each state. 2. Repeat O( N ) times the following two steps (the precise number of iterations is important, and discussed below): 1. Let the system be in any state S . If C ( S ) = 1 , rotate the phase by

π radians,

else leave system unaltered. It is worth noting that this operation has no classical analog. We do not observe the state of the quantum register, doing so would collapse the superposition. The selective phase rotation gate would be a quantum mechanical operator which would rotate only the amplitude proportional to the marked state within the superposition. 2. Apply the inversion about average operator Aˆ , whose matrix representation is:

Aij = 2 / N if i ≠ j and Aii = −1 + 2 / N to the quantum register. 3. Measure the quantum register. The measurement will yield the state C ( S M ) = 1 with probability at least 1/2.

3.2 Operators

2

bit label of the marked

3.2.1 Operator to Create Equal Superposition of States An equal superposition of states is created by the application of the well known Walsh-Hadamard operator. The matrix representing the Walsh-Hadamard operator for an n bit quantum register is a 2 × 2 matrix whose elements are defined to be: Wij = 2 − n /2 ( −1)i i j , where n

n

representation of i , and

ii j

i

is the binary

is the bitwise dot product of the n bit strings i and j , i and

j range from 0 to ( N − 1) , Put another way, Wij = ±2− n /2 , where the sign is positive if the bitwise AND of i and j has an even number of 1's and negative otherwise. 3.2.2 Operator to Rotate Phase The matrix representing an arbitrary rotation operator is very simple. It takes the form of a diagonal matrix with Rij = 0 if i ≠ j , and Rii = e

−1φi

. Here

φi is an arbitrary real number, and

from Euler's formula we know the diagonal entries of the entries are equivalently written as cos φi + −1sin φi . 3.2.3 Inversion About Average Operator We define the inversion about average operation on our state vector as an operator that takes the amplitude of the i'th state, and increases or decreases it so that it is as much above or below the average as it was below or above the average before the operation.

ˆ is defined: A = 2 / N if The matrix representation of the inversion about average operator A ij

i ≠ j and Aij = −1 + 2 / N . Note that A = − I + 2 P where I is the identity matrix, and P is the matrix with each element is equal to 1/ N . Observe that P has the following two properties, first P = P , and second Pν , for any vector 2

the arithmetic average of the elements of

ν , results in a vector ν ' with each element being

ν.

4 Results Grover’s algorithms works by iteratively applying and the inversion about the average operator to the current state. Each iteration amplifies the probability of a measurement collapsing the state to the correct needle value. Grover showed that performing a measurement after sqrt(n)*(Pi/4) iterations is highly likely to give the correct result.

3

References 1. Grover L.K.: A fast quantum mechanical algorithm for database search, Proceedings, 28th Annual ACM Symposium on the Theory of Computing, (May 1996) p. 212 2. Grover L.K.: From Schrodinger's equation to quantum search algorithm, American Journal of Physics, 69(7): 769-777, 2001. Pedagogical review of the algorithm and its history. 3. Dan C. Marinescu: Approaching Quantum Computing, 2005

Appendix Program s=[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]'; W=zeros(16,16); %Walsh-Hadamard transformation for i=1:16 for j=1:16 W(i,j)=2^(-4/2)*(-1)^double(bitand(uint8(i-1),uint8(j-1))); end end s=W*s; R=zeros(16,16); %Operator to rotate phase for i=1:16 if i==9 R(i,i)=-1;

4

else R(i,i)=1 end end A=(2/16)*ones(16,16); %inversion about average transformation for i=1:16 A(i,i)=-1+2/16; end path=zeros(7,16); path_i=1; path(path_i,:)=s'; surf(path); axis([0 20 0 8 -0.5 1]); xlabel('States');ylabel('Time');zlabel('Amplitude'); F(path_i)=getframe; path_i=2; n=1; while n<(pi/2)*sqrt(16), %needed iteration time is (pi/4)*sqrt(N) s=R*s; s=A*s; path(path_i,:)=s'; surf(path); xlabel('States');ylabel('Time');zlabel('Amplitude'); F(path_i)=getframe; path_i=path_i+1; n=n+1; end movie(F,3,3);

5

Simulation of Grover's algorithm using MATLAB

However, even quadratic speedup is considerable when N is large. Like all quantum computer algorithms, Grover's algorithm is probabilistic, in the sense that it.

81KB Sizes 0 Downloads 188 Views

Recommend Documents

Simulation and Research on Data Fusion Algorithm of the Wireless ...
Nov 27, 2009 - The Wireless Sensor Network technology has been used widely; however the limited energy resource is one of the bottlenecks for its ...

Detecting Cars Using Gaussian Mixture Models - MATLAB ...
Detecting Cars Using Gaussian Mixture Models - MATLAB & Simulink Example.pdf. Detecting Cars Using Gaussian Mixture Models - MATLAB & Simulink ...

TCP Retransmission Timeout Algorithm Using ...
Jan 2, 2010 - and HTTP) running on different hosts on the Internet [2, p. 82]. It is critical for TCP to have ... Manuscript received July 10, 2003; revised October 10, 2003. This work was .... cursive WM RTT estimates, produces the best results. Let

Enhance Performance of K-Mean Algorithm Using MCL
K- Mean does not determine the membership of data ... exploratory analysis scenario in which there are no predetermined notions about what will constitute an.

Lightpath Protection using Genetic Algorithm ... - Semantic Scholar
virtual topology onto the physical topology so as to minimize the failure ... applications and high speed computer networks because of huge bandwidth of optical ...

Using genetic algorithm to select the presentation order of training ...
Mar 18, 2008 - i ¼ 1 ہ ai. (1). F1 layer nodes are connected to output layer F2 nodes through a ..... http://www.ics.edu/mlearn/MLRespository.html (1994).

Implementation of Fast Radix-2 DCT Algorithm using ...
IJRIT International Journal of Research in Information Technology, Volume 2, Issue 4, ... signal flow graphs, and Coordinate rotation digital computer (CORDIC) .... The following are some major features of our proposed CORDIC-based fast ...

An Efficient Parallel Dynamics Algorithm for Simulation ...
portant factors when authoring optimized software. ... systems which run the efficient O(n) solution with ... cated accounting system to avoid formulation singu-.

Lightpath Protection using Genetic Algorithm ... - Semantic Scholar
connectivity between two nodes in the network following a failure by mapping ... applications and high speed computer networks because of huge bandwidth of ...

Generalized Stochastic simulation algorithm for Artificial ...
Artificial chemistries (AC) are useful tools and a simple shortcut for the ... should be large and have a huge number of reactions. Sec- ..... Note that if X = Y i.e bi- molecular .... update the data structure that keeps track of the graph for only

Efficient FDTD algorithm for plane-wave simulation for ...
propose an algorithm that uses a finite-difference time-domain ..... velocity is on the free surface; in grid type 2, the vertical component is on the free surface. ..... 50 Hz. The model consists of a 100-m-thick attenuative layer of QP. = 50 and QS

Simulation of Markovian models using Bootstrap method
Business. ▻ Computer science and telecommunication ... Queueing Networks (QN) [Little61, Basket et al. ... Stochastic Automata Networks (SAN) [Plateau84].

Simulation of Markovian models using Bootstrap method
equally important role when examining complex systems. There are ... Although numerical solution produces reliable results, it is .... transition matrix storage [9].

Direct Numerical Simulation of Pipe Flow Using a ...
These DNS are usually implemented via spectral (pseu- dospectral ... In this domain, the flow is naturally periodic along azimuthal (θ) direction and taken to be ...

Saving Time in a Space-Efficient Simulation Algorithm
Saving Time in a Space-Efficient Simulation Algorithm. J. Markovski. Abstract—We present an efficient algorithm for computing the simulation preorder and ...

Comparison of LMP Simulation Using Two DCOPF Algorithms and the ...
LMP calculated from the ACOPF algorithm and outperforms the conventional lossless DCOPF algorithm. This is reasonable since the FND model considers the ...

pdf-1464\steady-state-simulation-of-an-oil-refinery-using ...
Try one of the apps below to open or edit this item. pdf-1464\steady-state-simulation-of-an-oil-refinery-using-commercial-software-by-gerald-l-kaes.pdf.