Error of tan/tanf in libm.
Stephen L Moshier
moshier@mediaone.net
Sun Apr 15 11:51:00 GMT 2001
On Sun, 15 Apr 2001, Tim Prince wrote:
> I haven't looked that deeply; I simply ran elefunt tests on the
> functions used by cygwin. I think the results were consistent with your
> assessment of 3 ulps relative error.
The cygwin configuration appears to use the fdlibm versions from
libm/math. Newlib's ef_asin.c there compares the same as glibc's
e_asinf.c except for the spelling of a few labels.
Here is an example test case. Using the stock library routine it prints
The relative error is 2.2746e-07.
after applying the patch below it prints
The relative error is 0.0000e+00.
----
float asinf (float);
int
main()
{
float x, y, c, e;
x = 5.00433922E-01f;
c = 5.24099886E-01f;
y = asinf(x);
e = (y-c)/c;
printf("The relative error is %1.4e.\n", (double) e);
exit(0);
}
-----
Here is the minimal patch to correct the excess function error.
* newlib/libm/math/ef_asin.c (pio2_hi, pio2_lo, pio4_hi):
Correct the numerical values.
*** ef_asin.c Sun Apr 15 14:23:52 2001
--- ef_asin.c Sun Apr 15 14:23:32 2001
*************** static float
*** 22,30 ****
#endif
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
! pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
! pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
! pio4_hi = 7.8539818525e-01, /* 0x3f490fdb */
/* coefficient for R(x^2) */
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
pS1 = -3.2556581497e-01, /* 0xbea6b090 */
--- 22,30 ----
#endif
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
! pio2_hi = 1.57079637050628662109375f,
! pio2_lo = -4.37113900018624283e-8f,
! pio4_hi = 0.785398185253143310546875f,
/* coefficient for R(x^2) */
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
pS1 = -3.2556581497e-01, /* 0xbea6b090 */
More information about the Newlib
mailing list