3

I was looking all over and I couldn't find how the function computes or uses it's PI part. For my project I am using a defined constant that has precision of 34 decimal places for PI. However, this is much more than the normal math.h defined constant for PI which is 16 decimal places.

My question is how precise of PI is sincospi using to compute its answer? Is it just using the PI constant from math.h?

harmonickey
  • 1,299
  • 2
  • 21
  • 35
  • Sixteen decimal places isn't an accident, that is the limit of the representation in IEEE 64 bit floating point. Any more decimal places than that is just noise. – talonmies Jul 24 '12 at 08:10
  • 2
    The maximum ulp error for sincospi() is the same as the maximum ulp error for sincos(): The results differ by up to 1 ulp from a correctly rounded reference, or stated differently, the results deviate by less than 1.5 ulps from the infinitely precise mathematical result. On average, more 90+% of results are correctly rounded. The maximum observed error for all math functions is documented in an appendix of the CUDA C Programming Guide. The accuracy of sincospi(x) is superior to the accuracy achieved by sincos(M_PI*x). – njuffa Jul 24 '12 at 08:54
  • @njuffa Your comments sounds like a quality answer ;) – pQB Jul 24 '12 at 10:28
  • @njuffa Thanks. The last sentence definitely answers my question. – harmonickey Jul 24 '12 at 22:25
  • @pQB: Thanks, followed your advice and propagated comment to answer. – njuffa Sep 14 '12 at 01:28

1 Answers1

3

The maximum ulp error for sincospi() is the same as the maximum ulp error for sincos(): The results differ by up to 1 ulp from a correctly rounded reference, or stated differently, the results deviate by less than 1.5 ulps from the infinitely precise mathematical result. On average, more than 90+% of results are correctly rounded. The maximum observed error for all CUDA math functions is documented in an appendix of the CUDA C Programming Guide. The accuracy of sincospi(x) is superior to the accuracy achieved by sincos(M_PI*x), as the latter incurs additional rounding error due to the multiplication of the function argument.

njuffa
  • 23,970
  • 4
  • 78
  • 130