0

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.

Tita
  • 103
  • 2

1 Answers1

0

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

enter image description here

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