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

Qiskit version of sample 3-3 #17

Open
machinelevel opened this issue Jan 23, 2020 · 0 comments
Open

Qiskit version of sample 3-3 #17

machinelevel opened this issue Jan 23, 2020 · 0 comments
Assignees

Comments

@machinelevel
Copy link
Contributor

(sent from a reader to @mercedesGS )
This is regarding QISKIT code sample 3-3: Phase Kickback. According to the book, value of register 2 shall be 1 not 0.

However, if you run QISKIT 3-3 sample code, you can see that it’s 0.

## Example 3-3: Phase Kickback
# Set up the program
reg1 = QuantumRegister(2, name = 'reg1')
reg2 = QuantumRegister(1, name = 'reg2')
qc = QuantumCircuit(reg1, reg2)

qc.h(reg1) # put it into reg1 superposition of 0 and 1
qc.cu1(math.pi/4, reg1[0], reg2)
qc.cu1(math.pi/2, reg1[1], reg2)

backend = BasicAer.get_backend('statevector_simulator')
job = execute(qc, backend)
result = job.result()

outputstate = result.get_statevector(qc, decimals=3)
print(outputstate)
qc.draw()

How can I change it to 1 from 0 for register 2?

@machinelevel machinelevel self-assigned this Jan 23, 2020
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

1 participant