function ff = findsstrial(guess)

global  betac sigman chik epsilon_n deltac deltac_g alphac_b alphac_g omegab omegag epsilon_k epsilon_y epsilon_b epsilon_g ... 
        phi_1 phi_2 phi_3 d0 d1 d2 delta_x em_row delta_nw taubar iota_w gamma_w taub taug gamma_wg iota_wg mu_dmg
        %%gamma_w gamma_bank iota_w rho_r phi_pi phi_y rho_ab rho_ag r_ss pi_ss sigmac gamma_I gamma_k

kb=guess(1);
kg=guess(2);
nb=guess(3);
ng=guess(4);
em=guess(5);

abt=(taubar*phi_1/(phi_2*phi_3))^(1/(phi_3-1));
r=1/betac;
rkb=r+deltac-1;
rkg=r+deltac_g-1;
n=(nb^(1+epsilon_n)+ng^(1+epsilon_n))^(1/(1+epsilon_n)); 
ab=1;
ag=1;
x=(em+em_row)/(1-delta_x);
dmg=1-exp(-mu_dmg*x);
yb = ab*(1-dmg)*(kb^alphac_b)*(nb^(1-alphac_b));
yg = ag*(1-dmg)*(kg^alphac_g)*(ng^(1-alphac_g));
y=((omegab^(1/epsilon_k))*yb^((epsilon_k-1)/epsilon_k)+(omegag^(1/epsilon_k))*yg^((epsilon_k-1)/epsilon_k))^(epsilon_k/(epsilon_k-1));
pb=(omegab*(y/yb))^(1/epsilon_k);
pg=(omegag*(y/yg))^(1/epsilon_k);
%rkb=alphac_b*(yb/kb)*(pb-taubar*phi_1*(1-abt)-phi_2*(abt^phi_3))-deltac;
%rkg=alphac_g*(yg/kg)*pg-deltac_g;




ff1=kb/nb-(alphac_b*(1-dmg)*ab*(pb-taubar*phi_1*(1-abt)-phi_2*(abt^phi_3))/rkb)^(1/(1-alphac_b));                     
ff2=kg/ng-(alphac_g*(1-dmg)*ag*pg/rkg)^(1/(1-alphac_g));
ff3=chik*(n^(sigman-epsilon_n))*(nb^epsilon_n)-(1-alphac_b)*(yb/nb)*(pb-taubar*phi_1*(1-abt)-phi_2*(abt^phi_3));
ff4=chik*(n^(sigman-epsilon_n))*(ng^epsilon_n)-(1-alphac_g)*(yg/ng)*pg;
ff5=em-phi_1*(1-abt)*yb;
ff=[ff1, ff2, ff3, ff4, ff5]; 