Why the sum of first $1000$ terms of $\sum_{n = 0}^{\infty} \frac{4(-1)^n}{2n+1}$ differs from $\pi$ in only 3rd decimal place.

92 Views Asked by At

So I understand that $$\sum_{n = 0}^{\infty} \frac{4(-1)^n}{2n+1} = \pi\,.$$

I noticed that the sum of the first $1000$ terms differs from $\pi$ by $0.001$ then is correct to the 9th decimal point.

Sum of the first $1000$ terms is $3.1405926538...$

Adding more terms obviously gives closer approximations to $\pi$, but why is the sum of the first $1000$ terms so 'digitally close'?

Edit - I'm talking about the "unusual behaviour" mentioned here. I'd like to understand this to a level I could explain it to A Level students, but that looks unlikely! see also

2

There are 2 best solutions below

0
On BEST ANSWER

Suppose you have a nice smooth decreasing function $f \colon [0,+\infty) \to [0, +\infty)$ such that $$\lim_{x \to +\infty} f(x) = 0$$ and all derivatives $f^{(r)}$, $r \geqslant 1$ are absolutely integrable. Like for example $f(x) = \frac{4}{2x+1} = \frac{2}{x + 1/2}$. Then since $\bigl(f(n)\bigr)_{n \in \mathbb{N}}$ is a monotonic null sequence the series $\sum_{n = 0}^{\infty} (-1)^nf(n)$ converges (Leibniz). For our example it converges to $\pi$. For the difference between the value of the series and the partial sums we have the general bound by the absolute value of the first omitted term. For alternating series in general one cannot do better, but for alternating series where the terms follow a nice rule one can. In particular, if the terms are given by a function with the above properties one can write down a full asymptotic expansion of the difference, i.e. the remainder sums $$R_k := \sum_{n = k}^{\infty} (-1)^nf(n)\,.$$ If we pair up the terms of the remainder, we see that \begin{align} R_k &= (-1)^k\Bigl[\bigl(f(k) - f(k+1)\bigr) + \bigl(f(k+2) - f(k+3)\bigr) + \ldots \Bigr] \\ &= (-1)^k\sum_{m = 0}^{\infty} \int_{k+2m}^{k+2m+1} -f'(x)\,dx \\ &= (-1)^{k+1} \int_k^{\infty} \frac{1 + (-1)^{\lfloor x-k\rfloor}}{2}f'(x)\,dx \\ &= (-1)^k\frac{f(k)}{2} - \int_k^{\infty} \frac{(-1)^{\lfloor x\rfloor}}{2}f'(x)\,dx\,. \end{align}

Now we obtain the asymptotic expansion via repeated integration by parts. For that it is convenient to draw on the Euler–Maclaurin formula, namely the periodic functions obtained from the Bernoulli polynomials, $P_m(x) = B_m(x - \lfloor x\rfloor)$. Using those, we can write $$\frac{(-1)^{\lfloor x\rfloor}}{2} = P_1(x) - 2P_1(x/2)$$ and with $s_m(x) = P_m(x) - 2^mP_m(x/2)$ find $$\int_k^{\infty} \frac{s_m(x)}{m!}f^{(m)}(x)\,dx = -\frac{s_{m+1}(k)}{(m+1)!}f^{(m)}(k) - \int_k^{\infty} \frac{s_{m+1}(x)}{(m+1)!}f^{(m+1)}(x)\,dx$$ by induction.

It remains to determine $s_m(k) = P_m(k) - 2^mP_m(k/2)$ for $m \geqslant 2$. Using the generating function for the Bernoulli polynomials or otherwise one finds $$s_m(k) = (-1)^{k+1}(2^m-1)B_m,$$ where the $B_m$ are the Bernoulli numbers. Thus our expansion \begin{align} R_k &= (-1)^k\frac{f(k)}{2} - \int_k^{\infty} \frac{s_1(x)}{1!}f'(x)\,dx \\ &= (-1)^k \frac{f(k)}{2} + \frac{s_2(k)}{2!}f'(k) + \int_k^{\infty} \frac{s_2(x)}{2!}f''(x)\,dx \\ &= (-1)^k\frac{f(k)}{2} + \frac{s_2(k)}{2}f'(k) - \frac{s_3(k)}{6}f''(k) - \int_k^{\infty} \frac{s_3(x)}{6}f^{(3)}(x)\,dx \end{align} becomes $$R_k = (-1)^k\biggl[\frac{f(k)}{2} - \sum_{r = 1}^m \frac{(2^{2r}-1)B_{2r}}{(2r)!}f^{(2r-1)}(k)\biggr] - \int_k^{\infty} \frac{s_{2m+1}(x)}{(2m+1)!}f^{(2m+1)}(x)\,dx$$ using the fact that the odd indexed Bernoulli numbers with the exception of $B_1 = -\frac{1}{2}$ all vanish.

For our function $f(x) = \frac{2}{x+1/2}$ we have $f^{(r)}(x) = (-1)^r \frac{2\cdot r!}{(x + 1/2)^{r+1}}$ and thus the asymptotic expansion of $R_k$ starts $$(-1)^k\Biggl[ \frac{1}{k+\frac{1}{2}} + \frac{1}{2\bigl(k + \frac{1}{2}\bigr)^2} - \frac{1}{4\bigl(k + \frac{1}{2}\bigr)^4}\Biggr]$$ with the remainder being of order $O(k^{-6})$. Now $$\frac{1}{k+\frac{1}{2}} + \frac{1}{2\bigl(k + \frac{1}{2}\bigr)^2} = \frac{1}{k} - \frac{1}{2k\bigl(k+\frac{1}{2}\bigr)} + \frac{1}{2\bigl(k + \frac{1}{2}\bigr)^2} = \frac{1}{k} - \frac{1}{4k\bigl(k+\frac{1}{2}\bigr)^2}$$ and we see $$R_k = (-1)^k\biggl(\frac{1}{k} - \frac{1}{4k^3} + O(k^{-4})\biggr)\,.$$

In particular if $k = 10^m$, then the $m^{\text{th}}$ digit after the decimal point is one too small, and this is the only wrong one among the first $3m$, provided that the $m^{\text{th}}$ correct digit is not $0$ and the $(3m+1)^{\text{st}}$ is middling enough that no carry spills over. (If carry spills over, it usually affects only the $3m^{\text{th}}$ digit, but it can occasionally propagate farther when we have consecutive $0$s or $9$s. If the $m^{\text{th}}$ digit is $0$, then we get carry at least into the $(m-1)^{\text{st}}$ digit, but digits $m+1$ to $3m$ behave as in the previous case.)

Thus for $k = 1000$ the remainder is positive, and $$\sum_{n = 0}^{999} \frac{4(-1)^n}{2n+1} \approx 3.140592653839793 \approx 3.140592654\,.$$ In the version rounded to $15$ digits after the decimal point, we can see that taking also the $-\frac{1}{4k^3}$ into account actually gives us $15$ correct digits after the decimal point, not only the $12$ suggested by the $O(k^4)$ term. (Using the first three terms of the asymptotic expansion instead of the first two shows that this is no accident.)

0
On

The error term of a partial sum is asymptotic to $\frac{4(-1)^{n+1}}{n}$, so it takes $O(10^k)$ terms to get $k$ digits right. This is an example of logarithmic convergence, typically accelerated with a Shanks transformation.