) |
sage: R = RealField_mpf(); R Multi-precision Real Field sage: R('1/3') 0.333333333333333333333
Note that the second argument is the number of *bits* of precision, not the number of digits of precision:
sage: R('1/3',100) 0.3333333333333333333333333333333333333333 sage: R('1/3',200) 0.3333333333333333333333333333333333333333333333333333333333333 33333333
If we create a real without quotes, we loose precision, because the real is turned into a Python float:
sage: R(0.333333333333333333333) 0.33333333333333331483
We can also coerce rational numbers and integers into R, but coercing a polynomial in raising an exception.
sage: Q = RationalField() sage: R(Q('1/3')) 0.333333333333333333333 sage: S = PolynomialRing(Q) sage: R(S.gen()) Traceback (most recent call last): ... TypeError: unable to coerce x to a RealNumber_mpf sage: R.is_field() True sage: R.characteristic() 0 sage: R.name() 'R' sage: R == R True sage: R == 5 False
characteristic,
euler_constant,
is_atomic_repr,
is_field,
name,
pi
These methods are defined as follows:
) |
Returns the characteristic of the real field, which is 0.
[n=0]) |
Returns Euler's constant gamma = 0.57721566... = lim 1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/m - log m. to at most 219 decimal digits of precision.
IMPLEMENTATION: PARI C library.
sage: RealField_mpf().euler_constant() 0.577215664901532865549
) |
) |
Returns True, since the real field is a field.
) |
Returns a short string 'R' that describes the real field.
[n=0]) |
Returns pi to (at least) the given precision.
sage: RealField().pi(3) 3.14
Instances of class RealField also have the following special methods:
x, [prec=0]) |
other) |
See About this document... for information on suggesting changes.