/* Problem Setup */ /* linear vector in consumer surplus */ a={14.252,33.119}; /* quadratic matrix in consumer surplus */ aa={-0.00478 -0.00796, -0.00796 -0.02590}; /* linear vector in producer surplus */ b={-4.780,-15.140}; /* quadratic matrix in producer surplus */ bb={0.007097 0.001577, 0.001577 0.025684}; /* constraint matrix */ ac={1 0 -1 0,0 1 0 -1}; /* nullspace of constraint matrix */ z=null(ac); /* candidate point for optimum */ xstar={1000,750,1000,750}; /* objective function value */ f=(a|-b)'xstar+.5*xstar'((aa~zeros(2,2))|(zeros(2,2)~-bb))*xstar; /* gradient vector value */ g=(a|-b)+((aa~zeros(2,2))|(zeros(2,2)~-bb))*xstar; /* compute the projected gradient */ projg=g'z; projg; /* norm of the projected gradient */ norm=sqrt((g'z)*(g'z)'); norm; /* projected Hessian matrix */ hessp=z'((aa~zeros(2,2))|(zeros(2,2)~-bb))*z; /* eigenvalues of the projected Hessian matrix */ {va,ve}=eigrs2(hessp); va;