ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 01 Mar 2018 04:43:27 -0600Normal base of a finite extersion fieldhttp://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/ Hi all,
any finite extension (say degree *n*) of a field *K* may be considered as vector space over *K*. In particular, the roots of any irreducible polynomial *f* of degree *n* over a finite field *K* constitute a basis of this vector space.
Does SageMath provide a routine to construct the vector space for given *K* and *f*?
Such a vector space seems to be used internally when constructing *Kn=GF(K.order()^n,'a',modulus=f)*. If so then the question becomes: Is this vector space open to the public? And how can I use it?
Thanks in advance
Wolfgang JansenTue, 27 Feb 2018 09:04:13 -0600http://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/Answer by dan_fulea for <p>Hi all, </p>
<p>any finite extension (say degree <em>n</em>) of a field <em>K</em> may be considered as vector space over <em>K</em>. In particular, the roots of any irreducible polynomial <em>f</em> of degree <em>n</em> over a finite field <em>K</em> constitute a basis of this vector space. </p>
<p>Does SageMath provide a routine to construct the vector space for given <em>K</em> and <em>f</em>?</p>
<p>Such a vector space seems to be used internally when constructing <em>Kn=GF(K.order()^n,'a',modulus=f)</em>. If so then the question becomes: Is this vector space open to the public? And how can I use it?</p>
<p>Thanks in advance
Wolfgang Jansen</p>
http://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/?answer=41314#post-id-41314Depending on the application, the one or the other way to introduce and use objects may be favorable.
So i will suppose that the base field is a **finite** field, `F`, in the example having $11$ elements, so we work over
$$\mathbb F_{11}\ .$$
With respect to the irreducible polynomial $f=X^5-X+1$ we build the extension $K$ of $F$, and let $x$ be the image of $X$, taken modulo $f$.
Then we can start the following dialog with sage in the iron python interpreter:
sage: F = GF(11)
sage: R.<X> = PolynomialRing( F )
sage: f = X^5 - X + 1
sage: f.is_irreducible()
True
sage: K.<x> = GF( 11**5, modulus=f )
sage: V = K.vector_space()
sage: V
Vector space of dimension 5 over Finite Field of size 11
sage: V.basis()
[
(1, 0, 0, 0, 0),
(0, 1, 0, 0, 0),
(0, 0, 1, 0, 0),
(0, 0, 0, 1, 0),
(0, 0, 0, 0, 1)
]
sage: V.basis_matrix()
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
sage: V.base_field()
Finite Field of size 11
sage: k = K.random_element()
sage: k
8*x^3 + x^2 + 4
sage: V(k)
(4, 0, 1, 8, 0)
So applying the "class", the "convertor", the "constructor" `V` on an element of the field `K` implements the forgetful functor from $K$ to $V$.
In characteristic zero, over $$\mathbb Q$$ the above has to be changed slightly.
Sample code:
sage: R.<X> = QQ[]
sage: K.<x> = NumberField( X^3 + X + 1 )
sage: V, from_V, to_V = K.vector_space()
sage: from_V
Isomorphism map:
From: Vector space of dimension 3 over Rational Field
To: Number Field in x with defining polynomial X^3 + X + 1
sage: to_V
Isomorphism map:
From: Number Field in x with defining polynomial X^3 + X + 1
To: Vector space of dimension 3 over Rational Field
sage: to_V(1)
(1, 0, 0)
sage: to_V(x)
(0, 1, 0)
sage: to_V(x^2)
(0, 0, 1)
sage: to_V(x^3)
(-1, -1, 0)
sage: a = 2018*x + 1
sage: a.norm()
-8213877507
sage: matrix( QQ, 3, 3, [ to_V( a*x^k ) for k in [0,1,2] ] ).det()
-8213877507
The information above in the line `V, from_V, to_V = K.vector_space()` is taken from
sage: R.<X> = QQ[]
sage: K.<x> = NumberField( X^3 + X + 1 )
sage: K.vector_space?
and it is always a good idea to investigate in this way the doc(umentation) strings for the methods of some existing instances. In this case, after `K.` i was hitting the `TAB` (sometimes one has to do this twice), got a list of methods, saw the `vector_space` among them, then added the question mark to see if it is helpful for the given situation, yes it was.
Wed, 28 Feb 2018 13:27:08 -0600http://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/?answer=41314#post-id-41314Comment by wjansen for <p>Depending on the application, the one or the other way to introduce and use objects may be favorable.
So i will suppose that the base field is a <strong>finite</strong> field, <code>F</code>, in the example having $11$ elements, so we work over
$$\mathbb F_{11}\ .$$
With respect to the irreducible polynomial $f=X^5-X+1$ we build the extension $K$ of $F$, and let $x$ be the image of $X$, taken modulo $f$.
Then we can start the following dialog with sage in the iron python interpreter:</p>
<pre><code>sage: F = GF(11)
sage: R.<X> = PolynomialRing( F )
sage: f = X^5 - X + 1
sage: f.is_irreducible()
True
sage: K.<x> = GF( 11**5, modulus=f )
sage: V = K.vector_space()
sage: V
Vector space of dimension 5 over Finite Field of size 11
sage: V.basis()
[
(1, 0, 0, 0, 0),
(0, 1, 0, 0, 0),
(0, 0, 1, 0, 0),
(0, 0, 0, 1, 0),
(0, 0, 0, 0, 1)
]
sage: V.basis_matrix()
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
sage: V.base_field()
Finite Field of size 11
sage: k = K.random_element()
sage: k
8*x^3 + x^2 + 4
sage: V(k)
(4, 0, 1, 8, 0)
</code></pre>
<p>So applying the "class", the "convertor", the "constructor" <code>V</code> on an element of the field <code>K</code> implements the forgetful functor from $K$ to $V$. </p>
<p>In characteristic zero, over $$\mathbb Q$$ the above has to be changed slightly.</p>
<p>Sample code:</p>
<pre><code>sage: R.<X> = QQ[]
sage: K.<x> = NumberField( X^3 + X + 1 )
sage: V, from_V, to_V = K.vector_space()
sage: from_V
Isomorphism map:
From: Vector space of dimension 3 over Rational Field
To: Number Field in x with defining polynomial X^3 + X + 1
sage: to_V
Isomorphism map:
From: Number Field in x with defining polynomial X^3 + X + 1
To: Vector space of dimension 3 over Rational Field
sage: to_V(1)
(1, 0, 0)
sage: to_V(x)
(0, 1, 0)
sage: to_V(x^2)
(0, 0, 1)
sage: to_V(x^3)
(-1, -1, 0)
sage: a = 2018*x + 1
sage: a.norm()
-8213877507
sage: matrix( QQ, 3, 3, [ to_V( a*x^k ) for k in [0,1,2] ] ).det()
-8213877507
</code></pre>
<p>The information above in the line <code>V, from_V, to_V = K.vector_space()</code> is taken from</p>
<pre><code>sage: R.<X> = QQ[]
sage: K.<x> = NumberField( X^3 + X + 1 )
sage: K.vector_space?
</code></pre>
<p>and it is always a good idea to investigate in this way the doc(umentation) strings for the methods of some existing instances. In this case, after <code>K.</code> i was hitting the <code>TAB</code> (sometimes one has to do this twice), got a list of methods, saw the <code>vector_space</code> among them, then added the question mark to see if it is helpful for the given situation, yes it was.</p>
http://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/?comment=41326#post-id-41326Thanks, calling 'vector_space' on 'K' is the crucial point.
BTW, I read the documents in "sage/rings/finite_rings/finite_field_constructor.py" and many others up and down looking for all occurrences of 'def ' (restricted to these since I was looking for a method definition) but did not find something related to my question. Now I did it a second time and see 'V = k.vector_space()' is an example comment in "sage/rings/finite_rings/finite_field_ntl_gf2e.py" (probably, also in some other files). My failure was to ignore comments.Thu, 01 Mar 2018 04:43:27 -0600http://ask.sagemath.org/question/41281/normal-base-of-a-finite-extersion-field/?comment=41326#post-id-41326