I am creating a 2 qubit entangled state:
def density_matrix_chsh(i, j, qs):
circuit = chsh_circuit(i, j, qs)
return cirq.final_density_matrix(circuit, qubit_order=qs)
def chsh_circuit(i, j, qs):
return cirq.Circuit(cirq.H(qs[i]), cirq.CNOT(qs[i], qs[j]))
qs = [a, b]
state = density_matrix_chsh(0, 1, qs)
Then I am applying rotation for maximum violation:
th = np.pi/(-2)
th1 = np.pi/(4)
th2 = 0
random_angles = []
newlist = []
b_big = cirq.kron(cirq.unitary(cirq.ry(th)),cirq.unitary(cirq.ry(th)))
results = []
for choosen in itertools.product([th2, th1], repeat=2):
random_angles.append(choosen)
for i in range (1000):
choosen_combination = random.choice(random_angles)
a_big = cirq.kron(cirq.unitary(cirq.rz(choosen_combination[0])),cirq.unitary(cirq.rz(choosen_combination[1])))
rotated_state = b_big @ a_big @ state @ b_big.conj().T
measurement_rotated = cirq.measure_density_matrix(rotated_state,indices=[0, 1])
print("measuring qubits ",measurement_rotated)
qubit_result = measurement_rotated[0]
results.append(qubit_result)
For instance here I tried 1000 times and both qubits are either 0 or 1 at the sma time but I could never see one of them 1 and the other one is 0 after measurement. Probably I am doing something wrong and I can't see Thanks for helps