Entry 953
fminsearch
Submitted by anonymous
on Aug. 23, 2008 at 5:34 p.m.
Language: Matlab. Code size: 776 bytes.
%% find the cost minimizing input x0 = [1,1,1] [xstar,fval,exitflag,output] = fminsearch(objfn,x0) %disp('optimal input'), disp(xstar) %% verify with theoretical results fprintf('\nCompare numerical and Theoretical results\n') fprintf( '-----------------------------------------\n') %disp('cost shares'), xstar.*w/fval disp('numerical and analytic cost shares') wc=w.^(eta+1)./(theta.^eta); sharesv = wc/sum(wc) disp([xstar.*w/fval;wc/sum(wc)]) lambda = (sum(wc)/fval).^(1/eta); % formula for lambda with numerical unitcost lambda_r = sum(wc)^(1/(eta+1)); % formula for lambda without endogenous variables disp('fval lambda lambda_r'), disp([fval; lambda; lambda_r]) disp('numerical and theoretical demand') xd=(w./theta/lambda).^eta; disp([xstar;xd])
This snippet took 0.01 seconds to highlight.
Back to the Entry List or Home.