# What are the different real numbers in Sage ?

No computer can grasp the genuine real numbers, so I am trying to understand how sage handles them (and going to write a small tutorial about this). Here is a list of approaching objects i found:

#### Exact subfields of the reals:

QQ = RationalField() The genuine rationals. Denominators can be arbitrary big, the computations are exact, so the rounding error is only made when approaching a real by a rational, not during furher computations. Notice that the size of the denominators may grow along the computations, which can therefore become very slow.

NumberField? number fields described by an irreducible polynomial.

AA = AlgebraicField() The genuine algebraic numbers. Computations are exact.

SR = sage.symbolic.ring.SymbolicRing() This is the field made of expressions like sqrt(2+pi). It handles a lot of real numbers but seems very slow. Computations are not necessarily exact, since this field contains floating points real numbers. Is there a way to express any algebraic number in SR ?

CFF = ContinuedFractionField() reals are represented as a finite list of convergents. Claims it is exact but it actually approaches real numbers by rationals since the list of convergents are finite. However, we could imagine a future version using iterators instead of lists.

sage: CFF(sqrt(2))^2

[1, 1, 1491038293021224]

#### Floating point numbers:

RDF = RealDoubleField() Those are the of double precision floating numbers the processor. Definitely the fastest, but a rounding is done at each computation.

RR = RealField() Floating number with arbitrary (still fixed) many bits of precision. http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_mpfr.html Slower than RDF (in particular, atlas won't be used with them). Notice that changing precision back and forth is a bad idea. Notice that NaN and Infinity belong to RDF and RR.

RLF = RealLazyField() like RealField() but can wait that the user fixes the precision to get one. http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_lazy.html

sage: a = RLF(pi)

sage: RealField(100)(a+2)

5.1415926535897932384626433833

RIF = RealIntervalField() A real number is represented as an interval containing it, and whose extremities are RealFields elements http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_mpfi.html

RLF.interval_field() mixture of the two previous ones.

sage.rings.real_lazy.LazyAlgebraic

#### Relations between those fields

- Two fields approaching the real numbers K and L can be compared using the function composite_field(K,L), that finds the "best" field containing both K and L.

sage: composite_field(RDF,QQbar)

Complex Double Field

Some maps are also defined to embed an abstract number field into the real line.

The method algebraic_dependency() that allows to guess whether a floating number corresponds to some algebraic number of a given degree.

Is this list complete or am i missing other real representations ? Im i wrong in the previous descriptions ? Could you order them by speed, by number of methods available (without coercion) ? Do you have any remark that could help the beginner to understand the subtilities in the use of those fields in Sage ?

Given an algebraic ...

It would be really nice to have a list like this in the documentation.

Apparently there are also

`RealLiteral`

s, which seem to be none of the above.