# What is the logic behind applying $X$ or $Z$ conditionally to the received bits?

Circuit is as follows: Here, as we are trying to teleport the quantum state from Alice (q0) to Bob(q2).

Bob, on receiving the bits from Alice needs to apply appropriate transformations on his qubit based on Alice measurement to reconstruct Alice's state which are as follows: • – glS
Jun 5, 2022 at 9:13

The state to be teleported is $$|\psi\rangle=\alpha|0\rangle+\beta|1\rangle$$. So, the initial system is in state: $$(\alpha|0\rangle+\beta|1\rangle)|00\rangle$$ After the first Hadamard + CNOT, the state is: $$(\alpha|0\rangle+\beta|1\rangle)\left(\frac{|00\rangle+|11\rangle}{\sqrt{2}}\right)=\frac{1}{\sqrt{2}}\left(\alpha|000\rangle+\alpha|011\rangle+\beta|100\rangle+\beta|111\rangle\right)$$ We now apply the second CNOT: $$\frac{1}{\sqrt{2}}\left(\alpha|000\rangle+\alpha|011\rangle+\beta|110\rangle+\beta|101\rangle\right)$$ And finally the second Hadamard: $$\frac{1}{2}\left(\alpha|000\rangle+\alpha|100\rangle+\alpha|011\rangle+\alpha|111\rangle+\beta|010\rangle-\beta|110\rangle+\beta|001\rangle-\beta|101\rangle\right)$$ Now, we measure the first two qubits. Possible results are $$00$$, $$01$$, $$10$$ and $$11$$. Recall that this means that with appropriate normalisation, the state will collapse to a superposition of terms such that the first two qubits corresponds to what we've measured.
• If we measured $$|00\rangle$$, then the state collapsed to: $$\alpha|000\rangle+\beta|001\rangle=|00\rangle(\alpha|0\rangle+\beta|1\rangle)$$ Thus, the thirds qubit is in state $$|\psi\rangle$$, so nothing to do here.
• If we measured $$|01\rangle$$, then the state collapsed to: $$\alpha|011\rangle+\beta|010\rangle=|01\rangle(\alpha|1\rangle+\beta|0\rangle)$$ In order for the third qubit to be in state $$|\psi\rangle$$, we need to change $$|0\rangle$$ into $$|1\rangle$$ and reciprocally, which is what the $$X$$ gate does: $$X|0\rangle=|1\rangle, X|1\rangle=|0\rangle$$
• If we measured $$|10\rangle$$, then the state collapsed to: $$\alpha|100\rangle-\beta|101\rangle=|10\rangle(\alpha|0\rangle-\beta|1\rangle)$$ In order for the third qubit to be in state $$|\psi\rangle$$, we need to change flip the phase of $$|1\rangle$$, which is what the $$Z$$ gate does: $$Z|0\rangle=|0\rangle, Z|1\rangle=-|1\rangle$$
• If we measured $$|11\rangle$$, then the state collapsed to: $$\alpha|111\rangle-\beta|110\rangle=|11\rangle(\alpha|1\rangle-\beta|0\rangle)$$ In order for the third qubit to be in state $$|\psi\rangle$$, we need to first exchange $$|0\rangle$$ and $$|1\rangle$$ and then to flip the phase of $$|1\rangle$$, which corresponds to applying an $$X$$ gate followed by a $$Z$$ gate.