Skip to content

ENH: confirm accuracy of basic math functions #13515

Closed

Description

@mattip

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.

Activity

  1. mattip commented on May 9, 2019

    @mattip
    MemberAuthor

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

  2. seberg commented on May 9, 2019

    @seberg
    Member

    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

  3. juliantaylor commented on May 9, 2019

    @juliantaylor
    Contributor

    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

  4. mattip commented on May 22, 2019

    @mattip
    MemberAuthor

    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.

  5. r-devulap commented on Jul 19, 2019

    @r-devulap
    Member

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

  6. r-devulap commented on Jul 16, 2021

    @r-devulap
    Member

    PR #19485 can hopefully close this issue?

  7. mattip commented on Mar 16, 2023

    @mattip
    MemberAuthor

    Closing, we now have better accuracy tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions