4

Looking at Machin's formulas in this post Machin's formulas and cousins, and digging a bit, I've finally computed the next formulas, allowing to generate an infinite number of 2-terms Machins's formulas easily and that seem quite efficient to compute $\pi$:

Let $a1,a2,n \in \mathbb{N}^+$ such that: $$ \frac{\pi }{4}=n\times \text{arctan}\left(\frac{1}{\text{a1}}\right)+\text{arctan}\left(\frac{1}{\text{a2}}\right)\qquad\qquad(1) $$ And two sums $s1$, $s2$ such that: $$ \text{s1}(a,n)=\sum _{k=0}^{\left\lfloor \frac{n}{2}\right\rfloor } (-1)^k\left(\begin{array}{c} n \\ 2k+1\end{array}\right)a^{2k+1} $$ $$ \text{s2}(a,n)=\sum _{k=0}^{\left\lfloor \frac{n}{2}\right\rfloor } (-1)^k\left(\begin{array}{c} n \\ 2k\end{array}\right)a^{2k} $$ Then for any given $a1$ and $n$, you can compute $a2$ as follows: $$ \text{a2}=(-1)^{n+1}\left(\frac{\text{s1}(a1,n)+\text{s2}(a1,n)}{\text{s1}(a1,n)-\text{s2}(a1,n)}\right)^{(-1)^{n+1}} $$ Even if you can freely choose any given integer $n$, the best way is to compute $n$ as follows: $$ n=\left\lfloor \frac{\pi }{4\arctan \left(\frac{1}{\text{a1}}\right)}\right\rfloor $$ But remenber, $n$'s value is just a hint (a rounded integer value), so you can compute it using for example $\pi=3.14$ and only a few terms of the classic $arctan$ series (see formula $(2)$ below) to get a quick guess.

So, this is it:

choose any integer $a1$, then compute $n$ and finally $a2$. You can then use formula $(1)$ to get a $\pi/4$ approximation, using the classic $arctan$ series below (or any other...): $$ \text{arctan}(x,n)=\sum _{k=0}^n \frac{(-1)^k}{2k+1}x^{2k+1}\qquad\qquad(2) $$

Here is the Mathematica code where you can see that even with small $a1$ value ($a1=10$) and using only $nt=10$ terms to compute the classic $arctan$ series $(2)$, you already get a $10^{-24}$ precision result:

pi/4 code

Clear[k,n,a,f,g];
Manipulate[
Block[{atan,k,n,n1,a,a2,a3,s1,s2,f,g,h1},
$MaxPrecision=5*prec;
Nn[x_]:=N[x,prec];

atan[x_,n_]:=Sum[(-1)^k*x^(2*k+1)/(2*k+1),{k,0,n}];
n1=Floor[Pi/4/ArcTan[1/a1]];

s1[a_,n_]:=Sum[Binomial[n,2k+1]*a^(2k+1)*(-1)^(k),{k,0,Floor[n/2]}];
s2[a_,n_]:=Sum[Binomial[n,2k]*a^(2*k)*(-1)^(k),{k,0,Floor[n/2]}];

a2[a_,n_]:=(-1)^(n+1)*((s1[a,n]+s2[a,n])/(s1[a,n]-s2[a,n]))^((-1)^(n+1));

Grid[{
{"a1",a1},
{"n1",n1},
{"a2",Row@{a3=a2[a1,n1],"=",a3//Nn}},
{Pi/4,Pi/4//Nn},
{"ArcTan sum",h1=n1*ArcTan[1/a1]+ArcTan[1/a3];Row[{Pi/4,"=",h1,"=",h1//Nn}]},
{"ArcTan sum using\natan series with nt terms",h1=n1*atan[1/a1,nt]+atan[1/a3,nt];h1//Nn},
{Row@{"diff with ",Pi/4},h1-Pi/4//Nn}
},Frame->All]
]
,{{prec,30},1,100,1,Appearance->"Open"}
,{{nt,10},1,50,1,Appearance->"Open"}
,{{a1,10},1,100,1,Appearance->"Open"}
]

So as $a1$ goes to Infinity, the result gets closer to $\pi/4$.

You can also increase the number of steps used to compute the classic $arctan$ series (see formula $(2)$), number corresponding to the $nt$ variable in the above code, which drastically improves the result.

For what I know, the formula seems pretty efficient to get a $\pi$ approximation when using larger $a1$ value, even if you're using only a few terms to compute the $arctan$ series.

So finally my question: is this kind of formula already known? Also, how can I evaluate the formula's efficiency? To say the truth, I don't see why formulas with more $arctan$ terms should be more efficient: with this formula, you can arbitrarily choose the precision by choosing larger $a1$ value (which also guarantees that $arctan(1/a2)$ will be smaller than $arctan(1/a1)$), as of course the number of terms used to compute the $arctan$ series. So theoretically, we could get a better formula than any existing Machin's formula...

  • Since this is only a partial answer, I'll just comment: You can evaluate a formula's efficiency by looking at how many digits of pi (in whatever base) are added with each term in the arctan series. – Carl Schildkraut Jun 06 '16 at 03:10

0 Answers0