This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
acos / asin accuracy
- From: "Henri Verbeet" <hverbeet at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Sun, 21 Sep 2008 17:04:22 +0200
- Subject: acos / asin accuracy
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=mptVswcDkkejRohwIclZzPPtfWKk6FxbAfqRH+jzDdY=; b=CxfzALuwsy118b7qSN2sb+NpBX6R35WXe5aQF3oGlV97ayzUhkhEehL3TckZEsHiJi mJ1wzAxEsO0VoheNDHp+NwVO7rw8p+YZhWZ7eUiDqzNJRfiXoFIqclbiW/2TEJSn9rPS /8bISFRVEYhPpJHOQjDUElKYyU03Yg3wFe0yg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=br7QlTJVD28ygWzhBwVse4Skhg+q6lV6B9b8gKRASQ+pWT/K/3lPtb0CC5u0KYoaw/ 0zxbHsEgHo8Uld/1w5/yT9s3LW5a5cz0TU+7lxKyH91pOXQA6gr0Si+ejj1NkNihMzgl FD1MFk18Rt2IHQqtqEXTzg573MW/SmjU7I1J0=
Hi,
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.
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).