Machin Formulae
There are several approaches to proving Machin's formulae, such as
arctan(1) = 4*arctan(1/5) - arctan(1/239)
Here we consider one which is easy to follow if one is familiar with complex numbers.
Consider z1=a+ib and z2=c+id. One can also write these in the modulus and argument form z1=p*exp(iθ) and z2=q*exp(iφ).
Their product can be written as
z1*z2 = p*q*exp(i(θ+φ))
or
z1*z2 = (ac-bd) + (ad+bc)i
If the product has equal real and imaginary parts, then the argument, which is the sum of the arguments of the factors, will be arctan(1).
As (2+i)(3+i)=(5+5i), then arctan(1/2)+arctan(1/3)=arctan(1)
As (5+i)4(239-i)=(114244+114244i), then 4*arctan(1/5)-arctan(1/239)=arctan(1)
There are just two other solutions with two terms and simple reciprocals.
(2+i)2(7-i)=25+25i, giving 2*arctan(1/2)-arctan(1/7)=arctan(1)
(3+i)2(7+i)=50+50i, giving 2*arctan(1/3)+arctan(1/7)=arctan(1)
These four solutions were all known to Machin.
Alternatively one can write that the sum of the arguments of the factors is equal to the argument of their product:
θ + φ = (θ + φ)
arctan(b/a) + arctan(d/c) = arctan((ad+bc)/(ac-bd))
Then
2*arctan(1/5) = arctan(1/5)+arctan(1/5) = arctan((5+5)/(25-1)) = arctan(5/12)
4*arctan(1/5) = 2*(2*arctan(1/5)) = 2*arctan(5/12) = arctan((60+60)/(144-25)) = arctan(120/119)
arctan(1)-4*arctan(1/5) = arctan(1/1)+arctan(-120/119) = arctan((-120+119)/(119+120)) = arctan(-1/239)
So
4*arctan(1/5)-arctan(1/239)=arctan(1)
Useful
One can note that it is very easy to find Machin formulae. For instance, suppose one wanted something using arctan(1/10), as then the powers of 1/10 are easy to calculate, and each term should add two decimal digits to the convergence.
One can readily calculate arctan(1)/arctan(0.1)=7.88, and conclude that the formula should start with 8*arctan(0.1), and then have a small correction subtracted. Eight is good, as 8*arctan(0.1) can be calculated rapdily by hand as 2*(2*(2*arctan(0.1))).
8*arctan(1/10)=arctan(74,455,920/72,697,201)
Such large numerators and denominators are not at all convenient. The next step, of subtracting the above from arctan(1/1), gives
arctan(1)=8*arctan(1/10)-arctan(1,758,719/147,153,121)
Whilst the series arising from the first term is very easy to compute by hand, that arising from the second is not. Just the first term of the second series is somewhat painful, requiring a division by a nine-digit number. The second term will require a division by a 27-digit number.
The formula with 4*arctan(1/5)-arctan(1/239) is good for serveral reasons. Both numerators are one, simplifying raising these fractions to powers. The largest denominator is only three digits. And, given that the second fraction is a lot smaller than the first, its arctangent series will converge much faster. Although it is tempting to calculate an equal number of terms of both series, in fact one needs to calculate far fewer terms of the second series, as there is no point in converging one series to a tighter tolerance than the other.
The series for 4*arctan(1/5) starts with terms whose approximate sizes are:
0.8, 0.01, 0.0003, 7e-6, 2e-7, 7e-9, 3e-10, 9e-12, ...
The series for arctan(1/239) starts with terms whose approximate sizes are:
0.004, 2e-8, 3e-13, ...
If an answer with an absolute error of less than 1e-10 is desired, one must calculate the first seven terms of the arctan(1/5) series, but just the first two of the arctan(1/239) series.