Ask Your Question
1

doubt about cyclotomic polynomials

asked 2016-08-14 03:45:13 -0600

nebuckandazzer gravatar image

updated 2016-08-18 13:00:22 -0600

 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 08:01:37 -0600 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2016-08-18 17:26:36 -0600

tmonteil gravatar image

updated 2016-08-18 17:31:38 -0600

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 03:45:13 -0600

Seen: 382 times

Last updated: Aug 18 '16