Ask Your Question

mvk's profile - activity

2021-02-02 17:09:33 +0200 received badge  Good Question (source)
2020-12-15 15:04:20 +0200 received badge  Nice Question (source)
2020-12-15 11:59:32 +0200 received badge  Editor (source)
2020-12-15 11:44:22 +0200 asked a question 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?

2019-07-12 19:37:43 +0200 received badge  Good Question (source)
2019-07-12 17:57:20 +0200 received badge  Supporter (source)
2019-07-12 17:57:11 +0200 commented answer Constructing a number field with complex embedding

Thanks!

I am a bit confused though: Why can we not choose the solution with positive imaginary part for (x-1)^2+7? In fact, isn't this what sage is doing when it returns +I (as opposed to -I) for QQbar(sqrt(-1))?

2019-07-12 12:59:18 +0200 received badge  Nice Question (source)
2019-07-12 08:19:05 +0200 received badge  Student (source)
2019-07-12 08:05:18 +0200 asked a question Constructing a number field with complex embedding

I am using the function number_field_elements_from_algebraics in sage.rings.qqbar to write some algebraic numbers as elements of a number field. I am passing embedded=True to also construct an embedding into QQbar. This works fine if the algebraic numbers are real but fails if they are complex:

sage: number_field_elements_from_algebraics([1 + sqrt(7)], embedded=True)
(Number Field in a with defining polynomial y^2 - 7 with a = 2.645751311064591?,
 [a + 1],
 Ring morphism:
   From: Number Field in a with defining polynomial y^2 - 7 with a = 2.645751311064591?
   To:   Algebraic Real Field
   Defn: a |--> 2.645751311064591?)
sage: number_field_elements_from_algebraics([1 + sqrt(-7)], embedded=True)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-1-ac220615ad5b> in <module>()
----> 1 number_field_elements_from_algebraics([Integer(1) + sqrt(-Integer(7))], embedded=True)

/usr/lib/python2.7/site-packages/sage/rings/qqbar.pyc in number_field_elements_from_algebraics(
numbers, minimal, same_field, embedded, prec)
   2242         real_case = False
   2243         if embedded:
-> 2244             raise NotImplementedError
   2245     # Make the numbers algebraic
   2246     numbers = [mk_algebraic(_) for _ in numbers]

NotImplementedError: 

What is the reason for why only embeddings of real numbers are supported?

I modified the code in number_field_elements_from_algebraics to support complex embeddings by essentially removing the check for whether the numbers are real and replacing RealIntervalField by ComplexIntervalField. This seems to work and the doctests still pass with these modifications. However I am worried that there was a good reason (either mathematically or related to some sage internals) for restricting this function to the real case.

The relevant code in sage.rings.qqbar was introduced in these commits:

  • 26dc3e4e6a26f6f613a69d57929ea492c278dad0
  • a9045bf8a3aab2d0aa00be17e91227bc1b50262a