# Ticket #9240: trac_9240_full_simplify_gamma.patch

File trac_9240_full_simplify_gamma.patch, 2.2 KB (added by tomc, 11 years ago)

based on Sage 4.4.1

• ## sage/symbolic/expression.pyx

```# HG changeset patch
# User Tom Coates <tomc@imperial.ac.uk>
# Date 1276573549 25200
# Node ID a0911505b956f708ba4fd3acd07910a8e21e7787
# Parent  263f1caae32dd7ac94a108e8b279a9872b56f260
trac 9240: fix full_simplify() of gamma functions

diff -r 263f1caae32d -r a0911505b956 sage/symbolic/expression.pyx```
 a n + 1 :: sage: f = factorial(n)*(n+1); f (n + 1)*factorial(n) sage: simplify(f) 1/2*(x - 1)*x + 1/2*x + 1/2 sage: g.simplify_rational() 1/2*x^2 + 1/2 TESTS: Check that the problem with applying full_simplify() to gamma functions (Trac 9240) has been fixed:: sage: gamma(37) 371993326789901217467999448150835200000000 sage: gamma(0) Infinity sage: gamma(-4) Infinity sage: gamma(-4/3) gamma(-4/3) sage: gamma(1/3).full_simplify() gamma(1/3) sage: gamma(4/3).full_simplify() 1/3*gamma(1/3) """ return self.parent()(self._maxima_().makefact().factcomb().minfactorial())
• ## sage/symbolic/pynac.pyx

`diff -r 263f1caae32d -r a0911505b956 sage/symbolic/pynac.pyx`
 a from sage.rings.arith import factorial cdef public object py_factorial(object x) except +: # factorial(x) is only defined for non-negative integers x # so we first test if x can be coerced into ZZ and is non-negative. # If this is not the case then we return the symbolic expression gamma(x+1) # This fixes Trac 9240 try: x_in_ZZ = ZZ(x) coercion_success = True except TypeError: coercion_success = False if coercion_success and x_in_ZZ >= 0: return factorial(x) except TypeError: else: return py_tgamma(x+1) cdef public object py_doublefactorial(object x) except +: