# Phase relative : seule l'amplitude de |1⟩ tourne de l'angle φ
import cmath

import numpy as np
from common import h
from qsim.etape1_un_qubit import make_state, probabilities

s = 1 / np.sqrt(2)
for name, phi in [("0", 0), ("π/2", np.pi / 2), ("π", np.pi), ("3π/2", 3 * np.pi / 2)]:
    state = make_state(s, s * cmath.exp(1j * phi))
    direct = np.round(probabilities(state), 3)
    after_h = np.round(probabilities(h(state)), 3)
    formula = (1 + np.cos(phi)) / 2
    print(f"φ = {name:<5} directe : {direct}   après h : {after_h}   (1 + cos φ)/2 = {formula:.3f}")
