Post Reply 
[VA] SRC #012c - Then and Now: Sum
12-03-2022, 08:54 AM (This post was last modified: 12-03-2022 01:18 PM by J-F Garnier.)
Post: #24
RE: [VA] SRC #012c - Then and Now: Sum
Here is my "solution", based on Werner's reasoning, so most credit due to him:-)

I restarted from the step below, changing the K+1 limit (the point from where we use ln(2) as an approximation of the partial sum) to K. It's a just a notation:

S = 1 + 1/2 + 1/6 + (H(7)-H(3))/F(3) + (H(15)-H(7))/F(4) + .. + (H(2^(K-1)-1)-H(2^(K-2)-1))/F(K-1)
+ LN(2)*(1/F(K) + 1/F(K+1) + .... )

Here we can do to the last part S3 = (1/F(K) + 1/F(K+1) + .... ) what we already did for the first part of the sum,
i.e. writing F(K) = K.F(d) with d=number of binary digits of K.
If we choose K=2^(M-1), we have F(K) = K.F(M)

S3 = (H(2^M-1)-H(2^(M-1)-1)/F(M) + ... + (H(2^(K-1)-1)-H(2^(K-2)-1))/F(K-1)
+ LN(2)*(1/F(K) + 1/F(K+1) + .... )

And here we recognize that we can do the same thing again on the last (1/F(K) + 1/F(K+1) + .... ) part, and again and again.
Also the quantity S2= (H(2^M-1)-H(2^(M-1)-1)/F(M) + ... + (H(2^(K-1)-1)-H(2^(K-2)-1))/F(K-1)
has already been computed as part of the beginning of the sum.

So we end with:
S = 1 + 1/2 + 1/6 + (H(7)-H(3))/F(3) + .. + (H(2^(M-1)-1)-H(2^(M-2)-1))/F(M-1) + S2
+ LN(2) * ( S2 + LN(2) * (S2 + LN(2) * (S2 ...

The limit Sx of the quantity ( S2 + LN(2) * ( S2 + LN(2) * (S2 + LN(2) * S2 ... ) is finite and is such as S2 + LN(2) * Sx = Sx
so Sx = S2 / (1 - LN(2))

To compute the whole sum S:
compute S1 = 1 + 1/2 + 1/6 + (H(7)-H(3))/F(3) + .. + (H(2^(M-1)-1)-H(2^(M-2)-1))/F(M-1)
compute S2 = (H(2^M-1)-H(2^(M-1)-1)/F(M) + ... + (H(2^(K-1)-1)-H(2^(K-2)-1))/F(K-1)
compute S = S1 + S2 / (1 - LN(2))

M is chosen such as 2^K=2^(2^(M-1)) >> 1E12 to ensure the partial sum H(2^(K-1)-1)-H(2^(K-2)-1) is accurately represented by ln(2) :
I used M=7 so K=2^6=64.



10 ! SRC12C3
20  ! HP-71 / HP-75 version
30  L=63
40  DIM F(63)
50  !
60  L2=LOG(2) ! used several times
70  ! calculate the F(I)
80  F(1)=1 @ F(2)=2
90  FOR I=3 TO L @ D=INT(LOG(I)/L2)+1 @ F(I)=I*F(D) @ NEXT I
100 !
110 ! compute the sum S0 for K=1..2
120 S0=1/F(1)+1/F(2)+1/F(3)
130 ! compute the sum S1 for K=3..6
140 S1=0
150 FOR K=3 TO 6
160   J1=2^(K-1) @ J2=2*J1-1
170   X=0 @ FOR J=J1 TO J2 @ X=X+1/J @ NEXT J
180   S1=S1+X/F(K)
190 NEXT K
210 ! now compute the sum S2 for K=7..40 using the H approx
230 S2=0
240 FOR K=K TO 40
250   N=2^(K+1) @ N2=N*N
260   X=((((-272/N2+16)/N2-2)/N2+1)/N+1)/N+L2
270   S2=S2+X/F(K)
280 NEXT K
290 ! and complete the sum S2 up to K=L using the LOG(2) approx
310 FOR K=K TO L @ S2=S2+L2/F(K) @ NEXT K
320 !
330 ! now compute the final sum S
340 S=S2/(1-LOG(2))+S1+S0
350 DISP S


Result = 2.08637766501
HP-75D: 9.3s
HP-71B: 13.2s

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #012c - Then and Now: Sum - J-F Garnier - 12-03-2022 08:54 AM



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