Thanks for the discussion about this topic. I send this mail to re-iterate and summarize. It seems there are two things that you might want: 1) Get the coefficient of a specific monomial in the multivariate polynomial ring. 2) Get the coefficient of the polynomial in a tower of (two) polynomial extensions
I suggest that MPolynomial.coefficient method perform function #1 above. It currently does some strange things over the base rings I've tested. It does vary on base ring due to implementation differences. I suggest that there be a new method which performs function #2 and I suggest it be called "polynomial_coefficient", but I really don't like that name. I almost prefer "coefficient_polynomial" since it will sort beside coefficient in documentation and help people realize that if they are not happy with "coefficient" that they have an alternative. Of course, each method's documentation should probably mention the other. I'm wondering if we could have a vote on preferred syntax. I'm not going to describe the parameters because if they are not clear enough from context, it probably isn't a good parameter choice :) : sage: P.<v,w,x,y,z>=ZZ[] sage: f=(1-v)*(1-2*w)*(1-3*x); f -6*v*w*x + 2*v*w + 3*v*x + 6*w*x - v - 2*w - 3*x + 1 ############## # Alternative Number 1 ############## sage: f.polynomial_coefficient({w:0,v:1}) 3*x - 1 ############## # Alternative Number 2 ############## sage: f.polynomial_coefficient([x,y,z],v) 3*x - 1 ############## # Alternative Number 3 # Overloading of coefficient to handle both functionalities ############## sage: f.coefficient(v,base=ZZ['x,y,z']) 3*x - 1 sage: f.coefficient(v) # here's an example of functionality #1 above -1 Those are listed in the order of my preference for the interface. It feels to me that "Alternative Number 3" would not be much fun to implement (and involve coercions that some view as suspect). I basically implemented "Alternative Number 1" as a function in my own program and it feels like a straightforward implementation just iterating through the polydict. I'd love to have some other voters. NOTE: It is NOT sufficient to simply provide a monomial expression to the "polynomial_coefficient" method because it doesn't provide for the case when you explicitly want an exponent to be 0 -- this point seems to me to have caused a great deal of confusion in the current implementation. -- Joel --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---