# QWorld Bronze: Quantum Teleportation

## Quantum Teleportation

**Prepare a few blank sheets of paper**

**to draw the circuit of the following protocol step by step and****to solve some of tasks requiring certain calculations.**

Asja wants to send a qubit to Balvis by using only classical communication.

Let $\big\lvert v\rangle = a \ b \in \mathbf{R}^2$ be the quantum state.

*Discussion:* If Asja has many copies of this qubit, then she can collect the statistics based on these qubits and obtain an approximation of $a$ and $b$, say $\tilde a, \tilde b$, respectively. After this, Asja can send $\tilde a$ and $\tilde b$ by using many classical bits, the number of which depends on the precision of the amplitudes.

On the other hand, If Asja and Balvis share the entangled qubits in state $\sqrt{2}\big\lvert 00\rangle + \sqrt{2}\big\lvert 11\rangle$ in advance, then it is possible for Balvis to create $\lvert v\rangle$ in his qubit after receiving two bits of information from Asja.

### Protocol

The protocol uses three qubits as specified below:

Asja has two qubits and Balvis has one qubit.

Asja's quantum message (key) is $|v\rangle = a \ b = a|0\rangle + b|1\rangle$.

The entanglement between Asja's second qubit and Balvis' qubit is $\sqrt{2}|00\rangle + \sqrt{2}|11\rangle$.

So, the quantum state of the three qubits is

$a|0\rangle + b|1\rangle \\ \sqrt{2}|00\rangle + \sqrt{2}|11\rangle = \sqrt{2} \big( a|000\rangle + a|011\rangle + b|100\rangle + b|111\rangle \big)$

**CNOT operator by Asja**

Asja applies CNOT gate to her qubits where $q[2]$ is the control qubit and $q[1]$ is the target qubit.

### Task 1

Calculate the new quantum state after this CNOT operator.

**Hadamard operator by Asja**

Asja applies Hadamard gate to $q[2]$.

### Task 2

Calculate the new quantum state after this Hadamard operator.

Verify that the resulting quantum state can be written as follows:$\frac{1}{2} |00\rangle \big( a|0\rangle+b|1\rangle \big) + \frac{1}{2} |01\rangle \big( a|1\rangle+b|0\rangle \big) + \frac{1}{2} |10\rangle \big( a|0\rangle-b|1\rangle \big) + \frac{1}{2} |11\rangle \big( a|1\rangle-b|0\rangle \big)$

### Measurement by Asja

Asja measures her qubits. With probability $41 $, she can observe one of the basis states.

Depeding on the measurement outcomes, Balvis' qubit is in the following states:

- "00": $|{v_{00}}\rangle = a|0\rangle + b |{1}\rangle$
- "01": $|{v_{01}}\rangle = a|{1}\rangle + b |{0}\rangle$
- "10": $|{v_{10}}\rangle = a|{0}\rangle - b|{1}\rangle$
- "11": $|{v_{11}}\rangle = a|{1}\rangle - b |{0}\rangle$

As can be observed, the amplitudes $a$ and $b$ are "transferred" to Balvis' qubit in each case.

If Asja sends the measurement outcomes, then Balvis can construct $|{v}\rangle$ exactly.

### Task 3

Asja sends the measurement outcomes to Balvis by using two classical bits: $x$ and $y$.

For each $(x,y)$ pair, determine the quantum operator(s) that Balvis can apply to obtain $|{v}\rangle = a|{0}\rangle+b|{1}\rangle$ exactly.

### Task 4

Create a quantum circuit with three qubits as described at the beginning of this notebook and two classical bits.

Implement the protocol given above until Asja makes the measurements (included).

- The state of $q[2]$ can be set by the rotation with a randomly picked angle.
- Remark that Balvis does not make the measurement.

At this point, read the state vector of the circuit by using "statevector_simulator".

_When a circuit having measurement is simulated by "statevector_simulator", the simulator picks one of the outcomes, and so we see one of the states after the measurement._

Verify that the state of Balvis' qubit is in one of these: $|{v_{00}}\rangle$, $|{v_{01}}\rangle$, $|{v_{10}}\rangle$, and $|{v_{11}}\rangle$.

Guess the measurement outcome obtained by "statevector_simulator".

See the related project for the solution.

### Task 5

Implement the protocol above by including the post-processing part done by Balvis, i.e., the measurement results by Asja are sent to Balvis and then he may apply $X$ or $Z$ gates depending on the measurement results.

We use the classically controlled quantum operators.

Since we do not make measurement on $q[0]$, we define only 2 classical bits, each of which can also be defined separated.

`q = QuantumRegister(3)c2 = ClassicalRegister(1,'c2')c1 = ClassicalRegister(1,'c1')qc = QuantumCircuit(q,c1,c2)...qc.measure(q[1],c1)...qc.x(q[0]).c_if(c1,1) # x-gate is applied to q[0] if the classical bit c1 is equal to 1`

Read the state vector and verify that Balvis' state is $ab$ after the post-processing.

See the related project for the solution.