ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 07 Jun 2016 11:07:22 +0200Coefficient of polynomial in a Finite fieldhttps://ask.sagemath.org/question/33684/coefficient-of-polynomial-in-a-finite-field/Consider the following code :-
p=104711
r=101
K=GF(p)
L.<y>=K.extension(cyclotomic_polynomial(r))
for a in range(10000,10000000):
f=(y+1)^(a)
L=f.list()
if L.count(0)>1:
print "special low support %d" %a
for i in range(100):
if L[i]==0:
print i
I want the list of coefficient of f(y) but when L is a field (which it for the above stated parameters ) it is giving this error.
AttributeError:
'sage.rings.finite_rings.element_pari_ffelt.FiniteFieldElement_pari_ffel\
t' object has no attribute 'list'
when L is a ring it is working perfectly. Also when I try to use f.coeff() it basically consider f(y) as a constant.Tue, 07 Jun 2016 05:11:12 +0200https://ask.sagemath.org/question/33684/coefficient-of-polynomial-in-a-finite-field/Answer by B r u n o for <p>Consider the following code :- </p>
<pre><code>p=104711
r=101
K=GF(p)
L.<y>=K.extension(cyclotomic_polynomial(r))
for a in range(10000,10000000):
f=(y+1)^(a)
L=f.list()
if L.count(0)>1:
print "special low support %d" %a
for i in range(100):
if L[i]==0:
print i
</code></pre>
<p>I want the list of coefficient of f(y) but when L is a field (which it for the above stated parameters ) it is giving this error.</p>
<pre><code>AttributeError:
'sage.rings.finite_rings.element_pari_ffelt.FiniteFieldElement_pari_ffel\
t' object has no attribute 'list'
</code></pre>
<p>when L is a ring it is working perfectly. Also when I try to use f.coeff() it basically consider f(y) as a constant.</p>
https://ask.sagemath.org/question/33684/coefficient-of-polynomial-in-a-finite-field/?answer=33687#post-id-33687To get the coefficients, you need to view `f` as a polynomial in `y`, using `f.polynomial()`. Then `list` gives you the list of all coefficients, while `coefficients` gives you the list of *nonzero* coefficients:
sage: p = 104711
sage: r = 101
sage: K = GF(p)
sage: L.<y> = K.extension(cyclotomic_polynomial(r))
sage: f = (y+1)^10
sage: f.polynomial().list()
[1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]
sage: f.polynomial().coefficients() # no difference since all coefficients are nonzero
[1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]
sage: f = (y+1)^100
sage: len(f.polynomial().list())
100
sage: len(f.polynomial().coefficients()) # one zero coefficient
99
Tue, 07 Jun 2016 11:07:22 +0200https://ask.sagemath.org/question/33684/coefficient-of-polynomial-in-a-finite-field/?answer=33687#post-id-33687