lambertw, all branches
|
04-23-2023, 04:40 PM
(This post was last modified: 02-01-2024 03:35 PM by Albert Chan.)
Post: #16
|
|||
|
|||
RE: lambertw, all branches
complex.W version 3, adapted for system without signed zero.
This time I made a customized LN(x) to honor signed zero. Code: from mpmath import * # no signed zero support Trivia: W(a < -1/e) is complex, W0(a) = conj(W-1(a)) x + ln(x) = lnk(a) ln0(a) = ln(|a|) - pi*j + 2*pi*j = ln1(conj(a)) W0(a) = W1(conj(a)) = conj(W-1(a)) >>> a = -pi/2 >>> W(a, 0, True) (0.375191803678016 + 1.59508875325509j) (0.0128176527641888 + 1.58759064221342j) (-5.58573510823744e-5 + 1.57084664181356j) (6.00809277877961e-10 + 1.57079632603836j) (5.72587285769658e-17 + 1.5707963267949j) (1.30059124689582e-17 + 1.5707963267949j) >>> W(a, -1, True) (0.451582705289455 - 1.5707963267949j) (0.0200654830289762 - 1.59320451813763j) (-9.57300550001525e-5 - 1.57091376376939j) (1.39642133562001e-9 - 1.5707963231279j) (-3.14444301571107e-17 - 1.5707963267949j) (-5.01152163329281e-17 - 1.5707963267949j) Confirm x * exp(x) = a, both at the same time. (±pi/2*j) * exp(±pi/2*j) = (±pi/2*j) * (±j) = pi/2 * j² = -pi/2 Udpate 1/19/24: added |a| = ∞ or 0 edge cases p2> W(inf), W(-inf) ((+inf + 0.0j), (+inf + 3.14159265358979j)) p2> W(0, -1) (-inf - 3.14159265358979j) Default setup is 0 == +0, that is why we get W-1(+0) = -∞ - pi*I To get W-1(0) = -∞, we need special case for k=-1, 0 == −0 + 0*I Real part -0, Imag part +0 ... it is just too confusing. I am keeping 0 == +0, for consistency. ln(0) = ln(+0) = -∞ --> Wk(+0) = 0 if k==0 else -∞ + (2*k-sign(k))*pi*I Of course, we are free to patch it to make it pick what we wanted. But then, what is Wk(0) in general ? Is 0 still meant +0 + 0*I ? This is a weakness of not having signed zero. Update 2/01/24 lyuka branch relative limit reduced, from 1e-12 to 1e-9 (see post #14) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)