Repository navigation
Conversation
…/base/special/erfcx` For negative `x`, `erfcx(x) = 2 exp(x^2) - erfcx(-x)`, and `exp( x*x )` multiplies the rounding error of `x*x` by `x^2`: `erfcx( -25.15 )` was off by about 380 ULPs, and the error reaches about 490 ULPs before the function overflows. Split `x = xh + xl` so that `xh*xh` is exact and use `exp(xh^2) * exp(xl*(x+xh))`. The medium negative fixtures came from SciPy, whose `erfcx` has the same construction; they are now generated in BigFloat by a Julia runner, along with a new set down to `-26.6`. Signed-off-by: Abhist17 <abhistkamle.170903@gmail.com>
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Abhist17
marked this pull request as draft
October 14, 2026 04:17
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:
exp(x^2)in the negative branch ofmath/base/special/erfcxasexp(xh^2) * exp((x-xh)*(x+xh))(JS and C), wherexhisxtruncated to 16 fractional bits, soxh*xhis exact and the second factor is close to one.For
x < 0,erfcx(x) = 2 exp(x^2) - erfcx(-x). Formingx*xrounds it, andexpturns that absolute error of aboutx^2 εinto a relative error of the same size. That is several hundred ULPs oncex^2is in the hundreds:On the new fixture (2001 points in
[-26.6, -1]),developis off by up to 493 ULPs and this PR by up to 2.medium_negative.json([-10, -1], same grid) from the SciPy runner to a Julia runner that evaluateserfcxin 256-bitBigFloat. SciPy'serfcxuses the same Faddeeva-package construction, so its values carried the same error, up to 59 ULPs atx = -9.19284876905041(SciPy1.005985069797548e37, BigFloat1.0059850697975548e37). That test is now checked at 2 ULPs instead of 1.negative.json, down to-26.6, just above where the function overflows (-26.7).Related Issues
None.
Questions
No.
Other
test.jsandtest.native.jspass.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?