Date: Fri, 05 Jun 2026 22:21:00 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 295884] [libm] Implementation for acospi[fl], asinpi[fl], and atanpi[fl] Message-ID: <bug-295884-227-4HO0n6yq47@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-295884-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295884 --- Comment #2 from Steve Kargl <kargl@FreeBSD.org> --- The attached patch implements the inverse half-cycle trigonometric functions: asinpi(x) = asin(x) / pi Eq. (1) acospi(x) = acos(x) / pi atanpi(x) = 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 <= 0.5: 99.627% 1002878299 | 99.627% 1002878299 0.5 < ulp <= 0.6: 0.277% 2789599 | 99.904% 1005667898 0.6 < ulp <= 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 <= 0.5: 99.851% 1005129353 | 99.851% 1005129353 0.5 < ulp <= 0.6: 0.149% 1501097 | 100.000% 1006630450 0.6 < ulp <= 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 <= 0.5: 99.865% 2077574602 | 99.865% 2077574602 0.5 < ulp <= 0.6: 0.131% 2735011 | 99.997% 2080309613 0.6 < ulp <= 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 = 2.4423788416892520e-01, /* 0x3fcf432f, 0xde79920f */ libm = 4.2146222480005391e-01, /* 0x3fdaf93c, 0xb201001c */ mpfr = 4.2146222480005396e-01, /* 0x3fdaf93c, 0xb201001d */ ULP = 0.50499351466286857 Interval tested for acospi: [0.25,0.5] xm = 4.9689430915631438e-01, /* 0x3fdfcd1d, 0xc9d945c6 */ libm = 3.3447366122373884e-01, /* 0x3fd56804, 0x371513ef */ mpfr = 3.3447366122373889e-01, /* 0x3fd56804, 0x371513f0 */ ULP = 0.57195275455053829 Interval tested for acospi: [0.5,0.75] xm = 5.0238623667462079e-01, /* 0x3fe0138c, 0x4d0f4be0 */ libm = 3.3245556599062825e-01, /* 0x3fd546f3, 0xb5d36303 */ mpfr = 3.3245556599062820e-01, /* 0x3fd546f3, 0xb5d36302 */ ULP = 0.63427929243758807 Interval tested for acospi: [0.75,1] xm = 7.5853651919512177e-01, /* 0x3fe845ee, 0x60d8789f */ libm = 2.2591472240382732e-01, /* 0x3fcceac6, 0x0c3465ce */ mpfr = 2.2591472240382729e-01, /* 0x3fcceac6, 0x0c3465cd */ ULP = 0.56915750216472161 Interval tested for asinpi: [9.31323e-10,0.25] xm = 1.9502362835488171e-01, /* 0x3fc8f688, 0xc4dda0fb */ libm = 6.2478354989018887e-02, /* 0x3faffd29, 0xb6c57c61 */ mpfr = 6.2478354989018881e-02, /* 0x3faffd29, 0xb6c57c60 */ ULP = 0.52347765415885006 Interval tested for asinpi: [0.25,0.5] xm = 4.9937103583123676e-01, /* 0x3fdff5b1, 0xeeddbf62 */ libm = 1.6643553767987129e-01, /* 0x3fc54dc2, 0x7b9d15a4 */ mpfr = 1.6643553767987126e-01, /* 0x3fc54dc2, 0x7b9d15a3 */ ULP = 0.66214688371031072 Interval tested for asinpi: [0.5,0.75] xm = 5.0228515250761718e-01, /* 0x3fe012b8, 0x4fe92bbb */ libm = 1.6750722213679006e-01, /* 0x3fc570e0, 0x6c75edd5 */ mpfr = 1.6750722213679009e-01, /* 0x3fc570e0, 0x6c75edd6 */ ULP = 0.78223048105528226 Interval tested for asinpi: [0.75,1] xm = 7.5425933001419776e-01, /* 0x3fe822e4, 0x7663a4aa */ libm = 2.7200385380185182e-01, /* 0x3fd16882, 0xda1dc13b */ mpfr = 2.7200385380185188e-01, /* 0x3fd16882, 0xda1dc13c */ ULP = 0.53747973176773822 Interval tested for atanpi: [9.31323e-10,0.25] xm = 1.9666113418757322e-01, /* 0x3fc92c31, 0x29dd6d2f */ libm = 6.1810387818117797e-02, /* 0x3fafa59c, 0x7476baa5 */ mpfr = 6.1810387818117804e-02, /* 0x3fafa59c, 0x7476baa6 */ ULP = 0.54674297446584263 Interval tested for atanpi: [0.25,0.5] xm = 4.1312119637707068e-01, /* 0x3fda7093, 0xe2ee5494 */ libm = 1.2470309560460152e-01, /* 0x3fbfec8a, 0xc554ebec */ mpfr = 1.2470309560460154e-01, /* 0x3fbfec8a, 0xc554ebed */ ULP = 0.73116638175113347 Interval tested for atanpi: [0.5,0.75] xm = 5.0018949583396499e-01, /* 0x3fe0018d, 0x66cd1b82 */ libm = 1.4763186871058706e-01, /* 0x3fc2e599, 0xdffacb8f */ mpfr = 1.4763186871058709e-01, /* 0x3fc2e599, 0xdffacb90 */ ULP = 0.69192753950764663 Interval tested for atanpi: [0.75,1] xm = 7.5007880583359599e-01, /* 0x3fe800a5, 0x448f4c03 */ libm = 2.0484881828445453e-01, /* 0x3fca387c, 0x6f93f71f */ mpfr = 2.0484881828445450e-01, /* 0x3fca387c, 0x6f93f71e */ ULP = 0.65765471872064396 Interval tested for atanpi: [1,2] xm = 1.0103228000344093e+00, /* 0x3ff02a48, 0x3d88d0a2 */ libm = 2.5163447403817019e-01, /* 0x3fd01ac7, 0x7b229108 */ mpfr = 2.5163447403817013e-01, /* 0x3fd01ac7, 0x7b229107 */ ULP = 0.67409519689166042 Interval tested for atanpi: [2,4] xm = 2.0231383267437946e+00, /* 0x40002f63, 0x25a530a9 */ libm = 3.5387589538123299e-01, /* 0x3fd6a5e7, 0x156053c6 */ mpfr = 3.5387589538123293e-01, /* 0x3fd6a5e7, 0x156053c5 */ ULP = 0.69695587476021503 Interval tested for atanpi: [4,1.79769e+308] xm = 4.0000000000000000e+00, /* 0x40100000, 0x00000000 */ libm = 4.2202086962263069e-01, /* 0x3fdb0263, 0xd2508e31 */ mpfr = 4.2202086962263069e-01, /* 0x3fdb0263, 0xd2508e31 */ ULP = 0.27709400511686716 -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-295884-227-4HO0n6yq47>
