A chip sends the state |\psi\rangle = [\alpha, \beta] of qubit 0 to qubit 2 at the far end of a corridor, using a shared pair of qubits 1 and 2. When the pair is the Bell state (|00\rangle + |11\rangle)/\sqrt2 the transfer is perfect. The test engineers want to know what happens with a worse pair.
The start state is kron(psi, pair): eight amplitudes, where pair gives the four amplitudes of qubits 1 and 2 (qubit 1 as the left bit). Qubit 0 is the leftmost bit: |b_0 b_1 b_2\rangle is index int("b0b1b2", 2), so |011\rangle is index 3. The protocol:
- CNOT(0, 1): flip bit 1 of every basis state whose bit 0 is 1.
- H = \tfrac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix} on qubit 0.
- Measure qubits 0 and 1, giving bits m_0 m_1. With u = a_{m_0 m_1 0} and v = a_{m_0 m_1 1} (the amplitudes at |m_0 m_1 0\rangle and |m_0 m_1 1\rangle), this outcome has probability p = |u|^2 + |v|^2, and qubit 2 is left in the state [u, v] / \sqrt{p}.
- Corrections on qubit 2: if m_1 = 1 apply X=\begin{pmatrix}0&1\\1&0\end{pmatrix}; then, if m_0 = 1, apply Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}.
The fidelity of the transfer is F = \sum_m p_m\,|\langle\psi|\varphi_m\rangle|^2, over the outcomes m, where \varphi_m is qubit 2's corrected state and \langle\psi|\varphi\rangle = \sum_i \overline{\psi_i}\,\varphi_i. It is 1 for a perfect transfer.
Write teleport(psi, pair) that returns a pair (outcomes, fidelity): outcomes maps each outcome string "m0m1" with probability greater than 1e-9 to a tuple (p, state), the probability and qubit 2's corrected state as a list of two amplitudes. Any global phase on each state is accepted: [1j, 0] is the same state as [1, 0].
Examples
Input: psi = [0.6, 0.8j], pair = [0.7071067811865476, 0, 0, 0.7071067811865476]
Output: ({'00': (0.25, [0.6, 0.8j]), '01': (0.25, [0.6, 0.8j]),
'10': (0.25, [0.6, 0.8j]), '11': (0.25, [0.6, 0.8j])}, 1.0)
Input: psi = [0.6, 0.8j], pair = [1, 0, 0, 0]
Output: ({'00': (0.18, [1, 0]), '01': (0.32, [0, 1]),
'10': (0.18, [1, 0]), '11': (0.32, [0, 1])}, 0.5392)
Explanation: without entanglement qubit 2 learns only a coin toss.
Input: psi = [1, 0], pair = [1, 0, 0, 0]
Output: ({'00': (0.5, [1, 0]), '10': (0.5, [1, 0])}, 1.0)
Explanation: outcomes 01 and 11 have probability 0 and are left out.
Goals
- Simulate the full teleportation protocol on three qubits, measurement and corrections included
- Compute the probability of each outcome and the receiver's state after it
- Measure with the fidelity how much a weakly entangled pair spoils the transfer