Package sage :: Package rings :: Module real_field :: Class RealField
[show private | hide private]
[frames | no frames]

Type RealField

object --+
         |
  Ring --+
         |
        RealField

Known Subclasses:
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
  __call__(self, x)
Coerce x into the ring.
  __cmp__(self, other)
  __new__(cls, *args, **kwds)
(Static method)
  __repr__(self)
  characteristic(self)
Returns the characteristic of the real field, which is 0.
  euler_constant(self, n)
Returns Euler's constant gamma = 0.57721566...
  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)
Returns pi to at least the given precision.
    Inherited from Ring
  __init__(self)
  __hash__(self)
  is_atomic_repr(self)
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.
  type(self)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Method Details

__call__(self, x, prec=0)
(Call operator)

Coerce x into the ring.
Overrides:
sage.rings.ring.Ring.__call__ (inherited documentation)

characteristic(self)

Returns the characteristic of the real field, which is 0.
Overrides:
sage.rings.ring.Ring.characteristic

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.
Overrides:
sage.rings.ring.Ring.is_field

name(self)

Returns a short string 'R' that describes the real field.
Overrides:
sage.rings.ring.Ring.name

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

Generated by Epydoc 2.1 on Mon Jun 20 15:43:22 2005 http://epydoc.sf.net