X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>, <newlib@sourceware.org>
References: <20070829153331.GA95558@tetsuo.karasik.eu.org> <46D5A79E.C09EF7CE@dessent.net>
Subject: RE: 1.5.24: sin() bug
Date: Wed, 29 Aug 2007 18:12:40 +0100
Message-ID: <003201c7ea5f$d01db8f0$2e08a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <46D5A79E.C09EF7CE@dessent.net>
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On 29 August 2007 18:07, Brian Dessent wrote:

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

  Since when was pi less than 2^-27?

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

  I'd just like to point out that I got the exact same result as cygwin
supplies on a recent linux box:

  On cygwin, I get:

/tmp $ ./sin.exe
sin(3.141592654)=3.231089149e-15

... whereas on linux (x86_64), I get ...

[dk@ucho gxlinux-ent]$ ./sin 
sin(3.141592654)=3.231089149e-15

... and with mingw:

$ ./sin.exe 
sin(3.141592654)=3.231085104e-015

  I think it may be an artefact of FP precision and/or rounding mode, but I'd
need to do more experiments to make sure.  OTOH it could be an artifact of the
printf %g specfier.  Like I said, more experimentation is needed!


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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

