This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Sine and Cosine Accuracy


Marc Espie wrote:
> Heck, I can plot trajectories on a sphere that do not follow great circles,
> and that extend over 360 degrees in longitude.  I don't see why I should be
> restricted from doing that.

Can you show me a circumstance where sin(x - 2 * pi) and sin(x + 2 * pi)
are not equal to sin(x)?

Using an earlier example in these threads, do you deny that
sin(pow(2.0,90.0)) == sin(5.15314063427653548) ==
sin(-1.130044672903051) -- assuming no use of
-funsafe-math-optimizations, of course?

Shall we mark all potentially troublesome optimizations as "unsafe", and
chastise those who use them? Quite a few combinations of options can
cause specific applications to fail, and other programs to work very
well. Under such logic, we should replace -O3 with -Ounsafe, because
some programs break when compiled with -O3.

Since that's patently silly, perhaps we should be more concerned with
making useful choices and improvements to GCC.

> You can decide to restrict this stuff to plain old 2D geometry, and this would
> be fine for teaching in elementary school, but this makes absolutely 
> no sense with respect to any kind of modern mathematics.

The fact that trigonometric functions can extended beyond 2D geometry in
no way invalidates their use in their original domain. I've written many
2D and 3D applications over the years without need for a sine outside
the range [0, 2*PI] (or [-PI, PI] in some cases). Some people live and
die by one of those programs, and no one's died yet because I used
-ffast-math in compiling it.

(I expect Gabriel dos Rios to respond with something pithy here; please
don't disappoint me!)

I keep saying that GCC can and should support the different needs of
different applications. What is wrong with that?

..Scott


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]