Tricking numpy/python into representing very large and very small numbers -


i need compute integral of following function within ranges start low -150:

import numpy np scipy.special import ndtr  def my_func(x):     return np.exp(x ** 2) * 2 * ndtr(x * np.sqrt(2)) 

the problem part of function

np.exp(x ** 2) 

tends toward infinity -- inf values of x less approximately -26.

and part of function

2 * ndtr(x * np.sqrt(2)) 

which equivalent to

from scipy.special import erf  1 + erf(x) 

tends toward 0.

so, very, large number times very, small number should give me reasonably sized number -- but, instead of that, python giving me nan.

what can circumvent problem?

there such function: erfcx. think erfcx(-x) should give integrand want (note 1+erf(x)=erfc(-x)).


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -