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.Sun, 24 Mar 2013 08:55:53 +0100Rational reconstruction in ring of integershttps://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/I was wondering how to do the following in sage: let's say I have a number field $F$, an embedding $i$ of that field in the complex numbers, and an algebraic integer $\alpha\in F$, for which I know $i(\alpha)$ with good numerical precision. How can I find the exact value?Tue, 25 Dec 2012 15:14:36 +0100https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/Answer by daniels for <p>I was wondering how to do the following in sage: let's say I have a number field $F$, an embedding $i$ of that field in the complex numbers, and an algebraic integer $\alpha\in F$, for which I know $i(\alpha)$ with good numerical precision. How can I find the exact value?</p>
https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?answer=14440#post-id-14440If you are thinking of representing them as floating point numbers, in general it will not be possible to represent the exact value, but you can represent it to arbitrary precision. For example, when creating your number field you can pick an embedding into CC like so:
sage: K.<a> = NumberField(x^3 - 2, embedding=1.2)
sage: CC(a)
1.25992104989487
This gives you 53-bit of floating point precision. For more precision, you can use a a field with more precision:
sage: CC100 = ComplexField(100)
sage: CC100(a)
1.2599210498948731647672106073
Instead of fixing one embedding upon creating your number field, you can also compute all the embeddings into a given field L with `K.embeddings(L)`, and use one of them explicitly.
The field `QQbar` represents the algebraic closure of the rationals and allows you to do exact arithmetic with arbitrary algebraic numbers. Depending on what you want to do this may also be suitable for you. Tue, 08 Jan 2013 10:06:34 +0100https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?answer=14440#post-id-14440Comment by Snark for <p>If you are thinking of representing them as floating point numbers, in general it will not be possible to represent the exact value, but you can represent it to arbitrary precision. For example, when creating your number field you can pick an embedding into CC like so:</p>
<pre><code>sage: K.<a> = NumberField(x^3 - 2, embedding=1.2)
sage: CC(a)
1.25992104989487
</code></pre>
<p>This gives you 53-bit of floating point precision. For more precision, you can use a a field with more precision:</p>
<pre><code>sage: CC100 = ComplexField(100)
sage: CC100(a)
1.2599210498948731647672106073
</code></pre>
<p>Instead of fixing one embedding upon creating your number field, you can also compute all the embeddings into a given field L with <code>K.embeddings(L)</code>, and use one of them explicitly.</p>
<p>The field <code>QQbar</code> represents the algebraic closure of the rationals and allows you to do exact arithmetic with arbitrary algebraic numbers. Depending on what you want to do this may also be suitable for you. </p>
https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?comment=18414#post-id-18414What you say is nice, but explains how to obtain numerical approximations of known elements of a number field given an embedding. The question is about the converse: given a numerical approximation, how to find out the element?Thu, 10 Jan 2013 07:36:35 +0100https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?comment=18414#post-id-18414Answer by Snark for <p>I was wondering how to do the following in sage: let's say I have a number field $F$, an embedding $i$ of that field in the complex numbers, and an algebraic integer $\alpha\in F$, for which I know $i(\alpha)$ with good numerical precision. How can I find the exact value?</p>
https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?answer=14682#post-id-14682I finally found the time to think about the matter and look for a solution. Let us say I'm interested in an element $z$ in the integer ring of a number field $\mathbb K$; then if that field is Galois and I have an approximation of all complex embeddings of $z$, I can get a hold of the precise element by multiplying my approximations as a vector-column by the Minkowski embedding of the field to the left. Just take the nearest integer in each component and this gives an expression of the exact element which corresponds to the approximations.
An example is worth thousands words:
K.<a>=NumberField(x**2-2)
K.Minkowski_embedding()**(-1)*matrix(2,1,[477.6,0.1]) # this gives almost the element
(239-169*a).complex_embeddings() # check that it's looking good
(Added later) I must add that this example shows that a single embedding/approximation won't be enough : as you see the approximation $0.1$ could be an approximation of zero or of $239-169\sqrt2$, and there's no way to tell which.Sun, 24 Mar 2013 08:55:53 +0100https://ask.sagemath.org/question/9586/rational-reconstruction-in-ring-of-integers/?answer=14682#post-id-14682