Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for IEEE 754-2019 compliance #365

Open
2 tasks done
kgryte opened this issue Sep 15, 2020 · 8 comments
Open
2 tasks done

Add tests for IEEE 754-2019 compliance #365

kgryte opened this issue Sep 15, 2020 · 8 comments
Labels
Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality.

Comments

@kgryte
Copy link
Member

kgryte commented Sep 15, 2020

Checklist

Please ensure the following tasks are completed before filing a bug report.

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.

Description

Description of the issue.

To ensure conformance of @stdlib/math/base/special/* functions with IEEE 754-2019, we should explicitly include compliance tests in the various test suites of the mathematical functions (e.g., pow, exp, etc) present in the standard. The IEEE 754 standard explicitly states behavior for various edge cases for each mathematical function. By including these tests, we can ensure that the underlying implementations, should they change, always remain IEEE 754 compliant.

Related Issues

Does this issue have any related issues?

None.

Questions

Any questions for reviewers?

No.

Other

Any other information relevant to this issue? This may include screenshots, references, stack traces, sample output, and/or implementation notes.

No.

@kgryte kgryte added Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality. labels Sep 15, 2020
@munrocket
Copy link

Sinpi/cospi without correct rounding in last ulp.

@kgryte
Copy link
Member Author

kgryte commented Dec 17, 2020

@munsocket Can you explain in more detail? How are you arriving at this conclusion? Particularly, how did you determine that sinpi/cospi don't have correct rounding?

@munrocket
Copy link

I am just read source code :D

function sinpi(x) {
  return Math.sin(Math.PI*x);
}

Is not enough because floating point numbers perform rounding after each operation(multiplication) in round-to-nearest-even mode.

@kgryte
Copy link
Member Author

kgryte commented Dec 17, 2020

That is not our source, which can be found here.

We're not likely to require strict ulp requirements for special functions, as these functions are often affected in subtle ways by upstream deps. For example, simply because sin and cos are accurate to within 1 ulp, this does not mean that a special function consuming them will be accurate to 1 ulp. In fact, slightly less accurate implementations, when consumed by another special function, can result in more accurate results.

IEEE 754 only requires 1 ulp agreement for a small subset of special functions (e.g., sqrt), so we're not likely to enforce such requirements on all special functions.

@munrocket
Copy link

Ok, looks legit then :)

@kgryte
Copy link
Member Author

kgryte commented Dec 17, 2020

@munsocket Thanks for checking!

@munrocket
Copy link

munrocket commented Dec 18, 2020

By the way, if your sinpi/cospi will pass compliance tests it is very clever implementation and can be proposed in tc39 and added to javascript specification. Right not I am working on FMA emulation (here snippet), I found it in your 2do list too.

@kgryte
Copy link
Member Author

kgryte commented Dec 18, 2020

Yeah, I saw that you are working on fma emulation. :)

Re: TC39. That isn't particularly interesting for us, given that the spec does not require minimum precision requirements. And for good reason: implementations have historically needed the flexibility to trade-off accuracy for increased perf. While libm is the recommended implementation, this is by no means required.

In general, we cannot rely on native JavaScript built-ins to always fulfill accuracy guarantees, and this will remain the case. As such, if a user wants certain guarantees, they'll need to rely on userland implementations, such as those provided by stdlib.

kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
kgryte pushed a commit that referenced this issue Apr 5, 2025
Planeshifter pushed a commit that referenced this issue Apr 5, 2025
PR-URL: #6557
Ref: #365

Reviewed-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Karan Anand <[email protected]>
Planeshifter pushed a commit that referenced this issue Apr 5, 2025
PR-URL: #6561
Ref: #365

Co-authored-by: stdlib-bot <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Karan Anand <[email protected]>
Planeshifter pushed a commit that referenced this issue Apr 5, 2025
PR-URL: #6570
Ref: #365

Reviewed-by: Philipp Burckhardt <[email protected]>
Planeshifter pushed a commit that referenced this issue Apr 6, 2025
PR-URL: #6573
Ref: #365

Reviewed-by: Philipp Burckhardt <[email protected]>
Planeshifter pushed a commit that referenced this issue Apr 7, 2025
PR-URL: #6599
Ref: #365

Reviewed-by: Philipp Burckhardt <[email protected]>
Planeshifter pushed a commit that referenced this issue Apr 8, 2025
PR-URL: #6595
Ref: #365

Reviewed-by: Philipp Burckhardt <[email protected]>
kgryte pushed a commit that referenced this issue Apr 9, 2025
PR-URL: #6597
Ref: #365
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Karan Anand <[email protected]>
kgryte pushed a commit that referenced this issue Apr 9, 2025
PR-URL: #6593
Ref: #365
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Karan Anand <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
kgryte pushed a commit that referenced this issue Apr 9, 2025
PR-URL: #6594
Ref: #365
Reviewed-by: Athan Reines <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
anandkaranubc added a commit to anandkaranubc/stdlib that referenced this issue Apr 9, 2025
anandkaranubc added a commit to anandkaranubc/stdlib that referenced this issue Apr 9, 2025
anandkaranubc added a commit to anandkaranubc/stdlib that referenced this issue Apr 9, 2025
PR-URL: stdlib-js#6597
Ref: stdlib-js#365
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Karan Anand <[email protected]>
kgryte pushed a commit that referenced this issue Apr 9, 2025
PR-URL: #6620
Ref: #365
Reviewed-by: Athan Reines <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
kgryte pushed a commit that referenced this issue Apr 9, 2025
PR-URL: #6571
Ref: #365
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: stdlib-bot <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality.
Projects
None yet
Development

No branches or pull requests

2 participants