I implemented 2 versions of the entanglement swapping circuit in IBM Q. One is using classical measurement to control X, Z gates. Another is just us C-NOT and Controlled-Z. They should be equivalent. The 1st and 2nd bits were entangled. After teleportation of the 2nd bit to the 4th bit, I expect the 1st and the 4th bit will be entangled. I can see that when using the 2nd method. But not the case for 1st method. Did I make a mistake or there is a bug?

Method 1:

enter image description here

Method 2:

enter image description here


There is a mistake in design of the first circuit. Both $X$ and $Z$ gate work when value 1 is in classical register.

Gate $X$ should work in case qubit $q_2$ is in state $|1\rangle$. Similarly $Z$ acts when $q_1$ in state $|1\rangle$. Also you have to deal with state when both $X$ and $Z$ have to act. In your case you conditioned both $X$ and $Z$ on c==1. It means that both gates act in case $q_1$ is in state $|1\rangle$. Another mistake come from measuring qubits $q_1$ and $q_2$ in the first circuit while not to measure them in the second one (in this case they are alway zero).

Please see here QASM commented code producing results you desired:

include "qelib1.inc";

qreg q[4];
creg c[5];

h q[0];
h q[2];
cx q[0],q[1];
cx q[2],q[3];
cx q[1],q[2];
h q[1];

//measuring q1 and q2
//for controlled gates

measure q[2] -> c[0];
measure q[1] -> c[1];

//set q1 and q2 to |0> to
//emulate they are not measured
reset q[1];
reset q[2];

//controlled gates
  //q1 = |0>, q2 =|1>
if (c==1) x q[3];
  //q1 = |1>, q2 =|0>
if (c==2) z q[3];
  //q1 = |1>, q2 =|1>
if (c==3) x q[3];
if (c==3) z q[3];

//measure qubits
measure q[3] -> c[3];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
| improve this answer | |
  • 1
    $\begingroup$ Thank you very much! Now I understand the meaning of the "c" values. I am able to construct the circuit now. I will upload my solution too. $\endgroup$ – HYW Mar 31 at 6:06

Thanks to Martin Vesely! Now I modify method 1 by using the correct c values. I think I got the right answer. My goal is to see the 1st bit entangled with the 4th bit. As can be seen below, 1st and 4th bits always have the same values. So they are entangled.

enter image description here

| improve this answer | |
  • $\begingroup$ How does one translate the sentence ' if particles 2 and 3 measure $|\phi^+\rangle_{23}$ then 1 and 4 go into $ |\phi^+\rangle_{14}$. How to write the code for this. Does one look for 00 on the second and third qubit and then do a X or Z or XZ in the reverse order? $\endgroup$ – Upstart Jul 27 at 21:36

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.