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.Wed, 24 Apr 2019 10:42:16 +0200Defining a 'nice' Compositumhttps://ask.sagemath.org/question/46314/defining-a-nice-compositum/ I'm having two difficulties which I assume are simple to resolve. I have a set field, say $K= \mathbb{Q}(x^2+1)$, and a set of polynomials I want to check if they are irreducible over $K$. If they are irreducible, I would like to form the compositum of $K$ and this field generated by $f$ and then find a 'nice' generator. For example,
K.<root> = NumberField(x^2+1);
R = K['x'];
poly = [x^2 + 1, x^2 + 2, x^2 + x + 1];
f = R(poly[0]);
if f.is_irreducible:
L = NumberField([x^2+1, f]);
There are two issues:
1. Even when f.is_irreducible() gives True, the polynomial is not always irreducible, as in the case above, so that the construction of L gives an error.
2. Even if L can be formed, how do I find a 'nice' generator for L, i.e. a single polynomial $g$ which generates L so that I can form a 'better' (in terms of computation speed) field $M= \mathbb{Q}(g)$?Tue, 23 Apr 2019 07:07:29 +0200https://ask.sagemath.org/question/46314/defining-a-nice-compositum/Answer by dan_fulea for <p>I'm having two difficulties which I assume are simple to resolve. I have a set field, say $K= \mathbb{Q}(x^2+1)$, and a set of polynomials I want to check if they are irreducible over $K$. If they are irreducible, I would like to form the compositum of $K$ and this field generated by $f$ and then find a 'nice' generator. For example, </p>
<pre><code>K.<root> = NumberField(x^2+1);
R = K['x'];
poly = [x^2 + 1, x^2 + 2, x^2 + x + 1];
f = R(poly[0]);
if f.is_irreducible:
L = NumberField([x^2+1, f]);
</code></pre>
<p>There are two issues:</p>
<ol>
<li><p>Even when f.is_irreducible() gives True, the polynomial is not always irreducible, as in the case above, so that the construction of L gives an error.</p></li>
<li><p>Even if L can be formed, how do I find a 'nice' generator for L, i.e. a single polynomial $g$ which generates L so that I can form a 'better' (in terms of computation speed) field $M= \mathbb{Q}(g)$?</p></li>
</ol>
https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?answer=46315#post-id-46315The following works for me:
S.<X> = QQ[]
K.<j> = QuadraticField(-1)
R.<x> = K[]
polynomials = [X^2 + 1, X^2 + 2, X^2 + X + 1]
count = 0
for f in polynomials:
count += 1
print "[%s]" % count
if R(f).is_irreducible():
print "\tIrreductible case for %s over K..." % f
L = NumberField( [X^2+1, f], names='a');
print "\tThe number field L is:"
print "\t%s" % L
print "\tThe base field of L is:"
print "\t%s" % L.base_field()
print "\tL has absolute degree %s" % L.absolute_degree()
print "\tL has relative degree %s" % L.relative_degree()
else:
print "\tReducible case for %s over K" % f
Results:
[1]
Reducible case for X^2 + 1 over K
[2]
Irreductible case for X^2 + 2 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + 2
L has absolute degree 4
L has relative degree 2
[3]
Irreductible case for X^2 + X + 1 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + X + 1
L has absolute degree 4
L has relative degree 2
Note that `f.is_irreducible` is only a method, as a boolean it always avaluates to `True`, one has to **call** it, `f.is_irreducible()` to have the needed `True` or `False`. Also, always make the difference between the transcendentals like `x` over different fields.Tue, 23 Apr 2019 11:24:38 +0200https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?answer=46315#post-id-46315Comment by dan_fulea for <p>The following works for me:</p>
<pre><code>S.<X> = QQ[]
K.<j> = QuadraticField(-1)
R.<x> = K[]
polynomials = [X^2 + 1, X^2 + 2, X^2 + X + 1]
count = 0
for f in polynomials:
count += 1
print "[%s]" % count
if R(f).is_irreducible():
print "\tIrreductible case for %s over K..." % f
L = NumberField( [X^2+1, f], names='a');
print "\tThe number field L is:"
print "\t%s" % L
print "\tThe base field of L is:"
print "\t%s" % L.base_field()
print "\tL has absolute degree %s" % L.absolute_degree()
print "\tL has relative degree %s" % L.relative_degree()
else:
print "\tReducible case for %s over K" % f
</code></pre>
<p>Results:</p>
<pre><code>[1]
Reducible case for X^2 + 1 over K
[2]
Irreductible case for X^2 + 2 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + 2
L has absolute degree 4
L has relative degree 2
[3]
Irreductible case for X^2 + X + 1 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + X + 1
L has absolute degree 4
L has relative degree 2
</code></pre>
<p>Note that <code>f.is_irreducible</code> is only a method, as a boolean it always avaluates to <code>True</code>, one has to <strong>call</strong> it, <code>f.is_irreducible()</code> to have the needed <code>True</code> or <code>False</code>. Also, always make the difference between the transcendentals like <code>x</code> over different fields.</p>
https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46316#post-id-46316Something like `a0 + a1`, which may be obtained like this:
sage: sum(L.gens())
a0 + a1
should be a simple generator, but this should be checked in an *ad-hoc* manner.Tue, 23 Apr 2019 11:28:05 +0200https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46316#post-id-46316Comment by nbruin for <p>The following works for me:</p>
<pre><code>S.<X> = QQ[]
K.<j> = QuadraticField(-1)
R.<x> = K[]
polynomials = [X^2 + 1, X^2 + 2, X^2 + X + 1]
count = 0
for f in polynomials:
count += 1
print "[%s]" % count
if R(f).is_irreducible():
print "\tIrreductible case for %s over K..." % f
L = NumberField( [X^2+1, f], names='a');
print "\tThe number field L is:"
print "\t%s" % L
print "\tThe base field of L is:"
print "\t%s" % L.base_field()
print "\tL has absolute degree %s" % L.absolute_degree()
print "\tL has relative degree %s" % L.relative_degree()
else:
print "\tReducible case for %s over K" % f
</code></pre>
<p>Results:</p>
<pre><code>[1]
Reducible case for X^2 + 1 over K
[2]
Irreductible case for X^2 + 2 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + 2
L has absolute degree 4
L has relative degree 2
[3]
Irreductible case for X^2 + X + 1 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + X + 1
L has absolute degree 4
L has relative degree 2
</code></pre>
<p>Note that <code>f.is_irreducible</code> is only a method, as a boolean it always avaluates to <code>True</code>, one has to <strong>call</strong> it, <code>f.is_irreducible()</code> to have the needed <code>True</code> or <code>False</code>. Also, always make the difference between the transcendentals like <code>x</code> over different fields.</p>
https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46324#post-id-46324Once you have the field as a relative extension, you can get it as a primitive extension of Q via `L.absolute_field('b')`. You can then use `L.optimized_representation()` to get a nice representation.Tue, 23 Apr 2019 17:39:39 +0200https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46324#post-id-46324Comment by FrédéricC for <p>The following works for me:</p>
<pre><code>S.<X> = QQ[]
K.<j> = QuadraticField(-1)
R.<x> = K[]
polynomials = [X^2 + 1, X^2 + 2, X^2 + X + 1]
count = 0
for f in polynomials:
count += 1
print "[%s]" % count
if R(f).is_irreducible():
print "\tIrreductible case for %s over K..." % f
L = NumberField( [X^2+1, f], names='a');
print "\tThe number field L is:"
print "\t%s" % L
print "\tThe base field of L is:"
print "\t%s" % L.base_field()
print "\tL has absolute degree %s" % L.absolute_degree()
print "\tL has relative degree %s" % L.relative_degree()
else:
print "\tReducible case for %s over K" % f
</code></pre>
<p>Results:</p>
<pre><code>[1]
Reducible case for X^2 + 1 over K
[2]
Irreductible case for X^2 + 2 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + 2
L has absolute degree 4
L has relative degree 2
[3]
Irreductible case for X^2 + X + 1 over K...
The number field L is:
Number Field in a0 with defining polynomial X^2 + 1 over its base field
The base field of L is:
Number Field in a1 with defining polynomial X^2 + X + 1
L has absolute degree 4
L has relative degree 2
</code></pre>
<p>Note that <code>f.is_irreducible</code> is only a method, as a boolean it always avaluates to <code>True</code>, one has to <strong>call</strong> it, <code>f.is_irreducible()</code> to have the needed <code>True</code> or <code>False</code>. Also, always make the difference between the transcendentals like <code>x</code> over different fields.</p>
https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46329#post-id-46329Please use python3 print syntax in your answers.Wed, 24 Apr 2019 10:42:16 +0200https://ask.sagemath.org/question/46314/defining-a-nice-compositum/?comment=46329#post-id-46329