%WOFWY0 The Lambert function w_0(y) for -1/e\leq y<0
%
function w=wofy0(y)
if y<-exp(-1) | y>=0
  error('y out of range')
end
if y+exp(-1)>.5e-4
  w1=0;
  w0=1;
  while abs(w1-w0)>10^4*eps
    w0=w1;
    w1=(w0^2+y*exp(-w0))/(1+w0);
  end
  w=w1; 
else
  e=exp(1); x=sqrt(y+exp(-1));
  c1=sqrt(2*e); c2=-2*e/3;
  c3=11*sqrt(2)*e^(3/2)/36; c4=-43*e^2/135;
  c5=769*sqrt(2)*e^(5/2)/4320; c6=-1768*e^3/8505;
  w=-1+c1*x+c2*x^2+c3*x^3+c4*x^4+c5*x^5+c6*x^6;
end
