Repository navigation
Conversation
`acosh( 1/x )` loses the low bits of `1/x - 1` to the rounding of `1/x`, and near one those bits are most of the result: `asech( 1 - 1e-15 )` was off by 5% (`4.712e-8` for `4.470e-8`). For `0.5 <= x <= 1`, evaluate `log1p( ((1-x) + sqrt((1-x)*(1+x)))/x )` instead, where `1-x` is exact. The fixtures were generated with Julia's Float64 `asech`, which is also `acosh(inv(x))`; they are now evaluated in BigFloat, with a new set of values close to one. Signed-off-by: Abhist17 <abhistkamle.170903@gmail.com>
This was referenced Oct 13, 2026
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
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.
Description
This pull request:
math/base/special/asechaslog1p( ((1-x) + sqrt((1-x)*(1+x)))/x )for0.5 <= x <= 1(JS and C), instead ofacosh( 1/x ).acosh( 1/x )depends on1/x - 1, and rounding1/xloses its low bits. Near one, those bits are most of the result:In
[0.5, 1],1-xis exact, so the new form has no cancellation. Elsewhere the function is unchanged.data.jsonin 256-bitBigFloat. It was generated with Julia'sFloat64asech, which is alsoacosh(inv(x)), so its reference values carried the same error.near_one.json, 1000 values1 - 10^kforkin[-16, -1].developis off by up to about 2^30 ULPs on it, and this PR is within 2.data.jsonis checked at 2 ULPs instead of 1, since against the exact reference six of its 2003 points are 2 ULPs off.Related Issues
None.
asec,acothandacschave the samef( 1/x )construction and lose accuracy near|x| = 1too (acoth( 1.000000001 )andasec( 1.000000001 )are off by about 3e5 and 3e6 ULPs). I'll send those separately.Questions
No.
Other
test.jsandtest.native.js: 5008 pass.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?