1
$\begingroup$

enter image description here

from qutip import *
import numpy as np

# Define the quantum channel

basis = [basis(2,0), basis(2,1)] # Define the computational basis states |0> and |1>
ket_0 = basis[0]
ket_1 = basis[1]
H = (ket_0*ket_1.dag() + ket_1*ket_0.dag()) / np.sqrt(2) # Define the Hadamard gate

# Define the initial state of the qubits
alice_qubits = [ket_0]*10 # Alice prepares 10 qubits in the |0> state
bob_qubits = [ket_0]*10 # Bob prepares 10 qubits in the |0> state

# Alice prepares the qubits
for i in range(10):
    if np.random.random() < 0.5: # Alice randomly chooses to apply the Hadamard gate or not
        alice_qubits[i] = H * alice_qubits[i]

# Bob measures the qubits
for i in range(10):
    if np.random.random() < 0.5: # Bob randomly chooses to measure in the computational basis or the Hadamard basis
        bob_qubits[i] = H * bob_qubits[i]
    measurement = bob_qubits[i].measure() # Bob measures the qubit
    if measurement == 1: # If the measurement is |1>, Bob sends a bit to Alice
        print("Bob sends 1 to Alice")
    else: # If the measurement is |0>, Bob sends a bit to Alice
        print("Bob sends 0 to Alice")
$\endgroup$

0