math.erfc OverflowError

geremy condra debatem1 at gmail.com
Sun Jun 13 00:19:59 EDT 2010


On Sat, Jun 12, 2010 at 11:05 PM, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
> On Sat, 12 Jun 2010 15:49:37 -0700, geremy condra wrote:
>
>> In Python3.2, calling math.erfc with a value in [-27.2, -30) raises an
>> OverflowError: math range error. This is inconsistent with the erfc
>> function from scipy (scipy.special.erfc) as well as with the C99
>> function by the same name, both of which return 2. I suspect that this
>> is the result of the cutoff for the use of the continuing fraction
>> approximation of erfc beginning when abs(x) > 30, but I'm not sure. Is
>> this desired behavior or should I file a bug report?
>
>
> Geremy, I know that as a general rule, whenever a person finds what seems
> to be a bug in Python (or the standard library) they should suspect their
> own mistake rather than a bug, but I think this is taking caution to
> extremes. The domain of erfc is the set of all real numbers, and the
> result is bounded by [0, 2]. So asking if OverflowError is desired
> behaviour is a bit like the fellow who bought a new car and then asked if
> it's supposed to catch fire when starting the engine...
>
> :)

Well, that was more or less my feeling on it, but as a general rule
my opinion on math in python doesn't seem to be shared, so I
thought I'd ask.

Geremy Condra



More information about the Python-list mailing list