In mathematics, Machin-like formulas are a popular technique for computing (the ratio of the circumference to the diameter of a circle) to a large number of digits. They are generalizations of John Machin's formula from 1706:
\pi | |
4 |
=4\arctan
1 | |
5 |
-\arctan
1 | |
239 |
which he used to compute to 100 decimal places.[1] [2]
Machin-like formulas have the form
where
c0
cn
an
bn
an<bn
These formulas are used in conjunction with Gregory's series, the Taylor series expansion for arctangent:
The angle addition formula for arctangent asserts that
ifAll of the Machin-like formulas can be derived by repeated application of equation . As an example, we show the derivation of Machin's original formula one has:and consequentlyTherefore alsoand so finally
An insightful way to visualize equation is to picture what happens when two complex numbers are multiplied together:
(b1+a1i) ⋅ (b2+a2i)
=b1b2+a2b1i+a1b2i-a1a2
The angle associated with a complex number
(bn+ani)
\arctan
an | |
bn |
Thus, in equation, the angle associated with the product is:
\arctan
a1b2+a2b1 | |
b1b2-a1a2 |
Note that this is the same expression as occurs in equation . Thus equation can be interpreted as saying that multiplying two complex numbers means adding their associated angles (see multiplication of complex numbers).
The expression:
cn\arctan
an | |
bn |
is the angle associated with:
(bn+an
cn | |
i) |
Equation can be re-written as:
k ⋅ (1+
c0 | |
i) |
=
N | |
\prod | |
n=1 |
(bn+an
cn | |
i) |
Here
k
Other formulas may be generated using complex numbers.[3] For example, the angle of a complex number is given by and, when one multiplies complex numbers, one adds their angles. If then is 45 degrees or radians. This means that if the real part and complex part are equal then the arctangent will equal . Since the arctangent of one has a very slow convergence rate if we find two complex numbers that when multiplied will result in the same real and imaginary part we will have a Machin-like formula. An example is and . If we multiply these out we will get . Therefore, .
If you want to use complex numbers to show that you first must know that when multiplying angles you put the complex number to the power of the number that you are multiplying by. So and since the real part and imaginary part are equal then,
One of the most important parameters that characterize computational efficiency of a Machin-like formula is the Lehmer's measure, defined as[4] [5]
{\it{λ}}=
N | |
\sum | |
n=1 |
1 | |
log10(bn/an) |
an/bn
an=1
λ ≈ 1.51244
an=1~.
In the special case where the numerator
an=1
Euler's 1737 (known to Machin 1706):[9] [10]
\pi | |
4 |
=\arctan
1 | |
2 |
+\arctan
1 | |
3 |
Hermann's 1706 (known to Machin 1706):[11] [10]
\pi | |
4 |
=2\arctan
1 | |
2 |
-\arctan
1 | |
7 |
Hutton's or Vega's (known to Machin 1706):[8] [10]
\pi | |
4 |
=2\arctan
1 | |
3 |
+\arctan
1 | |
7 |
\pi | |
4 |
=4\arctan
1 | |
5 |
-\arctan
1 | |
239 |
In the general case, where the value of a numerator
an
\pi | |
4 |
=22\arctan
1 | |
28 |
+\arctan
1744507482180328366854565127 | |
98646395734210062276153190241239 |
The adjacent diagram demonstrates the relationship between the arctangents and their areas. From the diagram, we have the following:
\begin{array}{ll} {\rmarea}(PON)&={\rmarea}(MOF)=\pi x
\angleMOF | |
2\pi |
=\angleMEF=\arctan{1\over2}\\ {\rmarea}(POM)&={\rmarea}(NOF)=\arctan{1\over3}\\ {\rmarea}(POF)&={\pi\over4}=\arctan{1\over2}+\arctan{1\over3}\\ {\rmarea}(MON)&=\arctan{1\over7}\\ \arctan{1\over2}&=\arctan{1\over3}+\arctan{1\over7}, \end{array}
(3+i)(7+i)=21-1+(3+7)i=10 ⋅ (2+i).
The 2002 record for digits of, 1,241,100,000,000, was obtained by Yasumasa Kanada of Tokyo University. The calculation was performed on a 64-node Hitachi supercomputer with 1 terabyte of main memory, performing 2 trillion operations per second. The following two equations were both used:
\pi | |
4 |
=12\arctan
1 | |
49 |
+32\arctan
1 | |
57 |
-5\arctan
1 | |
239 |
+12\arctan
1 | |
110443 |
Kikuo Takano (1982).
\pi | |
4 |
=44\arctan
1 | |
57 |
+7\arctan
1 | |
239 |
-12\arctan
1 | |
682 |
+24\arctan
1 | |
12943 |
F. C. M. Størmer (1896).
Two equations are used so that one can check they both give the same result; it is helpful if the equations reuse some but not all of the arctangents because those need only be computed once - note the reuse of 57 and 239 above.
Machin-like formulas for can be constructed by finding a set of numbers where the prime factorisations of together use no more distinct primes than the number of elements in the set, and then using either linear algebra or the LLL basis-reduction algorithm to construct linear combinations of arctangents
\arctan\tfrac{1}{bn}
bn
572+1=2 ⋅ 53 ⋅ 13
2392+1=2 ⋅ 134
6822+1=53 ⋅ 612
129432+1=2 ⋅ 54 ⋅ 133 ⋅ 61
so four terms using between them only the primes 2, 5, 13 and 61.
In 1993 Jörg Uwe Arndt[12] found the 11-term formula:
\begin{align} | \pi |
4 |
=& 36462\arctan
1 | |
390112 |
+135908\arctan
1 | |
485298 |
+274509\arctan
1 | |
683982 |
\\ &-39581\arctan
1 | |
1984933 |
+178477\arctan
1 | |
2478328 |
-114569\arctan
1 | |
3449051 |
\\ &-146571\arctan
1 | |
18975991 |
+61914\arctan
1 | |
22709274 |
-69044\arctan
1 | |
24208144 |
\\ &-89431\arctan
1 | |
201229582 |
-43938\arctan
1 | |
2189376182 |
\\ \end{align}
\{2,5,13,17,29,37,53,61,89,97,101\}.
Another formula where 10 of the
\arctan
\begin{align} | \pi |
4 |
=& 36462\arctan
1 | |
51387 |
+26522\arctan
1 | |
485298 |
+19275\arctan
1 | |
683982 |
\\ &-3119\arctan
1 | |
1984933 |
-3833\arctan
1 | |
2478328 |
-5183\arctan
1 | |
3449051 |
\\ &-37185\arctan
1 | |
18975991 |
-11010\arctan
1 | |
22709274 |
+3880\arctan
1 | |
24208144 |
\\ &-16507\arctan
1 | |
201229582 |
-7476\arctan
1 | |
2189376182 |
\\ \end{align}
You will note that these formulas reuse all the same arctangents after the first one. They are constructed by looking for numbers where is divisible only by primes less than 102.
The most efficient currently known Machin-like formula for computing is:
\begin{align} | \pi |
4 |
=& 183\arctan
1 | |
239 |
+32\arctan
1 | |
1023 |
-68\arctan
1 | |
5832 |
\\ &+12\arctan
1 | |
110443 |
-12\arctan
1 | |
4841182 |
-100\arctan
1 | |
6826318 |
\\ \end{align}
(Hwang Chien-Lih, 1997)
where the set of primes is
\{2,5,13,229,457,1201\}.
A further refinement is to use "Todd's Process", as described in;[5] this leads to results such as
\begin{align} | \pi |
4 |
=& 183\arctan
1 | |
239 |
+32\arctan
1 | |
1023 |
-68\arctan
1 | |
5832 |
\\ &+12\arctan
1 | |
113021 |
-100\arctan
1 | |
6826318 |
\\ &-12\arctan
1 | |
33366019650 |
+12\arctan
1 | |
43599522992503626068 |
\\ \end{align}
(Hwang Chien-Lih, 2003)where the large prime 834312889110521 divides the of the last two indices.
M. Wetherfield found 2004
\begin{align} | \pi |
4 |
=& 83\arctan
1 | |
107 |
+17\arctan
1 | |
1710 |
-22\arctan
1 | |
103697 |
\\ &-24\arctan
1 | |
2513489 |
-44\arctan
1 | |
18280007883 |
\\ &+12\arctan
1 | |
7939642926390344818 |
\\ &+22\arctan
1 | |
3054211727257704725384731479018 |
.\\ \end{align}
In Pi Day 2024, Matt Parker along with 400 volunteers used the following formula to hand calculate
\pi
\begin{align} | \pi |
4 |
=& 1587\arctan
1 | |
2852 |
+295\arctan
1 | |
4193 |
+593\arctan
1 | |
4246 |
\\ &+359\arctan
1 | |
39307 |
+481\arctan
1 | |
55603 |
+625\arctan
1 | |
211050 |
\\ &-708\arctan
1 | |
390112 |
\end{align}
It was the biggest hand calculation of
\pi
There are further methods to derive Machin-like formulas for
\pi
\pi | |
4 |
=2k-1 ⋅ \arctan
1 | |
Ak |
+\sum
M | |
\limits | |
m=1 |
\arctan
1 | |
\left\lfloorBk,m\right\rfloor |
+\arctan
1 | |
Bk,M+1 |
,
a0:=0
ak:=\sqrt{2+ak
Bk,1:=
2 | |
\left(\dfrac{Ak+i |
{Ak-i}
2k | |
\right) |
-i
Bk,m:=
1+\left\lfloorBk,m\right\rfloorBk,m | |
\left\lfloorBk,m\right\rfloor-Bk,m |
~.
k=4
M=5
\begin{align} | \pi |
4 |
=& 8\arctan
1 | |
10 |
-\arctan
1 | |
84 |
-\arctan
1 | |
21342 |
\\ &-\arctan
1 | |
991268848 |
-\arctan
1 | |
193018008592515208050 |
\\ &-\arctan
1 | |
197967899896401851763240424238758988350338 |
\\ &-\arctan
1 | |
117573868168175352930277752844194126767991915008537018836932014293678271636885792397 |
\end{align}
\begin{align} z:=&(10+i)8 ⋅ (84-i) ⋅ (21342-i) ⋅ (991268848-i) ⋅ (193018008592515208050-i)\\ & ⋅ (197967899896401851763240424238758988350338-i)\\ & ⋅ (117573868168175352930277752844194126767991915008537018836932014293678271636885792397-i)\\ =&(1+i) ⋅ \Re(z)~. \end{align}
For large computations of
\pi
1/logbn
It is not the goal of this section to estimate the actual run time of any given algorithm. Instead, the intention is merely to devise a relative metric by which two algorithms can be compared against each other.
Let
Nd
\pi
Let
Nt
Let
un
The Taylor series will converge when:
\left(\left( | bn |
an |
\right)2\right)
Nt | |
=
Nd | |
10 |
Thus:
Nt=Nd
ln10 | |||||
|
For the first term in the Taylor series, all
Nd
NdNt | |
2 |
The run time is given by:
time=
unNdNt | |
2 |
Combining equations, the run time is given by:
time=
un{Nd | |
2 |
ln10}{4ln
bn | |
an |
Where
k
k
The total time, across all the terms of equation, is given by:
time=
N | |
\sum | |
n=1 |
un | |||||
|
un
The software spends most of its time evaluating the Taylor series from equation . The primary loop can be summarized in the following pseudo code:
1: term *=
2 | |
{a | |
n} |
2: term /=
2 | |
-{b | |
n} |
3: tmp = term / (2*n+1)
4: sum += tmp
In this particular model, it is assumed that each of these steps takes approximately the same amount of time. Depending on the software used, this may be a very good approximation or it may be a poor one.
The unit of time is defined such that one step of the pseudo code corresponds to one unit. To execute the loop, in its entirety, requires four units of time.
un
Note, however, that if
an
un
As an example, consider the equation:
The following table shows the estimated time for each of the terms:
an | bn |
| ln
| un | time | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
74684 | 14967113 | 200.41 | 5.3003 | 4 | 0.75467 | ||||||
1 | 239 | 239.00 | 5.4765 | 3 | 0.54780 | ||||||
20138 | 15351991 | 762.34 | 6.6364 | 4 | 0.60274 |
The total time is 0.75467 + 0.54780 + 0.60274 = 1.9052
Compare this with equation . The following table shows the estimated time for each of the terms:
an | bn |
| ln
| un | time | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
24478 | 873121 | 35.670 | 3.5743 | 4 | 1.1191 | ||||||
685601 | 69049993 | 100.71 | 4.6123 | 4 | 0.8672 |
The total time is 1.1191 + 0.8672 = 1.9863
The conclusion, based on this particular model, is that equation is slightly faster than equation, regardless of the fact that equation has more terms. This result is typical of the general trend. The dominant factor is the ratio between
an
bn
\overline{\tfrac{16}5-\tfrac4{239}} -\tfrac13\overline{\tfrac{16}{53}-\tfrac4{2393}} +\tfrac15\overline{\tfrac{16}{55}-\tfrac4{2395}} -,\&c.=
Reprinted in Book: Smith, David Eugene . 1929 . A Source Book in Mathematics . McGraw–Hill . William Jones: The First Use of for the Circle Ratio . https://archive.org/details/sourcebookinmath1929smit/page/346/ . 346–347 .