Hi Ondrej, I burrowed into the source code and the problem seems to be caused by the pattern matching in the `sympy/core/power.py` file. It expects a term of the form k*x**l, but if there are two terms of the same power in x it won't match. This gives l=0 and the following while loop doesn't terminate.
term2 = rest.as_leading_term(x) k, l = Wild("k"), Wild("l") r = term2.match(k*x**l) k, l = r[k], r[l] ... while l * m < n: A naive fix is attached below following, which seems to work, I'm not sure what it's limitations are. I think checking l>0 is a good thing though... Andrew --- sympy/core/power.py 2009-03-12 07:41:25.000000000 +1100 +++ power.py 2009-03-24 12:17:35.000000000 +1100 @@ -534,13 +534,15 @@ n2 = getn(rest) if n2 is not None: n = n2 - term2 = rest.as_leading_term(x) + + from sympy import collect + term2 = collect(rest.as_leading_term(x),x) k, l = Wild("k"), Wild("l") r = term2.match(k*x**l) k, l = r[k], r[l] - if l.is_Integer: + if l.is_Integer and l>0: l = int(l) - elif l.is_number: + elif l.is_number and l>0: l = float(l) else: raise Exception("Not implemented") On Mar 20, 2:00 pm, Ondrej Certik <ond...@certik.cz> wrote: > Hi Andrew! > > > > On Thu, Mar 19, 2009 at 6:20 PM, Andrew <doche...@gmail.com> wrote: > > > Hi, > > > I have just started using Sympy and find it to be terrific so far, so > > thanks for all the work you've done in creating it! > > > I'm having some problems getting series expansions of some functions, > > sympy hangs forever (or at least a few hours) for some functions. I've > > reduced the problem to the simplest case that causes this, and the > > code appears below. Am I doing something wrong here? > > >> from sympy import * > >> x,a,b = symbols('x,a,b') > >> f = 1/(1+a*x) > >> print f.series(x) > > > This works fine and prints the series to O(x**6) as expected > > >> f = 1/(1+(a+b)*x) > >> print f.series(x) > > > This just hangs and doesn't print anything! > > > I am running the latest version of sympy in the git repository. > > what an embarrasing bug. I'll try to look at it what went wrong and fix it. > > Thanks for discovering it. > > Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---