11.07.2015 Views

Fixed and Arbitrary Precision Numerical Fields - Sage

Fixed and Arbitrary Precision Numerical Fields - Sage

Fixed and Arbitrary Precision Numerical Fields - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> Reference Manual: <strong>Fixed</strong> <strong>and</strong> <strong>Arbitrary</strong> <strong>Precision</strong> <strong>Numerical</strong> <strong>Fields</strong>, Release 6.2Note: PARI is vastly more efficient at computing the Riemann zeta function. See the example below forhow to use it.EXAMPLES:sage: RDF(2).zeta()1.64493406685sage: RDF.pi()^2/61.64493406685sage: RDF(-2).zeta()-2.37378795339e-18sage: RDF(1).zeta()+infinity# slightly r<strong>and</strong>om-ish arch dependent outputsage.rings.real_double.RealDoubleField()Return the unique instance of the real double field.EXAMPLES:sage: RealDoubleField() is RealDoubleField()Trueclass sage.rings.real_double.RealDoubleField_classBases: sage.rings.ring.FieldAn approximation to the field of real numbers using double precision floating point numbers. Answers derivedfrom calculations in this approximation may differ from what they would be if those calculations were performedin the true field of real numbers. This is due to the rounding errors inherent to finite precision calculations.EXAMPLES:sage: RR == RDFFalsesage: RDF == RealDoubleField()Truesage: RDF(1)1.0sage: RDF(2/3)0.666666666667A TypeError is raised if the coercion doesn’t make sense:# RDF is the shorth<strong>and</strong>sage: RDF(QQ[’x’].0)Traceback (most recent call last):...TypeError: cannot coerce nonconstant polynomial to floatsage: RDF(QQ[’x’](3))3.0One can convert back <strong>and</strong> forth between double precision real numbers <strong>and</strong> higher-precision ones, though ofcourse there may be loss of precision:sage: a = RealField(200)(2).sqrt(); a1.4142135623730950488016887242096980785696718753769480731767sage: b = RDF(a); b1.41421356237sage: a.parent()(b)1.414213562373095145474621858738828450441360473632812500000018 Chapter 1. Double <strong>Precision</strong> Real Numbers

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!