Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Coefficients of polynomial of fixed degree [closed]

asked 3 years ago

dasdipayan519 gravatar image

updated 3 years ago

How can we extract the coefficient of any polynomial as a fixed degree polynomial? For example, if we have a=2+3x, then a.polynomial().coefficient() will extract (2,3), but I need the polynomial of degree 3, and the output will be (2,3,0,0).

Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by dasdipayan519
close date 2022-01-19 13:39:40.366721

1 Answer

Sort by » oldest newest most voted
2

answered 3 years ago

slelievre gravatar image

updated 3 years ago

If a lives in a polynomial ring rather than in the symbolic ring, then a[k] extracts the coefficient of x^k of a, regardless of the degree of a.

Example:

sage: x = polygen(ZZ)
sage: a = 2 + 3*x
sage: [a[k] for k in range(4)]
[2, 3, 0, 0]
Preview: (hide)
link

Question Tools

Stats

Asked: 3 years ago

Seen: 184 times

Last updated: Jan 19 '22