0
$\begingroup$

I have the following two-fold summation.

lim = 300;
Sum[((-1)^(n1 + n2) Gamma[5 + n1] (0.1)^(-1 - n1/5) (0.1)^(-1 - n2))/(
 5 Gamma[1 + n1] Gamma[29/3 + n1 + n2]), {n1, 0, lim}, {n2, 0, lim}]

which works fine and gives the correct numerical result 0.000577481. But now if I increase the summation upper-limit to 400, then Mathematica shows Indeterminant and Complex Infinity encountered. This is not expected because no terms between lim=300 and 400 blows up.

This is a possible issue with internal default numerical precision. Hence, I tried to increase $MaxExtraPrecision and $MaxPrecision as follows,

lim = 400;
Sum[Block[{$MaxExtraPrecision = Infinity, $MaxPrecision = Infinity}, 
  N[((-1)^(n1 + n2) Gamma[5 + n1] (0.1)^(-1 - n1/5) (0.1)^(-1 - n2))/(
    5 Gamma[1 + n1] Gamma[29/3 + n1 + n2]), Infinity] // Quiet], {n1, 
  0, lim}, {n2, 0, lim}]

But still, the same error persists.

Any reason for this behaviour, and what is the solution to this?

$\endgroup$
2
  • $\begingroup$ I think that Simplify might give a more stable version of your summand. Both your numerator and denominator are going to be very large. $\endgroup$
    – mikado
    Sep 3 '21 at 13:02
  • $\begingroup$ You can use 1/10 instead of 0.1 and get an exact answer. N[answer, precision] will give the decimal value to precision digits. $\endgroup$
    – Michael E2
    Sep 4 '21 at 21:12
1
$\begingroup$
Clear["Global`*"]

Instead of machine precision (0.1), use arbitrary-precision (0.1`20)

expr = ((-1)^(n1 + n2) Gamma[
      5 + n1] (0.1`20)^(-1 - n1/5) (0.1`20)^(-1 - n2))/(5 Gamma[1 + n1] Gamma[
      29/3 + n1 + n2]);

sum[lim_] := Sum[expr, {n1, 0, lim}, {n2, 0, lim}]

sum[400]

(* 0.00057748068405058200 *)

Precision[%]

(* 17.5845 *)

sum[500]

(* 0.00057748068405058200 *)

Precision[%]

(* 17.5845 *)

sum[Infinity]

(* 0.00057748068405058199972 + 0.*10^-24 I *)

Precision[%]

(* 20. *)

You can remove the imaginary artifact with Chop

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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