# $\pi$ and rapid series for the inverse tangent

I design an educational program to demonstrate convergence rate in computation of $\pi$ by using the Machin like formula. According to Weisstein, the Hwang’s equation (see eq. (32) in http://mathworld.wolfram.com/Machin-LikeFormulas.html): \begin{align} \frac{1}{4}\pi = & 183{{\cot }^{-1}}239+32{{\cot }^{-1}}1023-68{{\cot }^{-1}}5832 \\ & +12{{\cot }^{-1}}110443-12{{\cot }^{-1}}4841182-100{{\cot }^{-1}}6826318 \\ \end{align} is the most efficient Machin like formula to compute pi. I used three series for the inverse tangent ($\cot^{-1}x = \tan^{-1}\frac{1}{x}$): $$\tag{1}\tan^{-1}x=\sum\limits_{n=1}^{\infty }{\frac{{{\left( -1 \right)}^{n}}{{x}^{2n+1}}}{2n+1}},$$

$$\tag{2}\tan^{-1}x=\sum\limits_{n=1}^{\infty }{\frac{{{2}^{2n}}{{\left( n! \right)}^{2}}}{\left( 2n+1 \right)!}\frac{{{x}^{2n+1}}}{{{\left( 1+{{x}^{2}} \right)}^{n+1}}}},$$

$$\tag{3}\tan^{-1}x=2\sum\limits_{n=1}^{\infty }{\frac{1}{2n-1}\frac{{{a}_{n}}\left( x \right)}{a_{n}^{2}\left( x \right)+b_{n}^{2}\left( x \right)}},$$ where \begin{align} & {{a}_{1}}\left( x \right)=2/x, \\ & {{b}_{1}}\left( x \right)=1, \\ & {{a}_{n}}\left( x \right)={{a}_{n-1}}\left( x \right)\left( 1-4/{{x}^{2}} \right)+4{{b}_{n-1}}\left( x \right)/x, \\ & {{b}_{n}}\left( x \right)={{b}_{n-1}}\left( x \right)\left( 1-4/{{x}^{2}} \right)-4{{a}_{n-1}}\left( x \right)/x. \\ \end{align}

Eq. (1) is the Maclaurin series, eq. (2) is the Euler’s series, eq. (3) is from the paper Abrarov & Quine arXiv:1706.08835. It appears to be that eqs. (2) and (3) are more rapid than eq. (1). I want to ask you two questions. Is eq. (3) more efficient than eq. (2)? Are there other series for the inverse tangent with rapid convergence?

• Which of several methods is the most efficient generally depends on how clever the coder is and what software and hardware the coder is using, and what the range of the computation is. It's not just a matter of which formula. – Gerry Myerson Sep 29 '17 at 3:12
• @ Gerry Myerson. Hardware is the desktop computer. My main soft is Maple (or any other). Our goal is to show the best convergence rate by taking appropriate series for $tan^{-1} x$. If the convergence rate is 5 - 10 digits per term, the range of 30 - 50 decimals is enough. One may expect that the Hwang's equation (32) can produce up to 10 new digits of pi per increment. – Philip Thomas Sep 29 '17 at 12:46
• The software doesn't let you ping two people in one comment. I think that if you want coudy to see your comment, you have to have it as a comment to coudy's answer, not a comment to your question. Also, I think you have to not have a space between the at-sign and the username. – Gerry Myerson May 4 '18 at 1:02
• @Gerry Myerson. In this paper ijmcs.future-in-tech.net/13.2/R-Abrarov.pdf page 167 shows a Mathematica program that generates 17 digits of pi per term. This proves rapid convergence. – Philip Thomas May 13 '18 at 23:43

The Hwang equation is not the most efficient Machin like formula to compute $\pi$. The following formula

$${\pi \over 4} = 32 \, \hbox{arctan}({1\over 40}) - \hbox{arctan}\biggl( {38035138859000075702655846657186322249216830232319 \over 2634699316100146880926635665506082395762836079845121}\biggr)$$ has a Lehmer's measure around $1.16751$ thus beating Hwang's formula (with Lehmer's measure $1.51240$).

Abrarov and Quine gave a formula with Lehmer's measure $0.245319$ last summer, together with the relevant algorithms, in their paper An iteration procedure for a two-term Machin-like formula for pi with small Lehmer’s measure. That formula provides 16 new digits of $\pi$ per term increment thus beating the famous Chudnovsky formula.

The Abrarov-Quine formula won't fit on that small answer box though since one of the fraction has a numerator with $522\,185\,807$ digits and a denominator with $522\,185\,816$ digits.

• @ coudy. A fraction where a numerator with 522185807 digits and a denominator with 522185816 digits requires a specific FFT method dealing with long numbers for more efficient computation. As I know this FFT method were used for the Chudnovsky formula for beating the last record. However, this is beyond of my current scope. Thank you anyway! – Philip Thomas Sep 28 '17 at 20:34
• The aforementioned paper gives numerous Machin formulas together with efficient series to compute the arctangent. You should find something there to your liking. – coudy Sep 28 '17 at 20:39
• @ coudy. This method is unconventional although it (perhaps) beats the Chudnovsky formula for $\pi$ in convergence as claimed. I did not verify this claim. However, I verified series (3) from the same paper and confirm that it converges fast. This probably is what I need right now. – Philip Thomas Sep 28 '17 at 20:51

This is not exactly an answer, but R. P. Brent has an excellent survey of computing everything under the Sun (including $\arctan.$)

• @ Igor Rivin. Many thanks I will read this paper by R. P. Brent. – Philip Thomas Sep 28 '17 at 21:17

The efficiency of such series depends not just on the rate of convergence but on the bit size of the terms.

If $\sum_{k=0}^{\infty} T(k)$ converges linearly, you can always rewrite it as $\sum_{k=0}^{\infty} U(k)$ where $U(k) = \sum_{j=0}^{N-1} T(N k + j)$ to get a series that converges $N$ times faster. But nothing has really been gained since the terms now cost $N$ times more to compute.

• @ Fredrik Johansson. This formula is accurate. However it adds many new terms while k increases. Therefore efficiency of computation may be questionable. I will verify it. Thank you for suggestion! – Philip Thomas Sep 28 '17 at 21:11

Arctangent formula (3) that can also be written as $$\tan^{-1}\left(x\right)=i\sum\limits_{n=1}^{\infty}{\frac{1}{2n-1}}\left(\frac{1}{\left(1+2i/x\right)^{2n-1}}-\frac{1}{\left(1-2i/x\right)^{2n-1}}\right)$$ is more rapid in convergence than the equation (2). Therefore, it is more efficient in computation. Here is a link: How to compare convergence of two equations for the arctangent function?