function retval = logisticfn(x,P)
% usage:  y = logisticfn(x,P)
% description: returns logistic fn residual
% given arguments x and parameters P.

%retval = x(2)-x(3)*P(1)-log((x(1)-P(2))/P(2)); % P=x(1)/(1+exp(x(2)-x(3)*t))
%retval = P(2)*(1+exp(x(2)-x(3)*P(1))) - x(1); % P=x(1)/(1+exp(x(2)-x(3)*t))
retval = P(2)-x(2)*x(1)/(x(2)+(x(1)-x(2))*exp(-x(3)*P(1))); % just the formula