In this article

Putting it All Together: Teleportation

12/11/2017

2 minutes to read

Contributors

In this article

Let's return to the example of the teleportation circuit defined in Quantum Circuits. Shown below is a text-book quantum circuit that implements the teleportation, including the quantum part, the measurements, and the classically-controlled correction operations.

We can now translate each of the steps in this quantum circuit into Q#.
First, we begin the definition of a new operation while will perform the teleportation given two qubits msg and there:

operation Teleport(msg : Qubit, there : Qubit) : () {
body {

Next, we allocate a qubit here with a using block:

using (register = Qubit[1]) {
let here = register[0];

We can then create the entangled pair between here and there by using the H and CNOT operations:

H(here);
CNOT(here, there);

We then use the next $\operatorname{CNOT}$ and $H$ gates to move our message qubit:

CNOT(msg, here);
H(msg);

Finally, we use M to perform the measurements and feed them into classical control, as denoted by if statements:

This finishes the definition of our teleportation operator, so we can deallocate here, end the body, and end the operation.

}
}
}

Note

The feedback system for this content will be changing soon. Old comments will not be carried over. If content within a comment thread is important to you, please save a copy. For more information on the upcoming change, we invite you to read our blog post.