Ticket #9130: trac_9130_beta_function.4.patch

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

updated comments/examples/error message text.

  • sage/functions/other.py

    # HG changeset patch
    # User Karen T. Kohl <ktkohl96@gmail.com>
    # Date 1326228820 21600
    # Node ID db8ca66b70136deaa17c851b90b8467c531315c3
    # Parent  a3d0b4f386e9f57ce59dbfef61b67de77ee615aa
    Trac 9130:  beta function--additional comments and examples
    
    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    11771177
    11781178            B(p,q) = \int_0^1 t^{p-1}(1-t)^{1-q} dt
    11791179
    1180         for complex input `p` and `q`.
    1181         Note that the order of arguments of does not matter:  `B(p,q)=B(q,p)`.
     1180        for complex or symbolic input `p` and `q`.
     1181        Note that the order of inputs does not matter:  `B(p,q)=B(q,p)`.
    11821182
    1183         It is computed by GiNaC by either
     1183        GiNaC is used to compute `B(p,q)`.  However, complex inputs
     1184        are not yet handled in general.  When GiNaC raises an error on
     1185        such inputs, we raise a NotImplementedError.
     1186
     1187        If either input is 1, GiNaC returns the reciprocal of the
     1188        other.  In other cases, GiNaC uses one of the following
     1189        formulas:
    11841190
    11851191        .. math::
    11861192
     
    11901196
    11911197        .. math::
    11921198
    1193             B(p,q) = (-1)^q B(1-p-q, q)
     1199            B(p,q) = (-1)^q B(1-p-q, q).
    11941200
    1195         It is evaluated numerically in GiNaC by
     1201
     1202        For numerical inputs, GiNaC uses the formula
    11961203
    11971204        .. math::
    11981205
    1199             B(p,q) =  \exp(\log(\Gamma(p))+\log(\Gamma(q))-\log(\Gamma(p+q)))
     1206            B(p,q) =  \exp[\log\Gamma(p)+\log\Gamma(q)-\log\Gamma(p+q)]
    12001207
    12011208
    12021209        INPUT:
     
    12241231            beta(1/2*x, 3)
    12251232            sage: beta(.5,.5)
    12261233            3.14159265358979
    1227             sage: beta(1,2+I)
    1228             -1/5*I + 2/5
    12291234            sage: beta(1,2.0+I)
    12301235            0.400000000000000 - 0.200000000000000*I
     1236            sage: beta(3,x+I)
     1237            beta(x + I, 3)
    12311238
    12321239        Note that the order of arguments does not matter::
    12331240
    12341241            sage: beta(1/2,3*x)
    12351242            beta(3*x, 1/2)
    12361243
    1237         The following fails because we haven't implemented
    1238         beta yet for general complex values::
     1244        The following fails because GiNaC does not handle general
     1245        complex values::
    12391246
    12401247            sage: beta(2,1+5*I)
    12411248            Traceback (most recent call last):
    12421249            ...
    1243             NotImplementedError: beta not implemented for all complex arguments
     1250            NotImplementedError: beta not implemented for complex inputs
    12441251
    12451252        """
    12461253        GinacFunction.__init__(self, "beta", nargs=2,
     
    12651272            beta(1/2*x, 3)
    12661273            sage: beta(.5,.5)
    12671274            3.14159265358979
     1275            sage: beta(1,2.0+I)
     1276            0.400000000000000 - 0.200000000000000*I
     1277            sage: beta(3,x+I)
     1278            beta(x + I, 3)
    12681279            sage: beta(2,1+5*I)
    12691280            Traceback (most recent call last):
    12701281            ...
    1271             NotImplementedError: beta not implemented for all complex arguments
     1282            NotImplementedError: beta not implemented for complex inputs
    12721283
    12731284        """
     1285
    12741286        try:
    12751287            res = GinacFunction.__call__(self, p, q, coerce=coerce, hold=hold)
    12761288        except TypeError, err:
    12771289            if not str(err).startswith("cannot coerce"):
    1278                 raise NotImplementedError, "beta not implemented for all complex arguments"
     1290                raise NotImplementedError, "beta not implemented for complex inputs"
    12791291
    12801292        return res
    12811293