Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration can take a _long_ time (possibly forever) #11856

Closed
lxkain opened this issue Nov 15, 2016 · 7 comments · Fixed by #14059
Closed

integration can take a _long_ time (possibly forever) #11856

lxkain opened this issue Nov 15, 2016 · 7 comments · Fixed by #14059

Comments

@lxkain
Copy link

lxkain commented Nov 15, 2016

Hello,

When I do

t = symbols('t', real=True)
def nsinc(t):
    "normalized sinc function"
    return sinc(pi * t)

nsinc(t).integrate()

the process either takes a long time, or doesn't return.

@asmeurer
Copy link
Member

It's (unsurprisingly) stuck in the heurisch algorithm.

@rohitrango
Copy link
Contributor

This looks like a good start for something a little more advanced. I have fixed a few easy bugs but I don't feel that I have understood how SymPy works yet. Where should I start to fix this issue (and start learning more about the functioning of the framework) ?

@jksuom
Copy link
Member

jksuom commented Dec 6, 2016

The integrals module makes use of several integrators which are suited for different kinds of integrands. nsinc can be integrated by meijerint, which can be seen by setting the keyword meijerg:

 In [23]: nsinc(t).integrate(meijerg=True)
Out[23]: 
Si(π⋅t)
───────
   π 

The integration takes a long time because heurisch is attempted before meijerint in the current implementation. (The extra pi in the normalized sinc function makes heurisch particularly sluggish since it then reverts to using polynomial algebra in the very slow expression domain EX. Integrating the unnormalized sinc only takes a reasonable time.)

@asmeurer
Copy link
Member

asmeurer commented Dec 8, 2016

I seem to remember that there was a good reason for it, but why is heurisch tried before meijerg? Heurisch is the slowest and hence ought to be tried last.

@rohitrango
Copy link
Contributor

So, should the ordering of the algorithms be changed? That seems like a better fix than considering special functions separately.

@jksuom
Copy link
Member

jksuom commented Dec 8, 2016

should the ordering of the algorithms be changed?

Yes, meijerint should come before heurisch. It can integrate many functions that heurisch cannot handle. In those cases no time will be wasted with heurisch.

@rohitrango
Copy link
Contributor

Yes, actually I tried integrating some non common functions and meijerint was able to solve them quicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants