guesing algebraic numbers from floats

38 views
Skip to first unread message

Daniel Krenn

unread,
Jul 20, 2017, 10:32:06 AM7/20/17
to sage-s...@googlegroups.com
Dear all,

I vaguely remember a discussion on this list some years ago about the
following: Given a floating point number, what is a good guess for the
simplest possible algebraic number that approximates this?

E.g. The input 1.4142 gives back sqrt(2) or x^2-2 and says that this is
approximates the input on the first four digits. (Of course much more
precise guesses would be possible, but a simple one should just do fine.)

(I am aware that this is not a Sage-specific question, but when I
remember correctly, there was some software mentioned in that thread
years ago, which can do this. Maybe I am completely wrong and it was
somewhere else; but maybe someone has an idea if such a program exists.)

Best wishes

Daniel

Vincent Delecroix

unread,
Jul 20, 2017, 10:35:38 AM7/20/17
to sage-s...@googlegroups.com
sage: algdep(RealField(20)(1.4142), 2)
x^2 - 2

Note that you have to specify the maximal degree. Be careful about the input

sage: algdep(1.4142, 2)
5000*x - 7071

This is using the PARI/GP algdep command (whose algorithm is a LLL
reduction).

Vincent

Daniel Krenn

unread,
Jul 20, 2017, 1:45:00 PM7/20/17
to sage-s...@googlegroups.com
On 2017-07-20 16:34, Vincent Delecroix wrote:
> sage: algdep(RealField(20)(1.4142), 2)
> x^2 - 2
>
> Note that you have to specify the maximal degree. Be careful about the
> input
>
> sage: algdep(1.4142, 2)
> 5000*x - 7071
>
> This is using the PARI/GP algdep command (whose algorithm is a LLL
> reduction).

Thank you.

Daniel
Reply all
Reply to author
Forward
0 new messages