Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion in Qiskit to generate Bell states

I want to generate the bell state $(|01\rangle+|10\rangle)/\sqrt{2}$ from the state $|00\rangle$ in qiskit applying the Hadamard gate followed by the CNOT gate. But it generates $(|11\rangle-|00\rangle)/\sqrt{2}$. What is the problem?

This is my code.

sv1 = Statevector.from_label('01')
mycircuit1 = QuantumCircuit(2)
mycircuit1.h(0)
mycircuit1.cx(0,1)
new_sv1 = sv1.evolve(mycircuit1)
print(new_sv1)
plot_state_qsphere(new_sv1.data)
like image 484
Uriel Muñoz Avatar asked Oct 24 '25 15:10

Uriel Muñoz


1 Answers

Your code is correct but you are getting confused by the way qiskit orders the qubits in a state. According to qiskit documentation, qiskit uses an ordering convention called little-endian for both qubits and classical bits. Which means the qubit states will look something like this:

|(state of qubit q1) (state of qubit q0) \rangle

So following this convention, when you specify sv1 = Statevector.from_label('01') in your code what this means is that you want qubit q0 to be in 1 state and qubit q1 to be in 0 state. And so running your code will not give you your expected answer.

To fix this issue, you should replace sv1 = Statevector.from_label('01') with sv1 = Statevector.from_label('10'). I made this change and ran the code which gave me the output state that you are expecting. Below is the link to the qsphere plot for the same.

Qsphere representation of your state

like image 124
Shravan Patel Avatar answered Oct 27 '25 01:10

Shravan Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!