1
$\begingroup$

I want to do partial measurement of quantum circuit containing two qubits in entangled state. I want to first measure one qubit and record the result. Thereafter, record the measurement of second qubit and compare the two. Mathematically, the two should come out to be same.

How to do the same on Qiskit using Python?

$\endgroup$
  • 1
    $\begingroup$ By the way, the state $\dfrac{1}{\sqrt{2}} |01\rangle + |10\rangle$ is an entangled state. And if you measure the first qubit and get a $|0\rangle$ then the state has collapsed onto the state $|01\rangle$ so the second qubit measurement now will give you a $|1\rangle$. $\endgroup$ – KAJ226 Oct 23 at 15:38
  • $\begingroup$ With reference to comment by KA266, the results of measurement are the same in case of Bell state $\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle)$ or GHZ state $\frac{1}{\sqrt{2}}(|0\dots0\rangle+|1\dots1\rangle)$ but not generally. $\endgroup$ – Martin Vesely Oct 24 at 6:28
2
$\begingroup$

Consider the maximal entangled state

$$ |\psi \rangle = \dfrac{1}{\sqrt{2}} \big( |00\rangle + |11\rangle \big) $$

If I make a measurement on the first qubit and a zero is returned then this implies my state has collapsed into the eigenvector $|00\rangle$ and so the second qubit measurement will definitely returned a $|0\rangle$ as that the only possibility.

However, if you consider the another entangled state $$ |\phi \rangle = \dfrac{1}{\sqrt{2}} \big( |01\rangle + |10\rangle \big) $$

then measuring the first qubit and receiving a $|0\rangle$ means the quantum state has collapsed onto the eigenstate $|01\rangle$, and so measuring the second qubit will now definitely returned a $|1\rangle$ as that the only possibility.


If you want to extract the quantum state after making measurement on the first qubit before measuring the second qubit in Qiskit, you can use the function get_statevector() in the Aer's statevector_simulator.

So for example, suppose I want to do this on the state $|\psi\rangle$ defined above, which can be implemented on the quantum circuit as

     ┌───┐     
q_0: ┤ H ├──■──
     └───┘┌─┴─┐
q_1: ─────┤ X ├
          └───┘

Now I can will make the measurement on the first qubit and extract out the state after the measurement:

from qiskit import Aer, execute, QuantumCircuit
from qiskit.quantum_info import Statevector

backend = Aer.get_backend("statevector_simulator")
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0,1)
qc.measure([0], [0])
print(qc)
result = execute(qc, backend=backend, shots=1).result()
print('State after first measurement:', result.get_statevector() )
     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├
     └───┘┌─┴─┐└╥┘
q_1: ─────┤ X ├─╫─
          └───┘ ║ 
c: 2/═══════════╩═
                0 
State after first measurement: [1.+0.j 0.+0.j 0.+0.j 0.+0.j]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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