Ticket #9130: trac_9130-beta_function.3.patch

File trac_9130-beta_function.3.patch, 3.5 KB (added by jdemeyer, 8 years ago)
  • doc/en/reference/functions.rst

    # HG changeset patch
    # User Karen T. Kohl <ktkohl96@gmail.com>
    # Date 1326400728 21600
    # Node ID 21f9c69012b3d7dd92a8fe47f038803c792c0219
    # Parent  8aa5d8d33c990d7e24c63a29a80f698f4f614127
    Trac 9130: symbolic beta function
    
    diff --git a/doc/en/reference/functions.rst b/doc/en/reference/functions.rst
    a b  
    99   sage/functions/transcendental
    1010   sage/functions/piecewise
    1111   sage/functions/orthogonal_polys
     12   sage/functions/other
    1213   sage/functions/special
    1314   sage/functions/wigner
    1415   sage/functions/generalized
    15    sage/functions/prime_pi
    16  No newline at end of file
     16   sage/functions/prime_pi
  • sage/functions/all.py

    diff --git a/sage/functions/all.py b/sage/functions/all.py
    a b  
    1515
    1616
    1717
    18 from other import ( ceil, floor, gamma, psi, factorial,
     18from other import ( ceil, floor, gamma, psi, factorial, beta,
    1919                    abs_symbolic, erf, sqrt,
    2020                    gamma_inc, incomplete_gamma,
    2121                    arg, real_part, real,
  • sage/functions/other.py

    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    12161216
    12171217binomial = Function_binomial()
    12181218
     1219class Function_beta(GinacFunction):
     1220    def __init__(self):
     1221        r"""
     1222        Return the beta function.  This is defined by
     1223
     1224        .. math::
     1225
     1226            B(p,q) = \int_0^1 t^{p-1}(1-t)^{1-q} dt
     1227
     1228        for complex or symbolic input `p` and `q`.
     1229        Note that the order of inputs does not matter:  `B(p,q)=B(q,p)`.
     1230
     1231        GiNaC is used to compute `B(p,q)`.  However, complex inputs
     1232        are not yet handled in general.  When GiNaC raises an error on
     1233        such inputs, we raise a NotImplementedError.
     1234
     1235        If either input is 1, GiNaC returns the reciprocal of the
     1236        other.  In other cases, GiNaC uses one of the following
     1237        formulas:
     1238
     1239        .. math::
     1240
     1241            B(p,q) = \Gamma(p)\Gamma(q)/\Gamma(p+q)
     1242
     1243        or
     1244
     1245        .. math::
     1246
     1247            B(p,q) = (-1)^q B(1-p-q, q).
     1248
     1249
     1250        For numerical inputs, GiNaC uses the formula
     1251
     1252        .. math::
     1253
     1254            B(p,q) =  \exp[\log\Gamma(p)+\log\Gamma(q)-\log\Gamma(p+q)]
     1255
     1256
     1257        INPUT:
     1258
     1259        -  ``p`` - number or symbolic expression
     1260
     1261        -  ``q`` - number or symbolic expression
     1262
     1263
     1264        OUTPUT: number or symbolic expression (if input is symbolic)
     1265
     1266        EXAMPLES::
     1267
     1268            sage: beta(3,2)
     1269            1/12
     1270            sage: beta(3,1)
     1271            1/3
     1272            sage: beta(1/2,1/2)
     1273            beta(1/2, 1/2)
     1274            sage: beta(-1,1)
     1275            -1
     1276            sage: beta(-1/2,-1/2)
     1277            0
     1278            sage: beta(x/2,3)
     1279            beta(1/2*x, 3)
     1280            sage: beta(.5,.5)
     1281            3.14159265358979
     1282            sage: beta(1,2.0+I)
     1283            0.400000000000000 - 0.200000000000000*I
     1284            sage: beta(3,x+I)
     1285            beta(x + I, 3)
     1286
     1287        Note that the order of arguments does not matter::
     1288
     1289            sage: beta(1/2,3*x)
     1290            beta(3*x, 1/2)
     1291
     1292        The following must be fixed to remain symbolic::
     1293
     1294            sage: beta(2,1+5*I)
     1295            -0.0305039787798408 - 0.0198938992042440*I
     1296
     1297        """
     1298        GinacFunction.__init__(self, "beta", nargs=2,
     1299                conversions=dict(maxima='beta', mathematica='Beta'))
     1300
     1301beta = Function_beta()
     1302
    12191303def _do_sqrt(x, prec=None, extend=True, all=False):
    12201304        r"""
    12211305        Used internally to compute the square root of x.