omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / evidence / E1-ULP-EXPLOG / 20261027 / exp-log-ulp-bounds.md
| 1 | E1Open3 Wolfram derivation of the a-priori ulp bounds for omega_math_exp / omega_math_log |
| 2 | (src/omega_numeric.c at omega-mv 0919efc3c, lines 477-553). Run 2026-10-27 ~11:05Z through |
| 3 | mcp__wolfram_wolframlanguageevaluator (hosted, stateless kernel). First-order rounding analysis: |
| 4 | each rounded op contributes half an ulp of its own result times the derivative of the final value; |
| 5 | terms of order u^2 are dropped. Integer ulp distance against RN(exact) is bounded by Floor[Epre + 1], |
| 6 | where Epre is the error before the final rounding, in ulps of the exact result's binade. |
| 7 | |
| 8 | ## EXP |
| 9 | |
| 10 | Query: |
| 11 | f32[x_]:=With[{e=Floor[Log2[Abs[x]]]},Round[x 2^(23-e)] 2^(e-23)]; |
| 12 | ul[y_]:=If[y==0,0,2^(Floor[Log2[Abs[y]]]-23)];hu[y_]:=ul[y]/2; |
| 13 | c3=f32[1666666716/10^10];c4=f32[416666679/10^10];c5=f32[83333338/10^10]; |
| 14 | inv=f32[14426950408889634/10^16];hi=f32[693145751953125/10^15];lo=f32[14286068203094172/10^22]; |
| 15 | slack=2^-17+104 Abs[inv-1/Log[2]]; h=Log[2](1/2+slack); |
| 16 | p[r_]:=1+r+r^2/2+c3 r^3+c4 r^4+c5 r^5; |
| 17 | dr[r_]:=hu[150 lo]+hu[r]+150 Abs[Log[2]-hi-lo]; |
| 18 | rndPre[r_]:= Horner roundings a1=r c5, t1=c4+a1, p1=r t1, t2=c3+p1, p2=r t2, t3=1/2+p2, p3=r t3, t4=1+p3, t5=r t4, |
| 19 | weighted by r^4,r^4,|r|^3,|r|^3,r^2,r^2,|r|,|r|,1; |
| 20 | epre[r_]:=(Abs[p[r]-Exp[r]]+rndPre[r]+Exp[r] dr[r])/ul[Exp[r]]; grid of 8001 r over [-h,h], 30 digits. |
| 21 | |
| 22 | Result: |
| 23 | c3 -> 11184811/67108864, c4 -> 11184811/268435456, c5 -> 8947849/1073741824, |
| 24 | hi -> 22713/32768, lo -> 6283079/4398046511104, inv -> 12102203/8388608, |
| 25 | ln2-hi-lo -> 5.4979e-14, slack -> 9.6324e-6, h -> 0.346580266948, |
| 26 | maxApproxUlp -> 38.47122619 at r = -h; approx at +h -> 21.23492274, |
| 27 | maxEpreUlp -> 39.15458979 at r = -h (rounding part 0.68336360), |
| 28 | bound = Floor[Epre+1] -> 40 ulp. Declared NUM_ORACLE_EXP_ULP = 40. |
| 29 | Subnormal results: the final scale rounds once into a coarser ulp, so Epre in that ulp is no larger; same bound. |
| 30 | |
| 31 | ## LOG |
| 32 | |
| 33 | Query: |
| 34 | c1=f32[333333343/10^9];c2=f32[200000003/10^9];c3=f32[142857149/10^9];L=f32[6931471805599453/10^16];M=f32[141421356/10^8]; |
| 35 | z=(m-1)/(m+1) (m-1 exact by Sterbenz; m+1 and the correctly rounded divide each add half an ulp), |
| 36 | Horner s1=z2 c3, s2=c2+s1, s3=z2 s2, s4=c1+s3, s5=z2 s4, pl=1+s5, lm=2 z pl; |
| 37 | Epre(e,m) = (|e| |L-ln2| + hu[e L] + |lm-Log[m]| + roundings of lm + hu[lm] (e!=0)) / ul[e ln2 + Log[m]]; |
| 38 | m over 3001 grid points in (M/2, M], e in {-149,-148,-127,-126,-125,-100,-64,-10..10,64,100,126,127,128}. |
| 39 | |
| 40 | Result: |
| 41 | c1 -> 11184811/33554432, c2 -> 13421773/67108864, c3 -> 9586981/67108864, LN2f -> 1453635/2097152, |
| 42 | ln2-LN2f -> -1.9047e-9. |
| 43 | Per-e max Epre: e=-1 4.2186, e=1 4.1653, e=0 2.7825, e=-3 1.7727, e=3 1.8233, e=-6 1.3624, e=2 1.3526, |
| 44 | all |e|>=7 below 0.75. |
| 45 | worst -> {-1, 4.2186}; bound = Floor[Epre+1] -> 5 ulp. Declared NUM_ORACLE_LOG_ULP = 4. |
| 46 | The a-priori analysis does not prove 4; only the exhaustive measurement can (see ulp-LOG.log). |