First time here? Check out the FAQ!

Ask Your Question
1

coefficient function in sage

asked 8 years ago

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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 ?

Preview: (hide)

Comments

Could you please provide an example on how you construct f?

tmonteil gravatar imagetmonteil ( 8 years ago )

What does f.coefficients() give you?

calc314 gravatar imagecalc314 ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

slelievre gravatar image

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)
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 1,972 times

Last updated: Jun 20 '16