There are many many ways to approximateπ. One of the most efficient algorithms is using the following partial sums: \[ S_{n}=12 \sum_{k=0}^{n} \frac{(-1)^{k}(6 k) !(13591409+545140134 k)}{(3 k) !(k !)^{3} 640320^{3 k+3 / 2}} \] It is known thatSn→π1asn→∞and the convergence is very rapid. This series was discovered by the Chudnovsky brothers in 1988 and uses an approach first discovered by Ramanujan. Versions of this algorithm are used for all record-breaking calculations for digits ofπ. Write a function 'estimate_pi_chudnovsky' which uses this formula to approximateπ. The function should use 'SymPy', take a non-negative integernas input and return an estimate ofπgiven as a SymPy float with at least 1000 digits precision. Your function should raise a ValueError if the input is not a non-negative integer. For example:
There are many many ways to approximateπ. One of the most efficient algorithms is using the following partial sums: \[ S_{n}=12 \sum_{k=0}^{n} \frac{(-1)^{k}(6 k) !(13591409+545140134 k)}{(3 k) !(k !)^{3} 640320^{3 k+3 / 2}} \] It is known thatSn→π1asn→∞and the convergence is very rapid. This series was discovered by the Chudnovsky brothers in 1988 and uses an approach first discovered by Ramanujan. Versions of this
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images