public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64
@ 2012-02-03 14:42 vincent-srcware at vinc17 dot net
  2012-02-03 14:43 ` [Bug math/13658] sincos() is incorrect " vincent-srcware at vinc17 dot net
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: vincent-srcware at vinc17 dot net @ 2012-02-03 14:42 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13658

             Bug #: 13658
           Summary: sincos() is inaccurate for large inputs on x86_64
           Product: glibc
           Version: 2.13
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj@suse.de
        ReportedBy: vincent-srcware@vinc17.net
    Classification: Unclassified


sincos() is inaccurate for large inputs on x86_64: with glibc 2.13,

#define _GNU_SOURCE
#include <stdio.h>
#include <math.h>

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);
  return 0;
}

outputs:

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.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-06-27  9:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
2012-02-03 14:43 ` [Bug math/13658] sincos() is incorrect " vincent-srcware at vinc17 dot net
2012-02-03 15:00 ` aj at suse dot de
2012-02-03 15:09 ` vincent-srcware at vinc17 dot net
2012-02-03 19:58 ` ppluzhnikov at google dot com
2012-02-13  4:54 ` carlos at systemhalted dot org
2012-03-15 13:26 ` aj at suse dot de
2012-03-15 13:31 ` aj at suse dot de
2012-03-15 13:43 ` aj at suse dot de
2012-03-15 13:48 ` aj at suse dot de
2012-03-15 15:14 ` aj at suse dot de
2013-06-03 16:05 ` carlos at redhat dot com
2014-02-16 16:56 ` jackie.rosen at hushmail dot com
2014-05-28 19:42 ` schwab at sourceware dot org
2014-06-27  9:57 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).