lambertw, all branches
|
04-07-2023, 08:40 PM
(This post was last modified: 04-14-2023 04:40 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: lambertw, all branches
I am keeping code simple. Edge cases, example W0(0) = 0, are not implemented.
Code: r, err = 0.36787944117144233, -1.2428753672788363E-17 W01 is solving W branch 0 or an ambiguous ±1 branch (with the small imag part) The code is solving for y*ln(y) = a --> y = e^W(a) --> W(a) = a/y We can "pull out" conjugate: W01(conj(a),k) = conj(W01(a,k)) lua> I.W(3+4*I, 5, true) (0+31.41592653589793*I) (-1.815554248884793+30.714634540472343*I) (-1.8170058914565277+30.71333413897562*I) (-1.8170058918466272+30.713334137004896*I) (-1.8170058918466274+30.713334137004896*I) lua> I.W(3+4*I, -5, true) (-0-31.41592653589793*I) (-1.7565805546696363-28.861921295458465*I) (-1.7547636407605829-28.85710103800315*I) (-1.7547636279545493-28.85710104741841*I) (-1.7547636279545493-28.85710104741841*I) lua> I.W(-0.3,-1,true) (-1.7824743623491122+0*I) W01 (-1.7813374873395937+0*I) W01 (-1.7813370234217047+0*I) W01 (-1.781337023421628+0*I) W01 lua> I.W(-0.03,-1,true) (-3.506557897319982-0*I) (-5.261733759227882-0*I) (-5.144793893666586-0*I) (-5.1444827237861634-0*I) (-5.144482721515682-0*I) (-5.144482721515682-0*I) lua> I.W(-.1+1e-100*I, -1, true) (-2.3025850929940455-1e-099*I) (-3.7769077194622533+1.2592576024726166e-099*I) (-3.579124176402325-8.545840728943592*I) (-3.7689826579869887-0.8337217972782689*I) (-3.5535464061313635-0.025256342802877585*I) (-3.5771468383315437+6.535012002211599e-005*I) (-3.5770902410326704-8.721224618630954*I) (-3.7811926340275566-0.8444302692850991*I) (-3.5536175209072614-0.02647513850865879*I) (-3.5771431199160215+6.824715919089008e-005*I) (-3.5770875001635236+0*I) W01 (-3.5771520641833883-1.3880349425219542e-099*I) W01 (-3.5771520639572962-1.3880252213229777e-099*I) W01 (-3.5771520639572976-1.388025221322979e-099*I) W01 W code f=0 have trouble converging. Switched to W01 help a lot. W01 use W last guess, but dropped the unreliable imaginary part. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)