In Sage, how to extract coefficient of a polynomial in a ring

6.2k Views Asked by At

For instance, $f=x^2y^2+1$ is an element of $\mathbb{C}[x,y]$, I want to extract the coefficient of $x^2$, which is $y^2$. However "f.coefficient(x,2)" only works for symbolic expressions, are there similar functions for ring elements?

1

There are 1 best solutions below

0
On

Simply use f.coefficient(x^2), as in this example:

sage: R.<x,y> = CC[]
sage: f = x^2 *  y^2 + 1
sage: f.coefficient(x^2)
y^2