# In Sage, how to extract coefficient of a polynomial in a ring [closed]

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?

-

## closed as off-topic by Jonas Meyer, Arctic Char, Claude Leibovici, Macavity, TravisJJun 14 '15 at 6:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is not about mathematics, within the scope defined in the help center." – Jonas Meyer, Claude Leibovici, Macavity, TravisJ
If this question can be reworded to fit the rules in the help center, please edit the question.

I don't know anything about Sage, but perhaps you could tell it to find $\dfrac{1}{2}\dfrac{\partial^2 f}{\partial x^2}(0,y)$? – Jonas Meyer Jun 30 '12 at 7:51
By the way, there ask.sagemath.org for sage. In case you have more specific questions in the future. – Jernej Jun 30 '12 at 8:59

Simply use f.coefficient(x^2), as in this example:
sage: R.<x,y> = CC[]