# Work around bugs in Summation, Hypergeometric function?

I'm so confused I don't even know how to phrase the question, so here's what's happening:

I need an analytic form for this:

a = Sum[(j + n - 2)!^2/((j + n - m - 1)! (j - 1)!), {j, 1, Z - n}]


(* (Gamma[1 - m - n] Gamma[n]^2)/Gamma[1 - m]^2 - (((-1 + Z)!)^2 HypergeometricPFQ[{1, Z, Z}, {1 - m + Z, 1 - n + Z}, 1])/((-m + Z)! (-n + Z)!) *)

This form is not useful for integer m>1:

a /. Z -> 10 /. m -> 4 /. n -> 7

(*   Indeterminate expression 0\ ComplexInfinity encountered.   *)


But there's no issue if I skip calculating the analytic expression:

Sum[(j + n - 2)!^2/((j + n - m - 1)! (j - 1)!), {j, 1, Z - n}] /. Z -> 10 /. m -> 4 /. n -> 7

(* 36 *)


So... How can I MMa to give me the Sum in analytic form that works for m>1? Can I make MMa give results in factorials like a human instead of needless Hypergeometric functions?

• Compare (Gamma[1-m-n] Gamma[n]^2)/Gamma[1-m]^2 /. {m->4, n->7} and Limit[Limit[(Gamma[1-m-n] Gamma[n]^2)/Gamma[1-m]^2, n->7], m->4] and think a bit. WHY are each of those doing that? – Bill May 13 '15 at 0:58
• @Bill The first doesn't work because the gamma of a neg integer is complex infinity. So then how do I get MMa to give me an analytic form for my Sum that doesn't have that problem? – Jerry Guern May 13 '15 at 1:19
• Dear Jerry, can you please include the exact hypergeometric expression returned by Mathematica in your question? – J. M.'s technical difficulties May 13 '15 at 1:51
• Yes, @Bill, I understand the math, it's MMa that's new to me. The problem is that MMa is giving me a result in a form that contains Gamma[1-m] which is unusable for integer m>1. I would like to know how to make MMa give me the result in a usable form. – Jerry Guern May 13 '15 at 2:05
• What version of Mma are you using? Under 10.1, I get your Infinity::indet error using your third expression, which you say evaluates. Also, the three terms in your example series are 86400, 1058400, and 6773760, so how does this ever sum to 36? – Eric Towers May 13 '15 at 15:35

Here's the answer to your question, how Mathematica can give you a function wich calculates the sum for all combination of the parameters n, m, and z. And you almost have found it!

Simply define the function

a[n_, m_, z_] :=
Sum[(j + n - 2)!^2/((j + n - m - 1)!*(j - 1)!), {j, 1, z - n}]


Now you can calculate the correct result of your example

a[7, 4, 10]

(*
Out= 7918560
*)


or, fixing two parameters, leaving z real

a[7, 4, z]

(*
Out= 1/140 (-7 + z) (-6 + z) (-5 + z) (-4 + z) (-3 + z) (-2 + z) (-1 + z) (-120 + 203 z - 98 z^2 + 14 z^3)
*)


or, fixing just one parameter numerically, leaving the other symbolical

a[n, 2, z]

(*
Out= -(((n - z) (-1 - n + n z) ((-1 + z)!)^2)/(
n (1 + n) (-1 + z) (-2 + z)! (-n + z)!))
*)


or

a[1, m, z]

(*
Out= (-m (1 - m)! (-1 + z)! + z (1 - m)! (-1 + z)! - (-m + z)! +
m (-m + z)!)/(m (1 - m)! (-m + z)!)
*)


The fixed numerical parameters are not restricted to integer values.

A problem arises, as you pointed out in your problem, only if you leave all three parameters symbolic

a[n, m, z]

(*
Out= (Gamma[1 - m - n] Gamma[n]^2)/
Gamma[1 - m]^2 - (((-1 + z)!)^2 HypergeometricPFQ[{1, z, z}, {1 - m + z,
1 - n + z}, 1])/((-m + z)! (-n + z)!)
*)


and want to insert integer values for n and / or m into this expression. But, as I said, this is not necessary, as you can do this with a[].

However, the analytic symbolic expression is nevertheless useful. For instance, it can be used to calculate the asymptotic behaviour

Series[%, {z, \[Infinity], 2}] // Normal

(*
Out= ((1/z)^(-m -
n) ((1/z)^(m + n) Gamma[1 - m - n] Gamma[n]^2 - (
Gamma[1 - m]^2 HypergeometricPFQ[{1, z, z}, {1 - m + z, 1 - n + z}, 1])/
z^2))/Gamma[1 - m]^2
*)