text
stringlengths
0
8.13M
| i | i
Many quantum algorithms use the Hadamard transform as an initial step, since it maps
n qubits initialized with 0 to a superposition of all 2n orthogonal states in the 0 , 1 basis
| i | i | i
with equal weight.
Hadamard gate operations:
H 1 = 1 0 1 1 .
| i √2| i− √2| i
H 0 = 1 0 + 1 1 .
| i √2| i √2| i
H( 1 0 1 1 ) = 1( 0 + 1 ) 1( 0 1 ) = 1 ;
√2| i− √2| i 2 | i | i − 2 | i−| i | i
H( 1 0 + 1 1 ) = 1 1 ( 0 + 1 )+ 1 ( 1 0 1 1 ) = 0 .
√2| i √2| i √2√2 | i | i √2 √2| i− √2| i | i
13
E. Grover’s Quantum Search Algorithm
One of the most celebrated achievement of quantum computation is Lov Grover’s quan-
tum search algorithm (known as Grover’s algorithm), which was invented in 1996. Grover’s
algorithm is a quantum algorithm for searching an unsorted database with N entries in
O(N1/2) time and using O(log N) storage space.
In models of classical computation, searching an unsorted database cannot be done in less
than linear time (so merely searching through every item is optimal). Grover’s algorithm
illustrates that in the quantum model searching can be done faster than this; in fact its
time complexity O(N1/2) is asymptotically the fastest possible for searching an unsorted
database in the quantum model. It provides a quadratic speedup.
There are already related works about Grover algorithm, such as done by S. Paramita
et al, Matthew Whitehead, Ahmed Younes, and C. Lavor et al. S. Paramita et al wrote a
pseudo code for Grover algorithm in their paper [9]. They also gave the example of Grover’s
implementation using their pseudo code. Grover’s algorithm can be be combined with
another search algorithm. Matthew Whitehead’s paper [10] shows how Grover’s quantum
search may be used to improve the effectiveness of traditional genetic search on a classical
computer. He use repeated applications of Grover’s Algorithm to get a variety of decent
chromosomes that willthenbeused toforma startingpopulationfor classicalgenetic search.
He also provides the pseudo code for the modified genetic search, which is a combination
between Grover’s quantum search and standard genetic search. Another work related to
Grover algorithm is done by Ahmed Younes. In his paper [11], he described the performance
of Grover’s algorithm. Also, C. Lavor et al wrote a review about Grover algorithm by means
of a detailed geometrical interpretation and a worked out example. Some basic concepts of
Quantum Mechanics and quantum circuits are also reviewed.
III. DESIGN AND IMPLEMENTATION
Many problems in classical computer science can be reformulated as searching a list for
a unique element which matches some predefined condition. If no additional knowledge
about the search-condition C is available, the best classical algorithm is a brute-force search
i.e. the elements are sequentially tested against C and as soon as an element matches the
14
condition, the algorithmterminates. For a list of N elements, this requires an average of N/2
comparisons. By taking advantage of quantum parallelism and interference, Grover found a
quantum algorithm [1] which can find the matching element in only O(√N) steps.
In this thesis, Grover algorithm and its implementation will be explained process by
process. The algorithm consists of two parts: (1) Input and initialization (2) Main loop.
Each of the parts will be explained and implemented one by one below.
A. Input and Initialization
1. Input
This simulation needs to know what number it should search, so user will be prompted
to input a round number (integer). The implementation of this input process can be seen
below.
input "Masukkan bilangan bulat yang ingin dicari:",bil;
In the code implementation above we can see that bil is a variable that is used to store
the round number.
2. Initialization
Initializationisaprocess toinitiatevariablesandqubit registers needed inthesimulation.
The most important variables that we have to intiate are the number of qubits and the
number of iterations needed. Assume that the number of qubits is called jmlqubit, and the
number of iterations is called iterasi.
To calculate the number of qubits needed, we can use this formula:
jmlqubit = (log bil)+1
⌊ 2 ⌋
To calculate the number of iterations needed, we can use this formula:
iterasi = π/8 √2jmlqubit
⌈ ∗ ⌉
Then, after the value of both jmlqubit and iterasi are known, another important step to
do is to set up the registers for each qubits. Also, some variables need to be listed to for
common process; looping, storing result, etc. The code implementation for initialization can
be seen below.
15
int jmlqubit = floor(log(bil,2))+1;
int iterasi = ceil(pi/8*sqrt(2^jmlqubit));
int hasilmeasurement;
int i;
qureg q[jmlqubit];
qureg f[1];
print "Jumlah qubit yang digunakan:",jmlqubit;
print "Jumlah iterasi yang dibutuhkan:",iterasi;
print "Proses pencarian dimulai...";
B. Main Loop
Main loop is the main process to begin searching. The steps to do in the main loop are:
1. Reset all qubits to 0 and apply the Hadamard transform to each of them.
| i
2. Repeat the following operation as much as the number of iterations needed (see the
initialization part):
Rotate the marked state by a phase of π radians (Iπ). A query function needs to
• f
be applied. The query function is needed to flip the variable f if x (the qubits) is
equal to 1111...
Apply a phase process between pi and f.
Undo the query function.
Apply a diffusion function. The process are apply Hadamard transform, invert