#12353: wrong comparison between RealIntervalField and RealField
--------------------------------+-------------------------------------------
   Reporter:  zimmerma          |          Owner:  AlexGhitza
       Type:  defect            |         Status:  new       
   Priority:  blocker           |      Milestone:  sage-5.0  
  Component:  basic arithmetic  |       Keywords:            
Work_issues:                    |       Upstream:  N/A       
   Reviewer:                    |         Author:            
     Merged:                    |   Dependencies:            
--------------------------------+-------------------------------------------
Changes (by zimmerma):

 * cc: was (added)


Old description:

> consider the following:
> {{{
> sage: RealIntervalField(53)(-1) > RR(1)
> False
> sage: RealIntervalField(54)(-1) > RR(1)
> True
> }}}
> The second answer is clearly wrong.
>
> The problem seems to be the following: the {{{_richcmp}}} function
> from {{{structure/element.pyx}}} is called. With precision 54, the
> call to {{{coercion_model.canonical_coercion}}} fails, then we have
> {{{r=1}}}, the two tests around line 853 fail, and the returned value is
> {{{_rich_to_bool(op, r)}}} which does not depend on {{{left}}} and
> {{{right}}}!
>
> Paul

New description:

 on some machines we get the following:
 {{{
 sage: RealIntervalField(53)(-1) > RR(1)
 False
 sage: RealIntervalField(54)(-1) > RR(1)
 True
 }}}
 The second answer {{{True}}} is clearly wrong.

 If your machine gets the correct answer {{{False}}} in both cases, then it
 most probably gives:
 {{{
 sage: RealIntervalField(54)(1) > RR(-1)
 True
 sage: RealIntervalField(54)(1) > RR(-1)
 False
 }}}
 where the second answer {{{False}}} is wrong.

--

Comment:

 after some investigation, the function {{{_richcmp}}} in
 {{{structure/element.pyx}}}
 computes {{{r = cmp(type(left), type(right))}}}, which gives {{{r=-1}}} on
 sage.math,
 and {{{r=1}}} on my workstation (both with Sage 4.8).

 Note that the *types* only are compared, thus by swapping the values I can
 produce a
 bug on sage.math too:
 {{{
 sage: RealIntervalField(54)(1) > RR(-1)
 False
 }}}

 Something is badly wrong by comparing the types, not the values. Here we
 need help from someone more fluent in the Sage internals.

 Paul

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12353#comment:4>
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.

Reply via email to