# Ticket #9130: trac_9130_beta_function.2.patch

File trac_9130_beta_function.2.patch, 4.2 KB (added by ktkohl, 8 years ago)
• ## doc/en/reference/functions.rst

# HG changeset patch
# User Karen T. Kohl <ktkohl96@gmail.com>
# Date 1326168469 21600
# Node ID 85b045143057e5da2aaac4f05fb3afca74e4b7aa
# Parent  f189cfdef1c8669e8e8d88cfec579dc3c08ed343
Trac 9130:  beta function access with error for complex input

diff --git a/doc/en/reference/functions.rst b/doc/en/reference/functions.rst
 a sage/functions/transcendental sage/functions/piecewise sage/functions/orthogonal_polys sage/functions/other sage/functions/special sage/functions/wigner sage/functions/generalized sage/functions/prime_pi No newline at end of file sage/functions/prime_pi
• ## sage/functions/all.py

diff --git a/sage/functions/all.py b/sage/functions/all.py
 a from other import ( ceil, floor, gamma, psi, factorial, from other import ( ceil, floor, gamma, psi, factorial, beta, abs_symbolic, erf, sqrt, gamma_inc, incomplete_gamma, real_part, real,
• ## sage/functions/other.py

diff --git a/sage/functions/other.py b/sage/functions/other.py
 a def __init__(self): r""" Return the beta function.  This is defined by \Beta(p,q) = \int_0^1 t^{p-1}(1-t)^{1-q} dt .. math:: 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). It is computed by various libraries within Sage, depending on the input type. It is computed by GiNaC by either .. math:: B(p,q) = \Gamma(p)\Gamma(q)/\Gamma(p+q) or .. math:: B(p,q) = (-1)^q B(1-p-q, q) It is evaluated numerically in GiNaC by .. math:: B(p,q) =  \exp(\log(\Gamma(p))+\log(\Gamma(q))-\log(\Gamma(p+q))) INPUT: -  p, q - numbers or symbolic expressions. -  p - number or symbolic expression -  q - number or symbolic expression OUTPUT: number or symbolic expression (if input is symbolic) EXAMPLES:: sage: beta(3,2) 1/12 sage: beta(3,1) 0 sage: beta(x/2,3) 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 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:: sage: beta(2,1+5*I) Traceback (most recent call last): ... NotImplementedError: beta not implemented for all complex arguments """ GinacFunction.__init__(self, "beta", nargs=2, conversions=dict(maxima='beta', mathematica='Beta')) def __call__(self, p, q, prec=None, coerce=True, hold=False): """ TESTS:: sage: beta(3,2) 1/12 sage: beta(3,1) 1/3 sage: beta(1/2,1/2) beta(1/2, 1/2) sage: beta(-1,1) -1 sage: beta(-1/2,-1/2) 0 sage: beta(x/2,3) beta(1/2*x, 3) sage: beta(.5,.5) 3.14159265358979 sage: beta(2,1+5*I) Traceback (most recent call last): ... NotImplementedError: beta not implemented for all complex arguments """ 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" return res beta = Function_beta() def _do_sqrt(x, prec=None, extend=True, all=False):