Post Reply 
New Sum of Powers Log Function
03-29-2021, 10:47 PM
Post: #3
RE: New Sum of Powers Log Function
(03-29-2021 04:53 PM)Namir Wrote:  S = sum i^x for i=1 to N

We can solve for x, without actually summing N terms.

As a rough approximation, s ≈ ∫(t^x, t=1/2 .. n+1/2)
Since sum(k, k=1..n) = (n²+n)/2, a guess for x is log(s)/log(n) - 1

To get more accurate x, we can use Euler–Maclaurin formula, for f(t) = t^x:
Operator shorthand, we have s = Σf = (D^-1 - 1/2 + D/12 - D^3/720 + D^5/30240 - ...) f

Drop higher-order derivatives, we have:
Code:
RHS = lambda p,n: ((n+1)**(p+1)-1)/(p+1) - ((n+1)**p-1)/2 + p*((n+1)**(p-1)-1)/12
solvex = lambda n,s: findroot(lambda p: RHS(p,n)/s-1, log(s,n)-1)
roughx = lambda n,s: findroot(lambda X: ((n+.5)**X-0.5**X)/(s*X)-1, log(s,n)) - 1
Note: we solve RHS/LHS-1 = 0, because findroot like numbers in the "normal" range.

For comparision, I copied SopLog.pdf Table 1, for solved (s,x)

>>> from mpmath import *
>>> n=100
>>> SX = (100,0),(150,0.110121),(250,0.245589),(500,0.424944),(750,0.527995)
>>> SX += (1000,0.600423),(1100,0.624305),(1200,0.646061),(1300,0.666037)
>>>
>>> for s,x in SX: print '%g\t%f\t%f\t%f' % (s,x, solvex(n,s), roughx(n,s))
...
100    0.000000    0.000000    0.000000
150    0.110121    0.110121    0.110134
250    0.245589    0.245589    0.245605
500    0.424944    0.424944    0.424956
750    0.527995    0.527995    0.528004
1000   0.600423    0.600423    0.600430
1100   0.624305    0.624305    0.624311
1200   0.646061    0.646061    0.646067
1300   0.666037    0.666037    0.666042
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New Sum of Powers Log Function - Namir - 03-29-2021, 04:53 PM
RE: New Sum of Powers Log Function - C.Ret - 03-29-2021, 08:39 PM
RE: New Sum of Powers Log Function - Albert Chan - 03-29-2021 10:47 PM
RE: New Sum of Powers Log Function - Namir - 03-30-2021, 11:05 AM
RE: New Sum of Powers Log Function - Gene - 03-30-2021, 01:43 PM
RE: New Sum of Powers Log Function - C.Ret - 03-30-2021, 04:01 PM
RE: New Sum of Powers Log Function - Namir - 03-30-2021, 05:56 PM
RE: New Sum of Powers Log Function - Namir - 03-31-2021, 01:27 PM
RE: New Sum of Powers Log Function - Namir - 03-31-2021, 02:19 PM
RE: New Sum of Powers Log Function - Namir - 04-01-2021, 06:05 PM
RE: New Sum of Powers Log Function - Namir - 04-01-2021, 11:55 PM
RE: New Sum of Powers Log Function - Namir - 04-04-2021, 03:41 PM



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