[VA] SRC #010 - Pi Day 2022 Special
|
03-22-2022, 01:01 AM
Post: #17
|
|||
|
|||
RE: [VA] SRC #010 - Pi Day 2022 Special
(03-22-2022 12:14 AM)Valentin Albillo Wrote:(03-18-2022 04:22 PM)Albert Chan Wrote: Lets recover true PN, and compare errors of products vs exp(sum of logs) [...] Note that ln(C) is odd function. Rewrite ln(C) as polynomial of 1/N, we have: >>> from mpmath import * >>> mp.dps = 100 >>> pn = lambda n: exp(nsum(lambda x: 1+log1p(-1/(x*x))*x*x,[2,n]) + 1.5) >>> n = mpf(100000) >>> N = 2*n+1 >>> x = pn(n) >>> print x 3.141608361513791562872866895754895278060325823725833279147116393910631517290786764227775828378244404 It does matched my 34-digits "true" PN. ln(C) correction (terms upto 1/N^9) seems safe to use. >>> err = lambda c: float(pi - x * exp(-c)) >>> err(13/(45*N**5) + 5/(9*N**3) + 1/N) -9.8950471946808673e-38 >>> err(127/(315*N**7) + 13/(45*N**5) + 5/(9*N**3) + 1/N) 4.0449821226917704e-48 >>> err(-89/(135*N**9) + 127/(315*N**7) + 13/(45*N**5) + 5/(9*N**3) + 1/N) -1.229817502771026e-57 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)