Given a high precision real number, how should I go about guessing an algebraic integer that it's close to?

Of course, this is extremely poorly defined -- every real number is close to a rational number, of course! But I'd like to keep both the coefficients and the degree relatively small. Obviously we can make tradeoffs between how much we dislike large coefficents and how much we dislike large degrees.

But that aside, I don't even know how you'd start. Any ideas?

Background: this comes out of the project that prompted Noah's recent question on solving large systems of quadratics. We're trying to find subfactors inside their graph planar algebras. We've found that solving quadratics numerically, approximating the solutions by algebraic integers, and then checking that these are actually exact solutions is very effective. So far, we've been making use of Mathematica's "RootApproximant" function which does exactly what I ask here, but it's an impenetrable black box, like everything out of Wolfram.

  • $\begingroup$ Do you mean algebraic integers or algebraic numbers? $\endgroup$ Oct 27, 2009 at 20:57
  • 2
    $\begingroup$ I know this question seems long dead, but it seems to me that there is an issue here regarding algebraic integers vs algebraic numbers. For example the suggestion to use pari's "algdep" function below will only (at least if applied naively) find an algebraic number of smallish height close to the given number, not an algebraic integer. $\endgroup$ Feb 19, 2010 at 20:29
  • $\begingroup$ Related: How to approximate real numbers using members of Z(√d) ? $\endgroup$
    – Stef
    Sep 16, 2022 at 16:36

3 Answers 3


The Lenstra-Lenstra-Lovasz lattice basis reduction algorithm is what you need. Suppose that your real number is a and you want a quadratic equation with as small coefficients as possible, of which a is nearly a root. Then calculate 1,a,a^2 (to some precision), find a nontrivial integer relation between them, and use the LLL algorithm to find a much better one from the first one. Exactly this example is discussed in the Wikipedia entry on the LLL algorithm, applied to the Golden Section number. And there is a big literature on the algorithm and its many applications. (For higher degree, calculate 1,a,a^2,...,a^n).

  • $\begingroup$ This is implemented in Pari/GP as algdep. I am sure other packages have similar functionality. $\endgroup$ Feb 4, 2010 at 19:23

Basically you're looking for a small integral relation among the powers of the given number. This can be done effectively with the LLL algorithm (Lenstra-Lenstra-Lovasz) and variations of it (especially PSLQ), and indeed this approach is used to determine "inverse symbolic" candidates for an approximate real number. Look up papers by Plouffe and Bailey such as this one.


I do not know about algebraic number approximations; but the most canonical approximation to real numbers by rational numbers is the continued fraction expansion. They and their convergents (of first or second orders) are in many senses the best approximations to a real number by a rational number. These are simple to prove, but I do not want to get into it here. When you have a free weekend instead of reading some novel you can have a look at Khintchine's book "Continued Fractions", in which everything is explained very clearly.

For approximation with algebraic numbers, I suppose some experts on Mahler measure can contribute something.

This is an answer more theoretical in spirit compared to the algorithmic ones given so far.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.