Ask Your Question
1

coefficient function in sage

asked 2016-06-16 04:00:50 +0200

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 ?

edit retag flag offensive close merge delete

Comments

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

tmonteil gravatar imagetmonteil ( 2016-06-16 11:25:33 +0200 )edit

What does f.coefficients() give you?

calc314 gravatar imagecalc314 ( 2016-06-16 15:20:55 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-20 10:31:17 +0200

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)
edit flag offensive delete link more

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: 2016-06-16 04:00:50 +0200

Seen: 1,486 times

Last updated: Jun 20 '16