# Computing a binomial series

How can I compute the following series:

Module[{n = 10^6},
Sqrt[n] * (4^-n) * NSum[Binomial[2*n - 1, n - k]/((2 k - 1)^2 + Pi^2), {k, 1, n}]]


including the cases where n=10^7 and n=10^8?

While trying to compute the first variant, I get the following message from Mathematica 9:

"SequenceLimit::seqlim: The general form of the sequence could not be determined, and the result may be incorrect."

• Your code with n=10^6 results in 0.07008325392226862. n=10^7 in 0.07012898456782017. No messages. – Sander Nov 12 '14 at 14:34

Not an answer to your original question regarding the proper use of NSum, but I'd like to point out that Mathematica can return a symbolic result in this case for arbitrary $n$:

Sqrt[n]/4^n Sum[Binomial[2*n - 1, n - k]/((2 k - 1)^2 + Pi^2), {k, 1, n}]


which produces

$$\frac{2^{-2 n-1} \sqrt{n} \binom{2 n-1}{n-1} \left((\pi -i) \, _3F_2\left(1,1-n,\frac{1}{2}-\frac{i \pi }{2};n+1,\frac{3}{2}-\frac{i \pi }{2};-1\right)+(\pi +i) \, _3F_2\left(1,1-n,\frac{1}{2}+\frac{i \pi }{2};n+1,\frac{3}{2}+\frac{i \pi }{2};-1\right)\right)}{\pi +\pi ^3}.$$

Unfortunately, evaluation of HypergeometricPFQ is very slow at large values of n, so this is not too helpful.

What's the exact version of your Mathematica? On v9.0.1, Win 64bit, I can't reproduce the warning with n=10^6 or n=10^7 or n=10^8. According to this answer, SequenceLimit::seqlim is a evidence that NSum has chosen method "WynnEpsilon", but according to the timing and memory usage, NSum probably choose "EulerMaclaurin" when solving your specific problem. Anyway, I managed to get the warning by raising n to 10^10 and explicitly setting Method to "WynnEpsilon":

\$Version
Module[{n = 10^10},
Sqrt[n]*(4^-n)*
NSum[Binomial[2*n - 1, n - k]/((2 k - 1)^2 + Pi^2), {k, 1, n},
Method -> "WynnEpsilon"]] // AbsoluteTiming And the warning will disappear if I set a higher WorkingPrecision:

Module[{n = 10^10},
Sqrt[n]*(4^-n)*
NSum[Binomial[2*n - 1, n - k]/((2 k - 1)^2 + Pi^2), {k, 1, n},
Method -> "WynnEpsilon", WorkingPrecision -> 30]] // AbsoluteTiming 