(28/48/50) Lambert W Function
04-02-2023, 11:12 PM
Post: #23
 Albert Chan Senior Member Posts: 2,699 Joined: Jul 2018
RE: (28/48/50) Lambert W Function
(03-26-2023 06:43 PM)Albert Chan Wrote:  Because solving for y = e^W(a) is easier, W code is not recommended.

W code is perfect for other branches! (expW code for W branch 0, -1)

Numbering the branches of the Lambert W function

Except for 2*k*pi*I term, it is basically same formula for W code!

lua> f = fn'x: x + I.log(x) - I.log(a) - 2*k*pi*I'
lua> df = fn'x: 1 + 1/x'

Let X = |x|, A = |a|

log(x) - log(a) = log(X/A) + I*(arg(x) - arg(a))
log(X/A) = 1 + log(X*(r+err)/A) ≈ 1 + log1p((X*err - (A+r) + r*(1+X)) / A)

This means we can evaluate f accurately around branch point!

f=0 guaranteed we get the correct branch, which is nice.
There is no need to use complicated W guesses.

lua> a, k = 3+4*I, 5
lua> x = 2*k*pi*I -- guess for Wk(a)
lua> repeat h=f(x)/df(x); x=x-h; print(x, I.abs(h)) until x == x+1e-6*h

(-1.815554248884793+30.714634540472343*I)       1.9462907525577031
(-1.817005891456528+30.71333413897562*I)        0.0019489253984594729
(-1.8170058918466274+30.713334137004896*I)      2.0089622485451688e-009
(-1.8170058918466274+30.713334137004896*I)      0

>>> from mpmath import *
>>> lambertw(3+4j, k=5)
mpc(real='-1.8170058918466274', imag='30.713334137004896')
 « Next Oldest | Next Newest »

 Messages In This Thread (28/48/50) Lambert W Function - John Keith - 03-20-2023, 08:43 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-20-2023, 10:51 PM RE: (28/48/50) Lambert W Function - John Keith - 03-21-2023, 01:53 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-21-2023, 05:15 PM RE: (28/48/50) Lambert W Function - John Keith - 03-22-2023, 07:30 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-23-2023, 12:16 AM RE: (28/48/50) Lambert W Function - John Keith - 03-23-2023, 05:53 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-23-2023, 07:30 PM RE: (28/48/50) Lambert W Function - Gerald H - 03-21-2023, 06:15 AM RE: (28/48/50) Lambert W Function - John Keith - 03-22-2023, 08:55 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-23-2023, 02:56 AM RE: (28/48/50) Lambert W Function - Albert Chan - 03-26-2023, 06:43 PM RE: (28/48/50) Lambert W Function - Albert Chan - 04-02-2023 11:12 PM RE: (28/48/50) Lambert W Function - John Keith - 04-03-2023, 07:24 PM RE: (28/48/50) Lambert W Function - Albert Chan - 04-03-2023, 08:47 PM RE: (28/48/50) Lambert W Function - John Keith - 03-27-2023, 04:45 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-27-2023, 08:57 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-31-2023, 04:06 PM RE: (28/48/50) Lambert W Function - John Keith - 03-31-2023, 06:15 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-31-2023, 07:10 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-27-2023, 11:30 PM RE: (28/48/50) Lambert W Function - Albert Chan - 03-31-2023, 10:07 PM RE: (28/48/50) Lambert W Function - Albert Chan - 04-01-2023, 12:44 PM RE: (28/48/50) Lambert W Function - John Keith - 04-01-2023, 05:36 PM RE: (28/48/50) Lambert W Function - John Keith - 04-01-2023, 05:59 PM RE: (28/48/50) Lambert W Function - Albert Chan - 04-03-2023, 10:47 PM RE: (28/48/50) Lambert W Function - Albert Chan - 04-04-2023, 01:03 AM RE: (28/48/50) Lambert W Function - John Keith - 04-04-2023, 07:09 PM RE: (28/48/50) Lambert W Function - Gil - 01-29-2024, 11:04 AM RE: (28/48/50) Lambert W Function - Albert Chan - 01-29-2024, 03:51 PM RE: (28/48/50) Lambert W Function - Gil - 01-29-2024, 02:47 PM RE: (28/48/50) Lambert W Function - Gil - 01-29-2024, 06:46 PM RE: (28/48/50) Lambert W Function - Albert Chan - 01-29-2024, 07:30 PM RE: (28/48/50) Lambert W Function - Gil - 01-29-2024, 09:50 PM RE: (28/48/50) Lambert W Function - Albert Chan - 01-30-2024, 12:18 AM RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 12:33 AM RE: (28/48/50) Lambert W Function - Albert Chan - 01-30-2024, 01:09 AM RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 12:04 PM RE: (28/48/50) Lambert W Function - Albert Chan - 01-30-2024, 01:47 PM RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 02:52 PM RE: (28/48/50) Lambert W Function - Albert Chan - 01-30-2024, 04:04 PM RE: (28/48/50) Lambert W Function - Gil - 01-31-2024, 07:10 PM

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