This simple example implements the calculation of pi
using the Gregory-Leibniz series
\[ \frac{pi}{4}=1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-...=\sum_{k=0}^{\infty}\frac{(-1)^k}{2k+1} \]
The sum is computed for various number of terms from 10000000 to 200000000
The results are as follows:
Method Name | Mean | Standard Deviation |
---|---|---|
compute_pi(10000000) | 86.675 ms | +/- 5.592 ms |
compute_pi(100000000) | 849.100 ms | +/- 25.177 ms |
compute_pi(200000000) | 1.708 s | +/- 0.047 s |