Ask Your Question

Revision history [back]

First of all, when you want to use polynomials in Sage, it is always wiser to use elements in some polynomial ring rather than elements of Sage's symbolic ring.

Then, if f is such a polynomial, you can ask for the coefficient of x^k simply by asking f[k]. This works for any k, even if k is larger than the degree of f.

Here is an example.

sage: R.<x> = PolynomialRing(QQ)
sage: f = x^2 - 3
sage: f[0], f[1], f[2], f[3], f[20]
(-3, 0, 1, 0, 0)