Repository navigation
Conversation
…l`, `fresnelc` and `fresnels` Above `x = 36974` the functions returned exactly `0.5`, the Cephes cut-off, although the oscillating terms are of size `1/(πx)` (`3e-6` at `x = 1e5`). Below it, `sincos( π x^2 / 2 )` was evaluated on the rounded `x*x`, whose error the large argument turns into whole radians (81920 ULPs on the medium fixtures). Reduce `x^2` modulo 4 exactly, with a Veltkamp split so that each partial product is exact, and keep the asymptotic branch up to `x = 1e16`, where `1/(πx)` is below half an ulp of `0.5`. The fixtures came from Cephes itself and pinned both effects at 0 ULPs. They are replaced by a Julia runner evaluating the Fresnel integrals in BigFloat (power series below 10, the asymptotic expansions of `f` and `g` above); the medium, large and huge sets now pass at 0 ULPs, and the huge set extends to `1e15`. Signed-off-by: Abhist17 <abhistkamle.170903@gmail.com>
|
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
left a comment
There was a problem hiding this comment.
This is where it would benefit you to attend office hours and seek alignment before opening many PRs. You should not be deleting existing fixtures, as you need to understand their intent.
In this case (and others), we need the reference fixtures in order to access how well our implementation aligns with the reference implementation. If we notice large divergences, that tells us that something may be off with our implementation. Our special function tests are not just about total accuracy, they are also about helping us assess drift from a reference implementation.
So, in general, your approach in all these PRs is off. There is room for both reference implementation fixtures and arbitrary precision fixtures. One does not preclude the existence of the other. What it means is that we may need to duplicate tests so that we have separate test files exercising the different fixtures.
But again, this is where you need to seek alignment, rather than opening now dozens of similar PRs, none of which have been merged.
|
@kgryte thank you, that is clear, and I am sorry for the volume. I misread what the reference fixtures are for. I've moved this PR and the others like it (#16109–#16117, #16119) to draft, and I won't open more until we have agreed on the approach. Here is how I'd rework them. Please correct me if any of it is off:
One thing I'd like your view on before I touch the tests. In some packages the change deliberately departs from the reference implementation where the reference itself is inaccurate. Here, Cephes returns exactly
|
Description
This pull request:
math/base/special/fresnel,fresnelcandfresnels(JS and C; the three packages carry the same code).Two problems, both inherited from Cephes:
For
x > 36974, the functions returned exactly0.5. The oscillating part ofC(x)andS(x)isf(x) sin(πx²/2) - g(x) cos(πx²/2)withf(x) ≈ 1/(πx), which is3.2e-6atx = 1e5:Below that,
sincos( HALF_PI * x2 )used the roundedx*x. An error ofε x²there becomesπεx²/2radians in the argument, which atx = 1e4is about1.7e-8. On the medium fixtures ([100, 36968]), develop is off by up to 81920 ULPs.The fix reduces
x²modulo 4 (the period ofsin/cos( πu/2 )) exactly. A Veltkamp splitx = hi + lomakeshi*hi,2*hi*loandlo*loexact, and each term is reduced withfmod. The asymptotic branch then runs up tox = 1e16, beyond which1/(πx)is below half an ulp of0.5.BigFloat: the power series belowx = 10, and the asymptotic expansions offandg(Abramowitz and Stegun 7.3.27–28) above it. I spot-checked it against mpmath. Same ranges as before, except thathuge.jsonnow runs log-spaced up to1e15:[1e-4, 9.99][100, 36968][4e4, 6e4]0.5)[6e4, 1e15]0.5)Related Issues
None.
Questions
No.
Other
test.jsandtest.native.jspass.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?