Sine and Cosine Accuracy

chris jefferson caj@cs.york.ac.uk
Tue May 31 03:10:00 GMT 2005


Scott Robert Ladd wrote:

>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?
>
>  
>
I would like to say yes, I disagree that this should be true. By your 
argument, why isn't sin(pow(2.0,90.0)+1) == sin(6.153104..)? Also, how 
the heck do you intend to actually calculate that value? You can't just 
keep subtracting multiples of 2*pi from pow(2.0, 90.0) else nothing will 
happen, and if you choose to subtract some large multiple of 2*pi, your 
answer wouldn't end up accurate to anywhere near that many decimal 
places. Floating point numbers approximate real numbers, and at the size 
you are considering, the approximation contains values for which sin(x) 
takes all values in the range [-1,1].

Chris



More information about the Gcc mailing list