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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  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 ` vincent-srcware at vinc17 dot net
  2012-02-03 15:00 ` aj at suse dot de
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vincent-srcware at vinc17 dot net @ 2012-02-03 14:43 UTC (permalink / raw)
  To: glibc-bugs

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

Vincent Lefèvre <vincent-srcware at vinc17 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|sincos() is inaccurate for  |sincos() is incorrect for
                   |large inputs on x86_64      |large inputs on x86_64

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  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
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-02-03 15:00 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|aj at suse dot de           |drepper.fsp at gmail dot
                   |                            |com

--- Comment #1 from Andreas Jaeger <aj at suse dot de> 2012-02-03 15:00:02 UTC ---
Btw. x86-64 uses the same fsincos instruction like x86.

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  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
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: vincent-srcware at vinc17 dot net @ 2012-02-03 15:09 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Vincent Lefèvre <vincent-srcware at vinc17 dot net> 2012-02-03 15:09:07 UTC ---
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:

 
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

in particular Section 8.1.3.2, 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.

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (2 preceding siblings ...)
  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
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ppluzhnikov at google dot com @ 2012-02-03 19:58 UTC (permalink / raw)
  To: glibc-bugs

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

Paul Pluzhnikov <ppluzhnikov at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppluzhnikov at google dot
                   |                            |com

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (3 preceding siblings ...)
  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
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: carlos at systemhalted dot org @ 2012-02-13  4:54 UTC (permalink / raw)
  To: glibc-bugs

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

Carlos O'Donell <carlos at systemhalted dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |glibc_2.15
             Status|NEW                         |ASSIGNED
                 CC|                            |carlos at systemhalted dot
                   |                            |org
         AssignedTo|drepper.fsp at gmail dot    |carlos at systemhalted dot
                   |com                         |org

--- Comment #3 from Carlos O'Donell <carlos at systemhalted dot org> 2012-02-13 04:53:41 UTC ---
Andreas posted a possible patch for this issue here:
http://cygwin.com/ml/libc-alpha/2012-02/msg00194.html

GCC discussion is here:
http://gcc.gnu.org/ml/gcc/2012-02/msg00072.html

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (4 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-03-15 13:26 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |aj at suse dot de
         Resolution|                            |FIXED

--- Comment #4 from Andreas Jaeger <aj at suse dot de> 2012-03-15 13:24:59 UTC ---
This is fixed now for sincos, sin and cos on i386 and x86-64. I'm opening
separate bugs for float and long double.

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (5 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-03-15 13:31 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #5 from Andreas Jaeger <aj at suse dot de> 2012-03-15 13:31:20 UTC ---
*** Bug 13837 has been marked as a duplicate of this bug. ***

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (6 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-03-15 13:43 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |13851

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (7 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-03-15 13:48 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |13852

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (8 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: aj at suse dot de @ 2012-03-15 15:14 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Jaeger <aj at suse dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |13854

-- 
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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (9 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: carlos at redhat dot com @ 2013-06-03 16:05 UTC (permalink / raw)
  To: glibc-bugs

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

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |15563

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (10 preceding siblings ...)
  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
  13 siblings, 0 replies; 15+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 16:56 UTC (permalink / raw)
  To: glibc-bugs

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

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #6 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (11 preceding siblings ...)
  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
  13 siblings, 0 replies; 15+ messages in thread
From: schwab at sourceware dot org @ 2014-05-28 19:42 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jackie.rosen at hushmail dot com   |

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug math/13658] sincos() is incorrect for large inputs on x86_64
  2012-02-03 14:42 [Bug math/13658] New: sincos() is inaccurate for large inputs on x86_64 vincent-srcware at vinc17 dot net
                   ` (12 preceding siblings ...)
  2014-05-28 19:42 ` schwab at sourceware dot org
@ 2014-06-27  9:57 ` fweimer at redhat dot com
  13 siblings, 0 replies; 15+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27  9:57 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
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).