function fnfor=fomega2open(x0for,parsfor);

omegabarfor = x0for(1);
sigmawfor = x0for(2);
Fwbarfor = parsfor(1);
mucfor = parsfor(2);
bbar_kfor = parsfor(3);
muwfor  = -(1/2)*(sigmawfor^2);

Gwbarfor = 1 - normcdf(((-log(omegabarfor) + 0.5*(sigmawfor^2))/sigmawfor));
Fwbar_wfor = lognpdf(omegabarfor,muwfor,sigmawfor);

Gwbar_wfor = omegabarfor*Fwbar_wfor;

Gamawbarfor = omegabarfor*(1-Fwbarfor) + Gwbarfor;

Omegatfor = ((Gamawbarfor - mucfor*Gwbarfor)/(1-Gamawbarfor)) * ((1-Fwbarfor)/(1-Fwbarfor - mucfor*Gwbar_wfor));


fn1for = bbar_kfor*(1+Omegatfor) - Omegatfor;
fn2for = Fwbarfor - logncdf(omegabarfor,muwfor,sigmawfor);

fnfor = fn1for^2 + fn2for^2;