function Result = Function17_01(x,PAR)
%
% 

r         = PAR.r;
w         = PAR.w;
beta      = PAR.beta;

e_1       = PAR.e_1;
e_2       = PAR.e_2;
e_3       = PAR.e_3;

pi_21     = PAR.pi_21;
pi_22     = PAR.pi_22;
pi_23     = PAR.pi_23;

pi_31     = PAR.pi_31;
pi_32     = PAR.pi_32;
pi_33     = PAR.pi_33;

% Computes A_2 and A_3
% x(1)     is A_2
% x(2)     is A_3
% Result(1) = - 1 / (w - A_2) + beta*(1+r)* (pi_21 / ((1+r)*A_2 + e_1 * w - A_3) ...
%   + pi_22 / ((1+r)*A_2 + e_2 * w - A_3) + pi_23 / ((1+r)*A_2 + e_3 * w - A_3));
%     
% Result(2) = - (pi_21 / ((1+r)*A_2 + e_1 * w - A_3) ...
%   + pi_22 / ((1+r)*A_2 + e_2 * w - A_3) + pi_23 / ((1+r)*A_2 + e_3 * w - A_3)) ...
%   + beta*(1+r)*(pi_31 / ((1+r)*A_3 + e_1 * w) + pi_32 / ((1+r)*A_3 + e_2 * w) ...
%   + pi_33 / ((1+r)*A_3 + e_3 * w) );

Result = zeros(size(x));
    
Result(1) = - 1 / (w - x(1)) + beta*(1+r)* (pi_21 / ((1+r)*x(1) + e_1 * w - x(2)) ...
  + pi_22 / ((1+r)*x(1) + e_2 * w - x(2)) + pi_23 / ((1+r)*x(1) + e_3 * w - x(2)));
    
Result(2) = - (pi_21 / ((1+r)*x(1) + e_1 * w - x(2)) ...
  + pi_22 / ((1+r)*x(1) + e_2 * w - x(2)) + pi_23 / ((1+r)*x(1) + e_3 * w - x(2))) ...
  +beta*(1+r)*(pi_31 / ((1+r)*x(2) + e_1 * w) + pi_32 / ((1+r)*x(2) + e_2 * w) ...
  + pi_33 / ((1+r)*x(2) + e_3 * w) );
    
   

end

