First, I would recommend reading up on floating point arithmetic. A cannonical reference is http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html , but if that's a bit dense there are many other good sources on the web.
Things get more interesting for Sage, as there are several models for floating point numbers available depending on the use. In turn these are (1) float, created with float(3.0) or 3.0r, which is the native Python floating point represented by the machine (typically IEEE 754 double or extended precision), fastest but potentially less accurate and platform dependant. (2) sage.rings.real_double.RealDoubleElement, created by RDF(3.0), which is also IEEE 754 double or extended precision, but has more sage-specific functionality. (3) sage.rings.real_mpfr.RealNumber, the default, created by RR(3.0) or doing arithmetic with 3.0, back by http://www.mpfr.org/ to 53-bits of precision, accurate rounding on all operations, platform-independent, but slower than the above (3b) sage.rings.real_mpfr.RealNumber with alternative precision, e.g. RealField(1000)(3) for 1000 bits (not digits) of precision. Less common: (4) sage.rings.real_mpfi.RealIntervalFieldElement, created by RIF(3.0), which does arithmetic on intervals (as most real numbers can't be represented accurately) and can bue used to provide provable statements of inequality. Can also be arbitrary precision, e.g. RealIntervalField(1000)(3) (5) RLF, the real lazy field (mostly used under the hood for coercion from exact to in-exact domains). (5) sage.rings.real_mpfr.RealLiteral, which is what you get when typing 3.0, which stores the typed value to infinite precision and converts to a fixed precision (53-bit if implicit) upon demand. This is needed so that RealField(1000)(1.2) is 1.2 to 1000 bits, not just 53 bits (as it would be if 1.2 was parsed to 53 bits then passed in to RealField(1000)). For all of the above, see RR?, RDF?, etc. for (lots!) more documentation. - Robert On Wed, Jan 23, 2013 at 8:59 AM, LFS <[email protected]> wrote: > Hi - I would appreciate if someone could point me to a link explaining the > difference (if there is a difference) between: > > <type 'sage.rings.real_mpfr.RealLiteral'> (Here I input x=3.) > <type 'float'> (Here I input xx=float(3)) > <type 'sage.rings.real_mpfr.RealNumber'> (Here I input 1/x) > . > My page: http://sage.math.canterbury.ac.nz/home/pub/247 > Thanks so much, Linda > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > Visit this group at http://groups.google.com/group/sage-support?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support?hl=en.
