Opened 9 years ago

Last modified 4 years ago

#13039 new defect

improve mpmath-to-sage conversion

Reported by: dsm Owned by: jason, jkantor
Priority: major Milestone: sage-7.4
Component: numerical Keywords: sd40.5
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by mkoeppe)

Conversions between mpmath and sage objects don't always go smoothly when the number of digits required for the exponent is very large. This can cause problems for limiting behaviour when mpmath is used as the numerical backend for various special functions. For example:

from sage.libs.mpmath import utils as mpmath_utils 
sage: mpmath_utils.call(mpmath.airyai, 1e2)
2.63448215208818e-291
sage: mpmath_utils.call(mpmath.airyai, 1e4)
6.24874575695894e-289532
sage: mpmath_utils.call(mpmath.airyai, 1e8)
0.000000000000000
sage: mpmath_utils.call(mpmath.airyai, 1e16)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)

/Users/mcneil/sagedev/sage-5.1.beta0/devel/sage-hack/sage/<ipython console> in <module>()

/Users/mcneil/sagedev/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/libs/mpmath/utils.so in sage.libs.mpmath.utils.call (sage/libs/mpmath/utils.c:5667)()

/Users/mcneil/sagedev/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/libs/mpmath/utils.so in sage.libs.mpmath.utils.mpmath_to_sage (sage/libs/mpmath/utils.c:4420)()

/Users/mcneil/sagedev/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/libs/mpmath/utils.so in sage.libs.mpmath.utils.mpfr_from_mpfval (sage/libs/mpmath/utils.c:3701)()

OverflowError: Python int too large to convert to C long

This should probably return zero instead (and similarly go to an inf in the other case).

Change History (5)

comment:1 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 4 years ago by mkoeppe

  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-7.4
Note: See TracTickets for help on using tickets.