Coding the teleportation circuitry
In this section, we will provide code to teleport qubits and test the results. We’ve divided the code into three parts:
- Creating registers
- Adding gates to the registers
- Running the quantum circuit
Creating registers
We start with the imports:
from qiskit import QuantumCircuit, QuantumRegister, \ ClassicalRegister, Aer import random import numpy as np from qiskit.result import marginal_counts
In this chapter, the only new import is marginal_counts
. We will describe that function later in this section.
The following function defines a circuit:
def create_registers(): alice_q = QuantumRegister(1, 'alice (q)') peter_alice_q = \ QuantumRegister(1, 'peter/alice (q)') peter_bob_q = QuantumRegister(1, 'peter/bob (q)') ...