Ticket #9217: trac_9217-fix-1.patch

File trac_9217-fix-1.patch, 1.8 KB (added by tomc, 10 years ago)
  • sage/calculus/calculus.py

    # 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  
    290290    sage: f(x)=x
    291291    sage: integrate(f,x,0,1)
    292292    x |--> 1/2
     293
     294Check 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
    293300"""
    294301
    295302import re
     
    14231430
    14241431sci_not = re.compile("(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]\d+)")
    14251432
     1433maxima_polygamma = re.compile("psi\[(\d*)\]\(")  # matches psi[n]( where n is a number
     1434
    14261435def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
    14271436    """
    14281437    Given a string representation of a Maxima expression, parse it and
     
    14861495
    14871496    s = s.replace("#","!=") # a lot of this code should be refactored somewhere...
    14881497
     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   
    14891500    if equals_sub:
    14901501        s = s.replace('=','==')
    14911502