Algebraic manipulation of these equations yields the following:
(2)
if
All of the Machin-like formulae can be derived by repeated application of equation 2. As an example, we show the derivation of Machin's original formula:
An insightful way to visualize equation 2 is to picture what happens when two complex numbers are multiplied together:
(3)
The angle associated with a complex number is given by:
Thus, in equation 3, the angle associated with the product is:
Note that this is the same expression as occurs in equation 2. Thus equation 2 can be interpreted as saying that the act of multiplying two complex numbers is equivalent to adding their associated angles (see multiplication of complex numbers).
Here is an arbitrary constant that accounts for the difference in magnitude between the vectors on the two sides of the equation. The magnitudes can be ignored, only the angles are significant.
Using complex numbers
Other formulas may be generated using complex numbers. For example, the angle of a complex number is given by and, when one multiplies complex numbers, one adds their angles. If a=b 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,
Two-term formulas
In the special case where , there are exactly four solutions having only two terms.[2] These are
In the general case, where the value of is not restricted, there are infinitely many other solutions. For example:
(5)
Example
The adjacent diagram demonstrates the relationship between the arctangents and their areas. From the diagram, we have the following:
More terms
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 Hitachisupercomputer with 1 terabyte of main memory, performing 2 trillion operations per second. The following two equations were both used:
The most efficient currently known Machin-like formula pair discovered by Hwang Chien-Lih (黃見利) (2004) for computing π are:
The most efficient currently known Machin-like formulas for computing π are:
(Hwang Chien-Lih, 1997)
(Hwang Chien-Lih, 2003)
(M. Wetherfield, 2004)
Efficiency
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 be the number of digits to which is to be calculated.
Let be the number of terms in the Taylor series (see equation 4).
Let be the amount of time spent on each digit (for each term in the Taylor series).
The Taylor series will converge when:
Thus:
For the first term in the Taylor series, all digits must be processed. In the last term of the Taylor series, however, there's only one digit remaining to be processed. In all of the intervening terms, the number of digits to be processed can be approximated by linear interpolation. Thus the total is given by:
The run time is given by:
Combining equations, the run time is given by:
Where is a constant that combines all of the other constants. Since this is a relative metric, the value of can be ignored.
The total time, across all the terms of equation 1, is given by:
cannot be modelled accurately without detailed knowledge of the specific software. Regardless, we present one possible model.
The software spends most of its time evaluating the Taylor series from equation 4. The primary loop can be summarized in the following pseudo code:
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. is defined to be four.
Note, however, that if is equal to one, then step one can be skipped. The loop only takes three units of time. is defined to be three.
As an example, consider the equation:
(6)
The following table shows the estimated time for each of the terms:
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 5. The following table shows the estimated time for each of the terms:
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 6 is slightly faster than equation 5, regardless of the fact that equation 6 has more terms. This result is typical of the general trend. The dominant factor is the ratio between and . In order to achieve a high ratio, it is necessary to add additional terms. Often, there is a net savings in time.
References
^Beckmann, Petr (1971). A History Of Pi. USA: The Golem Press. p. 102. ISBN0-88029-418-3.