# Failed to use N[%] for a infinite series

I am trying to evaluate a infinite series: $$2 \sum _{l=1}^{\infty } \Re\left(n^{\frac{2 i \pi l}{\log (q)}} \Gamma \left(\alpha -\frac{2 i l \pi }{\log (q)}\right)\right)$$ With the code:

delta[\[Alpha]_, q_, n_] =
2 Sum[Re[Gamma[\[Alpha] - I 2 l \[Pi]/Log[q]] Exp[
I 2 l \[Pi] Log[n]/Log[q]]], {l, 1, Infinity}]
delta[1,10,10]
N[%]


But Mathematica complaints:


NSum::nsnum: Summand (or its derivative) ((0. +3.14159 I) 2.^(1. +(0. +2.72875 I) l) 5.^((0. +2.72875 I) l) Gamma[1. -(0. +2.72875 I) l]-(0. +1.36438 I) 2.^(1. +(>) l) > Gamma[1. -(0. +>) l] PolyGamma[0.,1. -(0. +2.72875 I) l]) > is not numerical at point l = 16.


Using Mathematica 10.0.2.0, I do not receive the error message you did. However, Sum returns unevaluated, which happens when Sum cannot do the summation. Since you are seeking a numerical answer, I suggest that you use a large upper bound on your Sum instead of Infinity. For instance,

delta[\[Alpha]_, q_, n_] := 2 Sum[Re[Gamma[\[Alpha] - I 2 l \[Pi]/Log[q]]
Exp[I 2 l \[Pi] Log[n]/Log[q]]], {l, 1, 100}];
N[delta[1, 10, 10]]
(* 0.0818184 *)


Incidentally, I tried NSum instead, but it did not return an answer in a reasonable time.

• Thank you for trying the code. Maybe I am too greed to let Mathematica to compute the infinite sum. You're right, I am trying a bigger upper bound now. By the way, I am using Mathematica 9.0.1.0 Thanks very much! – robit Jan 20 '15 at 8:29
Clear[delta]

delta[\[Alpha]_?NumericQ, q_?NumericQ, n_?NumericQ] :=
Module[
{z = I 2.0 l \[Pi]/Log[q]},
Re[2 NSum[Gamma[\[Alpha] - z] n^z,
{l, 1, Infinity}]]];

delta[1, 10, 10]


0.0818184

• It does work! And produce the answer in a reasonable time,While The code of @bbgodfrey did not. But why is the use of Module accelerate the calculation of Nsum? Because the compact expression with local variable z? – robit Jan 21 '15 at 6:24
• The compact form (reuse of sub calculation of local variable z) helps to speed the calculation up; however, the major cause of the speed up is doing the calculation with approximate real numbers rather than exact numbers and using NSum rather than Sum`. – Bob Hanlon Jan 21 '15 at 13:39