function distance=nonlinear_guido(x, BETTA, ALPHA, THETA, SIGMA, DELTHA, PAISS, BSS, GSS, EPSI, SSS, Q, ETA)

%x=[Y, Z, r]

e1 = ( (1-ALPHA*PAISS^(THETA-1))/(1-ALPHA) )^( (1-THETA+THETA/SIGMA)/(1-THETA) ) - ...
    ETA*THETA/ (SIGMA*(THETA-1)*(1-DELTHA)) * ( 1-ALPHA*(1+x(3))^-1*PAISS^(THETA-1) ) / ( 1-ALPHA*(1+x(3))^-1*PAISS^(THETA/SIGMA) ) * x(2)^-DELTHA*SSS^(EPSI-1)*x(1)^(EPSI/SIGMA-1);

e2 = (x(2)-GSS- (DELTHA/(1-DELTHA))^(-DELTHA) * (((1+x(3))*PAISS)/((1+x(3))*PAISS-1))^-DELTHA*ETA/EPSI*SSS^EPSI*x(1)^(EPSI/SIGMA))*(1-BETTA*(1+x(3)))+...
    (1-DELTHA)*(1-BETTA*Q)*(Q^-1-1)*(x(2)*(x(1)-GSS)/PAISS+BSS);

e3 = DELTHA/(1-DELTHA) * (((1+x(3))*PAISS)/((1+x(3))*PAISS-1))-x(2);


num_dist=[e1 e2 e3];

distance=num_dist*num_dist';