6
$\begingroup$

I am completely puzzled why splitting an infinite sum into two parts, one where the index $i$ is negative, and another where the index $i$ is not negative, leads to a different result.

I posted the code below, and unless I am missing something very basic, which I can't tell, this is a bug. Note that $i$ varies from $-3$ to $\infty$. It's then split into a sum where $i$ goes from $-3$ to $-1$, and another one where $i$ goes from $0$ to $\infty$. Mathematica gives a different result.

Note the only difference between the three parts (x1, x2 and x3) is the range of $i$. Loosely speaking, since we're talking about relative integers, we should have $[k-1, \infty]=[k-1, -1] \cup [0, \infty]$ (because $k$ is a negative integer, which is why that should hold).

j = 1; k = -2; x1 = Simplify[{x1 = 
Sum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], 
        {i, k - 1, Infinity}], x2 = Sum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], 
        {i, 0, Infinity}], x3 = Sum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], 
        {i, k - 1, -1}], x1 - (x2 + x3)}]

The output (difference should be zero):

{-3 + E^-z + 2 z - z^2/2, -E^-z (2 + E^z (-2 + z) + z), -2 + z, -3 + 2 z - z^2/2 + E^-z (3 + z)} 

I really appreciate the help.

Per my calculations, it's x1 that seems to be wrong.

$\endgroup$
2
  • $\begingroup$ What else can be said than that it is a bug in Mathematica? $\endgroup$ Commented Aug 15 at 18:07
  • 1
    $\begingroup$ ... and yes, x1 is wrong, x2+x3 is correct. $\endgroup$ Commented Aug 15 at 18:19

2 Answers 2

5
$\begingroup$

ORIGINAL answer:

The problem is with Binomial[n, m] where n<0. Thus, a fix is to replace it with a modified binomial such as B[n_, m_] := If[n<0, 0, Binomial[n, m]]. The recent version $14.1$ of Mathematica has PascalBinomial[] for this reason. However, it does not currently work for symbolic summation in this case. This is a correct code:

ClearAll[B, f, z, j, k];
B[n_, m_] := If[n<0, 0, Binomial[n, m]];
f[i_] := ((-z)^(i - k + 1)/(i - k + 1)!)*B[j + i, i];
j = 1; k = -2;
{x1 = Sum[ f[i], {i, k-1, Infinity}],
x2 = Sum[ f[i], {i, 0, Infinity}],
x3 = Sum[ f[i], {i, k-1, -1}],
x1 - (x2 + x3)} //Simplify //InputForm
(* {-((2 + E^z*(-2 + z) + z)/E^z), -((2 + E^z*(-2 + z) + z)/E^z), 0, 0} *)

However notice the difference between finite versus infinite summation:

ClearAll[B, f, z, j, k];
B[n_, m_] := Binomial[n, m];
f[i_] := ((-z)^(i - k + 1)/(i - k + 1)!)*B[j + i, i];
j = 1; k = -2; Inf = 100;
{x1 = Sum[ f[i], {i, k-1, Inf}],
x2 = Sum[ f[i], {i, 0, Inf}],
x3 = Sum[ f[i], {i, k-1, -1}]};
Print[x1 - (x2+x3) //Simplify //InputForm]
(* 0 *)
Inf = Infinity;
{x1 = Sum[ f[i], {i, k-1, Inf}],
x2 = Sum[ f[i], {i, 0, Inf}],
x3 = Sum[ f[i], {i, k-1, -1}]};
Print[x1 - (x2+x3) //Simplify //InputForm]
(* -3 + 2*z - z^2/2 + (3 + z)/E^z *)

The bug is due to nonzero values of Binomial[n, m] for n<0 and infinite summation.


NEW answer:

As 'azerbajdzan' commented, the bug is elsewhere. I tracked it down to:

ClearAll[f, z, j, k, s];
j = 1; k = -2;
f[i_] := ((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i];
s[m_] := Sum[ f[i], {i, m, Infinity}];
Do[Print["m=", m, " ", s[m] //InputForm], {m, -3, -1}];
s1 = s[-3]; s2 = f[-3] + f[-2] + s[-1];
Print[{s1, s2, s1-s2} //Simplify //InputForm]
(* m=-3 -1/2*(-2 + 6*E^z - 4*E^z*z + E^z*z^2)/E^z *)
(* m=-2 Sum[((1 + i)*(-z)^(3 + i))/(3 + i)!, {i, -2, Infinity}] *)
(* m=-1 -((2 - 2*E^z + z + E^z*z)/E^z) *)
(* {-3 + E^(-z) + 2*z - z^2/2, -((2 + z)/E^z), -3 + 2*z - z^2/2 + (3 + z)/E^z} *)

Note that s1 and s2 should have been equal to each other but are not. This is a bug. Also note that the s[-2] infinite sum is not summed, but that s[-3] is, although incorrectly.

$\endgroup$
3
  • 3
    $\begingroup$ OP did not say he wants Binomial[n, m]=0 for n<0. He is fine with definition that Mathematica uses for negative arguments. So your argument that binomial should be zero is irrelevant. The bug is elsewhere. $\endgroup$ Commented Aug 16 at 7:01
  • $\begingroup$ @azerbajdzan Thanks for that comment! I will have to fix my answer now. $\endgroup$
    – Somos
    Commented Aug 16 at 12:17
  • 1
    $\begingroup$ @azerbajdzan Exactly, thank you for sparing me the trouble. I want the binomial as generic as possible, fully generic. $\endgroup$
    – ThomasJr
    Commented Aug 17 at 7:38
3
$\begingroup$

Using AsymptoticSumyou get expected result

j = 1; k = -2;  {
asy1 = AsymptoticSum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], {i, k - 1, inf}, inf -> Infinity], 
asy2 = AsymptoticSum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], {i, 0, inf}, inf -> Infinity], 
x3 = Sum[((-z)^(i - k + 1)/(i - k + 1)!)*Binomial[j + i, i], {i,k - 1, -1}] ,asy1-(asy2+x3)}
(*{-2 E^-z - E^-z z, 2 - 2 E^-z - z - E^-z z, -2 + z, 0}*)

As @azerbajdzan mentions the first sum x1 is incorrect(don't know why).

$\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.