--- title: "Approximations of pi" chunk: 8/10 source: "https://en.wikipedia.org/wiki/Approximations_of_pi" category: "reference" tags: "science, encyclopedia" date_saved: "2026-05-05T16:19:48.727542+00:00" instance: "kb-cron" --- === Continued fractions === Besides its simple continued fraction representation [3; 7, 15, 1, 292, 1, 1, ...], which displays no discernible pattern, π has many generalized continued fraction representations generated by a simple rule, including these two. π = 3 + 1 2 6 + 3 2 6 + 5 2 6 + ⋱ {\displaystyle \pi ={3+{\cfrac {1^{2}}{6+{\cfrac {3^{2}}{6+{\cfrac {5^{2}}{6+\ddots \,}}}}}}}} π = 4 1 + 1 2 3 + 2 2 5 + 3 2 7 + 4 2 9 + ⋱ = 3 + 1 2 5 + 4 2 7 + 3 2 9 + 6 2 11 + 5 2 13 + ⋱ {\displaystyle \pi ={\cfrac {4}{1+{\cfrac {1^{2}}{3+{\cfrac {2^{2}}{5+{\cfrac {3^{2}}{7+{\cfrac {4^{2}}{9+\ddots }}}}}}}}}}=3+{\cfrac {1^{2}}{5+{\cfrac {4^{2}}{7+{\cfrac {3^{2}}{9+{\cfrac {6^{2}}{11+{\cfrac {5^{2}}{13+\ddots }}}}}}}}}}} The remainder of the Madhava–Leibniz series can be expressed as generalized continued fraction as follows. π = 4 ∑ n = 1 m ( − 1 ) n − 1 2 n − 1 + 2 ( − 1 ) m 2 m + 1 2 2 m + 2 2 2 m + 3 2 2 m + ⋱ ( m = 1 , 2 , 3 , … ) {\displaystyle \pi =4\sum _{n=1}^{m}{\frac {(-1)^{n-1}}{2n-1}}+{\cfrac {2(-1)^{m}}{2m+{\cfrac {1^{2}}{2m+{\cfrac {2^{2}}{2m+{\cfrac {3^{2}}{2m+\ddots }}}}}}}}\qquad (m=1,2,3,\ldots )} Note that Madhava's correction term is 2 2 m + 1 2 2 m + 2 2 2 m = 4 m 2 + 1 4 m 3 + 5 m {\displaystyle {\frac {2}{2m+{\frac {1^{2}}{2m+{\frac {2^{2}}{2m}}}}}}=4{\frac {m^{2}+1}{4m^{3}+5m}}} . The well-known values ⁠22/7⁠ and ⁠355/113⁠ are respectively the second and fourth continued fraction approximations to π. === Trigonometry === ==== Gregory–Leibniz series ==== The Gregory–Leibniz series π = 4 ∑ n = 0 ∞ ( − 1 ) n 2 n + 1 = 4 ( 1 1 − 1 3 + 1 5 − 1 7 + − ⋯ ) {\displaystyle \pi =4\sum _{n=0}^{\infty }{\cfrac {(-1)^{n}}{2n+1}}=4\left({\frac {1}{1}}-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+-\cdots \right)} is the power series for arctan(x) specialized to x = 1. It converges too slowly to be of practical interest. However, the power series converges much faster for smaller values of x {\displaystyle x} , which leads to formulae where π {\displaystyle \pi } arises as the sum of small angles with rational tangents, known as Machin-like formulae. ==== Arctangent ==== Knowing that 4 arctan 1 = π, the formula can be simplified to get: π = 2 ( 1 + 1 3 + 1 ⋅ 2 3 ⋅ 5 + 1 ⋅ 2 ⋅ 3 3 ⋅ 5 ⋅ 7 + 1 ⋅ 2 ⋅ 3 ⋅ 4 3 ⋅ 5 ⋅ 7 ⋅ 9 + 1 ⋅ 2 ⋅ 3 ⋅ 4 ⋅ 5 3 ⋅ 5 ⋅ 7 ⋅ 9 ⋅ 11 + ⋯ ) = 2 ∑ n = 0 ∞ n ! ( 2 n + 1 ) ! ! = ∑ n = 0 ∞ 2 n + 1 n ! 2 ( 2 n + 1 ) ! = ∑ n = 0 ∞ 2 n + 1 ( 2 n n ) ( 2 n + 1 ) = 2 + 2 3 + 4 15 + 4 35 + 16 315 + 16 693 + 32 3003 + 32 6435 + 256 109395 + 256 230945 + ⋯ {\displaystyle {\begin{aligned}\pi &=2\left(1+{\cfrac {1}{3}}+{\cfrac {1\cdot 2}{3\cdot 5}}+{\cfrac {1\cdot 2\cdot 3}{3\cdot 5\cdot 7}}+{\cfrac {1\cdot 2\cdot 3\cdot 4}{3\cdot 5\cdot 7\cdot 9}}+{\cfrac {1\cdot 2\cdot 3\cdot 4\cdot 5}{3\cdot 5\cdot 7\cdot 9\cdot 11}}+\cdots \right)\\&=2\sum _{n=0}^{\infty }{\cfrac {n!}{(2n+1)!!}}=\sum _{n=0}^{\infty }{\cfrac {2^{n+1}n!^{2}}{(2n+1)!}}=\sum _{n=0}^{\infty }{\cfrac {2^{n+1}}{{\binom {2n}{n}}(2n+1)}}\\&=2+{\frac {2}{3}}+{\frac {4}{15}}+{\frac {4}{35}}+{\frac {16}{315}}+{\frac {16}{693}}+{\frac {32}{3003}}+{\frac {32}{6435}}+{\frac {256}{109395}}+{\frac {256}{230945}}+\cdots \end{aligned}}} with a convergence such that each additional 10 terms yields at least three more digits. π = 2 + 1 3 ( 2 + 2 5 ( 2 + 3 7 ( 2 + ⋯ ) ) ) {\displaystyle \pi =2+{\frac {1}{3}}\left(2+{\frac {2}{5}}\left(2+{\frac {3}{7}}\left(2+\cdots \right)\right)\right)} This series is the basis for a decimal spigot algorithm by Rabinowitz and Wagon. Another formula for π {\displaystyle \pi } involving arctangent function is given by π 2 k + 1 = arctan ⁡ 2 − a k − 1 a k , k ≥ 2 , {\displaystyle {\frac {\pi }{2^{k+1}}}=\arctan {\frac {\sqrt {2-a_{k-1}}}{a_{k}}},\qquad \qquad k\geq 2,} where a k = 2 + a k − 1 {\displaystyle a_{k}={\sqrt {2+a_{k-1}}}} such that a 1 = 2 {\displaystyle a_{1}={\sqrt {2}}} . Approximations can be made by using, for example, the rapidly convergent Euler formula arctan ⁡ ( x ) = ∑ n = 0 ∞ 2 2 n ( n ! ) 2 ( 2 n + 1 ) ! x 2 n + 1 ( 1 + x 2 ) n + 1 . {\displaystyle \arctan(x)=\sum _{n=0}^{\infty }{\frac {2^{2n}(n!)^{2}}{(2n+1)!}}\;{\frac {x^{2n+1}}{(1+x^{2})^{n+1}}}.} Alternatively, the following simple expansion series of the arctangent function can be used arctan ⁡ ( x ) = 2 ∑ n = 1 ∞ 1 2 n − 1 a n ( x ) a n 2 ( x ) + b n 2 ( x ) , {\displaystyle \arctan(x)=2\sum _{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 a 1 ( x ) = 2 / x , b 1 ( x ) = 1 , a n ( x ) = a n − 1 ( x ) ( 1 − 4 / x 2 ) + 4 b n − 1 ( x ) / x , b n ( x ) = b n − 1 ( x ) ( 1 − 4 / x 2 ) − 4 a n − 1 ( x ) / x , {\displaystyle {\begin{aligned}&a_{1}(x)=2/x,\\&b_{1}(x)=1,\\&a_{n}(x)=a_{n-1}(x)\,\left(1-4/x^{2}\right)+4b_{n-1}(x)/x,\\&b_{n}(x)=b_{n-1}(x)\,\left(1-4/x^{2}\right)-4a_{n-1}(x)/x,\end{aligned}}} to approximate π {\displaystyle \pi } with even more rapid convergence. Convergence in this arctangent formula for π {\displaystyle \pi } improves as integer k {\displaystyle k} increases. The constant π {\displaystyle \pi } can also be expressed by infinite sum of arctangent functions as