This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Error of tan/tanf in libm.
- To: moshier at moshier dot ne dot mediaone dot net
- Subject: Re: Error of tan/tanf in libm.
- From: "J. Johnston" <jjohnstn at cygnus dot com>
- Date: Mon, 16 Apr 2001 20:28:00 -0400
- CC: Tim Prince <tprince at computer dot org>, newlib at sources dot redhat dot com
- Organization: Red Hat Inc.
- References: <Pine.LNX.4.20.0104151445060.20759-100000@moshier.ne.mediaone.net>
Stephen L Moshier wrote:
>
> 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.
>
Thanks for the patch Stephen.
-- Jeff J.
> ----
> 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 */