Ask Your Question
1

Coefficients of polynomial of fixed degree [closed]

asked 2022-01-19 12:04:24 +0200

dasdipayan519 gravatar image

updated 2022-01-19 12:30:00 +0200

How can we extract the coefficient of any polynomial as a fixed degree polynomial? For example, if we have $a=2+3*x$, 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).

edit retag flag offensive reopen merge delete

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 2022-01-19 12:32:37 +0200

slelievre gravatar image

updated 2022-01-19 12:32:59 +0200

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

Question Tools

Stats

Asked: 2022-01-19 12:04:24 +0200

Seen: 36 times

Last updated: Jan 19