This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Sine and Cosine Accuracy
- From: Scott Robert Ladd <scott dot ladd at coyotegulch dot com>
- To: Morten Welinder <mwelinder at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 26 May 2005 13:36:08 -0400
- Subject: Re: Sine and Cosine Accuracy
- References: <118833cc050526102760e52d59@mail.gmail.com>
Morten Welinder wrote:
> If you were to look up a serious math book like Abramowitz&Stegun1965
> you would see a definition like
>
> sin z = ((exp(iz)-exp(-iz))/2i [4.3.1]
Very true. However, the processor doesn't implement intrinsics for
complex functions -- well, maybe some do, and I've never encountered them!
As such, I was sticking to a discussion specific to reals.
> And there is the answer to your question: if you just think of "sin"
> as something
> with angles and triangles, then sin(2^90) makes very little sense. But "sin"
> occurs other places where there are no triangles in sight.
That's certainly true; the use of sine and cosine depend on the
application. I don't deny that many applications need to perform sin()
on any double value; however there are also many applications where you
*are* dealing with angles.
I recently wrote a GPS application where using the intrinsics improved
both accuracy and speed (the latter substantially), and using those
intrinsics was only "unsafe" because -funsafe-math-optimizations
includes other transformations.
I am simply lobbying for the separation of hardware intrinsics from
-funsafe-math-optimizations.
..Scott