# 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?

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?

add a comment

1

You 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.

0

Asked: **
2016-04-13 12:22:24 -0600
**

Seen: **43 times**

Last updated: **Apr 13 '16**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.