There is also degree(), but it seems that it uses the wrong thing too. We should probably fix degree to do the more expected thing. For now, using Poly.total_degree is fine. degree() and degree_list() create a Poly internally anyway.
Aaron Meurer On Mon, Jun 17, 2013 at 8:30 AM, Thilina Rathnayake <[email protected]> wrote: > Dear All, > > In my work related to the Diophantine Module for SymPy (PR #2168 ) > I came across a situation where I want to find the degree of an expression. > > I initially used max(degree_list(expr)) but it doesn't always return what I > want. > >> In [7]: from sympy import degree_list >> In [8]: from sympy.abc import x, y >> In [9]: max(degree_list(5*x*y + x - 5*y + 2)) >> Out[9]: 1 > > > I want the answer to be two in the above case. > I found the workaround, > >> In [10]: from sympy import Poly >> In [11]: Poly(5*x*y + x - 5*y + 2).total_degree() >> Out[11]: 2 > > > which gives me the desired result. Is there a better way to get the result > rather than converting it to Polynomial? Thanks in advance. > > Regards, > Thilina > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
