Ticket #9130: trac_9130-beta_function.2.patch

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

    # HG changeset patch
    # User Karen T. Kohl <ktkohl96@gmail.com>
    # Date 1326400728 21600
    # Node ID aa729a73616e28c3bdf89950090597856a2e61c3
    # Parent  92c93226b64f933e0af00bbcbd1a8a79c444f43f
    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                    real_part, real,
  • sage/functions/other.py

    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    11811181
    11821182binomial = Function_binomial()
    11831183
     1184class Function_beta(GinacFunction):
     1185    def __init__(self):
     1186        r"""
     1187        Return the beta function.  This is defined by
     1188
     1189        .. math::
     1190
     1191            B(p,q) = \int_0^1 t^{p-1}(1-t)^{1-q} dt
     1192
     1193        for complex or symbolic input `p` and `q`.
     1194        Note that the order of inputs does not matter:  `B(p,q)=B(q,p)`.
     1195
     1196        GiNaC is used to compute `B(p,q)`.  However, complex inputs
     1197        are not yet handled in general.  When GiNaC raises an error on
     1198        such inputs, we raise a NotImplementedError.
     1199
     1200        If either input is 1, GiNaC returns the reciprocal of the
     1201        other.  In other cases, GiNaC uses one of the following
     1202        formulas:
     1203
     1204        .. math::
     1205
     1206            B(p,q) = \Gamma(p)\Gamma(q)/\Gamma(p+q)
     1207
     1208        or
     1209
     1210        .. math::
     1211
     1212            B(p,q) = (-1)^q B(1-p-q, q).
     1213
     1214
     1215        For numerical inputs, GiNaC uses the formula
     1216
     1217        .. math::
     1218
     1219            B(p,q) =  \exp[\log\Gamma(p)+\log\Gamma(q)-\log\Gamma(p+q)]
     1220
     1221
     1222        INPUT:
     1223
     1224        -  ``p`` - number or symbolic expression
     1225
     1226        -  ``q`` - number or symbolic expression
     1227
     1228
     1229        OUTPUT: number or symbolic expression (if input is symbolic)
     1230
     1231        EXAMPLES::
     1232
     1233            sage: beta(3,2)
     1234            1/12
     1235            sage: beta(3,1)
     1236            1/3
     1237            sage: beta(1/2,1/2)
     1238            beta(1/2, 1/2)
     1239            sage: beta(-1,1)
     1240            -1
     1241            sage: beta(-1/2,-1/2)
     1242            0
     1243            sage: beta(x/2,3)
     1244            beta(1/2*x, 3)
     1245            sage: beta(.5,.5)
     1246            3.14159265358979
     1247            sage: beta(1,2.0+I)
     1248            0.400000000000000 - 0.200000000000000*I
     1249            sage: beta(3,x+I)
     1250            beta(x + I, 3)
     1251
     1252        Note that the order of arguments does not matter::
     1253
     1254            sage: beta(1/2,3*x)
     1255            beta(3*x, 1/2)
     1256
     1257        The following must be fixed to remain symbolic::
     1258
     1259            sage: beta(2,1+5*I)
     1260            -0.0305039787798408 - 0.0198938992042440*I
     1261
     1262        """
     1263        GinacFunction.__init__(self, "beta", nargs=2,
     1264                conversions=dict(maxima='beta', mathematica='Beta'))
     1265
     1266beta = Function_beta()
     1267
    11841268def _do_sqrt(x, prec=None, extend=True, all=False):
    11851269        r"""
    11861270        Used internally to compute the square root of x.