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

Robert Hetland hetland at tamu.edu
Mon Jan 23 08:46:53 CST 2006

```I get the same errors:  OS X 10.4, NumPy 0.9.2.1831, SciPy 0.4.4.1526.

It is clearly an almost 1.0 problem...  vis,

x = arange(0.,2.,0.1)
>>> x

array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9,  1. ,
1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8,  1.9])
>>> special.erf(x)

array([ 0.        ,  0.11246292,  0.22270259,  0.32862676,  0.42839236,
0.52049988,  0.60385609,  0.67780119,  0.74210096,  0.79690821,
nan,  0.88020507,  0.91031398,  0.93400794,  0.95228512,
0.96610515,  0.97634838,  0.98379046,  0.9890905 ,
0.99279043])
>>> x[10]
0.99999999999999989
>>> special.erf(x[10])
nan

But, look..
>>> x[10]+1.0-1.0
1.0
>>> special.erf(x[10]+1.0-1.0)
0.84270079294971478

-Rob.

On Jan 23, 2006, at 7:24 AM, Evan Monroig wrote:

> On Jan.23 09h20, Andrea Riciputi wrote :
>>
>> 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
>
> Did you really try the *almost 1.0 but not 1.0* number ? It should be
> something like the following:
>
> double x = 0.0;
> for (int i = 0; i < 10; ++i) {
>     x += 0.1;
> }
> result = erf(x);
> ...
>
>> 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?
>
> Sorry I don't have OSX at hand, but I know it is Tiger, and I am sure
> I used gcc 3.
>
> Evan
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user

-----
Rob Hetland, Assistant Professor
Dept of Oceanography, Texas A&M University
p: 979-458-0096, f: 979-845-6331
e: hetland at tamu.edu, w: http://pong.tamu.edu

```