# HG changeset patch
# User Tom Coates <tomc@imperial.ac.uk>
# Date 1276279970 25200
# Node ID 111ada4c5a615bffb26a9e9dd3bb675d67b6b87f
# Parent 263f1caae32dd7ac94a108e8b279a9872b56f260
trac 9217: fix problem with Taylor expansion of gamma functions
diff r 263f1caae32d r 111ada4c5a61 sage/calculus/calculus.py
a

b


290  290  sage: f(x)=x 
291  291  sage: integrate(f,x,0,1) 
292  292  x > 1/2 
 293  
 294  Check that the problem with Taylor expansions of the gamma function 
 295  (Trac #9217) is fixed:: 
 296  
 297  sage: taylor(gamma(1/3+x),x,0,3) 
 298  1/432*((36*(pi*sqrt(3) + 9*log(3))*euler_gamma^2 + 27*pi^2*log(3) + 72*euler_gamma^3 + 243*log(3)^3 + 18*(6*pi*sqrt(3)*log(3) + pi^2 + 27*log(3)^2)*euler_gamma + 36*(6*euler_gamma + pi*sqrt(3) + 9*log(3))*psi(1, 1/3) + (pi^3 + 81*pi*log(3)^2)*sqrt(3))*gamma(1/3)  72*gamma(1/3)*psi(2, 1/3))*x^3 + 1/24*(6*pi*sqrt(3)*log(3) + 4*(pi*sqrt(3) + 9*log(3))*euler_gamma + pi^2 + 12*euler_gamma^2 + 27*log(3)^2 + 12*psi(1, 1/3))*x^2*gamma(1/3)  1/6*(6*euler_gamma + pi*sqrt(3) + 9*log(3))*x*gamma(1/3) + gamma(1/3) 
 299  
293  300  """ 
294  301  
295  302  import re 
… 
… 

1423  1430  
1424  1431  sci_not = re.compile("(?(?:0[19]\d*))(\.\d+)?([eE][+]\d+)") 
1425  1432  
 1433  maxima_polygamma = re.compile("psi\[(\d*)\]\(") # matches psi[n]( where n is a number 
 1434  
1426  1435  def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima): 
1427  1436  """ 
1428  1437  Given a string representation of a Maxima expression, parse it and 
… 
… 

1486  1495  
1487  1496  s = s.replace("#","!=") # a lot of this code should be refactored somewhere... 
1488  1497  
 1498  s = maxima_polygamma.sub('psi(\g<1>,',s) # this replaces psi[n](foo) with psi(n,foo), ensuring that derivatives of the digamma function are parsed properly below 
 1499  
1489  1500  if equals_sub: 
1490  1501  s = s.replace('=','==') 
1491  1502  