sincos() is inaccurate for large inputs on x86_64: with glibc 2.13,
int main (void)
volatile double x = 1.0e22;
double s1, s2, c1;
sincos (x, &s1, &c1);
s2 = sin (x);
printf ("s1 = %.17g\n", s1);
printf ("s2 = %.17g\n", s2);
s1 = 0.46261304076460175
s2 = -0.85220084976718879
(s2 is the correct value). I suppose that contrary to the other trig functions, glibc uses the hardware sincos instruction, which has never been meant to be used directly by a C library (the hardware elementary functions of the x86 processors were designed for small inputs, and they must not be used by code where inputs can be large, like here). The sincos() function can simply be implemented by a call to sin() and a call to cos() on this target.
Ditto for sincosf() and sincosl().
Note: x86 (32 bits) has the same problem, but it has been claimed that users don't care about correctness on this target.
Btw. x86-64 uses the same fsincos instruction like x86.
For the reference about the hardware trig instructions, you can see "Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture" on:
in particular Section 22.214.171.124, which says:
"The FPTAN, FSIN, FCOS, and FSINCOS instructions set the C2 flag to 1 to indicate that the source operand is beyond the allowable range of ±2^63 and clear the C2 flag if the source operand is within the allowable range."
So, outside the interval [-2^63,+2^63] ("allowable range"), these instructions must not be used (or they can be used, but with a fallback if the C2 flag is set to 1). But note that the glibc implementation is more accurate, even with (very probably) correct rounding, so that it is better to use it anyway.
Andreas posted a possible patch for this issue here:
GCC discussion is here:
This is fixed now for sincos, sin and cos on i386 and x86-64. I'm opening separate bugs for float and long double.
*** Bug 13837 has been marked as a duplicate of this bug. ***
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.