code wiki / _hdl_build / _pe_f64gamma_refl.nx
_pe_f64gamma_refl.nx source
↩ module page · 27 lines · 1320 B
1// _pe_f64gamma_refl.nx -- f64 GAMMA REFLECTION kernel for 0 < x < 0.5 (closes the
2// gamma rung-1 LOUD-NAN debt the gamma spec named: x<0.5 reflection). Composes the
3// PROVEN sibling kernels via the Euler reflection formula -- no new core numerics:
4// Gamma(x) = pi / ( sin(pi*x) * Gamma(1-x) ), with 1-x in (0.5,1) so Gamma(1-x)
5// uses the existing nx_f64_gamma (its supported domain) and sin(pi*x) uses the
6// existing nx_f64_sin. Parallel to erfc closing erf's gap: a named honest debt
7// retired by composition, not fabrication. f64 software-IEEE throughout.
8// license_tier: ORIGINAL
9//
10// module: nishi-core.math.f64_gamma_refl
11// depends: nishi-core.math.f64, nishi-core.math.f64_sincos, nishi-core.math.f64_gamma
12// capability: F64_GAMMA_REFLECTION
13import "nx_syscalls.nx"
14import "nx_f64.nx"
15import "nx_f64_div.nx"
16import "_pe_f64sincos.nx"
17import "_pe_f64gamma.nx"
18
19const GR_PI: i64 = 0x400921FB54442D18 // pi
20const GR_ONE: i64 = 0x3FF0000000000000 // 1.0
21
22func nx_f64_gamma_refl(x: i64) -> i64 {
23 let omx: i64 = nx_f64_sub(GR_ONE, x) // 1 - x in (0.5, 1)
24 let g: i64 = nx_f64_gamma(omx) // Gamma(1-x)
25 let s: i64 = nx_f64_sin(nx_f64_mul(GR_PI, x)) // sin(pi*x)
26 return nx_f64_div(GR_PI, nx_f64_mul(s, g)) // pi / (sin(pi*x) * Gamma(1-x))
27}