0

Context: I recently discovered the formula for $\pi$ by Machin, $$\frac{\pi}{4} = 4\arctan \left(\frac15 \right) - \arctan{\left(\frac1{239} \right)}$$ In order to apply this formula, I used the Taylor series expansion for $\arctan x $ to create the following fixed-precision formula for $\frac{\pi}{4}$: $$ a(x) = \lim_{N\to\infty} \sum_{n=0}^N \frac{(-1)^n x^{2n+1}}{2n+1} \\ \implies \frac{\pi}{4} = 4a\left(\frac15 \right) - a \left(\frac{1}{239}\right)$$

I found that this was quite a useful computational formula: $N = 0$ already yields 1 correct decimal place, $N = 1$ yields 3 decimal places, $N = 2$ still yields 3 decimal places, and $N = 5$ yields 5 correct decimal places. Now I can't help but wonder: what's the pattern? Can I construct some explicit sequence $d(N)$ that returns the amount of correct decimal places for every $N$?

edit: removed superfluous example at the beginning

Mailbox
  • 896

1 Answers1

1

It is simple with alternating series.

Taking the case of $$\frac 1 {e^x}= \sum_{n=0}^\infty (-1)^n\,\frac{x^n}{n!}= \sum_{n=0}^{p-1} (-1)^n\,\frac{x^n}{n!}+ \sum_{n=p}^\infty (-1)^n\,\frac{x^n}{n!}$$ So, you want to know $p$ such that $$R_p=\frac {x^p}{p!} \leq 10^{-k}\qquad \implies \qquad p! \geq x^p\,10^k$$

If you look at this old question of mine, @robjohn proposed an almost exact solution $$\color{blue}{p\sim ex\exp\left(\operatorname{W}\left(\frac k{ex}\log(10)-\frac1{2ex}\log(2\pi x)\right)\right)-\frac12}$$ where $W(.)$ is Lambert function. For sure, as usual, you will use $\lceil p\rceil$.

If we use $x=1$, this gives $$p\sim \exp\left(1+\operatorname{W}\left(\frac 1{2e}\log \left(\frac{10^{2 k}}{2 \pi }\right)\right)\right)-\frac 12$$

Using for example $k=100$, this gives as a real $p=69.95744$ while the exact solution would be $p=69.95757$. So, $p=70$.

Checking $$R_{69}=5.84377\times 10^{-99} \quad \gt ~10^{-100}$$ $$R_{70}=8.34824\times 10^{-101}\quad \lt ~10^{-100}$$

If you cannot access Lambert function, for large arguments, use the series expansion given in the Wikipedia page $$W(t)=L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\frac{L_2(6-9L_2+2L_2^2)}{6L_1^3}+\cdots$$ where $L_1=\log(t)$ and $L_2=\log(L_1)$.

For the worked case, using the above truncated series would give $W(.)=3.29157$ (and then $p=73$) while the exact value is $W(.)=3.25501$.