function [eta0hat eta1hat] = Function15_01_est(EXO,x0)
% Computes the difference between the actual and model predicted
% survival function for the BCL demography:
%
%                       (eta_0 - eta_1 * exp(eta_1 * age) )
% surviving fraction =  -----------------------------------
%                                    eta_0 - 1 

age       = EXO.age;
survfrcn  = EXO.survfrcn;

[x, resnorm, residual, exitflag, output, jacobian] = lsqnonlin(@ErrSurv,x0);

% jacobian 
% Jacobian  = full(jacobian)
% whos

eta0hat   = x(1);
eta1hat   = x(2);

% x(1) = eta_0
% x(2) = eta_1

  function Result = ErrSurv(x)
  age_max   = log(x(1))/x(2);
  Result  = survfrcn - (age<age_max) .* (x(1) - exp(x(2) * age) ) / (x(1) - 1);
  end

end

