Represent a real algebraic number (RAN) in one of several ways:
- Implicitly by a univariate polynomial and an interval.
- Implicitly by a polynomial and a sequence of signs (called Thom encoding).
- Explicitly by a rational number. Rationale:
- A real number cannot always be adequately represented in finite memory, since it may be infinitely long. Representing it by a float or any other finite-precision representation and doing arithmetic may introduce unacceptable rounding errors. The algebraic reals, a subset of the reals, is the set of those reals that can be represented as the root of a univariate polynomial with rational coefficients so there is always an implicit, finite, full-precision representation by an univariate polynomial and an isolating interval that contains this root (only this root and no other). It is also possible to do relatively fast arithmetic with this representation without rounding errors.
- When the algebraic real is only finitely long prefer the rational number representation because it's faster.
- The idea of the Thom-Encoding is as follows: Take a square-free univariate polynomial p with degree n that has the algebraic real as its root, compute the first n-1 derivates of p, plug in this algebraic real into each derivate and only keep the sign. Then polynomial p with this sequence of signs uniquely represents this algebraic real.
Definition in file ran.h.