function grad = extrosenfngrad(x) % usage: y = extrosenfngrad(x) % description: Returns value of function of function of % Exercise 9.1 of Nocedal and Wright's text, Numerical % Optimization. This is the extended Rosenbrock % function. It is *assumed* that length(x) is even! % Solution is x* = (1,1,...,1), minimum value 0. % no bulletproofing % for adapting this problem, change c here and in % original and hessian functions. c = 10; m = length(x); grad = zeros(size(x)); grad(1:2:m-1) = 2*(x(1:2:m-1)-1) - 4*c*(x(2:2:m)-x(1:2:m-1).^2).*x(1:2:m-1); grad(2:2:m) = 2*c*(x(2:2:m)-x(1:2:m-1).^2);