[Numpy-discussion] Re: numpy.sin

Robert Kern robert.kern at gmail.com
Thu May 25 12:29:06 EDT 2006


Alan G Isaac wrote:
> On Thu, 25 May 2006, Robert Kern apparently wrote: 

>>That your demonstration results in the desired exact 0.0 
>>for multiples of 2*pi is an accident. The results for 
>>values other than integer multiples of pi will be as wrong 
>>or more wrong.
> 
> It seems that a continuity argument should undermine that as 
> a general claim.  Right?

What continuity? This is floating-point arithmetic.

[~]$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale = 50
s(1000000)
-.34999350217129295211765248678077146906140660532871
[~]$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import *
>>> sin(1000000.0)
-0.34999350217129299
>>> sin(1000000.0 % (2*pi))
-0.34999350213477698
>>>

> But like I said: I was just wondering if there was anything 
> exploitable here.

Like I said: not really.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco





More information about the NumPy-Discussion mailing list