Scott, 

> Actually, it tested every 1.8°, but who wants to be picky. 
> I've rerun the test overnight at greater resolution, testing every
> 0.00000018 degress, and saw no change in the result.

That's because the error is the same but symmetrical for sin and cos, so that, 
when you calculate the sum of their squares, one cancels the other out.

The lack of accuracy in x87 is well known: see 
http://www.gnu.org/software/libc/manual/html_node/Errors-in-Math-Functions.html#Errors-in-Math-Functions.

I modified your test slightly to return the number of error bits.  My results 
using GCC 4.0.0 on an Opteron system running SUSE 9.1 were:

x87sincos-32-fst
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-sse
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-x87
cumulative error: 2 (ulp)
                  -1.4432899320127e-15 (decimal)
x87sincos-64-sse
cumulative error: 4 (ulp)
                 -4.77395900588817e-15 (decimal)
x87sincos-64-x87
cumulative error: 2 (ulp)
                 -1.22124532708767e-15 (decimal)

On an Athlon MP system running SUSE 9.1:

x87sincos-32-fst
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-x87
cumulative error: 2 (ulp)
                  -1.4432899320127e-15 (decimal)

Now, adding -funsafe-math-optimizations, on the same systems:

x87sincos-32-fst
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-sse
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-x87
cumulative error: 0 (ulp)
                                    +0 (decimal)
x87sincos-64-sse
cumulative error: 4 (ulp)
                 -4.77395900588817e-15 (decimal)
x87sincos-64-x87
cumulative error: 0 (ulp)
                                    +0 (decimal)
And:

x87sincos-32-fst
cumulative error: 4 (ulp)
                 -5.10702591327572e-15 (decimal)
x87sincos-32-x87
cumulative error: 0 (ulp)
                                    +0 (decimal)

Any perceived increase in accuracy in this test comes from intermediary 
calculations being done with 80 bits and because the errors in fsin are 
complementary to those in fcos.

HTH


-- 
_______________________________________________________
Evandro Menezes            AMD               Austin, TX

Attachment: unsafe.tar.bz2
Description: unsafe.tar.bz2

Reply via email to