code wiki / _hdl_build / _gamma_probe.nx
_gamma_probe.nx
buildroot/runtime/_hdl_build/_gamma_probe.nx
about
_gamma_probe.nx -- DE-RISK the gamma kernel BEFORE building its emitter template
(design-intelligence law: validate the hard passage in isolation, don't rush a
multiday-bug door open). Computes Gamma(x) in plain f64 via the Stirling lnGamma
series with recurrence pull-up, using the EXISTING authored log + exp kernels
(kernel COMPOSITION proof), and compares against the known-good bigfloat oracle
(bf_gamma_f64) at integer + half-integer grid points. If max_ulp is small, the
GAMMA_STIRLING template is safe to author; if not, the probe NAMES the gap (which
term count / which domain) -- no emitter built on an unvalidated approach.
lnGamma(w) = (w-0.5)*ln(w) - w + 0.5*ln(2pi) + sum_k c_k / w^(2k-1) (w>=8)
Gamma(x) = exp(lnGamma(x+m)) / ((x)(x+1)...(x+m-1)) pull up to w=x+m>=8
Uses the spec table _pm_gamma_spec.nx (sovereign consts). Durable: GAMMAPROBE row
-> knowledge/status/math_engine.log. Exit 0 = approach validated (max_ulp<=8).
license_tier: ORIGINAL
dependencies 10 imports · 0 importers
imports: nx_syscalls.nxnx_f64.nxnx_f64_div.nxnx_f64_cvt.nxnx_bigfloat120.nxnx_bigfloat120_div.nxnx_bigfloat120_gamma.nx_pm_gamma_spec.nx_pe_f64log.nx_pe_f64sinhcosh.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 24 | func gp_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 25 | func gp_f(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 26 | func gp_n(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 28 | func gp_exp(v: i64) -> i64 { return nx_f64_add(nx_f64_cosh(v), nx_f64_sinh(v)) } |
| 30 | func gp_gamma(x: i64, c: *i64) -> i64 |
| 66 | func gp_ulp(a: i64, b: i64) -> i64 { if a >= b { return a - b } return b - a } called by 1: main |
| 67 | func main() -> i64 |