ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 11 Jul 2019 16:31:13 -0500Constructing a number field with complex embeddinghttp://ask.sagemath.org/question/47127/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:
<pre>
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?)
</pre>
<pre>
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:
</pre>
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`
mvkThu, 11 Jul 2019 16:31:13 -0500http://ask.sagemath.org/question/47127/Substituting a complex embedding for a number field elementhttp://ask.sagemath.org/question/40006/substituting-a-complex-embedding-for-a-number-field-element/Is there a way to take an element of a number field (or a polynomial or a number field) and replace the generator of the field by one of its complex embeddings? For example, something like
sage: K.<a> = NumberField(x^2 - 3)
sage: (3*a + 5).substitute(a=a.complex_embeddings()[1])
It's feasible to do this with `sage_eval`, but hopefully there is a better way.jaebondThu, 07 Dec 2017 23:34:33 -0600http://ask.sagemath.org/question/40006/From number field to interval fieldhttp://ask.sagemath.org/question/9217/from-number-field-to-interval-field/Hello,
I would like to understand why the following works
sage: K1.<s1> = NumberField(x^3 - 2, 's1', embedding=RR(1.26))
sage: RIF(s1)
1.259921049894873?
and the following does not
sage: K2.<s2> =NumberField(x^3 - 2, 's2', embedding=CC(-0.63,1.09))
sage: CIF(s2)
Traceback (most recent call last)
...
TypeError: unable to coerce to a ComplexIntervalFieldElement
Thank you,
VincentvdelecroixWed, 08 Aug 2012 00:39:23 -0500http://ask.sagemath.org/question/9217/