Sine and Cosine Accuracy
Scott Robert Ladd
scott.ladd@coyotegulch.com
Thu May 26 18:10:00 GMT 2005
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
More information about the Gcc
mailing list