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, 28 Apr 2013 08:58:42 +0200Modular reduction in Galois fieldshttps://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/I want to compute x^6 mod x^5+x^2+1 in the Galois Field GF(2^5). Does anyone know how to do this in SAGE?Sun, 28 Apr 2013 07:04:04 +0200https://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/Answer by tmonteil for <p>I want to compute x^6 mod x^5+x^2+1 in the Galois Field GF(2^5). Does anyone know how to do this in SAGE?</p>
https://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/?answer=14855#post-id-14855First, define `k` to be the field GF(2^5), whose generator is named `a`:
sage: k.<a> = FiniteField(2^5); k
Finite Field in a of size 2^5
Alternatively :
sage: k = GF(2^5, 'a'); k
Finite Field in a of size 2^5
Then, define the polynomial ring `k[x]`:
sage: R.<x> = PolynomialRing(k); R
Univariate Polynomial Ring in x over Finite Field in a of size 2^5
Alternatively:
sage: R = k['x']; R
Univariate Polynomial Ring in x over Finite Field in a of size 2^5
Then, do your computation in R:
sage: P = R(x^6)
sage: P.mod(x^5+x^2+1)
x^3 + x
Sun, 28 Apr 2013 08:18:18 +0200https://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/?answer=14855#post-id-14855Comment by Christian_Kossmann for <p>First, define <code>k</code> to be the field GF(2^5), whose generator is named <code>a</code>:</p>
<pre><code>sage: k.<a> = FiniteField(2^5); k
Finite Field in a of size 2^5
</code></pre>
<p>Alternatively : </p>
<pre><code>sage: k = GF(2^5, 'a'); k
Finite Field in a of size 2^5
</code></pre>
<p>Then, define the polynomial ring <code>k[x]</code>:</p>
<pre><code>sage: R.<x> = PolynomialRing(k); R
Univariate Polynomial Ring in x over Finite Field in a of size 2^5
</code></pre>
<p>Alternatively:</p>
<pre><code>sage: R = k['x']; R
Univariate Polynomial Ring in x over Finite Field in a of size 2^5
</code></pre>
<p>Then, do your computation in R:</p>
<pre><code>sage: P = R(x^6)
sage: P.mod(x^5+x^2+1)
x^3 + x
</code></pre>
https://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/?comment=17796#post-id-17796Thank you very much - helped me a lot!Sun, 28 Apr 2013 08:58:42 +0200https://ask.sagemath.org/question/10069/modular-reduction-in-galois-fields/?comment=17796#post-id-17796