Jordan Carter Hack WIT US: Hackathon

Finding Unique Integer – Grover’s Algorithm O (sqrt (N)) VS Classical Algorithm O (N)

Phase inversion – lowers mean because the unique value becomes negative ~-1o2/sqrt(n) as the coefficient Inversion about mean – invert all on basis so unique value goes up but 1/(sqrt(n) plus another 2/sqrt(n) so 3/sqrt(n) as the coefficient Repeat the above steps then you get 5/sqrt(n), then 7/sqrt(n), … when numbers are added it comes out to 1/sqrt(2) as the coefficient

With 8 numbers the quantum computer is able to solve the answer in first shot… if run for an infinite amount of time, it will choose between 2 states (makes sense because sqrt(8) = 2 .82). include "qelib1.inc"; qreg q[5]; creg c[5];

h q[0]; h q[1]; h q[2]; h q[1]; h q[2]; cx q[1],q[2]; cx q[0],q[1]; h q[1]; h q[2]; h q[0]; h q[1]; h q[2]; x q[0]; x q[1]; x q[2]; h q[1]; h q[2]; cx q[0],q[1]; cx q[1],q[2]; h q[1]; h q[2]; x q[0]; x q[1]; x q[2]; h q[0]; h q[1]; h q[2]; measure q[0] -> c[0]; measure q[1] -> c[1]; measure q[2] -> c[2]; *** The above is QASM IBM standard used on IBM’s Quantum Experience *** With the above code I am able to find the unique value in 1 try versus a classical computer which would take at least 3. The reason why I say at least 3 is because in the ‘array’ that is holding 8 numbers has a hard set value of 1 at position 3 and 0 everywhere else. The quantum computer uses Grover’s algorithm to find it on first shot, while classical would take 3 tries. When shot exceed 1 it becomes closer to a 50% chance of getting it right on the first time, but right on the second time always.

Built With

Share this project:

Updates