[SciPy-User] Warnings with QUAD
Etrade Griffiths
etrade.griffiths@dsl.pipex....
Mon Apr 26 11:47:44 CDT 2010
Hi
I am trying to integrate a function with an infinite upper limit but
keep getting these warnings from scipy.integrate.quad:
Warning: The maximum number of subdivisions (50) has been achieved.
If increasing the limit yields no improvement it is advised to analyze
the integrand in order to determine the difficulties. If the position of a
local difficulty can be determined (singularity, discontinuity) one will
probably gain from splitting up the interval and calling the integrator
on the subranges. Perhaps a special-purpose integrator should be used.
Not quite sure what this means. Increasing the number of
sub-divisions had no effect and the components of the function seem
reasonably well behaved. As the following example shows, I get these
messages over a wide range of values. Would be grateful for any
suggestions to stop these warnings - thanks in advance.
import math
import scipy.special
import scipy.integrate
# function to integrate
def func(u, tDa):
num = 1.0 - math.exp(-u * u * tDa)
j0u = scipy.special.j0(u)
y0u = scipy.special.y0(u)
den = j0u * j0u + y0u * y0u
return num / den / u / u / u
# main program
print(" tD wD")
for tD in [1.0E-3,1.0E-2,1.0E-1,1.0E0,1.0E1,1.0E2,1.0E3,1.0E4,1.0E5]:
x = scipy.integrate.quad(func, 0.0, scipy.integrate.inf, args=(tD))
wD = 4.0 * x[0] / math.pi / math.pi
print("%10.3e %10.3e" % (tD, wD) )
More information about the SciPy-User
mailing list