I probably do not understand the foregoing discussion but I also wonder:
With a definition of Lambert's W function as
# The Lambert W function (principal branch)
function lambert_W(x::Number)
# if x < -1/exp(1); return NaN; end
if x == -1/exp(1); return -1; end
w0 = 1.0
w1 = w0 - (w0 * exp(w0) - x)/((w0 + 1) * exp(w0) -
(w0 + 2) * (w0 * exp(w0) - x)/(2 * w0 + 2))
n::Int = 1
while abs(w1 - w0) > 1e-15 && n <= 20
w0 = w1
w1 = w0 - (w0 * exp(w0) - x)/((w0 + 1) * exp(w0) -
(w0 + 2) * (w0 * exp(w0) - x)/(2 * w0 + 2))
n += 1
end
return w1
end
how can I prevent this function to be used with complex numbers -- as the
result would be be completely wrong. Will I need a union of types, and will
this not make all function definitions quite cumbersome?
Hans Werner