Minimum number of terms to approximate $\pi=4\sum_{n=1}^\infty\frac{(-1)^{n-1}}{2n-1}$

247 Views Asked by At

Consider the Leibniz formula for $\pi$ $$ \pi=4\sum_{n=1}^\infty\frac{(-1)^{n-1}}{2n-1}. $$ What is the minimum number of terms needed to calculate $\pi$ accurate to $k$ decimal places?

My attempt: Let's consider $k=2$ decimal places for example and set $a_n=\frac{4}{2n-1}$. One way to think about this is to consider the remainder of the series and simply use $$ |R_n|\leq a_{n+1}\Leftrightarrow |R_n|\leq \frac{4}{2n+1}\leq 10^{-2} $$ which holds for $n\geq 200$. Alternatively, Calabrese's error bound yields $$ \frac{a_{n+1}}{2} < |R_n| < \frac{a_n}{2}\Leftrightarrow \frac{2}{2n+1} < |R_n| < \frac{2}{2n-1} $$ which leads to $99.5<n<100.5$ and thus $n=100$, a refined number. Indeed, either term order satisfies $$ \begin{align} R_{200}&=4\sum_{n=201}^\infty\frac{(-1)^{n-1}}{2n-1}\simeq 0.004999968751 \leq 10^{-2}\\ R_{100}&=4\sum_{n=101}^\infty\frac{(-1)^{n-1}}{2n-1}\simeq 0.009999750031 \leq 10^{-2} \end{align} $$ However, the partial sums give $$ \begin{align} S_{200}&=4\sum_{n=1}^{200}\frac{(-1)^{n-1}}{2n-1}\simeq 3.136592685\\ S_{100}&=4\sum_{n=1}^{100}\frac{(-1)^{n-1}}{2n-1}\simeq 3.131592904 \end{align} $$ which are not accurate to two decimal places ($\pi\simeq 3.14...$). In fact, the minimum value of $n$ I found (computationally) that gives an accuracy to two decimal places was $n=119$. Indeed, $$ \begin{align} S_{119}&=4\sum_{n=1}^{119}\frac{(-1)^{n-1}}{2n-1}\simeq 3.149995867\\ R_{119}&=4\sum_{n=120}^{\infty}\frac{(-1)^{n-1}}{2n-1}\simeq -0.008403213004 \end{align} $$ Is there an analytical way of determining the minimum number of terms for any accuracy $k$?

Comment: Out of curiosity, I have calculated the first $10$ minima for "accuracies" $k=0,...,9$. Respectively, I got $$ (3,19,119,167,10794,136121,1530012,18660304,155973051,1700659132) $$ On a log plot, we get

enter image description here

2

There are 2 best solutions below

1
On

I doubt the problem can be solved precisely. But some estimates can be obtained. Let's focus on the approximation from below. We have $$4\sum_{k=1}^{2n}\frac{(-1)^{k-1}}{2k-1}=4\sum_{k=1}^n\left ({1\over 4k-3}-{1\over 4k-1}\right )\\ =8\sum_{k=1}^n\frac{1}{(4k-3)(4k-1)} $$ The error is less than the $(2n+1)$th term of the original series i.e. $4/(4n+1).$ The actual error $E$ is equal $$8\sum_{k=n+1}^\infty\frac{1}{(4k-3)(4k-1)}>8\sum_{k=n+1}^{2n}\frac{1}{(4k-3)(4k-1)}>{8n\over (8n-3)(8n-1)}>{1\over 8n}$$ Thus $${1\over 8n}<E<{1\over n}$$ Hence if we want the error $E$ satisfies $10^{-N-1}<E< 10^{-N}$ we need $$ 10^N\le n\le 10^{N+1}/8$$ Similar analysis can be made for approximation from below.

0
On

It is known that the remainder in the Leibniz series possesses an asymptotic expansion of the form $$ \left| {\pi - 4\sum\limits_{k = 1}^N {\frac{{( - 1)^{k - 1} }}{{2k - 1}}} } \right| \sim \frac{1}{N} - \frac{1}{{4N^3 }} + \frac{5}{{16N^5 }} - \ldots $$ as $N\to +\infty$. Assume that $$ \left| {\pi - 4\sum\limits_{k = 1}^N {\frac{{( - 1)^{k - 1} }}{{2k - 1}}} } \right| = \varepsilon $$ for some small $\varepsilon>0$. Then by series reversion $$ \frac{1}{N} \sim \varepsilon + \frac{1}{4}\varepsilon ^3 - \frac{1}{8}\varepsilon ^5 + \ldots , $$ and thus $$ N \sim \frac{1}{\varepsilon } - \frac{1}{4}\varepsilon + \frac{3}{{16}}\varepsilon ^3 + \ldots $$ as $\varepsilon \to 0^+$.

This might also be of interest for you.