Skip to content

ENH: confirm accuracy of basic math functions #13515

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

Closed
mattip opened this issue May 9, 2019 · 7 comments
Closed

ENH: confirm accuracy of basic math functions #13515

mattip opened this issue May 9, 2019 · 7 comments

Comments

@mattip
Copy link
Member

mattip commented May 9, 2019

We do not verify results of our math functions (sin, cos, exp, log, ...) against a "gold standard" which makes changing the algorithms used to calculate them tricky. Python has a tests based on generating "true" values for certain interesting cases. We should explore adding these kinds of tests for the various built-in float and integer types, perhaps mpmath could help generate the "true" values.

@mattip
Copy link
Member Author

mattip commented May 9, 2019

See also this email thread from 2012 with the author of the python test files on using mpfr to calculate the results

@seberg
Copy link
Member

seberg commented May 9, 2019

Not sure it is relevant, but there was also just this to do testing for scipy on scipy-dev: https://mail.python.org/pipermail/scipy-dev/2019-May/023508.html

@juliantaylor
Copy link
Contributor

juliantaylor commented May 9, 2019

glibc has a testsuite for math functions which could be used as input for what is interesting to test:
https://sourceware.org/git/?p=glibc.git;a=blob;f=math/README.libm-test;h=53172bbff87ff54e2f93ecc142fb607a2b350650;hb=HEAD

see all the test-out files, they include input output and exceptions
other files define the current maximal error for all the different architectures and rounding modes

@mattip
Copy link
Member Author

mattip commented May 22, 2019

Python has a test suite for complex numbers when testing cmath based on a text file of results, we should be consistent with these results or document why we differ.

@r-devulap
Copy link
Member

PR #14048 addressed this issue for float32 exp, log, sin and cos.

@r-devulap
Copy link
Member

PR #19485 can hopefully close this issue?

@mattip
Copy link
Member Author

mattip commented Mar 16, 2023

Closing, we now have better accuracy tests

@mattip mattip closed this as completed Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants