Post Reply 
Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
03-28-2020, 01:31 PM (This post was last modified: 03-28-2020 03:05 PM by Albert Chan.)
Post: #32
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others]
(03-23-2020 04:34 PM)Albert Chan Wrote:  LN(2) = 2 * probability of integer part of RND/RND is odd

We can improve LN(2) estimate by scaling RND/RND
Let p(m) = probability of integer part of m*RND/RND is odd

XCas> [log2] := expand(solve(p(m) = floor(m/2)/(2*m) + (m/2)*(log2 + c), log2))     → [2*p(m)/m-floor(m/2)/m^2-c]
XCas> c := (m>1)*sum((-1)^k/k, k=1..2*floor(m/2))

XCas> expand(subst(log2, m=1))     → 2*p(1)
XCas> expand(subst(log2, m=2))     → p(2)+1/4
XCas> expand(subst(log2, m=3))     → 2*p(3)/3+7/18
XCas> expand(subst(log2, m=10))   → p(10)/5+1501/2520

> 10 DEF FNL(K) @ N=0
> 20 FOR L1=1 TO K @ N=N+MOD(IP(10*RND/RND),2) @ NEXT L1
> 30 FNL=N/(5*K)+1501/2520 @ END DEF
> RUN

> FIX 5 @ RANDOMIZE 1
> FOR I=1 to 5 @ FNL(1e4) @ NEXT I
0.69063
0.69441
0.69329
0.69347
0.69377
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Natural logarithm of 2 [HP-15C/HP-42S/Free42 & others] - Albert Chan - 03-28-2020 01:31 PM



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