This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC beaten by ICC in stupid trig test!
Scott Robert Ladd wrote:
Mathematical identities provide good tests of numerical accuracy; I have
found instances where certain compilers do *not* compute "sin**2+cos**2"
as equal to 1, usually due to a poor implementation of sin and cos.
You definitely cannot assume that sin**2+cos**2 = exactly 1.0 throughout
the defined domain of these functions. Expecting this identity is
similar to thinking that x**y can be computed using log and exp!
The actual line of code in question was part of a testing spike, and it
had no effect on the actual subject of the original post, and was not
intended to be part of a production program.
Sure, in fact I suspect the only use of sin**2+cos**2 in real programs
has to do with testing/exploiting the difference between the value of
this computed expression and 1.0. Yes, I know you can posit macros etc,
but I would be surprised if anyone comes up with a real program where
this expression appears in any other context.