Home | Trees | Index | Help |
|
---|
Package sage :: Package rings :: Module real_field :: Class RealField |
|
object
--+ |Ring
--+ | RealField
RealField_decimal
,
RealField_mpf
The field of real numbers. EXAMPLES: >>> R = RealField_mpf(); R Multi-precision Real Field >>> R('1/3') 0.333333333333333333333 Note that the second argument is the number of *bits* of precision, not the number of digits of precision: >> R('1/3',100) 0.3333333333333333333333333333333333333333 >> R('1/3',200) 0.333333333333333333333333333333333333333333333333333333333333333333333 If we create a real without quotes, we loose precision, because the real is turned into a Python float: >>> R(0.333333333333333333333) 0.33333333333333331483 We can also coerce rational numbers and integers into R, but coercing a polynomial in raising an exception. >>> Q = RationalField() >>> R(Q('1/3')) 0.333333333333333333333 >>> S = PolynomialRing(Q) >>> R(S.gen()) Traceback (most recent call last): ... TypeError: unable to coerce x to a RealNumber_mpf >>> R.is_field() True >>> R.characteristic() 0 >>> R.name() 'R' >>> R == R True >>> R == 5 False
Method Summary | |
---|---|
Coerce x into the ring. | |
__cmp__(self,
other)
| |
__new__(cls,
*args,
**kwds)
(Static method) | |
__repr__(self)
| |
Returns the characteristic of the real field, which is 0. | |
Returns Euler's constant gamma = 0.57721566... | |
Returns True, since the real field is a field. | |
Returns a short string 'R' that describes the real field. | |
Returns pi to at least the given precision. | |
Inherited from Ring | |
| |
| |
True if the elements have atomic string representations, in the sense that they print if they print at s, then -s means the negative of s. | |
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Instance Method Details |
---|
__call__(self,
x,
prec=0)
Coerce x into the ring.
|
characteristic(self)Returns the characteristic of the real field, which is 0.
|
euler_constant(self, 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: Cut and paste constant to 219 digits precision from http://primes.utm.edu/glossary/page.php?sort=Gamma EXAMPLES: >>> RealField_mpf().euler_constant() 0.577215664901532865549 |
is_field(self)Returns True, since the real field is a field.
|
name(self)Returns a short string 'R' that describes the real field.
|
pi(self, n=0)Returns pi to at least the given precision. WARNING: I'm not certain what the precision means yet. It seems to be > 9*n digits for n >= 30. EXAMPLES:>>> RealField().pi(3) 3.1415926535897932384626433833 |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon May 9 17:57:02 2005 | http://epydoc.sf.net |