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.Sun, 05 Mar 2017 19:56:43 +0100irreducible polynomial codehttps://ask.sagemath.org/question/34318/irreducible-polynomial-code/ K.<a>=GF(2^3)
A = [0,1,a,a^2,a^3,a^4,a^5,a^6]
for i=0 in [A]
for j=0 in [A]
f(x)=x^2+A[i]x+A[j]
print f(x)
I have written this code to generate irreducible polynomial f(x) by taking different values from A so it is represent A[i] and A[j] but its gives me error.Wed, 03 Aug 2016 16:51:19 +0200https://ask.sagemath.org/question/34318/irreducible-polynomial-code/Answer by vdelecroix for <pre><code>K.<a>=GF(2^3)
A = [0,1,a,a^2,a^3,a^4,a^5,a^6]
for i=0 in [A]
for j=0 in [A]
f(x)=x^2+A[i]x+A[j]
print f(x)
</code></pre>
<p>I have written this code to generate irreducible polynomial f(x) by taking different values from A so it is represent A[i] and A[j] but its gives me error.</p>
https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?answer=34319#post-id-34319There are at least 4 problems with your code:
- if you want polynomials, you need to declare x as a variable of a polynomial ring over K
- the syntax "f(x) = something" is only intended for symbolic functions, in your case you should just use standard affectation "f = something"
- implicit multiplication does not work A[i]x is an error you should write A[i]*x
- the syntax of the for loop is wrong
Here is a corrected version
K.<a> = GF(2^3)
x = polygen(K)
for ai in K:
for aj in K:
f = x^2 + ai*x + aj
print f
Wed, 03 Aug 2016 16:57:22 +0200https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?answer=34319#post-id-34319Comment by santoshi for <p>There are at least 4 problems with your code:</p>
<ul>
<li>if you want polynomials, you need to declare x as a variable of a polynomial ring over K</li>
<li>the syntax "f(x) = something" is only intended for symbolic functions, in your case you should just use standard affectation "f = something"</li>
<li>implicit multiplication does not work A[i]x is an error you should write A[i]*x</li>
<li>the syntax of the for loop is wrong</li>
</ul>
<p>Here is a corrected version</p>
<pre><code>K.<a> = GF(2^3)
x = polygen(K)
for ai in K:
for aj in K:
f = x^2 + ai*x + aj
print f
</code></pre>
https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=34356#post-id-34356thank a lot sirSat, 06 Aug 2016 19:21:41 +0200https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=34356#post-id-34356Comment by santoshi for <p>There are at least 4 problems with your code:</p>
<ul>
<li>if you want polynomials, you need to declare x as a variable of a polynomial ring over K</li>
<li>the syntax "f(x) = something" is only intended for symbolic functions, in your case you should just use standard affectation "f = something"</li>
<li>implicit multiplication does not work A[i]x is an error you should write A[i]*x</li>
<li>the syntax of the for loop is wrong</li>
</ul>
<p>Here is a corrected version</p>
<pre><code>K.<a> = GF(2^3)
x = polygen(K)
for ai in K:
for aj in K:
f = x^2 + ai*x + aj
print f
</code></pre>
https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=34357#post-id-34357sir thanks for your help the above code gives me all the second degree polynomial for field GF(2^3). now i want to find out from that irreducible polynomial please helpSat, 06 Aug 2016 19:29:40 +0200https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=34357#post-id-34357Comment by dan_fulea for <p>There are at least 4 problems with your code:</p>
<ul>
<li>if you want polynomials, you need to declare x as a variable of a polynomial ring over K</li>
<li>the syntax "f(x) = something" is only intended for symbolic functions, in your case you should just use standard affectation "f = something"</li>
<li>implicit multiplication does not work A[i]x is an error you should write A[i]*x</li>
<li>the syntax of the for loop is wrong</li>
</ul>
<p>Here is a corrected version</p>
<pre><code>K.<a> = GF(2^3)
x = polygen(K)
for ai in K:
for aj in K:
f = x^2 + ai*x + aj
print f
</code></pre>
https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=36839#post-id-36839[ x^2 + c*x + d for c in K for d in K if ( x^2 + c*x + d ) . is_irreducible() ] # does the jobSun, 05 Mar 2017 19:56:43 +0100https://ask.sagemath.org/question/34318/irreducible-polynomial-code/?comment=36839#post-id-36839