acos / asin accuracy

Henri Verbeet hverbeet@gmail.com
Sun Sep 21 17:09:00 GMT 2008


2008/9/21 Carlos O'Donell <carlos@systemhalted.org>:
> On Sun, Sep 21, 2008 at 11:04 AM, Henri Verbeet <hverbeet@gmail.com> wrote:
>> Acos and asin in sysdeps/i386/fpu are implemented as "atan2(sqrt(1 -
>> x*x), x)" and "atan2(x, sqrt(1 - x*x))"
>> (http://sources.redhat.com/git/?p=glibc.git;a=blob_plain;f=sysdeps/i386/fpu/e_acos.S;hb=HEAD
>> and http://sources.redhat.com/git/?p=glibc.git;a=blob_plain;f=sysdeps/i386/fpu/e_asin.S;hb=HEAD).
>> The expression "1-x*x" is bad for accuracy, especially for values of x
>> close to -1 or 1 (x*x introduces rounding error, subtracting from 1
>> cancels most of the remaining significant digits out). Obviously the
>> problem is worse when using single precision. A much better way would
>> be to use (1-x)*(1+x) instead.
>
> Do you have a patch, with before and after results, including the
> results of running the glibc math testsuite?
>
No, but I could write one if needed, just need to find the time. On
the other hand, it's easy enough to see that for a value like
0x3feffffffff00000 x*x gets rounded to 0x3fefffffffe00000, which after
subtracting from 1 becomes 0x3df0000000000000, while (1-x)(1+x)
correctly gives 0x3deffffffff80000.

>> I would have filed a bug in bugzilla for this, but it appears bugzilla
>> doesn't send the confirmation mails for new accounts (as other people
>> already noted).
>
> I have just registered without any problems. Please email
> sourcemaster@sourceware.org if you are having problems. If you don't
> get a response please tell me.
>
It appears to work fine now. Thanks to whoever fixed that.



More information about the Libc-help mailing list