Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
28061: reliable erf evaluation with real balls
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Jun 26, 2019
1 parent 8084b69 commit b36b7b3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/sage/functions/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from sage.rings.infinity import unsigned_infinity
from sage.libs.pynac.pynac import I

from sage.rings.real_arb import RealBallField

class Function_erf(BuiltinFunction):
r"""
Expand Down Expand Up @@ -264,10 +265,21 @@ def _evalf_(self, x, parent=None, algorithm=None):
1629.99462260157*I
sage: erf(33.0*I)
1.51286977510409e471*I
Check that real ball evaluation is fixed :trac:`28061`::
sage: RealBallField(128)(erf(5))
[0.99999999999846254020557196514981165651 +/- 7.33e-39]
"""
R = parent or s_parent(x)
import mpmath
return mpmath_utils.call(mpmath.erf, x, parent=R)
if isinstance(R, RealBallField):
# NOTE: erf exists on complex balls but not on real ones
C = R.complex_field()
return C(x).erf().real()
else:
import mpmath
y = mpmath_utils.call(mpmath.erf, x, parent=R)
return y

def _derivative_(self, x, diff_param=None):
"""
Expand Down

0 comments on commit b36b7b3

Please sign in to comment.