Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect output for QFT #16

Open
nighttrain7 opened this issue Aug 19, 2019 · 1 comment
Open

Incorrect output for QFT #16

nighttrain7 opened this issue Aug 19, 2019 · 1 comment

Comments

@nighttrain7
Copy link

This code was taken from here I changed some import statements because they were outdated and now the qft is returning 111 instead of 001 for inputs of all 0's. The output for qft3.quasm reads:
OPENQASM 2.0; include "qelib1.inc"; qreg q0[3]; creg c0[3]; h q0[0]; u1(3.14159265358979) q0[0]; h q0[1]; u1(1.57079632679490) q0[1]; h q0[2]; u1(0.785398163397448) q0[2]; h q0[0]; cu1(1.57079632679490) q0[1],q0[0]; h q0[1]; cu1(0.785398163397448) q0[2],q0[0]; cu1(1.57079632679490) q0[2],q0[1]; h q0[2]; measure q0[0] -> c0[0]; measure q0[1] -> c0[1]; measure q0[2] -> c0[2];
As oppose to the original:
OPENQASM 2.0; include "qelib1.inc"; qreg q0[3]; creg c0[3]; h q0[0]; u1(-3.14159265358979) q0[0]; h q0[1]; u1(-1.57079632679490) q0[1]; h q0[2]; u1(-0.785398163397448) q0[2]; h q0[0]; cu1(1.57079632679490) q0[1],q0[0]; h q0[1]; cu1(0.785398163397448) q0[2],q0[0]; cu1(1.57079632679490) q0[2],q0[1]; h q0[2]; measure q0[0] -> c0[0]; measure q0[1] -> c0[1]; measure q0[2] -> c0[2];
I believe the problem is here but I cant seem to solve it, if anyone could help that would be great, thanks!

`import math

# importing Qiskit
from qiskit import Aer, IBMQ
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit.providers.ibmq import least_busy

# useful additional packages 
from qiskit.tools.jupyter import *
from qiskit.tools.visualization import plot_histogram
provider = IBMQ.load_account()`


  # """n-qubit input state for QFT that produces output 1."""
`def input_state(circ, q, n):
    for j in range(n):
        circ.h(q[j])
        circ.u1(math.pi/float(2**(j)), q[j]).inverse()

def qft(circ, q, n):
  # """n-qubit QFT on q in circ."""
    for j in range(n):
        for k in range(j):
            circ.cu1(math.pi/float(2**(j-k)), q[j], q[k])
        circ.h(q[j])`
`q = QuantumRegister(3)
c = ClassicalRegister(3)
qft3 = QuantumCircuit(q, c)

input_state(qft3, q, 3)
qft(qft3, q, 3)
for i in range(3):
    qft3.measure(q[i], c[i])
print(qft3.qasm())`
`# run on local simulator
backend = Aer.get_backend("qasm_simulator")

simulate = execute(qft3, backend=backend, shots=1024).result()
simulate.get_counts()`
`%%qiskit_job_status

# Use the IBM Quantum Experience
backend = least_busy(IBMQ.backends(simulator=False))
shots = 1024

job_exp = execute(qft3, backend=backend, shots=shots)`
`results = job_exp.result()
plot_histogram(results.get_counts())`
@jaygambetta
Copy link
Contributor

this has moved to the Qiskit-community-tutorial

@jaygambetta jaygambetta transferred this issue from Qiskit/qiskit-tutorials Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants