11
$\begingroup$

In this post, I provided a solution to the integral $$\int_0^{\infty}\left[\int^1_0J_0(v\rho)\cos(\rho^2/2)\rho\,\mathrm{d}\rho \right]^2v\mathrm{d}v$$

However, I found a bug with Sum in my procedure, the following codes show that:

exp=((-1)^(j + k) 2^(-1 - 2 j - 2 k))/((1 + 2 j + 2 k) Gamma[1 + 2 j] Gamma[1 + 2 k]);

Sum[exp, {j, 0, \[Infinity]}, {k, 0, \[Infinity]}]
% // N
(*Sin[1]/4*)
(*0.210368*)

NSum[exp, {j, 0, \[Infinity]}, {k, 0, \[Infinity]}]
(*0.460368 - 1.99638*10^-45 I*)

So is it a bug?

$\endgroup$
1
  • 1
    $\begingroup$ From bugs tag wiki: "Please do not use this tag for new questions." But that said, I think everyone will think it's a a bug, and the tag would be put on in the end. So leave it, unless there is objection. $\endgroup$
    – Michael E2
    Commented May 26 at 19:13

2 Answers 2

7
$\begingroup$

Many times in Sum[], n = 0 seems to be a special case connected with bugs. Separate out j == 0 and k == 0:

exp = ((-1)^(j + k)  2^(-1 - 2  j - 2  k)) /
 ((1 + 2  j + 2  k)  Gamma[1 + 2  j]  Gamma[1 + 2  k]);

Sum[exp, {j, 1, \[Infinity]}, {k, 1, \[Infinity]}] +
   2 Sum[exp /. k -> 0, {j, 0, Infinity}] -
   exp /. {j -> 0, k -> 0} // Expand


(*  1/4 + Sin[1]/4  *)
$\endgroup$
2
  • $\begingroup$ Thanks for the comment on my incorrect answer. Based on your answer, I find Sum[exp, {j, 0, [Infinity]}, {k, 1, [Infinity]}] + Sum[exp /. k -> 0, {j, 0, [Infinity]}] // Expand also works. But seperating j=0 outside does not, although j and k are interchangeable. So it seems the "bug" comes from the first sum(summing k). $\endgroup$
    – metroidman
    Commented May 27 at 13:24
  • $\begingroup$ @metroidman Yes, there are several variations that work. IIRC, I tried Sum[exp, {j, 1, Infinity}, {k, 0, Infinity}] + Sum[exp /. k -> 0, {j, 0, Infinity}] first, which is similar to your example, but does not work and supports your claim of dependence on the first sum. Then I tried the above. Then I fiddled with various combinations. The one above and the similar Sum[exp, {j, 1, \[Infinity]}, {k, 1, \[Infinity]}] + Sum[exp /. k -> 0, {j, 1, Infinity}] + exp /. {j -> 0, k -> 0} // Expand seem fastest. Of the two, I'm not sure why I chose the answer; in hindsight, it seems more complicated. $\endgroup$
    – Michael E2
    Commented May 27 at 14:26
5
$\begingroup$

I guess MMA first do the substitution $j\to n-k$, and then there is a bug of Sum for $n=0$

expr=z^(2 j+2 k)/(Gamma[1+2 j] Gamma[1+2 k])/.j->n-k//Simplify

term=Sum[expr,{k,0,n}]

Table[{term,Sum[expr,{k,0,n}]},{n,0,4}]

Sum[expr,{k,0,n},Assumptions->n==0]

Sum[expr,{k,0,n},Assumptions->n>=0]/.n->0

enter image description here

Sum[1/(Gamma[1+2 k] Gamma[1-2k+n]),{k,0,n}]

Sum[z^(2k)/(Gamma[1+2 k]Gamma[1-2 k+n]),{k,0,n}]

Out[]/.z->1

enter image description here

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