`Poly.degree()` incorrect degree for multi-variable polynomials #12007

siefkenj opened this Issue Dec 31, 2016 · 3 comments


None yet

3 participants


Poly.degree() returns the incorrect degree for multi-variate polynomials.

>>> from sympy.abc import *
>>> from sympy import *
>>> pp = Poly(x*x*y)
>>> pp
Poly(x**2*y, x, y, domain='ZZ')
>>> pp.degree()

However, the degree of x*x*y is 3 as a polynomial in two variables.

jksuom commented Jan 1, 2017

Poly.degree(f, x=None) is defined as

The leading degree in ``x`` or the main variable.

The degrees in all variables can be obtained by .degrees().

siefkenj commented Jan 2, 2017

degrees appears to have been renamed degree_list. Nomatter, that is not the functionality I need, nor is it the meaning of the degree of a multi-variable polynomial. Poly(x*x*y).degree_list() returns (2,1). The degree of x*x*y is 3. See https://en.wikipedia.org/wiki/Polynomial#Definition for a reference.

asmeurer commented Jan 2, 2017

I believe you want total_degree

In [572]: Poly(x*x*y).total_degree()
Out[572]: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment