Opened 11 years ago
Last modified 8 years ago
#11643 new defect
Maxima precision
Reported by: | eviatarbach | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | interfaces | Keywords: | |
Cc: | kcrisman, nbruin | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The Sage–Maxima interface currently does not maintain precision:
sage: a = RealField(200)(8.987551787368175506591796875e9) sage: a 8.9875517873681755065917968750000000000000000000000000000000e9 sage: var('y') y sage: b = (a * x).mul(y, hold=True) sage: b (8.9875517873681755065917968750000000000000000000000000000000e9*x)*y sage: c = (b / (x * y)).simplify() sage: c 8987551787.37 sage: RealField(200)(c) 8.9875517873681697845458984375000000000000000000000000000000e9
See here for more details: http://groups.google.com/group/sage-devel/browse_thread/thread/3598040d05b8413c
Attachments (1)
Change History (9)
comment:1 Changed 11 years ago by
- Cc kcrisman nbruin added
comment:2 Changed 11 years ago by
Changed 11 years ago by
comment:3 Changed 11 years ago by
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)>
comment:4 Changed 9 years ago by
This is somewhat related to #9263.
comment:5 Changed 9 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:6 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:7 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:8 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
There are a couple of issues for this. The first is converting to Maxima which is currently
should be done with something like: calculus.symbolic_expression_from_string
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.