Prime calculator sum(1.0002^n/n, 1, 20000)
12-28-2020, 09:14 PM (This post was last modified: 12-31-2020 11:20 PM by Albert Chan.)
Post: #21
 Albert Chan Senior Member Posts: 2,066 Joined: Jul 2018
RE: Prime calculator sum(1.0002^n/n, 1, 20000)
Note that z = 0.0002 is a small number, perfect for taylor series approximation.

$$f = \Large {(1+z)^k \over k} \displaystyle \normalsize = {1\over k} + \sum_{j=1}^k \binom{k}{j}{z^j \over k} = {1\over k} + \sum_{j=1}^k \binom{k-1}{j-1}{z^j \over j}$$

$$\small \displaystyle\sum_{k=j}^n \binom{k-1}{j-1} = \sum_{k=j}^n \left[\binom{k}{j} - \binom{k-1}{j}\right] = \binom{n}{j} - \binom{j-1}{j} = \binom{n}{j}$$ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // middle terms telescopingly cancelled

Flip the order of sum, $$\large \sum _{k=1}^n \sum _{j=1}^k ≡ \sum _{j=1}^n \sum _{k=j}^n$$

$$\displaystyle\sum_{k=1}^n f = H(n) + \sum_{j=1}^n \displaystyle\sum_{k=j}^n \binom{k-1}{j-1} {z^j \over j} = H(n) + \sum_{j=1}^n \binom{n}{j}{z^j\over j}$$

H(n), we use Harmonic Number asymptotic formula:

lua> n, z = 20000, 0.0002
lua> euler_gamma = 0.5772156649015329
lua> Hn = (1-1/(6*n))/(2*n) + euler_gamma + log(n)
lua> Hn
10.480728217229327

Sum the other terms, until converged.
With small z, we may not need n terms for convergence.

lua> j, t, s = 1, 1, -1
lua> repeat s=s+t/j; j=j+1; t=t*(n-j+1)/j*z; until s==s+t/j
lua> s = n*z * (s+1)
lua> Hn + s ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -- = sum(1.0002^k/k, k = 1 .. 20000)
28.14397383505517

lua> j ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -- much less than 20000 terms 30
 « Next Oldest | Next Newest »

 Messages In This Thread Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-27-2020, 03:04 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Joe Horn - 12-27-2020, 04:16 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - toml_12953 - 12-27-2020, 04:27 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-27-2020, 10:37 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - toml_12953 - 12-27-2020, 10:53 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Steve Simpkin - 12-27-2020, 01:46 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Tyann - 12-27-2020, 03:17 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-27-2020, 05:32 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-27-2020, 05:35 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - StephenG1CMZ - 12-27-2020, 05:43 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - lrdheat - 12-27-2020, 05:56 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - ijabbott - 12-28-2020, 10:47 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - _nmr_ - 12-28-2020, 12:59 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - John Keith - 12-27-2020, 07:03 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Claudio L. - 12-30-2020, 09:02 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - lrdheat - 12-27-2020, 08:07 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gerson W. Barbosa - 12-27-2020, 10:43 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Valentin Albillo - 12-28-2020, 03:20 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Joe Horn - 12-28-2020, 03:02 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Didier Lachieze - 12-28-2020, 04:21 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Joe Horn - 12-28-2020, 11:13 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - StephenG1CMZ - 12-28-2020, 02:03 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Albert Chan - 12-28-2020 09:14 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-29-2020, 01:57 AM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Albert Chan - 12-29-2020, 05:10 PM RE: Prime calculator sum(1.0002^n/n, 1, 20000) - Gil - 12-31-2020, 01:19 AM

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