8

I'm working on a project and have found myself in a situation where I need a function to be able to get at least an approximation of the value of W(x), the Lambert W function, where x can be any real number. I'm working in Java. I couldn't find any implementations of W in java when I searched. I am willing to code up the implementation myself if need be, but I am unsure of how that would be done right now. Any pushes in the right direction would be much appreciated.

Michael J. Lee
12.5k3 gold badges25 silver badges39 bronze badges
asked Jul 22, 2011 at 16:19
1
  • Also, if it makes a difference, I think that I only need W on the domain of [0,inf). Commented Jul 22, 2011 at 16:30

2 Answers 2

6

Take a look at this page: http://mathworld.wolfram.com/LambertW-Function.html

It lists an approximation for z>3 as well as a series expansion for the function.

You can also use Newton's method and Halley's method to approximate the function: http://en.wikipedia.org/wiki/Lambert_W_function#Numerical_evaluation

answered Jul 22, 2011 at 16:31
Sign up to request clarification or add additional context in comments.

4 Comments

Looking at the approximation for z>3 on the first link you posted, I understand most of the formula except for the end bit. What does the O[(L1/L2)^6] part mean? Also when it says something like L2(-2 + L2) would that be lnlnz * (-2 + lnlnz) or lnln(-2 + lnlnz)?
The +O(stuff) at the end is just an error term. You can ignore it. And L2(-2 + L2) = lnlnz * (-2 + lnlnz)
Thanks! That clears some things up. So I could probably just use that formula for input to the function greater than 3, and find a simpler approximation formula for input between 0 and 3?
That sounds about right. You should compare all these different methods though to see which one gives you the best approximation. I don't know the answer to that question.
3

The lambert function is the reciprocal function of g(w) = w*exp(w) it verifies:

W(z)eW(z) = z.

A good way to evaluate W(z) on a given z would be to use newton raphson method :

to solve : f(Y)= Yexp(Y) - z = 0.

you will find Y = W(z) with the method

You would have to find and implementation in java of the method yourself.

Hope it helps

below an illustration from wikipedia of the method:

enter image description here

answered Jul 22, 2011 at 16:34

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.