#11506: Fix the infinity ring.
----------------------------+--------------------------
Reporter: vbraun | Owner: AlexGhitza
Type: defect | Status: new
Priority: critical | Milestone: sage-5.13
Component: algebra | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
----------------------------+--------------------------
Comment (by pbruin):
Here is a more systematic list with things that work correctly and things
that don't (compiled from earlier comments, with various additions). We
should probably have several tickets instead of trying to solve all
problems at once.
Most basic operations in the signed and unsigned infinity rings work as
expected:
{{{
sage: infinity.parent()
The Infinity Ring
sage: unsigned_infinity.parent()
The Unsigned Infinity Ring
sage: oo is infinity
True
sage: oo is Infinity
True
sage: infinity == unsigned_infinity
True
sage: -infinity == unsigned infinity
True
sage: infinity == -infinity
False
sage: oo * oo
+Infinity
sage: oo * unsigned_infinity
Infinity
}}}
The coercion maps also work as expected:
{{{
sage: UnsignedInfinityRing.has_coerce_map_from(InfinityRing)
True
sage: InfinityRing.has_coerce_map_from(UnsignedInfinityRing)
False
sage: UnsignedInfinityRing.has_coerce_map_from(RR)
True
sage: UnsignedInfinityRing.has_coerce_map_from(CC)
True
sage: InfinityRing.has_coerce_map_from(RR)
True
sage: InfinityRing.has_coerce_map_from(CC)
False
sage: RR.has_coerce_map_from(UnsignedInfinityRing)
False
sage: CC.has_coerce_map_from(UnsignedInfinityRing)
False
sage: RR.has_coerce_map_from(InfinityRing)
False
sage: CC.has_coerce_map_from(InfinityRing)
False
}}}
The following is debatable, since it makes the arbitrary choice that
unsigned infinity is "more positive than negative":
{{{
sage: InfinityRing(unsigned_infinity)
+Infinity # this should probably raise an error
}}}
The following wrongly suggests that `UnsignedInfinityRing` is ordered:
{{{
sage: UnsignedInfinityRing(0)
A number less than infinity # should be "A finite number"
}}}
A seemingly arbitrary typographical inconsistency (upper-case I vs. lower-
case i):
{{{
sage: oo
+Infinity
sage: RR(oo)
+infinity
}}}
Conversion to `InfinityRing` and `UnsignedInfinityRing`:
{{{
sage: InfinityRing(RR(oo))
+Infinity # OK
sage: InfinityRing(CC(oo))
+Infinity # should raise an error (complex infinity is unsigned)
UnsignedInfinityRing(CC(oo))
A number less than infinity # should be Infinity
UnsignedInfinityRing(CC(oo))
A number less than infinity # should be Infinity
}}}
Arithmetic in `RR`:
{{{
sage: RR(5) * RR(oo)
+infinity # OK
sage: RR(oo) * unsigned_infinity
...
ValueError: oo times number < oo not defined # should be Infinity
}}}
`CC` currently contains many infinity elements, whereas it should contain
at most one (the point at infinity in the Riemann sphere):
{{{
sage: RR(oo) * CC(oo)
+infinity - NaN*I # should be "complex infinity"
sage: CC(5) * CC(oo)
+infinity - NaN*I # should be "complex infinity"
}}}
Conversion from `InfinityRing` and `UnsignedInfinityRing`:
{{{
sage: RR(oo)
+infinity # OK
sage: RR(unsigned_infinity)
+infinity # should raise an error
sage: CC(oo)
+infinity # should be "complex infinity"
sage: CC(unsigned_infinity)
+infinity # should be "complex infinity
sage: f = RR.convert_map_from(InfinityRing); f
Conversion map:
From: The Infinity Ring
To: Real Field with 53 bits of precision
sage: f(oo)
+infinity # OK
sage: f(InfinityRing(0))
...
TypeError: Unable to convert x (='Zero') to real number. # should be
0.000000000000000
sage: f(InfinityRing(1))
TypeError: Unable to convert x (='Apositivefinitenumber') to real number.
# OK
sage: f(InfinityRing(-1))
TypeError: Unable to convert x (='Anegativefinitenumber') to real number.
# OK
sage: f = CC.convert_map_from(InfinityRing); f
Conversion map:
From: The Infinity Ring
To: Complex Field with 53 bits of precision
sage: f(oo)
+infinity # should be "complex infinity"
sage: f(InfinityRing(0))
TypeError: unable to coerce to a ComplexNumber: <class
'sage.rings.infinity.FiniteNumber'> # should be 0.000000000000000
sage: f(InfinityRing(1))
TypeError: unable to coerce to a ComplexNumber: <class
'sage.rings.infinity.FiniteNumber'> # OK
sage: f(InfinityRing(-1))
TypeError: unable to coerce to a ComplexNumber: <class
'sage.rings.infinity.FiniteNumber'> # OK
}}}
Comparison:
{{{
sage: RR(oo) == oo
True # might be OK; William Stein (comment:8) disagrees
sage: RR(oo) == unsigned_infinity
False # True might be acceptable
sage: CC(oo) == oo
False # OK
sage: CC(oo) == unsigned_infinity
False # True might be acceptable
sage: CC(oo) == RR(oo)
True # OK
}}}
Membership testing:
{{{
sage: Infinity in RR
True # should be False
sage: Infinity in CC
False # OK
sage: unsigned_infinity in RR
False # OK
sage: unsigned_infinity in CC
False # OK
}}}
Problems with the symbolic ring:
{{{
sage: InfinityRing(SR(oo))
...
TypeError: # should be +Infinity
sage: oo*i
(I)*Infinity # should probably be Infinity
sage: oo*i + oo
...
RuntimeError: indeterminate expression: infinity - infinity encountered.
# OK
sage: bool(SR(oo) > 5)
False # should be True
sage: oo*i - unsigned_infinity
Infinity # OK
sage: oo*i + unsigned_infinity
Infinity # OK
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/11506#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.