#13760: Wrong basic interval arithmetic in PolynomialRing
--------------------------------+-------------------------------------------
Reporter: gmoroz | Owner: AlexGhitza
Type: defect | Status: new
Priority: major | Milestone: sage-5.5
Component: basic arithmetic | Keywords: interval, polynomial,
multivariate
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
--------------------------------+-------------------------------------------
Some multiplications in multivariate polynomial rings over RIF or CIF are
wrong:
{{{
sage: R.<x,y> = PolynomialRing(RIF,2)
sage: RIF(-2,1)*x
0
}}}
== More tests ==
{{{
sage: R.<x,y> = PolynomialRing(RIF,2)
sage: RIF(-2,1) # OK
0.?e1
sage: RIF(-2,1)*x # Wrong
0
sage: RIF(-2,1)*x == 0 # Wrong
True
sage: cmp(RIF(-2,1)*x,0) # Wrong
0
sage: RIF(2,5)*x # OK
1.?e1*x
sage: RIF(2,5)*x == 0 # OK
False
}}}
== Code digging ==
The problem comes from the coercion:
{{{
sage: R(RIF(-2,1))
0
sage: R(RIF(-2,1)) == 0
True
}}}
This in turn comes from the creation (in `__init__` of class
`MPolynomial_polydict` in
`sage.rings.polynomial.multi_polynomial_element`) of a PolyDict object
(defined in `sage.rings.polynomial.polydict`) with the option `remove_zero
== True`.
{{{
from sage.rings.polynomial.polydict import PolyDict
sage: PolyDict({(0,0):1}, remove_zero=True) # OK
PolyDict with representation {(0, 0): 1}
sage: PolyDict({(0,0):0}, remove_zero=True) # OK
PolyDict with representation {}
sage: PolyDict({(0,0):RIF(-1,1)}, remove_zero=True) # Wrong
PolyDict with representation {}
}}}
To check if x is 0, PolyDict uses the test `x != 0`, which actually checks
for disjointness in interval field:
{{{
sage: RIF(-2,1) != 0
False
}}}
== Possible correction ==
This bug might be corrected by replacing in PolyDict the tests `x != zero`
by one of:
- `cmp(x,0) != zero`
- `not x.is_zero()`
- `not x == zero`
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13760>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.