2
$\begingroup$

I try to design the circuit for $b = 11$ and succeeded in running. Therefore, I start to think of the circuit for different secret string $b = 01$. The circuit I made is down below: The IBM Quantum circuit I made

Here is the problem: After the first Hadamard operator, if the input $x = \left|10\right\rangle$, the $f(x)$ result (That is the measurement of $q2$, $q3$, which is the last two bits of $\left|y_1y_2y_3y_4\right\rangle$ in Computational basis states) according to my circuit, should be $\left|11\right\rangle$, the same as the input $x = \left|11\right\rangle$. And the output of $y1, y2$ should match the condition:$$b\cdot{y} = 0\,(\,mod\,2\,)$$Hence, one of the output I believe is $\left|1011\right\rangle$, but the calculator gives me a wired (at least I think it is wired) result. What are the issues?

$\endgroup$

1 Answer 1

0
$\begingroup$

Measurements are only allowed at the end of the quantum circuit for current machines like those of IBM. Also for Simon's algorithm we don't care about the output of the second register. Thus only first register is measured.

enter image description here

So you have the possibility of observing the state $|00\rangle$ or $|01\rangle$. But we know that $|00\rangle$ is trivial so without much checking $|01\rangle$ is what you are looking for...

Here is the code to generate the above circuit and histogram plot in Qiskit:

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi
from qiskit import QuantumCircuit, BasicAer, execute
from qiskit.visualization import plot_histogram
%matplotlib inline

qreg_q = QuantumRegister(4, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)

circuit.h(qreg_q[0])
circuit.h(qreg_q[1])
circuit.cx(qreg_q[0], qreg_q[2])
circuit.cx(qreg_q[0], qreg_q[3])
circuit.barrier(range(4))
circuit.h(qreg_q[0])
circuit.h(qreg_q[1])
circuit.barrier(range(4))
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])
circuit.draw( 'mpl',style={'name': 'bw'}, scale = 1.5, plot_barriers = False)

backend = BasicAer.get_backend('qasm_simulator')
job = execute(circuit, backend, shots = 20000)
plot_histogram(job.result().get_counts(), color='black', title="Result")

A quick note: If I use the statevector_simulator option then I will either get $|00\rangle$ or $|11\rangle$ as it just a one-shot simulator.

$\endgroup$
3
  • $\begingroup$ The measurement in the first register should be 10 or 00, since b = 01 right? $\endgroup$
    – Kian Gao
    Oct 18, 2020 at 9:55
  • $\begingroup$ @KianGao I didn't see your comment until now... so sorry for the late reply. I have edited my answer. $\endgroup$
    – KAJ226
    Nov 13, 2020 at 16:49
  • $\begingroup$ Perfect thank you! I'd like to comment on another thing is that on Qiskit, the default b=01 circuit is pretty weird(with 3 CNOT). I need to do more learning and gain more intuition on those circuits. THANK YOU! $\endgroup$
    – Kian Gao
    Nov 16, 2020 at 18:55

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.