[SciPy-User] Overcoming slow/non-convergence w/ integrate.quad

David Goldsmith d.l.goldsmith at gmail.com
Thu Oct 24 23:40:32 EDT 2013


I've written a little function, based on the Cauchy Integral Formula and
utilizing scipy.integrate.quad for the integration, to return whether or
not a point is inside a simple closed curve made up from Bezier pieces.
 For my tests I'm using two quadratic Beziers, one beginning @ (1,0),
having (0,1) as the middle control point, and ending at (-1,0), the
"closer" being its reflection in the x-axis (i.e., (-1,0), (0,-1), (1,0)).
 For my interior test points, all of which pass, I'm using (so far)
(0,0), (1-1e-6,0), (-1+1e-6, 0).  For my exterior test points, I'm trying
to use (1+1e-6,0), (-1-1e-6, 0), and these are where I'm having trouble:
they don't pass (integral of the imaginary part non-zero), but (1+1e-5,0),
(-1-1e-5, 0), (1+5e-6,0), (-1-5e-6, 0) all do pass (integral of the
imaginary part zero to 12 decimal places), so I'm reasonably confident that
I have the algorithm right (I forgot to mention that the integral of the
imaginary part for my interior check points is 2pi, just as it should be).
 (1+2.5e-6,0) & (-1-2.5e-6, 0) don't pass, and full_output=1 returns the
clue (not returned for my "preferred" test points) "The integral is
probably divergent, or slowly convergent," which is what I supposed was the
problem; but I experimented w/ the epsabs, epsrel, and limit arguments,
none of which helped.  The other main clue I have is that, for the 1+1e-6
cases, the first error term in elist is twice as large (in abs val) as the
first integral sub-value in rlist!

Any advice?  Should I try a different quadrature function, and if so, which
one?  Should I just keep cranking down the eps's and/or cranking up the
limit?  Other options/suggestions?

Thanks!

OlyDLG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20131024/0aa90ae3/attachment.html>


More information about the SciPy-User mailing list