Repository navigation
Conversation
The single-precision counterpart of stdlib-js#16118. Above `x = 36974` the function returned exactly `0.5`, and below it `sincosf` was evaluated on the rounded `x*x`, which in single precision costs most of a radian by `x = 3000`. Reduce `x^2` modulo 4 exactly with a Veltkamp split (`4097 = 2^12+1`) and keep the asymptotic branch up to `2^24`, where `1/(πx)` is below half an ulp of `0.5`. The C/Cephes fixtures are replaced by the BigFloat Julia runner from Signed-off-by: Abhist17 <abhistkamle.170903@gmail.com> stdlib-js#16118, evaluated at single-precision inputs.
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/fresnel,fresnelcandfresnels#16118 to the single-precisionmath/base/special/fresnelf(JS and C).It has the same two problems, and the second is worse in single precision:
x > 36974it returned exactly0.5, although the oscillating terms are of size1/(πx).sincosf( HALF_PI * x2 )used the roundedx*x. A float32x*xnearx = 3000is off by up to0.5, which is most of a radian of argument.The fix reduces
x²modulo 4 exactly. A Veltkamp split with4097 = 2^12+1leaves 12-bit halves, so every partial product is exact in single precision, and each one is reduced withfmodf. The asymptotic branch now runs up to2^24, where1/(πx)is below half an ulp of0.5.math/base/special/fresnel,fresnelcandfresnels#16118, evaluated at single-precision inputs (huge.jsonnow runs log-spaced from4e4to2^24). Against those exact values:[1e-4, 9.99][10, 100][100, 36968][4e4, 2^24]Related Issues
None. Follows #16118.
Questions
No.
Other
test.jsandtest.native.jspass.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?