"""Analytic identities and scale illustrations; no cosmological fit is performed."""
from pathlib import Path
import json
import sympy as s
x,L,f,M=s.symbols('x Lambda f Mpl',positive=True)
U=L**4*x**2*(1-x)**2
eta=s.simplify(M**2*s.diff(U,x,2)/(f*f*U))
eta_top=s.simplify(eta.subs(x,s.Rational(1,2)))
assert eta_top==-16*M**2/f**2
m2=s.simplify(s.diff(U,x,2).subs(x,0)/f**2)
assert m2==2*L**4/f**2
alpha=s.simplify(M*s.diff(s.log((1-x)**2),x)/f)
assert s.simplify(alpha+2*M/(f*(1-x)))==0
# Illustrative SI comparison: density and DE scale are chosen inputs, not fitted data.
c=299792458.; density=1000.; rho_de=6e-10
rho_m=density*c*c;L4_hilltop=16*rho_de;L4_cold_bound=8*rho_m
r=rho_m/L4_hilltop
results={'kind':'symbolic checks and illustrative scale estimate',
 'vacuum_scalar_mass_squared':str(m2),'hilltop_slow_roll_eta':str(eta_top),'ordinary_scalar_coupling':str(alpha.subs(x,0)),
 'inputs':{'density_kg_m3':density,'illustrative_dark_energy_J_m3':rho_de},
 'derived':{'matter_rest_energy_J_m3':rho_m,'Lambda4_if_hilltop_is_dark_energy_J_m3':L4_hilltop,'Lambda4_lower_bound_for_cold_ordinary_branch_J_m3':L4_cold_bound,'scale_ratio':L4_cold_bound/L4_hilltop,'r_at_dark_energy_choice':r},
 'scope':'The density contradiction applies to the same universal mass function, homogeneous cold matter, no extra supports or screening; it is not a theorem excluding all theories.'}
Path(__file__).with_name('consistency_results.json').write_text(json.dumps(results,ensure_ascii=False,indent=2))
print(json.dumps(results,ensure_ascii=False,indent=2))
