Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test_math: new acospi test cases exceed the 5-ulp tolerance on NetBSD, OpenBSD and DragonFly #154146

Description

@serhiy-storchaka

Bug report

Three mtest cases added in gh-150534 fail bit-identically on NetBSD 10.1, OpenBSD 7.9 and DragonFly 6.4:

acospi10016: acospi[0.9999999998835847]: expected 4.857023409833964e-06, got 4.857023409975323e-06 (error = 1.41e-16 (166887 ulps); permitted error = 0 or 5 ulps)
acospi10022: acospi[0.9999999999999964]: expected 2.6831517105016303e-08, got 2.6831517105016326e-08 (error = 2.32e-23 (7 ulps); permitted error = 0 or 5 ulps)
acospi10104: acospi[0.9999996241289419]: expected 0.0002759844303031754, got 0.00027598443030317065 (error = 4.77e-18 (88 ulps); permitted error = 0 or 5 ulps)

These platforms have no acospi() in libm, so the fallback in Modules/mathmodule.c is used. It computes via acos(), and these libms (a shared old fdlibm lineage — hence the identical results) lose precision in acos(x) for x close to 1. The same fallback passes on FreeBSD and OpenIndiana, whose acos() is accurate.

Possible fixes: compute the fallback near 1 through the half-angle identity acospi(x) = 2*asinpi(sqrt((1-x)/2)), which avoids the inaccurate region of acos(); or relax the tolerance for these platforms.

Linked PRs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.16new features, bugs and security fixesOS-netbsdextension-modulesC modules in the Modules dirtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions