New Sum of Powers Log Function
|
03-30-2021, 04:35 PM
Post: #9
|
|||
|
|||
RE: New Sum of Powers Log Function
Hi, Namir
The algorithm for LambertW -1 branch is the same as W0, just different guess, see here y = W-1(a) is real only for a = [-1/e, 0] A simple way is just iterate for it: y = log(-a), then iterate y = log(a/y) ... If converged, y=log(a/y) ⇒ e^y = a/y ⇒ y*e^y = a >>> a = mpf(-0.005) # example >>> y = log(-a) >>> for i in range(5): y = log(a/y); print y ... -6.9657066586895 -7.23931642716726 -7.27784415235106 -7.28315205198181 -7.28388110922369 We could speed up convergence with Newton's method f(y) = y - log(a/y) f'(y) = 1 + 1/y y = y - (y-log(a/y))/(1+1/y) = y * (1+log(a/y))/(1+y) >>> y = log(-a) # same guess >>> for i in range(5): y *= (1+log(a/y))/(1+y); print y ... -7.3536234060935 -7.28404934413218 -7.28399713512886 -7.28399713509908 -7.28399713509908 >>> y*exp(y) # confirm y = W-1(a) -0.005 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)