1
$\begingroup$

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]
$\endgroup$

2 Answers 2

5
$\begingroup$

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]]

Mathematica graphics

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

p1[4,2,x]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ 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? $\endgroup$
    – Lomath
    Aug 5, 2023 at 9:00
  • 1
    $\begingroup$ @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 $\endgroup$
    – Nasser
    Aug 5, 2023 at 9:19
  • $\begingroup$ Thanks! It seems that under the command "Limit", the second terms goes to 0, remaining the first term A/(n-nx). $\endgroup$
    – Lomath
    Aug 5, 2023 at 9:31
  • 1
    $\begingroup$ 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. $\endgroup$
    – Lomath
    Aug 5, 2023 at 9:46
2
$\begingroup$

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

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:
enter image description here

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.