noun: math.hoon transcendental jets (@rd/@rs/@rh/@rq) [ml64]#1045
Open
sigilante wants to merge 3 commits into
Open
noun: math.hoon transcendental jets (@rd/@rs/@rh/@rq) [ml64]#1045sigilante wants to merge 3 commits into
sigilante wants to merge 3 commits into
Conversation
Collaborator
Author
|
CI failure: near is a reserved identifier/macro on the CI toolchain (it compiles on macOS clang but not Linux gcc — near is a legacy reserved word). That hits the @rh inverse-trig code in math.c and affects both vere PRs. |
Register the math.hoon transcendental library (numerics /lib/math) in the userspace %non chapter, so the four IEEE precision doors run native SoftFloat instead of interpreted Hoon. 64-bit (vere64) counterpart of the develop-targeted change; chub-based math.c is byte-identical bar the two two-arg u3r_mean call sites. - 15 transcendentals x 4 doors (exp log sin cos tan atan atan2 asin acos sqt cbt pow pow-n log-2 log-10) for @rd/@rs/@rh/@rq, as non -> math -> <door> -> arm in the 135 tree. - Jet bodies in jets/i/math.c, u3qi_*/u3wi_* decls in q.h/w.h, build.zig source entry. Bit-exact to the Hoon door; -test %/tests/lib 247/247 green on a fresh fakezod, jet identical to interpreted Hoon arm-by-arm. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sigilante
force-pushed
the
neal/math-transcendental-jets
branch
from
June 26, 2026 04:46
9965a23 to
17ef447
Compare
Collaborator
Author
…al/math-transcendental-jets
Two accuracy bugs found while writing up this jet work for publication, both now fixed to match the corrected math.hoon (numerics repo): - _rh_sin/_rh_cos: the native-f16 quarter-turn reduction broke down past |x|~500 (q=round(|x|*2/pi) exceeds f16's 2048 exact-integer ceiling, amplifying rounding error by pi/2's leading term) -- catastrophic errors up to 10 orders of magnitude past 1 ULP, well within f16's ordinary range. Fixed by widening to f32 (f16_to_f32, exact) around the already-correct _rs_sin/_rs_cos, narrowing back via f32_to_f16 (correctly rounded RNE) -- both primitives already linked via SoftFloat. - _rs_tan: was (div (sin x) (cos x)), the same composed ratio used at @rh/@rq (~1.2 ULP). Given a genuine dedicated kernel, mirroring @rd's own __kernel_tan structure (Chebyshev-fit Q(z)=(tan(r)/r-1)/z, 7 coefficients, -cot path via reciprocal for odd reduction quadrants), reaching ~0.94 ULP -- beating the ratio outright. The key structural detail: the dominant linear term must be added last (w2=x+r), not multiplied through the polynomial, matching fdlibm's own convention. Verified on a freshly booted ship with jets enabled: the full tests/lib/math-rh.hoon and math-tan.hoon suites (numerics repo) pass, every case running in tens of microseconds (jetted, not falling back to interpretation). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
64-bit (ml64) counterpart of #1044. Registers the math.hoon transcendental
library (numerics /lib/math) in the userspace %non chapter so the four IEEE
precision doors run native SoftFloat instead of interpreted Hoon.
Stacked on
neal/lagoon-softblas-64; merge after the 64-bit lagoon work.What
exp log sin cos tan atan atan2 asin acos sqt cbt pow pow-n log-2 log-10) for@rd/@rs/@rh/@rqasnon → math → <door> → armin the 135 tree.jets/i/math.c(chub I/O; byte-identical to the 32-bit copybar the two two-arg
u3r_meancall sites),q.h/w.hdecls, build.zig entry.Verification
On a fresh hoon-136 fakezod (with 136 scaffolding applied locally): all four
doors fire (
exp:rd/rs/rh~1 µs/call,exp:rq~1.8 µs, vs ~250 µsinterpreted) and
-test %/tests/libis 247/247 green, bit-exact to theHoon door and identical to the 32-bit runtime.
🤖 Generated with Claude Code