Module infinity
source code
Infinity Rings
The unsigned infinity ``ring'' is the set of two elements
\begin{verbatim}
* infinity
* A number less than infinity
\end{verbatim}
The rules for arithmetic are that the unsigned infinity ring does not canonically
coerce to any other ring, and all other rings canonically coerce to
the unsigned infinity ring, sending all elements to the single element
``a number less than infinity'' of the unsigned infinity ring.
Arithmetic and comparisons then takes place in the unsigned infinity ring,
where all arithmetic operations that are well defined are defined.
The infinity ``ring'' is the set of five elements
\begin{verbatim}
* plus infinity
* a positive finite element
* zero
* a negative finite element
* negative infinity
\end{verbatim}
The infinity ring coerces to the unsigned infinity ring, sending the infinite elements to infinity and the non-infinite elements to ``a number less than infinity.'' Any ordered ring coerces to the infinity ring in the obvious way.
EXAMPLES:
We fetch the unsigned infinity ring and create some elements:
sage: P = UnsignedInfinityRing; P
The Unsigned Infinity Ring
sage: P(5)
A number less than infinity
sage: P.ngens()
1
sage: oo = P.0; oo
Infinity
We compare finite numbers with infinity.
sage: 5 < oo
True
sage: 5 > oo
False
sage: oo < 5
False
sage: oo > 5
True
We do arithmetic.
sage: oo + 5
Infinity
Note that many operations are not defined, since the result is
not well defined.
sage: oo/0
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for '/': 'The Unsigned Infinity Ring' and 'Integer Ring'
What happened above is that 0 is canonically coerced to
"a number less than infinity" in the unsigned infinity ring, and the quotient
is then not well defined.
sage: 0/oo
A number less than infinity
sage: oo * 0
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for '*': 'The Unsigned Infinity Ring' and 'Integer Ring'
sage: oo/oo
Traceback (most recent call last):
...
TypeError: infinity 'ring' has no fraction field
In the infinity ring, we can negate infinity, multiply positive numbers by infinity, etc.
sage: P = InfinityRing; P
The Infinity Ring
sage: P(5)
A positive finite number
sage: oo = P.0; oo
+Infinity
We compare finite and infinite elements
sage: 5 < oo
True
sage: P(-5) < P(5)
True
sage: P(2) < P(3)
False
sage: -oo < oo
True
We can do more arithmetic than in the unsigned infinity ring.
sage: 2 * oo
+Infinity
sage: -2 * oo
-Infinity
sage: 1 - oo
-Infinity
sage: 1 / oo
Zero
sage: -1 / oo
Zero
If we try to subtract infinities or multiply infinity by zero we still get an error.
sage: oo - oo
Traceback (most recent call last):
...
SignError: cannot add infinity to minus infinity
sage: 0 * oo
Traceback (most recent call last):
...
SignError: cannot multiply infinity by zero
sage: P(2) + P(-3)
Traceback (most recent call last):
...
SignError: cannot add positive finite value to negative finite value
TESTS:
sage: P = InfinityRing
sage: P == loads(dumps(P))
True
sage: P(2) == loads(dumps(P(2)))
True
The following is assumed in a lot of code (i.e., "is" is used
for testing whether something is infinity), so make sure it
is satisfied:
sage: loads(dumps(infinity)) is infinity
True
|
|
_obj = {0: The Unsigned Infinity Ring, 1: Infinity, 2: The Inf...
|
|
|
UnsignedInfinityRing = The Unsigned Infinity Ring
|
|
|
unsigned_infinity = Infinity
|
|
|
less_than_infinity = A number less than infinity
|
|
|
InfinityRing = The Infinity Ring
|
|
|
infinity = +Infinity
|
|
|
Infinity = +Infinity
|
|
|
minus_infinity = -Infinity
|
_obj
- Value:
{0: The Unsigned Infinity Ring,
1: Infinity,
2: The Infinity Ring,
3: -Infinity,
4: +Infinity}
|
|