# HG changeset patch
# User Volker Braun <vbraun@stp.dias.ie>
# Date 1325267921 0
# Node ID 547974050a2468583bd1c98d5d29a459a55831f9
# Parent 29829c29f3379831ac259e5fd359d27b638ee577
Trac #12237: erf of complex arguments
diff git a/sage/functions/other.py b/sage/functions/other.py
a

b


40  40  erf(2) 
41  41  sage: erf(2).n() 
42  42  0.995322265018953 
 43  sage: erf(2+I).n() 
 44  1.00360634272565  0.0112590060288150*I 
43  45  sage: loads(dumps(erf)) 
44  46  erf 
45  47  
46   The following fails because we haven't implemented 
47   erf yet for complex values:: 
48   
49   sage: complex(erf(3*I)) 
50   Traceback (most recent call last): 
51   ... 
52   TypeError: unable to simplify to complex approximation 
53   
54  48  TESTS: 
55  49  
56  50  Check if conversion from maxima elements work:: 
… 
… 

71  65  Traceback (most recent call last): 
72  66  ... 
73  67  NotImplementedError: erf not implemented for precision higher than 53 
 68  
 69  TESTS:: 
 70  
 71  sage: integrate(sin(x)*(x^(1/2)),x,0,1).n() # maxima's solution involves erf(complex) 
 72  0.364221932032132 
 73  sage: type( erf(2+I).n() ) 
 74  <type 'sage.rings.complex_number.ComplexNumber'> 
 75  sage: type( erf(2).n() ) 
 76  <type 'sage.rings.real_mpfr.RealNumber'> 
74  77  """ 
75  78  try: 
76  79  prec = parent.prec() 
… 
… 

78  81  prec = 0 
79  82  if prec > 53: 
80  83  raise NotImplementedError, "erf not implemented for precision higher than 53" 
81   return parent(1  pari(float(x)).erfc()) 
 84  return parent(1  pari(complex(x)).erfc()) 
82  85  
83  86  def _derivative_(self, x, diff_param=None): 
84  87  """ 