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, 28 Jun 2018 00:32:53 -0500Extension field adjoining two rootshttp://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/I'm trying to construct given an irreducible polynomial $f \in \mathbb{Q}[X]$ an extension field that adjoins two of its roots $\alpha_1,\alpha_2$. I'm trying to follow the approach suggested in [this question](https://ask.sagemath.org/question/40374/factorization-of-f-in-mathbbqx-in-field-extension-mathbbqalpha/)
. However, with the following code:
P.<x> = QQ[]
f = x^3+2*x+5 # f = P([5,2,0,0,1]) if you want
f_roots = f.roots(QQbar, multiplicities=False)
print f_roots
alpha = f_roots[0]
beta = f_roots[1]
K = QQ[alpha,beta]
K['x'](f).is_irreducible()
But this gives the error:
ValueError: defining polynomial (x^3 + 2*x + 5) must be irreducible
Although, the polynomial is clearly irreducible over $\mathbb{Q}$. Doing it as:
P.<x> = QQ[]
f = x^3+2*x+5
f_roots = f.roots(QQbar, multiplicities=False)
alpha = f_roots[0]
K.<a> = QQ[alpha]
beta = f_roots[1]
K1.<b> = K[beta]
Gives error:
ValueError: base field and extension cannot have the same name 'a'
What is going wrong? Is this the right way to construct the extension field with two roots?
**Edit**
Let me emphasize that I'm looking for a method that works for an arbitrary degree not just for degree 3. My actual problem goes on a degree four polynomial. So take as an example:
f = x^4+2*x+5
instead of the previous one.Sat, 30 Dec 2017 19:49:21 -0600http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/Comment by slelievre for <p>I'm trying to construct given an irreducible polynomial $f \in \mathbb{Q}[X]$ an extension field that adjoins two of its roots $\alpha_1,\alpha_2$. I'm trying to follow the approach suggested in <a href="https://ask.sagemath.org/question/40374/factorization-of-f-in-mathbbqx-in-field-extension-mathbbqalpha/">this question</a>
. However, with the following code:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5 # f = P([5,2,0,0,1]) if you want
f_roots = f.roots(QQbar, multiplicities=False)
print f_roots
alpha = f_roots[0]
beta = f_roots[1]
K = QQ[alpha,beta]
K['x'](f).is_irreducible()
</code></pre>
<p>But this gives the error:</p>
<pre><code>ValueError: defining polynomial (x^3 + 2*x + 5) must be irreducible
</code></pre>
<p>Although, the polynomial is clearly irreducible over $\mathbb{Q}$. Doing it as:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5
f_roots = f.roots(QQbar, multiplicities=False)
alpha = f_roots[0]
K.<a> = QQ[alpha]
beta = f_roots[1]
K1.<b> = K[beta]
</code></pre>
<p>Gives error:</p>
<pre><code>ValueError: base field and extension cannot have the same name 'a'
</code></pre>
<p>What is going wrong? Is this the right way to construct the extension field with two roots?</p>
<p><strong>Edit</strong></p>
<p>Let me emphasize that I'm looking for a method that works for an arbitrary degree not just for degree 3. My actual problem goes on a degree four polynomial. So take as an example:</p>
<p>f = x^4+2*x+5 </p>
<p>instead of the previous one.</p>
http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?comment=42763#post-id-42763Note: also asked as [math StackExchange question #2586636: Extension field adjoining two roots in Sage](https://math.stackexchange.com/q/2586636).Thu, 28 Jun 2018 00:32:53 -0500http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?comment=42763#post-id-42763Comment by slelievre for <p>I'm trying to construct given an irreducible polynomial $f \in \mathbb{Q}[X]$ an extension field that adjoins two of its roots $\alpha_1,\alpha_2$. I'm trying to follow the approach suggested in <a href="https://ask.sagemath.org/question/40374/factorization-of-f-in-mathbbqx-in-field-extension-mathbbqalpha/">this question</a>
. However, with the following code:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5 # f = P([5,2,0,0,1]) if you want
f_roots = f.roots(QQbar, multiplicities=False)
print f_roots
alpha = f_roots[0]
beta = f_roots[1]
K = QQ[alpha,beta]
K['x'](f).is_irreducible()
</code></pre>
<p>But this gives the error:</p>
<pre><code>ValueError: defining polynomial (x^3 + 2*x + 5) must be irreducible
</code></pre>
<p>Although, the polynomial is clearly irreducible over $\mathbb{Q}$. Doing it as:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5
f_roots = f.roots(QQbar, multiplicities=False)
alpha = f_roots[0]
K.<a> = QQ[alpha]
beta = f_roots[1]
K1.<b> = K[beta]
</code></pre>
<p>Gives error:</p>
<pre><code>ValueError: base field and extension cannot have the same name 'a'
</code></pre>
<p>What is going wrong? Is this the right way to construct the extension field with two roots?</p>
<p><strong>Edit</strong></p>
<p>Let me emphasize that I'm looking for a method that works for an arbitrary degree not just for degree 3. My actual problem goes on a degree four polynomial. So take as an example:</p>
<p>f = x^4+2*x+5 </p>
<p>instead of the previous one.</p>
http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?comment=40394#post-id-40394May I suggest leaving the original example, and adding the new example in the "Edit" part?Sun, 31 Dec 2017 09:54:23 -0600http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?comment=40394#post-id-40394Answer by vdelecroix for <p>I'm trying to construct given an irreducible polynomial $f \in \mathbb{Q}[X]$ an extension field that adjoins two of its roots $\alpha_1,\alpha_2$. I'm trying to follow the approach suggested in <a href="https://ask.sagemath.org/question/40374/factorization-of-f-in-mathbbqx-in-field-extension-mathbbqalpha/">this question</a>
. However, with the following code:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5 # f = P([5,2,0,0,1]) if you want
f_roots = f.roots(QQbar, multiplicities=False)
print f_roots
alpha = f_roots[0]
beta = f_roots[1]
K = QQ[alpha,beta]
K['x'](f).is_irreducible()
</code></pre>
<p>But this gives the error:</p>
<pre><code>ValueError: defining polynomial (x^3 + 2*x + 5) must be irreducible
</code></pre>
<p>Although, the polynomial is clearly irreducible over $\mathbb{Q}$. Doing it as:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5
f_roots = f.roots(QQbar, multiplicities=False)
alpha = f_roots[0]
K.<a> = QQ[alpha]
beta = f_roots[1]
K1.<b> = K[beta]
</code></pre>
<p>Gives error:</p>
<pre><code>ValueError: base field and extension cannot have the same name 'a'
</code></pre>
<p>What is going wrong? Is this the right way to construct the extension field with two roots?</p>
<p><strong>Edit</strong></p>
<p>Let me emphasize that I'm looking for a method that works for an arbitrary degree not just for degree 3. My actual problem goes on a degree four polynomial. So take as an example:</p>
<p>f = x^4+2*x+5 </p>
<p>instead of the previous one.</p>
http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?answer=40411#post-id-40411There is a simple approach that consists in using `number_field_elements_from_algebraics`
sage: from sage.rings.qqbar import number_field_elements_from_algebraics
sage: number_field_elements_from_algebraics([alpha, beta])
sage: K, (a,b), phi = number_field_elements_from_algebraics([alpha, beta])
sage: K # the field
Number Field in a with defining polynomial y^6 + 12*y^4 + 36*y^2 + 707
sage: a # alpha in K
1/90*a^4 + 1/9*a^2 + 1/2*a + 8/45
sage: b # beta in K
1/90*a^4 + 1/9*a^2 - 1/2*a + 8/45
sage: phi(a) == alpha and phi(b) == beta # phi is the embedding K -> QQbar
TrueMon, 01 Jan 2018 05:06:40 -0600http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?answer=40411#post-id-40411Answer by Daniel Jimenez for <p>I'm trying to construct given an irreducible polynomial $f \in \mathbb{Q}[X]$ an extension field that adjoins two of its roots $\alpha_1,\alpha_2$. I'm trying to follow the approach suggested in <a href="https://ask.sagemath.org/question/40374/factorization-of-f-in-mathbbqx-in-field-extension-mathbbqalpha/">this question</a>
. However, with the following code:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5 # f = P([5,2,0,0,1]) if you want
f_roots = f.roots(QQbar, multiplicities=False)
print f_roots
alpha = f_roots[0]
beta = f_roots[1]
K = QQ[alpha,beta]
K['x'](f).is_irreducible()
</code></pre>
<p>But this gives the error:</p>
<pre><code>ValueError: defining polynomial (x^3 + 2*x + 5) must be irreducible
</code></pre>
<p>Although, the polynomial is clearly irreducible over $\mathbb{Q}$. Doing it as:</p>
<pre><code>P.<x> = QQ[]
f = x^3+2*x+5
f_roots = f.roots(QQbar, multiplicities=False)
alpha = f_roots[0]
K.<a> = QQ[alpha]
beta = f_roots[1]
K1.<b> = K[beta]
</code></pre>
<p>Gives error:</p>
<pre><code>ValueError: base field and extension cannot have the same name 'a'
</code></pre>
<p>What is going wrong? Is this the right way to construct the extension field with two roots?</p>
<p><strong>Edit</strong></p>
<p>Let me emphasize that I'm looking for a method that works for an arbitrary degree not just for degree 3. My actual problem goes on a degree four polynomial. So take as an example:</p>
<p>f = x^4+2*x+5 </p>
<p>instead of the previous one.</p>
http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?answer=40392#post-id-40392This works for this particular case:
sage: P.<x> = QQ[]
sage: f = x^3+2*x+5 # f = P([5,2,0,1]) if you want
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-1.328268855668609?,
0.664134427834305? - 1.822971095411114?*I,
0.664134427834305? + 1.822971095411114?*I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K['x'](f).is_irreducible()
False
sage: factors = K['x'](f).factor()
sage: factors
(x - a) * (x^2 + a*x + a^2 + 2)
sage: g = factors[1][0]
sage: g
x^2 + a*x + a^2 + 2
sage: L.<b> = K.extension(g)
sage: L
Number Field in b with defining polynomial x^2 + a*x + a^2 + 2 over its base field
sage: L['x'](g).factor()
(x - b) * (x + b + a)
sage: L['x'](f).factor()
(x - b) * (x - a) * (x + b + a)Sun, 31 Dec 2017 05:32:51 -0600http://ask.sagemath.org/question/40389/extension-field-adjoining-two-roots/?answer=40392#post-id-40392