[SciPy-user] scipy.special.erf randomly returns NANs on OSX

Andrea Riciputi ariciputi at pito.com
Mon Jan 23 02:20:42 CST 2006


OS X here too (10.4.4 with gcc 4.0.0), but sorry I've not installed  
numpy yet. However, I've tried to reproduce the problem using pure C.  
Using the Apple math.h the strange behaviour showed by Evan Monroig  
doesn't show up. The returned results are as expected:

> Totila:~/Documents/Dottorato/Codice/erf andrea$ ./erf1
> erf(0.000000) = 0.000000e+00
> erf(0.100000) = 1.124629e-01
> erf(0.200000) = 2.227026e-01
> erf(0.300000) = 3.286268e-01
> erf(0.400000) = 4.283924e-01
> erf(0.500000) = 5.204999e-01
> erf(0.600000) = 6.038561e-01
> erf(0.700000) = 6.778012e-01
> erf(0.800000) = 7.421010e-01
> erf(0.900000) = 7.969082e-01
> erf(1.000000) = 8.427008e-01
> erf(1.100000) = 8.802051e-01
> erf(1.200000) = 9.103140e-01
> erf(1.300000) = 9.340079e-01
> erf(1.400000) = 9.522851e-01
> erf(1.500000) = 9.661051e-01
> erf(1.600000) = 9.763484e-01
> erf(1.700000) = 9.837905e-01
> erf(1.800000) = 9.890905e-01
> erf(1.900000) = 9.927904e-01

Even the code proposed by Robert Kern (when translated in C) works  
correctly:

> Totila:~/Documents/Dottorato/Codice/prova andrea$ ./erf2
> erf(1.900000) = 9.927904e-01

So I don't think it's a problem with Apple erf implementation. Which  
OS X version are you running? Which compiler did you used to compile  
numpy and scipy?

HTH,
  Andrea

On Jan 23, 2006, at 03:15 , Robert Kern wrote:

> Evan Monroig wrote:
>> Hi,
>>
>> I have this strange problem that the special erf function returns  
>> NANs
>> when the input is an array:
>
>> Can anyone reproduce the problem?
>
> Yes, also on OS X, and only with the almost-but-not-quite-1.0 that  
> you get by
> adding 0.1 to 0.0 ten times.
>
> In [9]: x = 0.0
>
> In [10]: for i in range(10):
>    ....:     x += 0.1
>    ....:
>
> In [11]: x
> Out[11]: 0.99999999999999989
>
> In [12]: scipy.special.erf(x)
> Out[12]: nan
>
> It's probably a platform-specific bug in Cephes. I'll try to see if  
> it shows up
> in C, too.
>
> -- 
> Robert Kern
> robert.kern at gmail.com
>
> "In the fields of hell where the grass grows high
>  Are the graves of dreams allowed to die."
>   -- Richard Harter
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



More information about the SciPy-user mailing list