Open eviatarbach opened 13 years ago
There are a couple of issues for this. The first is converting to Maxima which is currently
sage: a._maxima_init_()
'8.9875517873681755065917968750000000000000000000000000000000000e9'
should be done with something like: calculus.symbolic_expression_from_string
sage: a._maxima_init_()
'8.987551787368175506591796875b9,fpprec:200'
Then, there is an issue going from Maxima to Sage. In sage.calculus.calculus.calculus.symbolic_expression_from_string
, sage.rings.real_mpfr.create_RealNumber
, but does not pass it any precision. This should try and detect the precision of the bigfloat.
Attachment: trac_11643-preliminary.patch.gz
I have added a patch that can be applied on top of 4.7.1, that tries to preserve precision when translating back and forth between SR and maxima_lib. (not the string-level conversions; only the routines that are now used for integrate and limit). However, it looks like Maxima itself does not try to preserve precision at all with its bigfloats. Any arithmetic defaults to the set precision. So trying to preserve precision is not going to be very useful. At the very least, fpprec should be set appropriately every time. Evidence in the transcript below:
sage: M=sage.calculus.calculus.maxima
sage: from sage.interfaces.maxima_lib import *
sage: a=12345.6789012345678
sage: a.sign_mantissa_exponent()
(1, 868749920300559282, -46)
sage: a.prec()
60
sage: b=sr_to_max(SR(a))
sage: b
<ECL: ((BIGFLOAT SIMP 60) 868749920300559282 14)>
sage: M(b)
1.2345678901234568b4
sage: c=M(b)+M(b)
sage: c.ecl()
<ECL: ((BIGFLOAT SIMP 56) 54296870018784955 15)>
sage: sr_to_max(SR(2*a))
<ECL: ((BIGFLOAT SIMP 60) 868749920300559282 15)>
This is somewhat related to #9263.
The Sage–Maxima interface currently does not maintain precision:
See here for more details: http://groups.google.com/group/sage-devel/browse_thread/thread/3598040d05b8413c
CC: @kcrisman @nbruin
Component: interfaces
Issue created by migration from https://trac.sagemath.org/ticket/11643