text
stringlengths
0
8.13M
q, then apply a phase process between pi and q (rotate if q=1111..). After that,
undo the invert process and undo Hadamard transform.
Do an oracle function by measure the quantum register that has been found, then
compare the result to the input.
This iterations must be repeated again if the measurement result does not match with
the wanted number.
Thecode implementation of themainloopincluding thefunctions init canbeseen below.
16
{
reset;
H(q);
for i= 1 to iterasi {
print "Iterasi",i;
query(q,f,bil);
CPhase(pi,f);
!query(q,f,bil);
diffuse(q);
}
oracle(q,hasilmeasurement,bil);
} until hasilmeasurement==bil;
reset;
1. Query Procedure
procedure query(qureg x,quvoid f,int bil) {
int i;
for i=0 to #x-1 {
if not bit(bil,i)
{Not(x[i]);}
}
CNot(f,x);
for i=0 to #x-1 {
if not bit(bil,i)
{!Not(x[i]);}
}
}
2. Diffuse Procedure
procedure diffuse(qureg q) {
17
H(q);
Not(q);
CPhase(pi,q);
!Not(q);
!H(q);
}
3. Oracle Procedure
This procedure is for checking whether the measurement result is match with the wanted
number or not. In general, the oracle function can be formulated as below.
1 if x = x
0
f(x) =
{
0 if x = x
0
6
x is the indexes in the database, and x is the wanted index. Back to the simulation,
0
before we implement the oracle, we need to do a measurement to check if the number that
been found is already matched with the wanted number. The code implementation can be
seen below.
procedure oracle(qureg q,int hasilmeasurement,bil) {
measure q,hasilmeasurement;
if hasilmeasurement==bil {
print "Hasil measurement:",hasilmeasurement;
print "Telah sama dengan bilangan yang dicari...";
}
else {
print "Hasil measurement:",hasilmeasurement;
print "Belum sama dengan bilangan yang dicari...";
}
}
18
IV. RESULT AND DISCUSSION
The grover’s quantum search simulation can be running from Linux’s terminal, by going
to the directory where the file is put in then typing "qcl -i -b32 SimulasiGrover.qcl". This
command will start QCL then run a file named SimulasiGrover.qcl, and providing all qubits
that QCL has (32 qubits).
To discuss the results of the program, table I containing ten outputs from grover’s quan-
tum search simulation program is provided.
TABLE I: Outputs from the program
Input Qubits Iterations List of Measured Number Total Iterations
10 4 2 10 2
30 5 3 30 3
175 8 7 175 7
500 9 9 373 - 500 18
1000 10 13 327 - 1000 26
1676 11 18 1676 18
2000 11 18 1645 - 1497 - 1493 - 703 - 2000 90
2200 12 26 3765 - 2349 - 2200 78
8111 13 36 8111 36
9999 14 54 9999 54
IntableI,column"Input"isforthenumber thattheuserwantstofind. Column"Qubits"
isthetotalofqubitsneededtosearchthenumber. Column"Iterations"isthetotaliterations
needed to find one number to be measuring. Column "List of Measured Numbers" is the list
of numbers that are found and get measured until the number is same to the input. Column
"Total Iterations" is the total of iterations needed to find the correct number. The value
of this column is the multiplication of the value in column "Iterations" and the amount of
numbers in column "List of Measured Number.
Fromthe table, we can see that the number of qubits and the number of iterations needed
are depend on the value of the number that user wants to find. If the number is bigger,
so will the qubits and the iterations be. Sometimes, the number that the program found is