# Entanglement Swapping Circuit

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: Method 2: 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:

OPENQASM 2.0;
include "qelib1.inc";

qreg q;
creg c;

//teleport
h q;
h q;
cx q,q;
cx q,q;
cx q,q;
h q;

//measuring q1 and q2
//for controlled gates

measure q -> c;
measure q -> c;

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

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

//measure qubits
measure q -> c;
measure q -> c;
measure q -> c;
measure q -> c;

• 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.
– HYW
Mar 31, 2020 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. • 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? Jul 27, 2020 at 21:36