public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug math/15563] New: sincos() is incorrect for long double and large inputs on x86_64
Date: Mon, 03 Jun 2013 16:05:00 -0000	[thread overview]
Message-ID: <bug-15563-131@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 15563
           Summary: sincos() is incorrect for long double and large inputs
                    on x86_64
           Product: glibc
           Version: 2.18
            Status: NEW
          Keywords: glibc_2.15
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: carlos at redhat dot com
                CC: aj at suse dot de, bugdal at aerifal dot cx, carlos at redhat dot com,
                    ppluzhnikov at google dot com, vincent-srcware at vinc17 dot net
        Depends on: 13658
            Blocks: 13851, 13852, 13854

Still broken for long double on x86/x86_64.

Tested with current sources.

+++ This bug was initially created as a clone of Bug #13658 +++

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.

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


             reply	other threads:[~2013-06-03 16:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03 16:05 carlos at redhat dot com [this message]
2013-06-03 16:06 ` [Bug math/15563] " carlos at redhat dot com
2013-06-03 17:01 ` joseph at codesourcery dot com
2013-06-03 17:47 ` carlos at redhat dot com
2013-06-03 19:01 ` joseph at codesourcery dot com
2014-06-13 17:32 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-15563-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).