function v=vweg1(v1,v2,g,tmin,tmax)
% vweg1: Makes a "single" Wegstein step inside VWEG2
%function v=vweg1(v1,v2,g,tmin,tmax)
%
%Argument 	Gives
%   v1		the initial guess for x
%   v2		the value of function g at initial guess v1
%    g          the character vector naming a function that tells
%		how to find a better value for the unknown vector x
%		given an approximate set: v1
%  tmin		min allowed change in a step
%  tmax		max allowed change in a step
%revised help by TYLC
x=v1;
g1=eval(g);
x=v2;
g2=eval(g);
t=[];
for k=1:length(g1)
   dg=g2(k)-g1(k);
   if abs(dg)<eps
      t=[t,1];
   else
      s=dg/(v2(k)-v1(k));
      if eps>abs(s)
         s=s+1;
      end
      tk=max(1/(1-s),tmin);
      t=[t,min(tk,tmax)];
    end
end
v=(v1.*(1-t))+t.*g1;
