This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11422] New: sin(x) (actually probably all trig) is inaccurate for large x
- From: "simon dot fenney at imgtec dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 23 Mar 2010 14:13:46 -0000
- Subject: [Bug libc/11422] New: sin(x) (actually probably all trig) is inaccurate for large x
- Reply-to: sourceware-bugzilla at sourceware dot org
Was reported to (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43490) but was then
sent here...
sin(x) (and sinf(x)) *used* to work accurately on earlier gcc versions, e.g.
gcc 3.4.6 20060404 (Red Hat 3.4.6-9) ON x86_64-redhat-linux
gcc 4.2.1 on Macintosh
OR
cross compiling for ARM Cortex-A8 with gcc version 4.3.2
But sin(x) becomes progressively more inaccurate with increasing magnitude of
x, as with the above version (on x86). At a guess, it would seem like something
has broken the "range reduction" maths.
Systems that were found to be broken:
gcc 4.4.1 (Ubuntu 4.4.1-4ubuntu9)
gcc 4.4.3 20100108 (prerelease) (Debian 4.4.2-9)
GNU C 4.3.2 (i686-pc-linux-gnu) (Gentoo 4.3.2-r3 p1.6, pie-10.1.5
Build command: gcc -v -save-temps -o simplesintest -g -DDEBUG=1 -DDEBUG_INFO=1
-Wall -W -pedantic -std=c99 simplesintest.c -lm
Command line: ./simplesintest
Typical output is:
=========================
Test 0:
sin(43998769152.000000) (i.e. sin(0xa3e87f * 2^12))
is computed as -4.081937e-09 (-0x1.188230b6dp-28)
It SHOULD be ~ -4.025292e-09 (-0x1.149dafd6b8987p-28)
Relative error is 1.407% !!!!
sinf(43998769152.000000) (i.e. sinf(0xa3e87f * 2^12))
is computed as -4.081937e-09 (-0x1.18823p-28)
It SHOULD be ~ -4.025292e-09 (-0x1.149dbp-28)
Relative error is 1.407% !!!!
Test 1:
sin(9903547467890318699652972544.000000) (i.e. sin(0x800017 * 2^70))
is computed as 2.763719e-01 (0x1.1b013a2290cc8p-2)
It SHOULD be ~ 2.003433e-01 (0x1.9a4d9074cecaap-3)
Relative error is -37.949% !!!!
sinf(9903547467890318699652972544.000000) (i.e. sinf(0x800017 * 2^70))
is computed as 2.763719e-01 (0x1.1b013ap-2)
It SHOULD be ~ 2.003433e-01 (0x1.9a4d9p-3)
Relative error is -37.949% !!!!
Test 2:
sin(8773115793420245409943394342404096.000000) (i.e. sin(0xd84625 * 2^89))
is computed as 7.399661e-01 (0x1.7adcd596e1d56p-1)
It SHOULD be ~ 2.044974e-08 (0x1.5f52ea84f120cp-26)
Relative error is -3618461696.000% !!!!
sinf(8773115793420245409943394342404096.000000) (i.e. sinf(0xd84625 * 2^89))
is computed as 7.399661e-01 (0x1.7adcd6p-1)
It SHOULD be ~ 2.044974e-08 (0x1.5f52eap-26)
Relative error is -3618461696.000% !!!!
Test 3:
sin(10633823966279326983230456482242756608.000000) (i.e. sin(0x800000 * 2^100))
is computed as -7.480374e-01 (-0x1.7efec078c6a44p-1)
It SHOULD be ~ -4.205416e-02 (-0x1.5881f6eeb6a8dp-5)
Relative error is 1678.748% !!!!
sinf(10633823966279326983230456482242756608.000000) (i.e. sinf(0x800000 *
2^100))
is computed as -7.480373e-01 (-0x1.7efecp-1)
It SHOULD be ~ -4.205416e-02 (-0x1.5881f6p-5)
Relative error is 1678.748% !!!!
=========================
--
Summary: sin(x) (actually probably all trig) is inaccurate for
large x
Product: glibc
Version: 2.10
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: simon dot fenney at imgtec dot com
CC: glibc-bugs at sources dot redhat dot com
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11422
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.