[Bug 295884] [libm] Implementation for acospi[fl], asinpi[fl], and atanpi[fl]

[email protected] Sun, 02 Aug 2026 12:11:15 +0000
Newsgroups gmane.os.freebsd.bugs
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D295884

--- Comment #7 from [email protected] ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=3Dae417b3194e76ce26065dc20281493ee8=
3619879

commit ae417b3194e76ce26065dc20281493ee83619879
Author:     Steve Kargl <[email protected]>
AuthorDate: 2026-07-29 11:45:42 +0000
Commit:     Robert Clausecker <[email protected]>
CommitDate: 2026-08-02 11:17:45 +0000

    msun: add asinpi, acospi, and atanpi

    This commit implements the inverse half-cycle
    trigonometric functions:

       asinpi(x) =3D asin(x) / pi                        Eq. (1)
       acospi(x) =3D acos(x) / pi
       atanpi(x) =3D atan(x) / pi

    Implemention details are contained in src/s_asinpi.c and
    src/a_atanpi.c, where the details for acospi(x) appear in
    the former.

    *************

    CAVEAT EMPTOR: The ld128 code has been only compiled.  It has
    not been tested for correctness due to lack of hardware.

    *************

    Code compiled on AMD Ryzen 7 7700X system run FreeBSD 16.0-CURRENT
    main-n284956-de9fe28ab847.

    Exhaustive testing of acospif(x), asinpif(x), and atanpif(x)
    on the indicated intervals yields

    % ./tlibm acospi -fPE -x 0x1p-120 -X 1
    Interval tested for acospif: [7.52316e-37,1]
          ulp <=3D 0.5: 99.627% 1002878299 |  99.627% 1002878299
    0.5 < ulp <=3D 0.6:  0.277%    2789599 |  99.904% 1005667898
    0.6 < ulp <=3D 0.7:  0.096%     965062 | 100.000% 1006632960
    Max ulp: 0.63661975 at 5.96046412e-08 0x1.fffffep-25

    % ./tlibm asinpi -fPED -x 0x1p-120f -X 1.f
    Interval tested for asinpif: [7.52316e-37,1]
          ulp <=3D 0.5: 99.851% 1005129353 |  99.851% 1005129353
    0.5 < ulp <=3D 0.6:  0.149%    1501097 | 100.000% 1006630450
    0.6 < ulp <=3D 0.7:  0.000%       2510 | 100.000% 1006632960
    Max ulp: 0.68957579 at 5.04878759e-01 0x1.027f78p-1

    % ./tlibm atanpi -fPE -x 0x1p-120 -X max > zatanpif.txt &
    Interval tested for atanpif: [7.52316e-37,3.40282e+38]
          ulp <=3D 0.5: 99.865% 2077574602 |  99.865% 2077574602
    0.5 < ulp <=3D 0.6:  0.131%    2735011 |  99.997% 2080309613
    0.6 < ulp <=3D 0.7:  0.003%      65170 | 100.000% 2080374783
    Max ulp: 0.68433094 at 5.01186252e-01 0x1.009b7cp-1

    Testing the double and long double version cannot be done
    in an exhaustive manner.  For 300 M values, uniformily
    distributed in the indicated interals, one finds the max ULP:

    Interval tested for acospi: [9.31323e-10,0.25]
      xm =3D  2.4423788416892520e-01, /* 0x3fcf432f, 0xde79920f */
    libm =3D  4.2146222480005391e-01, /* 0x3fdaf93c, 0xb201001c */
    mpfr =3D  4.2146222480005396e-01, /* 0x3fdaf93c, 0xb201001d */
     ULP =3D 0.50499351466286857

    Interval tested for acospi: [0.25,0.5]
      xm =3D  4.9689430915631438e-01, /* 0x3fdfcd1d, 0xc9d945c6 */
    libm =3D  3.3447366122373884e-01, /* 0x3fd56804, 0x371513ef */
    mpfr =3D  3.3447366122373889e-01, /* 0x3fd56804, 0x371513f0 */
     ULP =3D 0.57195275455053829

    Interval tested for acospi: [0.5,0.75]
      xm =3D  5.0238623667462079e-01, /* 0x3fe0138c, 0x4d0f4be0 */
    libm =3D  3.3245556599062825e-01, /* 0x3fd546f3, 0xb5d36303 */
    mpfr =3D  3.3245556599062820e-01, /* 0x3fd546f3, 0xb5d36302 */
     ULP =3D 0.63427929243758807

    Interval tested for acospi: [0.75,1]
      xm =3D  7.5853651919512177e-01, /* 0x3fe845ee, 0x60d8789f */
    libm =3D  2.2591472240382732e-01, /* 0x3fcceac6, 0x0c3465ce */
    mpfr =3D  2.2591472240382729e-01, /* 0x3fcceac6, 0x0c3465cd */
     ULP =3D 0.56915750216472161

    Interval tested for asinpi: [9.31323e-10,0.25]
      xm =3D  1.9502362835488171e-01, /* 0x3fc8f688, 0xc4dda0fb */
    libm =3D  6.2478354989018887e-02, /* 0x3faffd29, 0xb6c57c61 */
    mpfr =3D  6.2478354989018881e-02, /* 0x3faffd29, 0xb6c57c60 */
     ULP =3D 0.52347765415885006

    Interval tested for asinpi: [0.25,0.5]
      xm =3D  4.9937103583123676e-01, /* 0x3fdff5b1, 0xeeddbf62 */
    libm =3D  1.6643553767987129e-01, /* 0x3fc54dc2, 0x7b9d15a4 */
    mpfr =3D  1.6643553767987126e-01, /* 0x3fc54dc2, 0x7b9d15a3 */
     ULP =3D 0.66214688371031072

    Interval tested for asinpi: [0.5,0.75]
      xm =3D  5.0228515250761718e-01, /* 0x3fe012b8, 0x4fe92bbb */
    libm =3D  1.6750722213679006e-01, /* 0x3fc570e0, 0x6c75edd5 */
    mpfr =3D  1.6750722213679009e-01, /* 0x3fc570e0, 0x6c75edd6 */
     ULP =3D 0.78223048105528226

    Interval tested for asinpi: [0.75,1]
      xm =3D  7.5425933001419776e-01, /* 0x3fe822e4, 0x7663a4aa */
    libm =3D  2.7200385380185182e-01, /* 0x3fd16882, 0xda1dc13b */
    mpfr =3D  2.7200385380185188e-01, /* 0x3fd16882, 0xda1dc13c */
     ULP =3D 0.53747973176773822

    Interval tested for atanpi: [9.31323e-10,0.25]
      xm =3D  1.9666113418757322e-01, /* 0x3fc92c31, 0x29dd6d2f */
    libm =3D  6.1810387818117797e-02, /* 0x3fafa59c, 0x7476baa5 */
    mpfr =3D  6.1810387818117804e-02, /* 0x3fafa59c, 0x7476baa6 */
     ULP =3D 0.54674297446584263

    Interval tested for atanpi: [0.25,0.5]
      xm =3D  4.1312119637707068e-01, /* 0x3fda7093, 0xe2ee5494 */
    libm =3D  1.2470309560460152e-01, /* 0x3fbfec8a, 0xc554ebec */
    mpfr =3D  1.2470309560460154e-01, /* 0x3fbfec8a, 0xc554ebed */
     ULP =3D 0.73116638175113347

    Interval tested for atanpi: [0.5,0.75]
      xm =3D  5.0018949583396499e-01, /* 0x3fe0018d, 0x66cd1b82 */
    libm =3D  1.4763186871058706e-01, /* 0x3fc2e599, 0xdffacb8f */
    mpfr =3D  1.4763186871058709e-01, /* 0x3fc2e599, 0xdffacb90 */
     ULP =3D 0.69192753950764663

    Interval tested for atanpi: [0.75,1]
      xm =3D  7.5007880583359599e-01, /* 0x3fe800a5, 0x448f4c03 */
    libm =3D  2.0484881828445453e-01, /* 0x3fca387c, 0x6f93f71f */
    mpfr =3D  2.0484881828445450e-01, /* 0x3fca387c, 0x6f93f71e */
     ULP =3D 0.65765471872064396

    Interval tested for atanpi: [1,2]
      xm =3D  1.0103228000344093e+00, /* 0x3ff02a48, 0x3d88d0a2 */
    libm =3D  2.5163447403817019e-01, /* 0x3fd01ac7, 0x7b229108 */
    mpfr =3D  2.5163447403817013e-01, /* 0x3fd01ac7, 0x7b229107 */
     ULP =3D 0.67409519689166042

    Interval tested for atanpi: [2,4]
      xm =3D  2.0231383267437946e+00, /* 0x40002f63, 0x25a530a9 */
    libm =3D  3.5387589538123299e-01, /* 0x3fd6a5e7, 0x156053c6 */
    mpfr =3D  3.5387589538123293e-01, /* 0x3fd6a5e7, 0x156053c5 */
     ULP =3D 0.69695587476021503

    Interval tested for atanpi: [4,1.79769e+308]
      xm =3D  4.0000000000000000e+00, /* 0x40100000, 0x00000000 */
    libm =3D  4.2202086962263069e-01, /* 0x3fdb0263, 0xd2508e31 */
    mpfr =3D  4.2202086962263069e-01, /* 0x3fdb0263, 0xd2508e31 */
     ULP =3D 0.27709400511686716

    PR:             295884
    MFC after:      1 month
    Reviewed by:    fuz

 lib/msun/Makefile                |  14 ++-
 lib/msun/Symbol.map              |   9 ++
 lib/msun/ld128/s_asinpil.c (new) | 173 ++++++++++++++++++++++++++++
 lib/msun/ld128/s_atanpil.c (new) | 157 +++++++++++++++++++++++++
 lib/msun/ld80/s_asinpil.c (new)  | 191 ++++++++++++++++++++++++++++++
 lib/msun/ld80/s_atanpil.c (new)  | 175 ++++++++++++++++++++++++++++
 lib/msun/man/acospi.3 (new)      |  77 +++++++++++++
 lib/msun/man/asinpi.3 (new)      |  77 +++++++++++++
 lib/msun/man/atanpi.3 (new)      |  73 ++++++++++++
 lib/msun/src/math.h              |   9 ++
 lib/msun/src/math_private.h      |  38 ++++--
 lib/msun/src/s_asinpi.c (new)    | 243 +++++++++++++++++++++++++++++++++++=
++++
 lib/msun/src/s_asinpif.c (new)   | 157 +++++++++++++++++++++++++
 lib/msun/src/s_atanpi.c (new)    | 215 ++++++++++++++++++++++++++++++++++
 lib/msun/src/s_atanpif.c (new)   | 142 +++++++++++++++++++++++
 15 files changed, 1735 insertions(+), 15 deletions(-)

--=20
You are receiving this mail because:
You are the assignee for the bug.=