[SciPy-User] Not enough intervals in scipy.integrate.quad

Ralf Gommers ralf.gommers@gmail....
Sun Apr 7 08:19:04 CDT 2013


On Wed, Apr 3, 2013 at 1:31 PM, Kauffmann, Thierry <
Thierry.Kauffmann@saint-gobain.com> wrote:

>  Hello,****
>
> ** **
>
> I have a function that is peaked around k (a given value) –the expression
> is not very complicated, and the graph is attached to this email. I would
> like to integrate it from –inf to +inf.****
>
> ** **
>
> quad is taking 90 evaluations only, and is returning a value of e-66 (with
> a accuracy of e-66 too).****
>
> ** **
>
> But if I integrate from 0 to 2*k, the value is 1.6, with an accuracy of
> e-10. This takes 900 iterations. ****
>
> The integral from –inf to 0 and from 2*k to +inf are very low.****
>
> ** **
>
> Indeed, the correct value is close to the one given by the integration
> between –k and k.****
>
> ** **
>
> ** **
>
> My question is: how can I force quad to integrate with smaller intervals
> around k ? I have tried to play with the arguments ‘limit’ and ‘epsabs’ or
> ‘epsrel’, but without any outcome. I could not find any clue either in API
> or in the various forums.****
>
> ** **
>
> Can someone help me? My code is attached too.
>
It looks to me that this is what the 'points' keyword is for, except that
that does't work with non-finite integration bounds. That looks fixable
though - in the case where now a ValueError is used (code from
quadpack._quad below), the integral could be split up in a way similar to
what you now did by hand.

Ralf


    if points is None:
        if infbounds == 0:
            return
_quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit)
        else:
            return
_quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
    else:
        if infbounds !=0:
            raise ValueError("Infinity inputs cannot be used with break
points.")
        else:
            nl = len(points)
            the_points = numpy.zeros((nl+2,), float)
            the_points[:nl] = points
            return
_quadpack._qagpe(func,a,b,the_points,args,full_output,epsabs,epsrel,limit)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130407/6c7d8923/attachment.html 


More information about the SciPy-User mailing list