import numpy as np

from qsim import ZERO, H, apply_all, probabilities


def phase(phi):
    return np.array([[1, 0], [0, np.exp(1j * phi)]])


# On cherche phi tel que cos²(phi / 2) = 3/4, donc cos(phi / 2) = √3 / 2 : phi / 2 = π/6
phi = 2 * np.arccos(np.sqrt(3) / 2)
print("phi / π =", round(float(phi / np.pi), 3) + 0.0)
p0, p1 = np.round(probabilities(apply_all(ZERO, [H, phase(phi), H])), 3) + 0.0
print(f"P(0) = {p0:.3f}, P(1) = {p1:.3f}")
