function z=facevalue(eta,c,mu,sigma,r_m,d)

%this function computes the face value of the debt contract, v_barl that solves
%problem 2.

%eta: percent of assets retained by firm in case of bankruptcy
%c  : bankruptcy cost
%mu : Mean of normal (or T-distribution)
%sigma: stdv of normal (or T-distribution)
%r_m  : reservation return to entrepreneur
%d    : percent of debt finance (1-d) is equity

for ie=1:length(eta)
    for ic=1:length(c);
        for im=1:length(mu);
            for is=1:length(sigma);
                for ir=1:length(r_m);
                    for id=1:length(d);
                        bar_u=(1+r_m(ir))*(1-d(id));
                        [v_bar,x_star,payoff_lender,payoff_firm]=optimization(eta(ie),c(ic),mu(im),sigma(is),bar_u);
                        z(ie,ic,im,is,ir,id)=v_bar;
                    end;
                end;
            end;
        end;
    end;
end;

z=squeeze(z);       

