Series sum approximation

Since there is no closed formula, as far as I know, to find the sum of

$$\sum _{n=2}^{\infty } \frac{(-1)^n}{\sqrt{\log (n)}}$$

I used //N to find an approximation and Mathematica gave me 0.69024445098278 in 0.04 seconds. The problem is that the given series converges SO slowly that an error less than 0.001 requires adding about $$3\times 10^{434294}$$ terms!

How does Mathematica manage to give fine approximations of series like this one?

Writing:

NSum[(-1)^n/Sqrt[Log[n]], {n, 2, Infinity}, Method -> "AlternatingSigns"]


I get:

0.690243

which is what you want.

In particular, directly from Numerical Evaluation of Sums and Products you read:

The way NSum works is to include a certain number of terms explicitly, and then to try and estimate the contribution of the remaining ones. There are three approaches to estimating this contribution. The first uses the Euler–Maclaurin Method, and is based on approximating the sum by an integral. The second method, known as the Wynn's Epsilon Method, samples a number of additional terms in the sum, and then tries to fit them to a polynomial multiplied by a decaying exponential. The third approach, useful for alternating series, uses an alternating signs method (cf. Euler's Series Transform); it also samples a number of additional terms and approximates their sum by the ratio of two polynomials (Padé Approximation; cf. Convergence Acceleration of Alternating Series).

The links I've added them are not present in the official guide.

In light of all this, given a convergent alternating series with sum \begin{aligned} S = \sum_{n = n_{min}}^{\infty} (-1)^n\,a_n \end{aligned}, I can define the Euler's transformation (1755) as \begin{aligned} S \approx \sum_{n = n_{min}}^{n_{max}} \frac{b_n}{2^{n + 1}} \end{aligned} (Knopp, 1990) committing a maximum error $$R_{max} = \left|\frac{b_{n_{max}}}{2^{n_{max}}}\right|$$, where \begin{aligned} b_n := \sum_{m = n_{min}}^n (-1)^m\,\binom{n}{m}\,a_m \end{aligned}. Now, writing in MMA:

EulerTransformation[nmin_, nmax_] :=
Module[{b, m, n},
b[n_] = Sum[(-1)^m Binomial[n, m] a[m], {m, nmin, n}];
{Chop[NSum[b[n]/2^(n + 1), {n, nmin, nmax}]],
ScientificForm[N[Abs[b[nmax]/2^nmax]]]}
];

a[n_] := 1/Sqrt[Log[n]];

EulerTransformation[2, 24]


I get the sum and the maximum error committed:

{0.690243, 2.68419*10^-6}

for $$n_{max} = 24 \ll 3 \cdot 10^{434294}$$.

Can you do better? The answer is yes and lies in the method of Henri Cohen, Fernando Rodriguez Villegas and Don Zagier (2000), above linked, on Convergence Acceleration of Alternating Series.

In particular, writing in MMA:

CohenVillegasZagierMethod[nmin_, nmax_] :=
Module[{b, c, d, n, s},
d = ((3 + Sqrt[8])^nmax + (3 - Sqrt[8])^nmax)/2;
b = -1;
c = -d;
s = 0;
Table[c = b - c;
s = s + c a[n + nmin] (-1)^nmin;
b = (n + nmax) (n - nmax) b/((n + 1/2) (n + 1)),
{n, 0, nmax - 1}];
{Chop[N[s/d]], ScientificForm[N[Abs[s/d^2]]]}
];

a[n_] := 1/Sqrt[Log[n]];

CohenVillegasZagierMethod[2, 8]


I get the sum and the maximum error committed:

{0.690244, 1.03663*10^-6}

for $$n_{max} = 8 < 24 \ll 3 \cdot 10^{434294}$$.

• Great! I got 14 correct decimals of Pi with 50 iterations using (-1)^(n+1)/(2n-1) – Raffaele Jun 26 '17 at 16:47

Using identity: $$\int_0^{\infty } \frac{2 n^{-t^2}}{\sqrt{\pi }} \, dt=\frac{1}{\sqrt{\log (n)}}$$ and then:

SUM = Sum[(-1)^n*(2 n^-t^2)/Sqrt[π], {n, 2, Infinity}] // Expand

(*2/Sqrt[π] - (2 Zeta[t^2])/Sqrt[π] + (2^(2 - t^2) Zeta[t^2])/Sqrt[π] *)

NIntegrate[SUM, {t, 0, 1, Infinity}, Method -> "PrincipalValue", WorkingPrecision -> 100]

(* 0.6902444509827817592722818703896943268934565604750857324852809551957617912451978141496673702035964490 *)