#4892: Changing precision of a Complex can convert it to a real
------------------------------+---------------------------------------------
 Reporter:  cremona           |       Owner:  somebody              
     Type:  defect            |      Status:  new                   
 Priority:  major             |   Milestone:  sage-3.4              
Component:  basic arithmetic  |    Keywords:  real complex precision
------------------------------+---------------------------------------------
 georg.grafendorfer reported this to sage-support:
 {{{
 sage: a = CC(-5).n(prec=100)
 sage: b = ComplexField(100)(-5)
 sage: a == b
 True
 sage: type(a) == type(b)
 False
 sage: ln(a)
 NaN
 sage: ln(b)
 1.6094379124341003746007593332 + 3.1415926535897932384626433833*I
 }}}
 The issue is that both a and b are equal to -5 (exactly, to 100 bit
 precision) but a is a Real while b is a Complex.  This happens because
 {{{
 Looking at the code for numerical_approx() in sage.misc.functional,
 this happens because the attempt to coerce z into RealField(100)
 succeeds.  To fix this (if it is agreed that it is a bug) that
 function would need to test the type of the input and return something
 of the same type (real/complex).
 }}}
 The suggested fix is that the numerical_approx function should always
 return a complex number to the appropriate precsion if the input has type
 complex, even if the coercion into a real succeeded.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4892>
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