This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/13942] x86 acos inaccurate near 1


http://sourceware.org/bugzilla/show_bug.cgi?id=13942

--- Comment #3 from Rich Felker <bugdal at aerifal dot cx> 2012-04-04 14:13:00 UTC ---
Hi Joseph,

I did some preliminary tests, and that formula does not seem to fix it.

Given the following, which has been written in C to use extended precision for
intermediate results:

  double x = 0x0.ffffffffffffp0;
  printf("%.17g\n", acos(x));
  printf("%.17g\n", (double)atanl(sqrtl(1-(long double)x*x)));
  printf("%.17g\n", (double)atanl(sqrtl((1-(long double)x)*(1+(long
double)x))));

I'm getting:

8.4293697021788083e-08
8.4293697021787858e-08
8.4293697021787791e-08

The first result (our current implementation in musl) agrees with Wolfram
Alpha's value for acos(0.999999999999996447286321199499070644378662109375).
Both of the latter results have relatively huge error. So unless I screwed up
something in doing the intermediate results at extended precision, I don't
think your solution works.

Note that our algorithm avoids performing any multiplication or division that
would lose precision. The only loss of precision takes place at the sqrt
operations (which will be correctly rounded for extended precision) and the
atan operation.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]