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

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> 2012-04-04 01:16:15 UTC ---
We experienced the same issue in musl's implementation, and fixed it by using
the following formula for acos in the asm:

acos(x) = 2*atan2(sqrt(1-x), sqrt(1+x))

Assuming the right hand side is evaluated in extended precision, it seems to
give <1ulp error for double precision inputs. We were doing the division
(rather than relying on the FPU's 2-argument atan) so we could avoid one sqrt,
but it was causing incorrect results with downward rounding direction on some
corner cases, so we switched to using two sqrts.

asin does not seem to suffer from precision issues with the usual formula
involving xÂ.

Here's our asm:

http://git.etalabs.net/cgi-bin/gitweb.cgi?p=musl;a=blob;f=src/math/i386/acos.s;h=bfff0c5c9a89d3332ea7df6a8e5d3cd0a68a01f3;hb=HEAD

-- 
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]