oreilly-qc / oreilly-qc.github.io

Code samples for Programming Quantum Computers, from O'Reilly Media
130 stars 59 forks source link

Qiskit version of sample 3-5 #18

Open machinelevel opened 4 years ago

machinelevel commented 4 years ago

(sent by a reader to @mercedesGS)

I believe that there is an error with QISKIT sample code at 3-5.

# Example 3-5: Custom conditional-phase
# Set up the program
reg = QuantumRegister(2, name='reg')
qc = QuantumCircuit(reg)

theta = math.pi / 2
qc.h(reg)
qc.rz(theta/2, reg[1])
qc.cx(reg[0], reg[1])
qc.rz(-theta/2, reg[1])
qc.cx(reg[0], reg[1])
qc.rz(-theta/2, reg[0])

I believe that the sign of last theta shall be ‘theta/2’ rather than ‘-theta/2’

Please let me know your thought.