
function [ F ]  = find_steady_final(x, gamma,gammaz,eta,beta,betaz,alpha1,alpha2,alpha2bar,alpha1z,alpha2z,alpha2barz,kappaG,kappaGz,GAM,n,delta,iota,zeta,csi,kappaA,mu,muz,nu,tau,tauz,A,r,rz,v,g,gz,Az,psiG,psiB,kappaB,kappaBz,rho,deltax)
yH=x(1);
pH=x(2);
pB=x(3);
pBz=x(4);
prB=x(5);
prBz=x(6);
prG=x(7);
prGz=x(8);
yFz=x(9);

pF=((1-(1-gamma)*pH^(1-eta))/gamma)^(1/(1-eta));
s=(gammaz*pH^(1-eta)+(1-gammaz)*pF^(1-eta))^(1/(1-eta));
dH=(1-beta/betaz)/GAM;
dF=s/GAM*(betaz/beta-1);
b=-(v+dH+dF*(1-n)/n);
gdp=pH*yH;
rkB=iota/beta-(1-delta)+prB;            % brown return of AE domestic capital
rkB_zd=iota/beta-(1-delta)+prB;         % brown return of EME foreign capital
rkB_zu=iota/betaz-(1-delta)+prBz;       % brown return of AE foreign capital
rkB_zz=iota/betaz-(1-delta)+prBz;       % brown return of EME domestic capital
rkG=iota/beta-(1-delta)+prG;            % green return of AE domestic capital
rkG_zz=iota/betaz-(1-delta)+prGz;       % green return of EME domestic capital
rkG_zd=iota/beta-(1-delta)+prG;         % green return of EME foreign capital
rkG_zu=iota/betaz-(1-delta)+prGz;       % green return of AE foreign capital
yB=zeta*(pB/pH)^(-csi)*yH;
pB2=pB-tau*(1-mu)-kappaA/(1+nu)*mu^(1+nu);
pB2z=pBz-tauz*(1-muz)-kappaA/(1+nu)*muz^(1+nu);
pGY=pH*yH-pB*yB;
kB=alpha1*iota/rkB*pB2*yB;
kG=alpha1*iota/rkG*pGY;
i=(kB+kG)*(1-(1-delta)/iota);
kB_zu=alpha2bar*iota/rkB_zu*pB2*yB;
kG_zu=alpha2bar*iota/rkG_zu*pGY;
i_zu=(kB_zu+kG_zu)*(1-(1-delta)/iota);
hB=(yB/(A*(kB/iota)^alpha1*(kB_zu/iota)^alpha2))^(1/(1-alpha1-alpha2));
w=(1-alpha1-alpha2)*pB2*yB/hB;
hG=(1-alpha1-alpha2)*pGY/w;
yG=A*(kG/iota)^alpha1*(kG_zu/iota)^alpha2*(hG)^(1-alpha1-alpha2);
pG=pGY/yG;
yBz=zeta*(s*pBz/pF)^(-csi)*yFz;
gdpz=pF*yFz/s;
pGYz=gdpz-pBz*yBz;
kB_zz=alpha1z*iota*pB2z*yBz/rkB_zz;
kG_zz=alpha1z*iota*pGYz/rkG_zz;
kB_zd=alpha2barz*iota*pB2z*yBz/rkB_zd;
kG_zd=alpha2barz*iota*pGYz/rkG_zd;
i_zd=(kB_zd+kG_zd)*(1-(1-delta)/iota);
i_zz=(kB_zz+kG_zz)*(1-(1-delta)/iota);
c=-(i+pH*g+kappaA/(1+nu)*mu^(1+nu)*yB+b+(1-n)/n*s*i_zd-s*(1-n)/n*(rkB_zd*kB_zd    +rkG_zd*kG_zd)    /iota+(rkB_zu*kB_zu    +rkG_zu*kG_zu)    /iota+rz            *(dH+v)    /iota-r/iota    *(b+    dH    +v)-gdp);
cz=n/((1-n)*gammaz)*(pH/s)^(eta)*(yH-((1-gamma)*pH^(-eta)*(c+i+kappaA/(1+nu)*mu^(1+nu)*yB+i_zu)+g))-(i_zz+i_zd+kappaA/(1+nu)*muz^(1+nu)*yBz);
wz=(1-alpha1z-alpha2z)*(pB2z*yBz+pGYz);
hBz=(1-alpha1z-alpha2z)*pB2z*yBz/wz;
hGz=1-hBz;
yGz=Az*(kG_zz/iota)^alpha1z*(kG_zd/iota)^alpha2z*(hGz)^(1-alpha1z-alpha2z);
pGz=pGYz/yGz;
e=(1-mu)*yB;                                                                                                 
ez=(1-muz)*yBz;   
x=(n*e+(1-n)*ez)/((1-(1-deltax)/iota));
F=[hB+hG-1
    (1-n)*((1-gammaz)*(pF/s)^(-eta)*(cz+i_zz+i_zd+kappaA/(1+nu)*muz^(1+nu)*yBz)+gz)+n*(gamma*(pF^(-eta))*(c+i+i_zu+kappaA/(1+nu)*mu^(1+nu)*yB))-(1-n)*yFz
    yGz-(1-zeta)*(s*pGz/pF)^(-csi)*yFz
    yG-(1-zeta)*(pG/pH)^(-csi)*yH
    Az-yBz/((kB_zz/iota)^alpha1z*(kB_zd/iota)^alpha2z*(hBz)^(1-alpha1z-alpha2z))
    kappaG-(1-beta/iota*(rkG+1-delta))/((kG+(1-n)/n*s*kG_zd)^(-psiG)*(c-rho*x))
    kappaGz-(1-betaz/iota*(rkG_zz+1-delta))/((kG_zz+n/(1-n)*kG_zu/s)^(-psiG)*(cz-rho*x))
    kappaB-(beta/iota*(rkB+1-delta)-1)/((kB+(1-n)/n*s*kB_zd)^(psiB)*(c-rho*x))
    kappaBz-(betaz/iota*(rkB_zz+1-delta)-1)/((kB_zz+n/(1-n)*kB_zu/s)^(psiB)*(cz-rho*x))
    ];
end