Ask Your Question
1

doubt about cyclotomic polynomials

asked 2016-08-14 10:45:13 +0100

nebuckandazzer gravatar image

updated 2016-08-18 20:00:22 +0100

 sage: from sage.rings.polynomial.cyclotomic import cyclotomic_coeffs
 sage: cyclotomic_coeffs(30)
 [1, 1, 0, -1, -1, -1, 0, 1, 1]
 sage: cyclotomic_coeffs(10^5)
 {0: 1, 10000: -1, 40000: 1, 30000: -1, 20000: 1}

I don't understand the notation. What does the last line mean ?

edit retag flag offensive close merge delete

Comments

Read the doc. The result of this function is either the list of all coefficients, or a dictionary {index: coefficient}.

FrédéricC gravatar imageFrédéricC ( 2016-08-14 15:01:37 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2016-08-19 00:26:36 +0100

tmonteil gravatar image

updated 2016-08-19 00:31:38 +0100

This is the difference between dense and sparse representations. In the first case, the polynomial is x^8 + x^7 - x^5 - x^4 - x^3 + x + 1 so it can be represented as the list of its first 9 coefficients: [1, 1, 0, -1, -1, -1, 0, 1, 1]. In the second case, the polynomial is x^40000 - x^30000 + x^20000 - x^10000 + 1 so instead of storing the first 40001 coefficients, it is wiser to only store the nonzero ones. For this, Sage use a dictionary that tells that x^0 has coefficient 1, x^1000 has coefficient -1, and so on.

As written in the doc, you can get the polynomials as follows:

sage: R = QQ['x']
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: R(cyclotomic_coeffs(30))
x^8 + x^7 - x^5 - x^4 - x^3 + x + 1
sage: R(cyclotomic_coeffs(10^5))
x^40000 - x^30000 + x^20000 - x^10000 + 1
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-08-14 10:45:13 +0100

Seen: 1,254 times

Last updated: Aug 19 '16