function [objf,objgrd]=objfun(mode,x,objf,objgrd) % Routine to evaluate objective function and its 1st derivatives. if mode == 0 || mode == 2 objf = x(1) * x(4) * (x(1) + x(2) + x(3)) + x(3); end if mode == 2 objgrd(1) = x(4) * (2.0*x(1) + x(2) + x(3)); objgrd(2) = x(1) * x(4); objgrd(3) = x(1) * x(4) + 1.0; objgrd(4) = x(1) * (x(1) + x(2) + x(3)); end endfunction