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 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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)