1
$\begingroup$

I am sorry if this question is trivial, I am relatively new to QC. Here is my grover's circuit, as you can see it is displaying that it has a 100% probability of measuring 100 enter image description here

however when placed into the quantum simulator (IBMQ statevector) here is the result: enter image description here

I am stumped as to why this is the case. it clearly displays 100% output probability which means the algorithm is working right? Or am I missing something fundamental?

Edit:

enter image description here

OKAY? I fixed it somehow? by getting rid of the bottom H gate? I am even more confused than I was before. Why is this working, how does this work?

$\endgroup$
1
  • 2
    $\begingroup$ This link might be helpful, I think. $\endgroup$
    – narip
    Jun 20 at 12:00
2
$\begingroup$

As @narip already mentioned in the comments, the statevector simulator of the IQX (your top picture) shows that one state has 100% measure probability since you added measurements and thus the state collapses. You should only add measurements for shot-based readouts, not if you do statevector simulations.

Regarding your question about the Hadamard gate: I think there are actually some Hadamards missing! Based on your circuit I assume the oracle/boolean function you want to implement is $f(x_1, x_2) = x_1 \text{ and } x_2$. The Toffoli gate with surrounding X gates you implemented indeed flips a target qubit if both qubit 1 and 2 are 0. But keep in mind that Grover's oracle must do phaseflip and not a bitflip! To convert your oracle you should add two Hadamards around the target qubit, to be

        ┌───┐     ┌───┐
   x_1: ┤ X ├──■──┤ X ├
        ├───┤  │  ├───┤
   x_2: ┤ X ├──■──┤ X ├
        ├───┤┌─┴─┐├───┤
target: ┤ H ├┤ X ├┤ H ├
        └───┘└───┘└───┘

And on top of that, you should have an initial layer of Hadamards, to initialize in an equal superposition. In total your circuit would be something like

        ┌───┐┌───┐     ┌───┐┌───┐┌───┐     ┌───┐┌───┐
   x_1: ┤ H ├┤ X ├──■──┤ X ├┤ H ├┤ X ├──■──┤ X ├┤ H ├────
        ├───┤├───┤  │  ├───┤├───┤├───┤  │  ├───┤├───┤
   x_2: ┤ H ├┤ X ├──■──┤ X ├┤ H ├┤ X ├──■──┤ X ├┤ H ├────
        ├───┤├───┤┌─┴─┐├───┤└───┘└───┘     └───┘└───┘
target: ┤ H ├┤ H ├┤ X ├┤ H ├─────────────────────────────          
        └───┘└───┘└───┘└───┘
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.