HP49-50G Lambert function
10-18-2020, 10:22 AM
Post: #2
 Gil Senior Member Posts: 378 Joined: Oct 2019
RE: HP49-50G Lambert function
Lambert function for HP49-50G
Version 1.2*
W.Y=>X

Having the value Y,
find the X value such that (...X) × EXP (...X) = Y.

The program gives almost instantaneous answer,
but do no tamper on previously registered variable.

* On that version 2, I slightly modified the code when testing possible existence of variable X: I included here the case of possible existing variable X being a program.

Here is the program code:

« "Lambert W(Y):
Having result Y,
W(Y) finds / gives X
such that
(X * EXP X) = Y
W(X * EXP X) =X

" DROP =>Y
«
IFERR 'X' 'X' RCL
THEN
ELSE
END 'X*EXP(X)-Y' 'X' 1 ROOT UNROT DUP2 SAME
IF
THEN DROP2 'X' PURGE
ELSE SWAP STO
END "W(" Y + ")" + =>TAG
»
»

The same calculation example may apply:

Example of use:

What is the Lambert x value for y=(sqrt 2) /2?
1) 2 SQRT 2 / gives. 707
2) 2 SQRT 2 / W.Y=>X gives 0.4506

Application:

Solve x^2*e^x=2

Take square root, on both sides, of the above expression:
x*e^(x/2) = sqrt 2

Divide both sides by 2:
(x/2)*e^(x/2) = (sqrt 2) / 2

The above result has a[/u] form of:
"(X..X)" * e ^"(X..X) " = (sqrt 2)/2

Then W ["(X..X)" * e ^"(X..X)"] = W [(sqrt 2)/2]
Or "X.. X" = W [(sqrt 2)/2]

In our case we have:
W[(x/2)*e^(x/2)] = W[(sqrt 2) / 2]
Or x/2 = W[(sqrt 2) / 2]
Or x = 2 * W[(sqrt 2) / 2] = 2 * 0.4506 = 0.9012

Remarks welcome.

Regards,
Gil Campart

Attached File(s)