function thestar= Funccapifliendom(bta,muu,sig,gA,pistar,tau,Rstar,ge)
%function thestar = Funccapifliendom
x_ini = 0.10;
% bta=0.995;
% muu=1;
% sig=0.9540; % 0.721;
% gA=1.02;
% pistar=1.005;
% tau=1;
% Rstar=1.0175; % 1.0120;
% ge=1;
thestar = broyden(@(thestar)SolveTheta(thestar,bta,muu,sig,gA,pistar,tau,Rstar,ge),x_ini);
end

function res = SolveTheta(thestar,bta,muu,sig,gA,pistar,tau,Rstar,ge)
sigtil  = (log(1+sig^2/muu^2))^(1/2);
muutil  = log(muu)-1/2*sigtil^2;
F1      = normcdf((log(thestar)-muutil)/sigtil);
F2      = normcdf((log(thestar)-(muutil+sigtil^2))/sigtil);
Phi     = thestar*F1+muu*(1-F2);
res     = tau-Phi*Rstar*ge*bta/(gA*pistar);
end