# Simplifying long expressions leads to memory allocation failure

I am currently trying to manipulate a number of expressions into a particular form that will allow me to determine their poles and zeros:

exprSimp =
Collect[
Expand[expr, Gamma[x_]] /. pochhammer /. pochhammer,
PolyGamma[0, x_],
Simplify]

pochhammer = {Gamma[x_]/
Gamma[y_] /;
(Simplify[Element[x - y, Integers]] && Simplify[x - y > 0]) ->
Pochhammer[y, Simplify[x - y]]};


I'm using the fact that I know the expression contains two gamma functions in the numerator and denominator that simplify to produce Pochammer symbols (Mathematica evidently won't automatically do this replacement), and that the important singular part of expr come from polygamma functions.

The code works exactly as intended for most of the expressions I've been using it with, however I have one particularly long expression that it seems to fail on, returning a memory allocation failure. Is there anything I can do to remedy this, short of splitting up the long expression?

### Edit:

Here is one piece of one of the expressions that successfully simplifies; the longer expressions contain many terms with PolyGamma functions in them, hence the use of Collect.

testExpr =
(Gamma[1/2 (3 - I k + m + n)] Gamma[1/2 (3 + I k + m + n)]
(-2 m (1 + 2 m) (3 - I k + m - n) (3 + I k + m - n)
PolyGamma[0, 1/2 (3 - I k + m + n)] -
2 m (1 + 2 m) (3 - I k + m - n) (3 + I k + m - n)
PolyGamma[0, 1/2 (3 + I k + m + n)])) /
(4 m^3 (1 + 2 m)^2 (2 + m)! Gamma[2 m]
Gamma[1/2 (-3 - I k - m + n)] Gamma[1/2 (-3 + I k - m + n)]);

testExprSimp =
Collect[
Expand[testExpr, Gamma[x_]] /. pochhammer /. pochhammer,
PolyGamma[0, x_],
Simplify]


The output is

-(((3 - I k + m - n) (3 + I k + m - n)
Pochhammer[1/2 (-3 - I k - m + n), 3 + m]
Pochhammer[1/2 (-3 + I k - m + n), 3 + m]
PolyGamma[0, 1/2 (3 - I k + m + n)]) /
(2 m^2 (1 + 2 m) (2 + m)! Gamma[2 m])) -
((3 - I k + m - n) (3 + I k + m - n)
Pochhammer[1/2 (-3 - I k - m + n), 3 + m]
Pochhammer[1/2 (-3 + I k - m + n), 3 + m]
PolyGamma[0, 1/2 (3 + I k + m + n)]) /
(2 m^2 (1 + 2 m) (2 + m)! Gamma[2 m])

• Can you supply a simple example of these expressions and how it simplifies and place it in your question, please? Absurdly long is a problem itself. – Somos Mar 20 '19 at 18:48
• All of the expressions I'm actually simplifying are absurdly long, however I can try and include a piece of one and show how it simplifies – w.ice Mar 20 '19 at 18:51