# Ticket #9130: trac_9130_beta_function.4.patch

File trac_9130_beta_function.4.patch, 3.3 KB (added by ktkohl, 8 years ago)

# HG changeset patch
diff --git a/sage/functions/other.py b/sage/functions/other.py
 a B(p,q) = \int_0^1 t^{p-1}(1-t)^{1-q} dt for complex input p and q. Note that the order of arguments of does not matter:  B(p,q)=B(q,p). for complex or symbolic input p and q. Note that the order of inputs does not matter:  B(p,q)=B(q,p). It is computed by GiNaC by either GiNaC is used to compute B(p,q).  However, complex inputs are not yet handled in general.  When GiNaC raises an error on such inputs, we raise a NotImplementedError. If either input is 1, GiNaC returns the reciprocal of the other.  In other cases, GiNaC uses one of the following formulas: .. math:: .. math:: B(p,q) = (-1)^q B(1-p-q, q) B(p,q) = (-1)^q B(1-p-q, q). It is evaluated numerically in GiNaC by For numerical inputs, GiNaC uses the formula .. math:: B(p,q) =  \exp(\log(\Gamma(p))+\log(\Gamma(q))-\log(\Gamma(p+q))) B(p,q) =  \exp[\log\Gamma(p)+\log\Gamma(q)-\log\Gamma(p+q)] INPUT: beta(1/2*x, 3) sage: beta(.5,.5) 3.14159265358979 sage: beta(1,2+I) -1/5*I + 2/5 sage: beta(1,2.0+I) 0.400000000000000 - 0.200000000000000*I sage: beta(3,x+I) beta(x + I, 3) Note that the order of arguments does not matter:: sage: beta(1/2,3*x) beta(3*x, 1/2) The following fails because we haven't implemented beta yet for general complex values:: The following fails because GiNaC does not handle general complex values:: sage: beta(2,1+5*I) Traceback (most recent call last): ... NotImplementedError: beta not implemented for all complex arguments NotImplementedError: beta not implemented for complex inputs """ GinacFunction.__init__(self, "beta", nargs=2, beta(1/2*x, 3) sage: beta(.5,.5) 3.14159265358979 sage: beta(1,2.0+I) 0.400000000000000 - 0.200000000000000*I sage: beta(3,x+I) beta(x + I, 3) sage: beta(2,1+5*I) Traceback (most recent call last): ... NotImplementedError: beta not implemented for all complex arguments NotImplementedError: beta not implemented for complex inputs """ try: res = GinacFunction.__call__(self, p, q, coerce=coerce, hold=hold) except TypeError, err: if not str(err).startswith("cannot coerce"): raise NotImplementedError, "beta not implemented for all complex arguments" raise NotImplementedError, "beta not implemented for complex inputs" return res