1 | initial version |
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 the list of coefficients is [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.
2 | No.2 Revision |
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 the list of coefficients is [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
3 | No.3 Revision |
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 coefficients is 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