ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Jun 2016 03:31:17 -0500coefficient function in sagehttp://ask.sagemath.org/question/33811/coefficient-function-in-sage/I want to compute the coefficient of certain polynomial but he coefficient function in sage gives me back for the coefficient of X^0 that is for any polynomial f
f.coefficient(x^0) = 0
Can you some suggest how to change this thing in sage library ? Wed, 15 Jun 2016 21:00:50 -0500http://ask.sagemath.org/question/33811/coefficient-function-in-sage/Comment by calc314 for <p>I want to compute the coefficient of certain polynomial but he coefficient function in sage gives me back for the coefficient of X^0 that is for any polynomial f
f.coefficient(x^0) = 0
Can you some suggest how to change this thing in sage library ? </p>
http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?comment=33815#post-id-33815What does `f.coefficients()` give you?Thu, 16 Jun 2016 08:20:55 -0500http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?comment=33815#post-id-33815Comment by tmonteil for <p>I want to compute the coefficient of certain polynomial but he coefficient function in sage gives me back for the coefficient of X^0 that is for any polynomial f
f.coefficient(x^0) = 0
Can you some suggest how to change this thing in sage library ? </p>
http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?comment=33812#post-id-33812Could you please provide an example on how you construct `f`?Thu, 16 Jun 2016 04:25:33 -0500http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?comment=33812#post-id-33812Answer by slelievre for <p>I want to compute the coefficient of certain polynomial but he coefficient function in sage gives me back for the coefficient of X^0 that is for any polynomial f
f.coefficient(x^0) = 0
Can you some suggest how to change this thing in sage library ? </p>
http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?answer=33856#post-id-33856First 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)
Mon, 20 Jun 2016 03:31:17 -0500http://ask.sagemath.org/question/33811/coefficient-function-in-sage/?answer=33856#post-id-33856