delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/29/13:07:05

X-Spam-Check-By: sourceware.org
Message-ID: <46D5A79E.C09EF7CE@dessent.net>
Date: Wed, 29 Aug 2007 10:06:38 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: newlib AT sourceware DOT org
CC: cygwin AT cygwin DOT com
Subject: Re: 1.5.24: sin() bug
References: <20070829153331 DOT GA95558 AT tetsuo DOT karasik DOT eu DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Dmitry Karasik wrote:

> #include <math.h>
> #include <stdio.h>
> int main( int argc, char ** argv)
> {
>         double g = (double) 3.1415926535897900074;
>         printf("sin(%.10g)=%.10g\n", g, sin(g));
> }
> 
> output is :
> 
> sin(3.141592654)=3.231089149e-15
> 
> whereas all other sin() implementation I could find ( freebsd, linux, msvc)
> report this:
> 
> sin(3.141592654)=3.231085104e-015
> 
> the difference is in 7th digit, and is significant for double precision.

This appears to be due to an approximation in __kernel_sin in which if
|x| < 2**-27 the approximation sin(x) ~ x is used.

<http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/newlib/libm/math/k_sin.c?content-type=text/plain&cvsroot=src>.

This code seems to be completely untouched since the original import
into CVS in 2000, so I'm guessing it's a very old implementation.  I'm
not sure how we'd go about fixing this other than to look for a more
sophisticated implementation and contribute it to newlib.

In any case this is more of a newlib issue than a Cygwin issue as we are
just a consumer of this code, so followups should go to the newlib list.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019