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.Tue, 02 Feb 2021 17:18:36 +0100Inconsistentency in parent of specialization of a polynomial?https://ask.sagemath.org/question/54684/inconsistentency-in-parent-of-specialization-of-a-polynomial/I have a family of polynomials and I want to consider special members of this family. In other words I'm considering polynomials in a ring $R = K[x]$ where $K = \mathbb{Q}[t]$. In sage I do the following:
K = PolynomialRing(QQ, ["t"])
R = PolynomialRing(K, ["x"])
t = K.gen(0)
x = R.gen(0)
f = (t**2 - QQ(1/10)*t + 1)*x**2 + (QQ(3/4)*t + QQ(7/2))*x - t + 8
f1 = f.specialization({t: 1})
This works fine and as expected $f_1$ is a polynomial only in $x$:
f1.parent() == QQ["x"] # True
Now I want to do exactly the same but over $\overline{\mathbb{Q}}$ instead:
L = PolynomialRing(QQbar, ["t"])
S = PolynomialRing(L, ["x"])
t = L.gen(0)
x = S.gen(0)
g = (t**2 - QQ(1/10)*t + 1)*x**2 + (QQ(3/4)*t + QQ(7/2))*x - t + 8
g1 = g.specialization({t: 1})
I would expect $g_1$ to be a polynomial only in $x$ as above, i.e. I would expect $g_1 \in \overline{\mathbb{Q}}[x]$. However, I get:
g1.parent() == QQbar["x"] # False
g1.parent() == S # True
Is this a bug? Or am I misunderstanding something?Tue, 15 Dec 2020 11:44:22 +0100https://ask.sagemath.org/question/54684/inconsistentency-in-parent-of-specialization-of-a-polynomial/Comment by Max Alekseyev for <p>I have a family of polynomials and I want to consider special members of this family. In other words I'm considering polynomials in a ring $R = K[x]$ where $K = \mathbb{Q}[t]$. In sage I do the following:</p>
<pre><code>K = PolynomialRing(QQ, ["t"])
R = PolynomialRing(K, ["x"])
t = K.gen(0)
x = R.gen(0)
f = (t**2 - QQ(1/10)*t + 1)*x**2 + (QQ(3/4)*t + QQ(7/2))*x - t + 8
f1 = f.specialization({t: 1})
</code></pre>
<p>This works fine and as expected $f_1$ is a polynomial only in $x$:</p>
<pre><code>f1.parent() == QQ["x"] # True
</code></pre>
<p>Now I want to do exactly the same but over $\overline{\mathbb{Q}}$ instead:</p>
<pre><code>L = PolynomialRing(QQbar, ["t"])
S = PolynomialRing(L, ["x"])
t = L.gen(0)
x = S.gen(0)
g = (t**2 - QQ(1/10)*t + 1)*x**2 + (QQ(3/4)*t + QQ(7/2))*x - t + 8
g1 = g.specialization({t: 1})
</code></pre>
<p>I would expect $g_1$ to be a polynomial only in $x$ as above, i.e. I would expect $g_1 \in \overline{\mathbb{Q}}[x]$. However, I get:</p>
<pre><code>g1.parent() == QQbar["x"] # False
g1.parent() == S # True
</code></pre>
<p>Is this a bug? Or am I misunderstanding something?</p>
https://ask.sagemath.org/question/54684/inconsistentency-in-parent-of-specialization-of-a-polynomial/?comment=55553#post-id-55553I do not know why SageMath does not reduce the parent ring upon specialization, but it can be enforced either by explicit conversion `g1 = QQbar["x"](g1)` or by defining a polynomial ring in two variables from the beginning:
LS = PolynomialRing(QQbar, ["t","x"])
t, x = LS.gens()Tue, 02 Feb 2021 17:18:36 +0100https://ask.sagemath.org/question/54684/inconsistentency-in-parent-of-specialization-of-a-polynomial/?comment=55553#post-id-55553