0
$\begingroup$

I am trying to find a proper way to write a code that will give me the resulting quantum state $i|10\rangle$ using qiskit in Python (using Jupiter notebook). I think I have figured out that the following works:

from qiskit import QuantumCircuit, execute, Aer
from math import pi

qc = QuantumCircuit(2,2)

qc.x(1)
qc.crz(3*pi,1,0)

which (if I choose to print the state vector) gives me this result:

job = execute(qc, Aer.get_backend(‘statevector_simulator’),optimization_level=0)
current_quantum_state = job.result().get_statevector(qc)
print(current_quantum_state)
—————————————————————————————————————————————————————————————————————————————————————
Statevector([0.00000000e+00+0.j, 0.00000000e+00+0.j, -2.22044605e-16+1.j,
             0.00000000e+00-0.j],
            dims=(2,2))

Using an X gate first and then a CRZ gate I get the result I want, but I was told that we can get this through just one line (therefore one gate?) and not the last two lines I provided. I looked everywhere through my notes and the Qiskit manual online, but I can’t seem to find something that works and I was wondering if someone could direct me to the faster approach to this.

$\endgroup$

1 Answer 1

0
$\begingroup$

Note that $Y|0\rangle = i|1\rangle$ and so the circuit you are looking for is

enter image description here

$\endgroup$
5
  • $\begingroup$ Oh! Then this would mean that qc.y(1) would suffice! Is that correct? $\endgroup$
    – Tita
    Commented Apr 13, 2022 at 15:55
  • 1
    $\begingroup$ qc.y(0) since you want $|10\rangle$ and not $|01\rangle$. $\endgroup$
    – KAJ226
    Commented Apr 13, 2022 at 15:57
  • $\begingroup$ I understand it better now, thank you very much! $\endgroup$
    – Tita
    Commented Apr 13, 2022 at 15:58
  • $\begingroup$ However, in Python I’m still inclined to believe the code would be qc.y(1) because of the way it twists the qubits. $\endgroup$
    – Tita
    Commented Apr 13, 2022 at 16:18
  • $\begingroup$ yeah. qiskit uses little endian convention so that makes sense quantumcomputing.stackexchange.com/questions/8244/… $\endgroup$
    – KAJ226
    Commented Apr 13, 2022 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.