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

%retval = [P(2)/(x(1)-P(2));1;-P(1)]; % P=x(1)/(1+exp(x(2)-x(3)*t))
%retval = [-1;P(2)*exp(x(2)-x(3)*P(1));-P(1)*P(2)*exp(x(2)-x(3)*P(1))]; % P=x(1)/(1+exp(x(2)-x(3)*t))
tmp1 = 1/exp(x(3)*P(1));
tmp2 = x(2) + (x(1)-x(2))*tmp1;
retval = [x(2)*x(1)*tmp1 - x(2)*tmp2; x(2)*x(1)*(1-tmp1) - x(1)*tmp2; ...
          -x(2)*x(1)*(x(1) - x(2))*P(1)*tmp1]/tmp2^2;