Well i dont think there is some direct function in sympy doing this. I would go for this. suppose expr = 1 + x*y + x**2 * y**2 + x**k * y**m ..... expr1 = expr.subs(x,y) This would substitute all x's with y and ull now get a polynomial in y. expr1.args would return you (1,y**2,y**4,y**k+m) degree(expr1.args[..]) would return you the exponent. I think you can sort it out from here and build a best code that suits your requirement.
On Thu, Jun 21, 2012 at 6:38 PM, Reckoner <[email protected]> wrote: > Hi, > > I'm trying to expand polynomials such as > > (1+x+x**2+...+x**n)(1+y+y**2+...+y**n) > > and I would like to keep only those terms where the sum of the > respective exponents is equal to some number. For example, I want only > terms x^k*y^m where (k+m)==N. > > Can you help me get started with this using sympy? I read the > documentation, but I'm not sure how to proceed with the extraction part. I > can expand and create the polynomials just fine. > > Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sympy/-/fU3tJk7pUDYJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
