Post Reply 
(28/48/50) Lambert W Function
03-23-2023, 07:30 PM (This post was last modified: 03-23-2023 07:42 PM by Albert Chan.)
Post: #11
RE: (28/48/50) Lambert W Function
(03-23-2023 05:53 PM)John Keith Wrote:  There is one line in your program that concerns me:

if h == err then return -1 end

It seems that the program would return -1 if a is the closest machine representation of -1/e, which would be -.367879441171 on the HP calculators. Instead, we would want the program to return -.999998449288 in branch 0, or -1.00000155071 in branch -1, which are the correct 12-digit representations of W(-.367879441171).

You are right.

Guard should be if (h == 0) ... but that would never happen.
Guard is not needed. I'll remove it.

Quote:x = sqrt(2*h/r) * (x and -1 or 1)

Last term is Lua idiom for ternary operators

It says that pick -1 if x evaluated true (neither nil nor false), 1 otherwise.
Signs are the result of solving W guess quadratic equation, 2 roots for W 2 branches
Find all posts by this user
Quote this message in a reply
Post Reply 


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-23-2023 07:30 PM
RE: (28/48/50) Lambert W Function - Gil - 01-29-2024, 11:04 AM
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 - Gil - 01-29-2024, 09:50 PM
RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 12:33 AM
RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 12:04 PM
RE: (28/48/50) Lambert W Function - Gil - 01-30-2024, 02:52 PM
RE: (28/48/50) Lambert W Function - Gil - 01-31-2024, 07:10 PM



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