function z=optxstar(v_bar,eta,c,mu,sigma)

%computes the the value of x_star at which contstraint (10) is satisfied
%a value of -99 is reported if (10) cannot be satisfied.


%x_bar is the upper end of the distribution of project realizations. For
%normal or T-distribution it is sufficient to choose a value such that
%there is little probability mass to the right of x_bar.
x_bar=10;

x_star=v_bar/(1-eta);

if defaultpayoff(v_bar,x_star,eta,c,mu,sigma)>=0
    z=x_star;
else
    if defaultpayoff(v_bar,x_bar,eta,c,mu,sigma)<0
        z=-99;
    else
        startvalue=x_star+1;
        [z,fval,exitflag] = fsolve(@(x_star) defaultpayoff(v_bar,x_star,eta,c,mu,sigma),startvalue);
    end;
end;


