function wv=lambert(x)
  w=1;
  we=1;
  wv=[];
  n=length(x);
  tol=10^-12;
  for j=1:n
    while (abs(we)>tol)
      we=-(w*exp(w)-x(j))/(exp(w)*(w+1)-(w+2)*(w*exp(w)-x(j))/(2*w+2));
      w=w+we;
    endwhile
    wv=[wv w];
  endfor
endfunction