1

When I call the sin() function from math.h, on MSVC for example (or GCC), which kind of approximation is it used? Is it well know?

And which accuracy does it have?

If I use the ippsSin IPP SIMD function, for example, I can choose which accuracy (even if I don't know the approx algorithm). Using double, I feel good with the performance I get from ippsSin_64fc_A26, but I'm not able to quantify its error (which is specified as guarantee 26 correctly rounded bits of significand, or 6.7E+7 ulps, or approximately 8 exact decimal digits;), compared to the native/scalar sin().

Is sin() more accurate? More than ippsSin_64f_A53 also?

Just to give an idea if its worth to lose precision due to performances.

markzzz
  • 47,390
  • 120
  • 299
  • 507
  • 1
    TLDR: It depends on the compiler you're using and which system you're running on. You have to look up each case individually. – Max Langhof Jan 11 '19 at 16:41
  • @MaxLanghof: And which bit of the function domain you're using. For small inputs it may well end up being better if you roll your own Taylor expansion in case you hit a discontinuity if the method changes. – Bathsheba Jan 11 '19 at 16:43
  • 2
    @Downvoter: What's the problem with the question? If it was `sqrt` rather than `sin` then you could reply "well in IEEE754 it's standardised". The problem here is that `sin` isn't, but that doesn't make this a poor question. – Bathsheba Jan 11 '19 at 16:46
  • @Bathsheba For small inputs, the result is actually the input itself (for `sin`) or constant (for `cos`). Since a lot of floating point numbers are _really small_, you perfectly cover almost half the domain with a single instruction: https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/ – Max Langhof Jan 11 '19 at 16:50
  • @Bathsheba what do you mean by "small input"? Its in radians, so 0 to 2pi is the range... – markzzz Jan 11 '19 at 19:50
  • 1
    I’d say up to 1e-6 but would have to analyse carefully. Note that the function has a 2pi periodicity which is effectively half that with a sign reversal. – Bathsheba Jan 11 '19 at 20:04
  • @Bathsheba I mean, the range I'm working on its 0 2pi. Which approx fit better in your opinion? – markzzz Jan 11 '19 at 20:06

0 Answers0