function retval = exerfnhess(x) % usage: hess = exerfnhess(x) % description: Returns the Hessian matrix for % exerfn(x). It is *assumed* that length(x) is even! % for adapting this problem, use c c = 10; m = length(x); retval = zeros(m,m); for j = (1:2:m) retval(j:j+1,j:j+1) = [2-4*c*x(j+1)+12*c*x(j)^2, -4*c*x(j); -4*c*x(j) 2*c]; end