#4544: comparison of CDF (or any inexact) elements needs work
------------------------+---------------------------------------------------
 Reporter:  craigcitro  |       Owner:  jkantor   
     Type:  defect      |      Status:  new       
 Priority:  major       |   Milestone:  sage-3.2.1
Component:  numerical   |    Keywords:            
------------------------+---------------------------------------------------
 So currently, we compare elements of inexact rings like `CDF` by just
 comparing their components as `double`s. We use this for sorting, and
 expect the results to be consistent between runs, architectures, etc.
 However, this is wildly untrue. Here's a good example:

 {{{
 sage: z1, z2 = [ x[0] for x in f.roots()[-2:] ]
 sage: R = CDF['x']
 sage: f = R([17,1,0,0,0,1]) ; f
 1.0*x^5 + 1.0*x + 17.0
 sage: f.roots()
 [(-1.72502775061, 1),
  (1.4372759883 + 1.06991737978*I, 1),
  (1.4372759883 - 1.06991737978*I, 1),
  (-0.574762112991 + 1.65506825348*I, 1),
  (-0.574762112991 - 1.65506825348*I, 1)]
 sage: z1, z2 = [ x[0] for x in f.roots()[-2:] ]
 sage: z1
 -0.574762112991 + 1.65506825348*I
 sage: z2
 -0.574762112991 - 1.65506825348*I
 sage: z1.real() == z2.real()
 False
 }}}

 Notice that the `+`/`-` ordering is different for the two pairs of complex
 conjugate roots. What we '''should''' do is pass a parameter to `__cmp__`
 that describes a threshold such that if the difference is smaller than
 this threshold in absolute value, things compare equal. This could even be
 a parameter to the ring.

 There are a ton of questions this brings up, such as, "how is this done in
 other systems?" Notice this also underlies the following confusing result:

 {{{
 sage: [ f(x[0]).is_zero() for x in f.roots() ]
 [False, False, False, False, False]
 }}}

 Someone should do some research and start a sage-devel conversation,
 probably.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4544>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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