function[val,g,H]=givenfGNM(x)
%givenf() modified to output the Hessian approximated by the Jacobian, as
%required by the Gauss-Newton Method
val=(1/2)*((2*x(1)-(x(2)*x(3))-1)^2+(1-x(1)+x(2)-exp(x(1)-x(3)))^2+(-x(1)-2*x(2)+3*x(3))^2);
if(nargout>1)
g=gradient(val, [x(1), x(2), x(3)]);
end
if(nargout>2)
J=jacobian(val, [x(1), x(2), x(3)]);
K=transpose(J);
H=mtimes(K,J);
end
end