# HG changeset patch
# User Karen T. Kohl <ktkohl96@gmail.com>
# Date 1326228820 21600
# Node ID db8ca66b70136deaa17c851b90b8467c531315c3
# Parent a3d0b4f386e9f57ce59dbfef61b67de77ee615aa
Trac 9130: beta functionadditional comments and examples
diff git a/sage/functions/other.py b/sage/functions/other.py
a

b


1177  1177  
1178  1178  B(p,q) = \int_0^1 t^{p1}(1t)^{1q} dt 
1179  1179  
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)`. 
1182  1182  
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: 
1184  1190  
1185  1191  .. math:: 
1186  1192  
… 
… 

1190  1196  
1191  1197  .. math:: 
1192  1198  
1193   B(p,q) = (1)^q B(1pq, q) 
 1199  B(p,q) = (1)^q B(1pq, q). 
1194  1200  
1195   It is evaluated numerically in GiNaC by 
 1201  
 1202  For numerical inputs, GiNaC uses the formula 
1196  1203  
1197  1204  .. math:: 
1198  1205  
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)] 
1200  1207  
1201  1208  
1202  1209  INPUT: 
… 
… 

1224  1231  beta(1/2*x, 3) 
1225  1232  sage: beta(.5,.5) 
1226  1233  3.14159265358979 
1227   sage: beta(1,2+I) 
1228   1/5*I + 2/5 
1229  1234  sage: beta(1,2.0+I) 
1230  1235  0.400000000000000  0.200000000000000*I 
 1236  sage: beta(3,x+I) 
 1237  beta(x + I, 3) 
1231  1238  
1232  1239  Note that the order of arguments does not matter:: 
1233  1240  
1234  1241  sage: beta(1/2,3*x) 
1235  1242  beta(3*x, 1/2) 
1236  1243  
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:: 
1239  1246  
1240  1247  sage: beta(2,1+5*I) 
1241  1248  Traceback (most recent call last): 
1242  1249  ... 
1243   NotImplementedError: beta not implemented for all complex arguments 
 1250  NotImplementedError: beta not implemented for complex inputs 
1244  1251  
1245  1252  """ 
1246  1253  GinacFunction.__init__(self, "beta", nargs=2, 
… 
… 

1265  1272  beta(1/2*x, 3) 
1266  1273  sage: beta(.5,.5) 
1267  1274  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) 
1268  1279  sage: beta(2,1+5*I) 
1269  1280  Traceback (most recent call last): 
1270  1281  ... 
1271   NotImplementedError: beta not implemented for all complex arguments 
 1282  NotImplementedError: beta not implemented for complex inputs 
1272  1283  
1273  1284  """ 
 1285  
1274  1286  try: 
1275  1287  res = GinacFunction.__call__(self, p, q, coerce=coerce, hold=hold) 
1276  1288  except TypeError, err: 
1277  1289  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" 
1279  1291  
1280  1292  return res 
1281  1293  