2 from sympy
.core
.basic
import Basic
, S
, cache_it
, cache_it_immutable
3 from sympy
.core
.function
import SingleValuedFunction
5 ###############################################################################
6 ################################ ERROR FUNCTION ###############################
7 ###############################################################################
9 class erf(SingleValuedFunction
):
13 def fdiff(self
, argindex
=1):
15 return 2*Basic
.exp(-self
[0]**2)/Basic
.sqrt(S
.Pi
)
17 raise ArgumentIndexError(self
, argindex
)
20 def _eval_apply_subs(cls
, *args
):
24 def _eval_apply(self
, arg
):
25 arg
= Basic
.sympify(arg
)
27 if isinstance(arg
, Basic
.Number
):
28 if isinstance(arg
, Basic
.NaN
):
30 elif isinstance(arg
, Basic
.Infinity
):
32 elif isinstance(arg
, Basic
.NegativeInfinity
):
34 elif isinstance(arg
, Basic
.Zero
):
38 elif isinstance(arg
, Basic
.Mul
):
39 coeff
, terms
= arg
.as_coeff_terms()
46 def taylor_term(self
, n
, x
, *previous_terms
):
47 if n
< 0 or n
% 2 == 0:
54 if len(previous_terms
) > 2:
55 return -previous_terms
[-2] * x
**2 * (n
-2)/(n
*k
)
57 return 2*(-1)**k
* x
**n
/(n
*Basic
.Factorial(k
)*Basic
.sqrt(S
.Pi
))
59 def _eval_as_leading_term(self
, x
):
60 arg
= self
[0].as_leading_term(x
)
62 if Basic
.Order(1,x
).contains(arg
):
67 def _eval_is_real(self
):
68 return self
[0].is_real
71 def _eval_apply_evalf(self
, arg
):
74 if isinstance(arg
, Basic
.Number
):
76 from sympy
.core
.numbers
import Real
77 from sympy
.numerics
import evalf
78 from sympy
.numerics
.functions2
import erf