import numpy as np

from common import ry, show
from qsim.etape1_un_qubit import ZERO, probabilities

# On tourne |0⟩ autour de l'axe y, par huitièmes de tour
for k, label in enumerate(("0", "π/4", "π/2", "3π/4", "π")):
    theta = k * np.pi / 4
    state = ry(theta) @ ZERO
    p1 = probabilities(state)[1]
    print(f"θ = {label:<5} RY(θ)|0⟩ = {show(state):<16} P(1) = {p1:.3f}   sin²(θ/2) = {np.sin(theta / 2) ** 2:.3f}")

# La matrice elle-même, pour un quart de tour
print("RY(π/2) =", show(ry(np.pi / 2)))
