I want to make a three qubit system that marks the states where the last qubit is 0. I have made an oracle function but when I try to run the reflection the amplitudes are only higher than the others by around 15%. Is there something I'm missing out on the second reflection/diffusion operator, I'm kinda new to this field so don't know much. I have attached a picture of the second reflection as well as the probabilities:

Reflection: enter image description here


enter image description here

New contributor
At2005 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

It seems that $\mathrm{CNOT}$ gates should not be in your circuit. Here is Grover algorithm for 3 qubits:

Grover algorithm - 3 qubits

Put your Oracle instead of dashed line. The Oracle should have three inputs $q_0$, $q_1$ and $q_2$, output should be on qubit $q_3$ after $\mathrm{H}$ gate.

  • 1
    $\begingroup$ What is the output qubit used for? I always thought in the oracle you change the state of 3 qubits to 1 and use CZ to change the sign from + to -, and then reverse the operation. $\endgroup$ – At2005 Jan 14 at 15:37
  • $\begingroup$ @At2005: Yes, you are right that you read marked state on input qubits. But you have to somehow tell to Grover operator ($\mathrm{CZ}$ is part of it) that this state is the right one. The output is used for doing so. Although it can seems that the output is not connected to the Grover operator, it acually is because of entanglement between oracle and output qubit. When the oracle returns one on the output, phase of whole state defined by all qubits is reversed. This reversal is captured by Grover operator and after that the probability of this state is amplified. $\endgroup$ – Martin Vesely Jan 14 at 22:26
  • $\begingroup$ So for my oracle should I just change it to have a CZ on the output qubit controlled by the state of the last qubit? I'm trying to mark 1/2 of all possible states. So, e.g. if the last qubit is 0 it'll mark, otherwise nothing $\endgroup$ – At2005 2 days ago
  • $\begingroup$ @At2005: The oracle output is not connected to Grover operator, $CZ$ gate acts on last qubit of input. $\endgroup$ – Martin Vesely 2 days ago
  • $\begingroup$ So right now for my oracle I've got an X gate applied before the last qubit. Then I'm doing CZ with that as a control and output qubit as a target, but it just doesn't seem to work, and I'm getting equal probabilities. I'm just a beginner so I don't have much experience with Oracles. $\endgroup$ – At2005 2 days ago

Your Answer

At2005 is a new contributor. Be nice, and check out our Code of Conduct.

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.