On May 7, 2009, at 2:15 PM, John Cremona wrote: > It is a documented feature -- look at the docstring which says > > def coefficient(self, degrees): > """ > Return the coefficient of the variables with the degrees > specified in the python dictionary \code{degrees}. > Mathematically, > this is the coefficient in the base ring adjoined by the > variables > of this ring not listed in \code{degrees}. However, the > result > has the same parent as this polynomial. > > This function contrasts with the function \code > {monomial_coefficient} > which returns the coefficient in the base ring of a monomial. > > I do agree that it is a strange design, and would prefer > f.coefficient() to return an element of the base ring.
I agree. I think it's to support stuff like sage: sage: K.<x,y,z>=QQ[] sage: f = (x+1)^5*(y+1)^3 sage: f.coefficient(x^2*y^0) 10*y^3 + 30*y^2 + 30*y + 10 which is also an annoying interface to work with. > 2009/5/7 Soroosh Yazdani <syazd...@gmail.com>: >> Hi, >> >> this might be a design decision, so I haven't filed a bug report >> for it yet. >> However, it seems that coefficient is returning the wrong type >> when it's >> called on multinomials. Here is an example code: >> >> sage: K.<x,y,z>=QQ[] >> sage: f = x^3+y^3+z^3 >> sage: f.coefficient([3,0,0]).parent() >> Multivariate Polynomial Ring in x, y, z over Rational Field >> >> It makes more sense for the above return value to be the Rational >> Field. >> Similarly, f.coefficient([3,None,None]).parent(), should probably >> return >> "Multivariate Polynomial Ring in x, z over Rational Field". >> >> Should I file a bug for this? >> Soroosh >> >> >>> >> > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---