quantum-computingqiskit

What went wrong while calculating the state ψ = 1/ √2 (|011⟩ − |100⟩)


I've been trying to create the state ψ = √(1/2)(|011⟩ − |100⟩), but in qiskit it is generating ψ = 1/√2(|001⟩ − |110⟩) instead. Is this type of things happen in qiskit, or my calculation is wrong, or is it because of the noise. I'm unable to detect what went wrong.

I've 1st initialize the 3 qubit system with |0> state, then have applied H gate on qubit-0, then have applied X gate on qubit-1, then CNOT gate on qubit-0 (control), and on qubit-1 (target), then again CNOT gate on qubit-1 (control), and on qubit-2 (target), and at last Z gate to make it negative, My calculation shows that it was able to successfully create the ψ = 1/√2(|011⟩ − |100⟩) state,

the Calculations that I've done:

To make the state Ψ = (|011⟩ - |100⟩)/√2:
First applying H gate to qubit-0 in a 3 qubit system, so the output becomes: H(|000>) => (|000⟩ + |100⟩)/√2
Then applying X-gate to qubit-1, so the output becomes: X((|000⟩ +|100⟩)/√2) => |010⟩+ |110⟩)/√2
Then applying CNOT gate to qubit-0 as control, and qubit-1 as target, so: CNOT((|010⟩ +|110⟩)/√2) => (|010⟩ +|100⟩)/√2
Then again applying CNOT gate to qubit-1 as control, and qubit-2 as target, so: CNOT((|010⟩+|100⟩)/√2) => (|011⟩ +|100⟩)/√2
Then applying Z gate on the qubit-0, so it becomes: Z (|011⟩ +|100⟩)/√2 => (|011⟩ -|100⟩)/√2 which is the expected state

qc = QuantumCircuit(3)   #creating a 3-qubit system
qc.h(0)     #applying H gate to make entagled state
qc.x(1)     #X gate: if 0, then 1; if 1 then 0
qc.cx(0,1)  #if control 0, then target no change; if control 1, then will flip the target
qc.cx(1,2)
qc.z(0)     #if 0, then no change; if 1 then will make it -1

but in qiskit, I've created the circuit that way, have measured it and plotted histogram and have run it on QASM simulator, but it was showing the wrong entangled state, which is the following:

histogram showing equal distribution between |001> and |100> .


Solution

  • Qiskit orders qubits from right to left, that is, qubit 0 is the rightmost and so on, so the last qubit (qubit 2 in your case) is the leftmost. You can use Statevector to check the state you have created

    from qiskit.quantum_info import  Statevector
    sv = Statevector.from_instruction(qc)
    display(sv.draw('latex', prefix='|\psi \\rangle ='))
    

    If you prefer to see the final state with qubits in the usual order, you can use qc.reverse_bits() which reverses qubits order.