#13322: Precision loss when converting between Magma and Sage
--------------------------+-------------------------------------------------
   Reporter:  mstreng     |             Owner:  was                             
         
       Type:  defect      |            Status:  new                             
         
   Priority:  major       |         Milestone:  sage-5.3                        
         
  Component:  interfaces  |          Keywords:  magma numerical real precision 
truncation
Work issues:              |   Report Upstream:  N/A                             
         
  Reviewers:              |           Authors:                                  
         
  Merged in:              |      Dependencies:                                  
         
   Stopgaps:              |  
--------------------------+-------------------------------------------------
 There is a significant amount of precision loss when converting Magma real
 numbers to Sage or Sage real numbers to Magma.
 {{{
 sage: s = RealField(1000)(1/3)
 sage: m = magma(RealField(1000))(1/3)
 sage: s
 
0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
 sage: m
 
0.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
 sage: magma(s)
 
0.3333333333333333333333333333334648101508701686342352880942137977049455344058515038341283798217773437500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 sage: m.sage()
 
0.333333333333333314829616256247390992939472198486328125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 }}}
 From Sage to Magma, this is because the interface goes via 30 digit
 precision Magma {{{FldReElt}}}:
 {{{
 sage: s = RealField(300)(1/3)
 sage: s
 
0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
 sage: magma(s)
 
0.333333333333333333333333333333464810150870168634235288094213797704945534405851503834128380
 sage: s._magma_init_(magma)
 'RealField(300 : Bits :=
 
true)!0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333'
 sage:
 
magma('0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333')
 0.333333333333333333333333333333
 sage:
 
magma('0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333').Type()
 FldReElt
 sage:
 
magma('0.333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333').Precision()
 30
 }}}
 From Magma to Sage, this is because the interface goes via Python floats:
 {{{
 sage: m = magma(RealField(200))(1/3); m
 0.333333333333333333333333333333333333333333333333333333333333
 sage: m.sage()
 0.33333333333333331482961625624739099293947219848632812500000
 sage: str(m.Sage())
 
'RealField(200)(0.333333333333333333333333333333333333333333333333333333333333)'
 0.33333333333333331482961625624739099293947219848632812500000
 sage: sage_eval(str(m.Sage()))
 0.33333333333333333333333333333333333333333333333333333333333
 sage: sage_eval(str(m.Sage()), preparse=False)
 0.33333333333333331482961625624739099293947219848632812500000
 sage: type(sage_eval('0.3333333333333333333333333333333333333333333',
 preparse=False))
 <type 'float'>
 }}}

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