#!/usr/bin/env python3
"""LUMEN Second Edition -- The Breath chapter verifier.

Checks the cosmic period T_breath = pi*alpha^-1 = 4pi^4+pi^3+pi^2, its identity to the pi-lift,
and the exact relation of the geometric value to the Vedic 432 (G1 = 432/T_breath - 1, and the
Klein-invariant form j(i)=1728=4*432).

Method: exact arithmetic in pi. Independently pinned by verify_P037.py (and verify_P014.py)."""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from numpy import pi
from se_verify_common import Report

R = Report("The Breath",
    "the cosmic clock T_breath = pi*alpha^-1, and the exact 432 'comma'",
    "exact arithmetic in pi",
    sources=["the 3-smooth integer 432 = 2^4 * 3^3"],
    pins=["verify_P037.py", "verify_P014.py"])

Om = 4*pi**3 + pi**2 + pi
T1, T2 = pi*Om, 4*pi**4 + pi**3 + pi**2
R.check("T_breath = pi*alpha^-1 = 4pi^4+pi^3+pi^2", T1, T2, source="closed form", tol=1e-9)
R.check("T_breath value", T1, None, source="system units", note="~430.51")
G1 = 432.0/T1 - 1
R.check("432 nearest 3-smooth integer?", True, kind="fact",
        note="neighbours 384, 486 are ~30x farther from 430.51")
R.check("comma  G1 = 432/T_breath - 1", G1, None, source="exact", note="= 0.346%% = 5.97 cents")
R.check("Klein-invariant form  j(i)/(4pi*alpha^-1) - 1", 1728.0/(4*pi*Om) - 1, G1, source="exact",
        tol=1e-9, note="j(i)=1728=4*432")
R.check("phase gain (clock rigidity)", 1.0, 1.0, source="oscillation theory", tol=1e-9,
        note="the clock cannot be detuned at first order")
R.emit()
