This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/43490] sin(x) (actually probably all trig) is inaccurate for large x
- From: "simon dot fenney at imgtec dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Mar 2010 13:10:06 -0000
- Subject: [Bug c/43490] sin(x) (actually probably all trig) is inaccurate for large x
- References: <bug-43490-18948@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from simon dot fenney at imgtec dot com 2010-03-23 13:10 -------
(In reply to comment #4)
> > 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.
>
> Since pi is irrational, "range reduction" is inherently "broken" for large x.
> Try to compute sin(x) for a large value of x and its nearest values from below
> and above.
Yes, I am aware of that, but the *standard* seems to be to assume that the
source value is accurate, compute the range reduced result to sufficient
precision, and then compute sine/cosine to the required ULP accuracy. (e.g. see
Payne-Hanek reduction algorithm or any of the newer methods such as
ftp://ftp.inria.fr/INRIA/publication/dienst/RR-4267.pdf).
It was working on earlier incarnations so is frustrating that it's now broken.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43490