# Complex infinity when using Fullsimplify to sum

I am trying to simply and speed up a sum using Fullsimplify, when I try the simplified expression with a simple example, it comes up with Complex infinity. How do the Fullsimplify itself give an expression like that?

ClearAll[p, p1, n, A, v];

p[n_, A_, v_, x_] :=
Sum[Sum[Binomial[n - 1, n - j]*v^(j - 1)*
Binomial[n - j, n - i]*(1 - x)^(n - i)*(x - v)^(i - j)*
A/(n - i + 1), {j, i}], {i, n - A}];

Sum[Sum[Binomial[n - 1, n - j]*v^(j - 1)*
Binomial[n - j, n - i]*(1 - x)^(n - i)*(x - v)^(i - j)*
A/(n - i + 1), {j, i}], {i, n - A}] // FullSimplify

p1[n_, A_, x_] := (1 - x)^
n ((1/(1 - x))^n/(
n - n x) - ((x/(-1 + x))^(1 - A + n)
Gamma[-A] Hypergeometric2F1Regularized[1, -A, 1 - A + n,
x/(-1 + x)])/(x Gamma[1 - n]));

p1[4,2,x]


use Limit

ClearAll[p,p1,n,A,v,x];
p[n_,A_,v_,x_]:=Sum[Sum[Binomial[n-1,n-j]*v^(j-1)*Binomial[n-j,n-i]*(1-x)^(n-i)*(x-v)^(i-j)*A/(n-i+1),{j,i}],{i,n-A}];
simplifiedExpr=FullSimplify[p[n,A,v,x]]


p1[nValue_,AValue_,xValue_]:=Limit[simplifiedExpr,n->nValue]/.A->AValue/.x->xValue

p1[4,2,x]


• It works, but the result is different from the original expression, Expand[p[4,2,v,x]//Fullsimplify] gives 1/2+x/2-5*x^2/2+3*x^3/2, am I miss anything? Aug 5, 2023 at 9:00
• @Lomath I looked more into it. I do not know why Expand[p[4,2,v,x]//Fullsimplify gives different result. But if you do Series[ p1[4,2,x],{x,0,6}] it now becomes similar in the first few terms at least to what your command gives. anyway, maybe there is something else going on. But my point in this answer is to avoid the 1/0 you had by taking the limit. screen shot !Mathematica graphics Aug 5, 2023 at 9:19
• Thanks! It seems that under the command "Limit", the second terms goes to 0, remaining the first term A/(n-nx). Aug 5, 2023 at 9:31
• Maybe the problem is about Gamma[-A]/Gamma[1-n] in the second terms, when Gamma[] comes up with a negative parameter, it gives ComplexInfinity, but I do not know why FullSimplify gives such expression. Aug 5, 2023 at 9:46

Using Assuming is one way to this problem. As we can see, without Assuming, The FullSimplify gives:

When A>0 and n>1, there will be Gamma[] with a negative parameter, which gives ComplexInfinity.

Given that we want n,A are positive intergers,we use Assuming:

Assuming[Element[n, PositiveIntegers] && Element[A, PositiveIntegers],
FullSimplify[
Sum[Sum[Binomial[n - 1, n - j]*v^(j - 1)*
Binomial[n - j, n - i]*(1 - x)^(n - i)*(x - v)^(i - j)*
A/(n - i + 1), {j, i}], {i, n - A}]]]


It will give:

That's what I want, an expression that is useful for positive intergers n,A.