Closed oxarbitrage closed 2 years ago
I can comment this - my mistake, essentially what the code is doing here is demonstrating that the probability of measuring the marked state is oscillating since each application of Us Uw is rotating by some angle. Since rotations are by 2 pi*sqrt(1/N) we see that 100 iterations goes full circle (maximizing the probability when at 25 and 75 since it's aligned and antialigned [which doesn't matter up to a global phase]). I'll take care of the documentation though to fully explain the reasoning.
We don't see the correct key from the output, instead we see the chance you'd get the correct key if you stopped the algorithm at N iterations.
Addressed in 56757b5a3eb2474542aa8a47ff839470d98d4f91
Grovers algorithm code (https://github.com/Renmusxd/RustQIP/blob/master/examples/grovers.rs) has no comments in the code so understating how it works is not easy.
For example i can't understand why iterating 100 times with an N of 10 and how the correct key value x (42) is found from the printed outputs:
@Renmusxd if you can explain me briefly how it works in this issue i will be happy to send a PR to add comments details to the file.