def _evalf_(self, x, parent): """ EXAMPLES:: sage: erf(2).n() 0.995322265018953 sage: erf(2).n(200) 0.99532226501895273416206925636725292861089179704006007673835 sage: erf(pi - 1/2*I).n(100) 1.0000111669099367825726058952 + 1.6332655417638522934072124548e-6*I TESTS: Check that PARI/GP through the GP interface gives the same answer:: sage: gp.set_real_precision(59) # random 38 sage: print gp.eval("1 - erfc(1)"); print erf(1).n(200); 0.84270079294971486934122063508260925929606699796630290845994 0.84270079294971486934122063508260925929606699796630290845994 """ try: prec = parent.prec() except AttributeError: # not a Sage parent prec = 0 return parent(1) - parent(pari(x).erfc(prec))
def _evalf_(self, n, z, parent=None): """ EXAMPLES:: """ import mpmath if isinstance(parent, Parent) and hasattr(parent, 'prec'): prec = parent.prec() else: prec = 53 return mpmath_utils.call(mpmath.expint, n, z, prec=prec)
def _evalf_(self, x, parent=None): """ EXAMPLES:: sage: Ei(10).n() 2492.22897624188 sage: Ei(20).n() 2.56156526640566e7 sage: Ei(I).n() 0.337403922900968 + 2.51687939716208*I sage: Ei(3+I).n() 7.82313467600158 + 6.09751978399231*I """ import mpmath if isinstance(parent, Parent) and hasattr(parent, 'prec'): prec = parent.prec() else: prec = 53 return mpmath_utils.call(mpmath.ei, x, prec=prec)