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
Post a Comment