1 | initial version |
You may try the following:
a = var(",".join( "a%i" %i for i in range(0, 7)))
R.<x,y> = LaurentPolynomialRing(SR,2)
f = x*y + a6*x + a4*y + x*y^-1 + x^-1*y + a3*y^-1 + a1*x^-1 + x^-1*y^-1
(f/(x^1*y^0)).constant_coefficient()
It gives a6 as you expect and e.g.
(f/(x^0*y^1)).constant_coefficient()
is equal to a4. Also you can determine the coefficient of any monomial:
(f/(x^0*y^1)).coefficient(x^-1*y^-2)
is 1.