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.Thu, 14 Apr 2016 15:29:32 +0200approximate real numbers by algebraic numbershttps://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/Hi
suppose I have a real number x in decimal digits, how do I find an approximate polynomial f(x) \in ZZ[x] with x a root?Wed, 13 Apr 2016 19:22:24 +0200https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/Answer by kcrisman for <p>Hi </p>
<p>suppose I have a real number x in decimal digits, how do I find an approximate polynomial f(x) \in ZZ[x] with x a root?</p>
https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?answer=33092#post-id-33092There exists such software, and there is an [open ticket](http://trac.sagemath.org/ticket/237) for trying to add such capability (though it is much broader than just algebraic numbers, things like zeta function values usually are available as well). Such as [RIES](http://mrob.com/pub/ries/). But Sage does not currently have inverse symbolic calculation capability, as far as I know.Wed, 13 Apr 2016 21:32:01 +0200https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?answer=33092#post-id-33092Answer by tmonteil for <p>Hi </p>
<p>suppose I have a real number x in decimal digits, how do I find an approximate polynomial f(x) \in ZZ[x] with x a root?</p>
https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?answer=33094#post-id-33094You can use the `algebraic_dependency` method for that. Given an integer `n` as parameter, it finds a polynomial of degree (at most) `n` with small coefficients that is almost on you floating-point number `a`.
Here is an example on how you can find a good polynomial: loop over degrees and see if there are some levels:
sage: a = 3.146264369941973
sage: for n in range(10):
....: print a.algebraic_dependency(n)
1
5947484*x - 18712357
4113*x^2 - 17841*x + 15418
82*x^3 + 1380*x^2 - 6929*x + 5586
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
So, it seems that `x^4 - 10*x^2 + 1` is a very good candidate.
Thu, 14 Apr 2016 00:03:25 +0200https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?answer=33094#post-id-33094Comment by kcrisman for <p>You can use the <code>algebraic_dependency</code> method for that. Given an integer <code>n</code> as parameter, it finds a polynomial of degree (at most) <code>n</code> with small coefficients that is almost on you floating-point number <code>a</code>.</p>
<p>Here is an example on how you can find a good polynomial: loop over degrees and see if there are some levels:</p>
<pre><code>sage: a = 3.146264369941973
sage: for n in range(10):
....: print a.algebraic_dependency(n)
1
5947484*x - 18712357
4113*x^2 - 17841*x + 15418
82*x^3 + 1380*x^2 - 6929*x + 5586
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
x^4 - 10*x^2 + 1
</code></pre>
<p>So, it seems that <code>x^4 - 10*x^2 + 1</code> is a very good candidate.</p>
https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?comment=33107#post-id-33107Wow, I did not know about this! Thanks.Thu, 14 Apr 2016 15:29:32 +0200https://ask.sagemath.org/question/33091/approximate-real-numbers-by-algebraic-numbers/?comment=33107#post-id-33107