I am confused about the qubit ordering in circuit diagrams and endianness used in qiskit. As far as I understand, qiskit uses little endian (least significant qubit is rightmost) and while drawing circuits, qiskit plots least siginificant qubit at the top. So, we have the following table:
qubits | decimal representaion | ckt | statevector |
---|---|---|---|
$|00\rangle$ | $|0\rangle$ | ![]() |
[1 0 0 0] |
$|01\rangle$ | $|1\rangle$ | ![]() |
[0 1 0 0] |
$|10\rangle$ | $|2\rangle$ | ![]() |
[0 0 1 0] |
$|11\rangle$ | $|3\rangle$ | ![]() |
[0 0 0 1] |
But, when I use QFT on the 2 qubit state $|10\rangle(i.e.|2\rangle)$, the result I expect is $\frac{1}{2}\Sigma_{y=0}^{3}exp(\frac{2\pi j*2y}{4})|y\rangle = \frac{1}{2}(|0\rangle - |1\rangle + |2\rangle - |3\rangle)$ i.e. statevector [0.5,-0.5,0.5,-0.5], however the following code:
from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT
from qiskit import Aer,execute
qc2 = QuantumCircuit(2)
qc2.x(1)
# prepare the state |10>
two_qbit_QFT_ckt = QFT(2)
qft_ckt_2 = qc2+two_qbit_QFT_ckt
# apply QFT on the state |10>
state_backend = Aer.get_backend('statevector_simulator')
qft_res_2 = execute(qft_ckt_2,state_backend).result().get_statevector()
print(qft_res_2)
outputs [0.5,-0.5,0.5j,-0.5j]. I believe there is some qubit ordering problem that I am not getting right, but I can't figure out what it is. I have also seen the following two questions, but they didn't help much.
Q1: Big Endian vs. Little Endian in Qiskit
Q2: qiskit: IQFT acting on subsystem of reversed-ordered qubits state
Can you please help me find the problem?