Home | Trees | Index | Help |
|
---|
Package sage :: Package rings :: Module rational_field :: Class RationalField |
|
Ring
--+ |object
--+ | | |_uniq
--+ | RationalField
The field of rational numbers.
EXAMPLES: We create the rational numbers and call a few functions:>>> Q = RationalField(); Q Rational Field >>> Q.characteristic() 0 >>> Q.is_field() True >>> Q.zeta() -1We illustrate arithmetic in Q.
>>> Q('49/7') 7 >>> type(Q('49/7')) <type '_rational.Rational'> >>> a = Q('19/374'); b = frac(17, 371); print a, b 19/374 17/371 >>> a + b 13407/138754 >>> b + a 13407/138754 >>> a * b 19/8162 >>> b * a 19/8162 >>> a - b 691/138754 >>> b - a -691/138754 >>> a / b 7049/6358 >>> b / a 6358/7049 >>> b < a True >>> a < b FalseNext we illustrate arithmetic with automatic coercion. The types that coerce are: str, int, long, Integer.
>>> a + '17/371' 13407/138754 >>> a * 374 19 >>> 374 * a 19 >>> a/19 1/374 >>> a + 1 393/374
Method Summary | |
---|---|
Coerce x into the ring. | |
__cmp__(self,
other)
| |
__contains__(self,
x)
| |
__repr__(self)
| |
characteristic(self)
| |
gen(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. | |
is_field(self)
| |
name(self)
| |
ngens(self)
| |
random(self,
num_bound,
den_bound)
| |
zeta(self)
| |
Inherited from object | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
Inherited from Ring | |
|
Instance Method Details |
---|
__call__(self,
x)
Coerce x into the ring.
|
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. For example, integers are atomic but polynomials are not.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jun 20 15:43:22 2005 | http://epydoc.sf.net |