Post Reply 
Python: Complex Number Arithmetic and Lambert Function
07-14-2021, 04:17 PM (This post was last modified: 07-14-2021 05:27 PM by Albert Chan.)
Post: #2
RE: Python: Complex Number Arithmetic and Lambert Function
Newton's method with f(w) = w*e^w - z is not stable with bad guess.
https://www.hpmuseum.org/forum/thread-15...#pid138282

A better setup is with f(w) = w + log(w/z), more stable and faster convergence.
https://www.hpmuseum.org/forum/thread-15...#pid138355

>>> from mpmath import *
>>> z = 2+3j
>>> w = 1+1j # guess of W(z)
>>> for i in range(5): w -= (w-z*exp(-w)) / (w+1); print i+1, w
...
1 (0.925920455007468 + 0.525629062362773j)
2 (1.11168436157991 + 0.529383890736917j)
3 (1.09040865244656 + 0.530090770362652j)
4 (1.09007661082612 + 0.530139691067221j)
5 (1.09007653448579 + 0.530139720774835j)

>>> w = 1+1j # guess of W(z)
>>> for i in range(5): w -= (w+log(w/z))*w/(w+1); print i+1, w
...
1 (1.1220615411005 + 0.505617553600088j)
2 (1.09019950929821 + 0.530419495346751j)
3 (1.09007653522354 + 0.530139702926175j)
4 (1.09007653448579 + 0.530139720774839j)
5 (1.09007653448579 + 0.530139720774839j)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python: Complex Number Arithmetic and Lambert Function - Albert Chan - 07-14-2021 04:17 PM



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