Calculating Pi upto 5000 digits using different methods:
- Machin-like formula
- Vieta and Accelerated Vieta
- Wallis Product
- Monte Carlo Approximation Method
This equation was discovered in 1706 by John Machin, and has been in use for around 300 years. It is suitable for the calculation of Pi because it converges quickly.
References: Wikipedia Youtube - Machin Formula Visualization
In mathematics, Viète's formula is the following infinite product of nested radicals representing twice the reciprocal of the mathematical constant
It can also be represented as:
The formula is named after François Viète, who published it in 1593.
References: Wikipedia
This infinite product formula, while elegant, is a poor choice for computing the decimal digits of π because it converges so slowly.
You may have observed that each Viète iteration requires a square root operation. Square root operations are computationally very expensive making Viète's Formula computationally uninteresting.
An article by Rick Kreminski, offers a recursion that accelerates the convergence of Viète's Formula. Viète became computationally interesting.
${\displaystyle {\begin{aligned}V_{(k,n)}&=\frac{4^{k}V_{(k-1, n+1)} - V_{(k-1, n)}}{4^k-1} \V_{(0,n)}&=p_n \end{aligned}}}$
Let
In mathematics, the Wallis product for π, published in 1656 by John Wallis, states that
${\displaystyle {\begin{aligned}{\frac {\pi }{2}}&=\prod_{n=1}^{\infty }{\frac {4n^{2}}{4n^{2}-1}}=\prod_{n=1}^{\infty }\left({\frac {2n}{2n-1}}\cdot {\frac {2n}{2n+1}}\right)\[6pt]&={\Big (}{\frac {2}{1}}\cdot {\frac {2}{3}}{\Big )}\cdot {\Big (}{\frac {4}{3}}\cdot {\frac {4}{5}}{\Big )}\cdot {\Big (}{\frac {6}{5}}\cdot {\frac {6}{7}}{\Big )}\cdot {\Big (}{\frac {8}{7}}\cdot {\frac {8}{9}}{\Big )}\cdot ;\cdots \\end{aligned}}}$
Monte Carlo methods, or Monte Carlo experiments, are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results.
Given that the ratio of their areas is
- Draw a square, then inscribe a quadrant within it
- Uniformly scatter a given number of points over the square
- Count the number of points inside the quadrant, i.e. having a distance from the origin of less than 1
- The ratio of the inside-count and the total-sample-count is an estimate of the ratio of the two areas,
$\pi/4$ . Multiply the result by 4 to estimate π.
Reference: Wikipedia