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

David Goldsmith d.l.goldsmith at gmail.com
Fri Oct 25 01:45:30 EDT 2013


Never mind: it finally dawned on me that as long as all I need to know is
insies or outsies, so I can just integrate f(z)=1--as I am--then my
integral is almost trivial analytically.

Sorry for the noise.

DG
---------- Forwarded message ----------
From: David Goldsmith <d.l.goldsmith at gmail.com>
Date: Thu, Oct 24, 2013 at 8:40 PM
Subject: Overcoming slow/non-convergence w/ integrate.quad
To: scipy-user at scipy.org


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



-- 
>From "A Letter From The Future" in "Peak Everything" by Richard Heinberg:

"By the time I was an older teenager, a certain...attitude was developing
among the young people...a feeling of utter contempt for anyone over a
certain age--maybe 30 or 40.  The adults had consumed so many resources,
and now there were none left for their own children...when those adults
were younger, they [were] just doing what everybody else was doing...they
figured it was normal to cut down ancient forests for...phone books, pump
every last gallon of oil to power their SUV's...[but] for...my generation
all that was just a dim memory...We [grew up] living in darkness, with
shortages of food and water, with riots in the streets, with people begging
on street corners...for us, the adults were the enemy."

Want to *really* understand what's *really* going on?  Read "Peak
Everything."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20131024/370645f2/attachment.html>


More information about the SciPy-User mailing list