function W = lambertw(k,X)
%LAMBERTW Lambert's W function.
%   W = LAMBERTW(X) is the solution to w*exp(w) = x.
%   W = LAMBERTW(K,X) is the K-th branch of this multi-valued function.
%   Reference: Robert M. Corless, G. H. Gonnet, D. E. G. Hare,
%   D. J. Jeffrey, and D. E. Knuth, "On the Lambert W Function",
%   Advances in Computational Mathematics, volume 5, 1996, pp. 329-359.
%   Also available from:
%   http://pineapple.apmaths.uwo.ca/~rmc/papers/LambertW/index.html

%   Copyright (c) 1993-1999 The Mathworks, Inc. All Rights Reserved.
%   $Revision: 1.8 $  $Date: 1999/01/05 13:58:15 $

if nargin == 1
   W = double(lambertw(sym(k)));
else
   W = double(lambertw(sym(k),sym(X)));
end
