function fn=fomega2(x0,pars);

omegabar = x0(1);
sigmaw = x0(2);
Fwbar = pars(1);
muc = pars(2);
bbar_k = pars(3);
muw   = -(1/2)*(sigmaw^2);

% Christiano's notation
%Fwbar = normcdf((log(omegabar) + 0.5*(sigmaw^2))/sigmaw);
%Gwbar = normcdf(((log(omegabar) + 0.5*(sigmaw^2))/sigmaw) - sigmaw);
%Fwbar_w = (1/(omegabar*sigmaw))*normpdf((log(omegabar) + 0.5*(sigmaw^2))/sigmaw);

% Matlab + JFV
Gwbar = 1 - normcdf(((-log(omegabar) + 0.5*(sigmaw^2))/sigmaw));
Fwbar_w = lognpdf(omegabar,muw,sigmaw);

% Additional computations indifferent to the previous derivation
Gwbar_w = omegabar*Fwbar_w;

Gamawbar = omegabar*(1-Fwbar) + Gwbar;

Omegat = ((Gamawbar - muc*Gwbar)/(1-Gamawbar)) * ((1-Fwbar)/(1-Fwbar - muc*Gwbar_w));


fn1 = bbar_k*(1+Omegat) - Omegat;
fn2 = Fwbar - logncdf(omegabar,muw,sigmaw);

fn = fn1^2 + fn2^2;