code wiki / _hdl_build / nx_mathspec_tan.nx

nx_mathspec_tan.nx

buildroot/runtime/_hdl_build/nx_mathspec_tan.nx

6005 B171 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic mathspec
docsdependenciesstructsconstsfunctions

about

nx_mathspec_tan.nx -- SOVEREIGN SPEC EMITTER for the TAN kernel: every constant from the 120-bit bigfloat (trig + tan oracle organs). No python, no minimax: the small-residual polynomial uses the EXACT tangent-number Taylor family tan d = d + sum_{n>=2} T_n d^(2n-1)/(2n-1)! with the integer tangent numbers T_2..T_8 = 2 16 272 7936 353792 22368256 1903757312 (OEIS A000182, mathematical integers like k!); each coefficient divides by 2..(2n-1) one factor at a time (bf_div_small bound). |d| <= 1/16 -> 7 correction terms truncate below 2^-57 relative. Kernel scheme (accurate-table + dd): pi/2 Cody-Waite 3-part reduce (same 21-zeroed HI/MID construction as the sincos spec) -> r dd; anchors a_j = j/8 (j = 0..6 covers [0, pi/4]); tan(a+d) = T + t*sec2(a)/(1 - T*t) with T and sec2 carried hi/lo from this spec and the quotient refined in dd; odd quadrants reconstruct -1/tan via a dd reciprocal. Layout: c[0]=one c[1]=half c[2]=2/pi c[3]=HI c[4]=MID c[5]=LO c[6]=eight c[7..13] anchors j/8 c[14..20] T_hi[j] = fl(tan(j/8)) c[21..27] T_lo[j] (signed) c[28..34] S_hi[j] = fl(1+tan^2(j/8)) c[35..41] S_lo[j] (signed) c[42..48] Q coeffs hi-first (T_8.. down to T_2) license_tier: ORIGINAL

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_pattern_emit.nx nx_bigfloat120.nx nx_bigfloat120_div.nx nx_bigfloat120_trig.nx nx_mathspec_tan.nx

imports: nx_syscalls.nxnx_pattern_emit.nxnx_bigfloat120.nxnx_bigfloat120_div.nxnx_bigfloat120_trig.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_openat_wr sys_exit pe_w sys_write bf_new sys_mmap bf_set_int mtn_emit_row pe_w ↻ pe_wn sys_mmap ↻ sys_write ↻ mtn_wlit pe_w ↻ pe_wn ↻ bf_to_f64 bf_is_zero bf_copy bf_pi bf_new ↻ bf_atan_inv bf_new ↻ bf_set_int ↻ bf_div_small bf_is_zero ↻ bf_copy ↻ bf_norm bf_mul bf_is_zero ↻ bf_copy ↻ sys_mmap ↻ bf_copy ↻ bf_add bf_is_zero ↻ bf_copy ↻ sys_mmap ↻ bf_shr2 bf_norm ↻ bf_sub

structs

none

consts

26const K_MAGIC_7936: i64 = 7936
27const K_MAGIC_353792: i64 = 353792
28const K_MAGIC_22368256: i64 = 22368256
29const K_MAGIC_1903757312: i64 = 1903757312

functions

31func mtn_wlit(fd: i64, v: i64) -> i64
called by 1: mtn_emit_row calls 2: pe_wpe_wn
41func mtn_emit_row(fd: i64, idx: i64, v: i64) -> i64
called by 2: mtn_emit_hilomain calls 3: pe_wpe_wnmtn_wlit
49func mtn_emit_hilo(fd: i64, idxhi: i64, idxlo: i64, a: *i64) -> i64
71func main() -> i64