LambertW function
11-07-2020, 11:57 AM (This post was last modified: 11-07-2020 12:37 PM by Albert Chan.)
Post: #3
 Albert Chan Senior Member Posts: 2,682 Joined: Jul 2018
RE: LambertW function
(11-07-2020 08:41 AM)Stevetuc Wrote:  Edit: add initial guess of 0 to avoid terminal screen in cas.
This forces going direct to iterative solver rather than first trying and failing with bisection solver.

You might want to mention guess of 0 will iterate for W0(x), i.e. principle branch. (*)

Also, guess 0 is same as guess x, but wasted 1 Newton iteration.
We might as well use guess = x

Newton: w - (w*exp(w) - x) / (w*exp(w) + exp(w))

With guess 0, first iteration of w = 0 - (0 - x) / (0 + 1) = x

(*) Assumed W0 is not complex (x ≥ -1/e), see comment below.

Comment: For fsolve, some randomization of guess is going on.
With complex ON, if we fsolve again and again, we got different solutions.

XCas> fsolve(w*e^w = -1.78, w=0)

0.0892180498562+1.62562367443*i
-1.4781113814-7.66344321151*i
-3.68225172433+70.6337502365*i
-2.07259091944+13.9900896316*i
-2.9207293675-32.8981741284*i
...

Without randomization, fsolve should not even converge. (w will not flip to complex)
Maybe this is the reason guess randomization kick in ...
 « Next Oldest | Next Newest »

 Messages In This Thread LambertW function - Stevetuc - 05-17-2020, 08:48 AM RE: LambertW function - Stevetuc - 11-07-2020, 08:41 AM RE: LambertW function - Albert Chan - 11-07-2020 11:57 AM RE: LambertW function - Stevetuc - 11-07-2020, 01:50 PM

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