Accurate x - log(1+x)
05-05-2022, 08:57 PM
Post: #3
 Albert Chan Senior Member Posts: 2,501 Joined: Jul 2018
RE: Accurate x - log(1+x)
From [VA] SRC #010 - Pi Day 2022 Special

(03-14-2022 08:03 PM)Valentin Albillo Wrote:  unexpected infinite product for $$\pi$$ announced in the title, the awesome expression:

which beautifully relates $$\pi$$ and e.
(03-22-2022 01:01 AM)Albert Chan Wrote:
(03-22-2022 12:14 AM)Valentin Albillo Wrote:  To settle down the question, if someone with access to Mathematica or some other arbitrary-precision software can compute the product for N=100,000 using 100 digits, say, or as many as necessary to ensure full 34 correct digits or more, and post here the resulting value I'd appreciate it. Thanks in advance.

>>> 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

lua> n = 100000
lua> s = 0
lua> for x=n,2,-1 do y=x*x; s = s + (1 + log1p(-1/y)*y) end
lua> exp(s + 1.5) -- error = -440 ULP
3.141608361513987

lua> s = 0
lua> for x=n,2,-1 do y=x*x; s = s - x_sub_log1p(-1/y)*y end
lua> exp(s + 1.5) -- error = 0 ULP
3.1416083615137915

Using x_sub_log1p(x), we get true PN, without ULP error !
 « Next Oldest | Next Newest »

 Messages In This Thread Accurate x - log(1+x) - Albert Chan - 05-05-2022, 07:52 PM RE: Accurate x - log(1+x) - Albert Chan - 05-05-2022, 08:18 PM RE: Accurate x - log(1+x) - Albert Chan - 05-05-2022 08:57 PM RE: Accurate x - log(1+x) - Albert Chan - 05-06-2022, 02:03 PM RE: Accurate x - log(1+x) - Albert Chan - 05-09-2022, 12:41 AM RE: Accurate x - log(1+x) - Albert Chan - 04-04-2023, 11:05 PM

User(s) browsing this thread: 1 Guest(s)