Ask Your Question

Revision history [back]

The method .N() or .n() is a shortcut for .numerical_approx() and will try to give you a numerical approximation that lives in RR which is a shortcut for RealField().

If you specify a precision, .N(10) or .n(10) or .numerical_approx(10) give you a numerical approximation that lives in RealField(10). Here, the precision 10 specifies the number of bits of precision.

You can also specify the number of (base ten) digits of precision: by using .N(digits=10) or .n(digits=10) or .numerical_approx(digits=10).

So the answer to your question is yes, the two things you are using are doing the same thing.

Note that the fastest floating-point real numbers in Sage are RDF, short for RealDoubleField.

So in general, I would advise to compute in RDF, use RDF's pi

sage: pi_n = RDF.pi()

and map everything you need to compute with into RDF.

See a more detailed comparison of all approximations of the real field in SageMath in this ask-sage question:

http://ask.sagemath.org/question/9950/what-are-the-different-real-numbers-in-sage/