Post Reply 
lambertw, all branches
01-21-2024, 01:14 AM (This post was last modified: 01-24-2024 07:27 PM by Albert Chan.)
Post: #20
RE: lambertw, all branches
(01-20-2024 10:52 PM)Gil Wrote:  I looked your case k=-1 & k=1, x=-.1 + i ×1E-99.

With my initial guess=
'LN(((-.1,1.E-100)+1./e)*(e-\v/2.-1.)+\v/(((-.1,1.E-100)+1./e)*2./e)+1./e)'

= (-.11284787341,1.26802807724E-100),

the built-in multisolver from HP50 runs endless.

x = Wk(a)

Newton's method required a good guess to start. (iterations cannot cross discontinuity!)

lyuka's e^W formula is only used when a ≈ -1/e, and (k=0 or k=±1 and x with small imag part)
Above example probably too far away from -1/e (my code use lyuka if |a+1/e| < 0.25)

Also, your formula is only good for k=0. For k=-1, you need to flip sqrt sign.

lua> a, e = I(-0.1, 1e-100), exp(1)
lua> I.log((a+1/e)*(e-sqrt(2)-1) + I.sqrt((2/e)*(a+1/e)) + 1/e) -- x guess for k=0
(-0.1128478734106899+1.268028077236754e-99*I)
lua> I.log((a+1/e)*(e-sqrt(2)-1) I.sqrt((2/e)*(a+1/e)) + 1/e) -- x guess for k=-1
(-5.225138594746179-9.75118016335884e-98*I)

If x imag part is big, it just use that.

-- local A, T = I.abs(a), I.new(0,2*k*pi+I.arg(a))
-- local x = T -- W rough guess

lua> I.W(a, 1, true)
(0+9.42477796076938*I)
(-4.330508133087424+7.394500450320804*I)
(-4.448949088733658+7.307107936743056*I)
(-4.449098178536345+7.307060789152774*I)
(-4.44909817870089+7.3070607892176085*I)
(-4.44909817870089+7.3070607892176085*I)

If k=-1 and x imag part is small, we wanted real guess when a is negative real.
Also, x→-∞ if a→0, log(-a) fit the bill.

But if a is too negative (left of -1/e), code added some imaginery part.
Imag part is needed because a=-1 --> log(-a) = log(1) = 0, very bad x guess!

-- if small_imag then x = I.log(-a) + (A<.5 and 0 or T/2) end

lua> I.W(a, -1, true)
(-2.3025850929940455-1e-99*I)
(-3.776907719462253-5.084465616380437e-100*I)
(-3.5791241764023245-5.180347740277738e-100*I)
(-3.577152274695805-5.181454351722727e-100*I)
(-3.5771520639572993-5.18145447016809e-100*I)
(-3.577152063957297-1.388025221322979e-99*I)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
lambertw, all branches - Albert Chan - 04-07-2023, 01:24 PM
RE: lambertw, all branches - Albert Chan - 04-07-2023, 02:47 PM
RE: lambertw, all branches - Albert Chan - 04-19-2023, 01:30 AM
RE: lambertw, all branches - pier4r - 04-07-2023, 06:04 PM
RE: lambertw, all branches - Albert Chan - 04-07-2023, 07:54 PM
RE: lambertw, all branches - Albert Chan - 04-08-2023, 03:21 PM
RE: lambertw, all branches - Albert Chan - 04-08-2023, 05:54 PM
RE: lambertw, all branches - Albert Chan - 04-07-2023, 08:40 PM
RE: lambertw, all branches - Albert Chan - 04-09-2023, 03:59 AM
RE: lambertw, all branches - Albert Chan - 04-09-2023, 04:36 PM
RE: lambertw, all branches - Albert Chan - 04-10-2023, 04:44 PM
RE: lambertw, all branches - Albert Chan - 04-10-2023, 06:47 PM
RE: lambertw, all branches - Albert Chan - 04-13-2023, 03:03 PM
RE: lambertw, all branches - floppy - 04-13-2023, 04:14 PM
RE: lambertw, all branches - Albert Chan - 04-23-2023, 02:49 PM
RE: lambertw, all branches - Albert Chan - 04-23-2023, 04:40 PM
RE: lambertw, all branches - Albert Chan - 01-19-2024, 04:14 PM
RE: lambertw, all branches - Albert Chan - 01-20-2024, 04:48 PM
RE: lambertw, all branches - Gil - 01-20-2024, 10:52 PM
RE: lambertw, all branches - Albert Chan - 01-21-2024 01:14 AM
RE: lambertw, all branches - Albert Chan - 01-21-2024, 01:54 AM
RE: lambertw, all branches - Gil - 01-21-2024, 01:53 PM
RE: lambertw, all branches - Albert Chan - 01-21-2024, 04:19 PM
RE: lambertw, all branches - Gil - 01-21-2024, 04:35 PM
RE: lambertw, all branches - Albert Chan - 01-21-2024, 06:03 PM
RE: lambertw, all branches - Albert Chan - 01-21-2024, 07:01 PM
RE: lambertw, all branches - Gil - 01-21-2024, 07:30 PM
RE: lambertw, all branches - Gil - 01-21-2024, 08:39 PM
RE: lambertw, all branches - Albert Chan - 01-21-2024, 10:06 PM
RE: lambertw, all branches - Gil - 01-21-2024, 09:51 PM
RE: lambertw, all branches - Gil - 01-21-2024, 10:56 PM
RE: lambertw, all branches - Albert Chan - 01-22-2024, 01:34 AM
RE: lambertw, all branches - Gil - 01-21-2024, 11:15 PM
RE: lambertw, all branches - Gil - 01-22-2024, 06:09 PM
RE: lambertw, all branches - Albert Chan - 01-22-2024, 07:29 PM
RE: lambertw, all branches - Gil - 01-22-2024, 11:33 PM
RE: lambertw, all branches - Albert Chan - 01-23-2024, 02:32 AM
RE: lambertw, all branches - Gil - 01-23-2024, 02:35 PM
RE: lambertw, all branches - Albert Chan - 01-23-2024, 03:54 PM
RE: lambertw, all branches - Gil - 01-23-2024, 04:57 PM
RE: lambertw, all branches - Albert Chan - 01-23-2024, 06:17 PM
RE: lambertw, all branches - Gil - 01-23-2024, 06:44 PM
RE: lambertw, all branches - Gil - 01-23-2024, 11:00 PM
RE: lambertw, all branches - Gil - 01-24-2024, 03:18 PM
RE: lambertw, all branches - Albert Chan - 01-24-2024, 08:53 PM
RE: lambertw, all branches - Gil - 01-25-2024, 12:37 AM
RE: lambertw, all branches - Gil - 01-25-2024, 01:10 AM
RE: lambertw, all branches - Gil - 01-25-2024, 03:04 AM
RE: lambertw, all branches - Albert Chan - 01-25-2024, 07:02 AM
RE: lambertw, all branches - Gil - 01-25-2024, 10:09 AM
RE: lambertw, all branches - Albert Chan - 01-25-2024, 04:13 PM
RE: lambertw, all branches - Gil - 01-25-2024, 05:14 PM
RE: lambertw, all branches - Albert Chan - 01-25-2024, 05:57 PM
RE: lambertw, all branches - Gil - 01-25-2024, 06:19 PM
RE: lambertw, all branches - Albert Chan - 01-28-2024, 11:18 PM
RE: lambertw, all branches - Albert Chan - 02-01-2024, 02:17 AM
RE: lambertw, all branches - Albert Chan - 02-01-2024, 04:16 PM
RE: lambertw, all branches - Albert Chan - 02-02-2024, 11:49 AM



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