function [ H ] = Hessian_NLS_example( x )
% function [ H ] = Hessian_NLS_example( x ) returns the Hessian matrix of
% the least squares function corresponding to the simple nonlinear least 
% squares fitting problem in Chapter 8 of Ackleh and Kearfott, 
% "Applied Numerical Methods."

Hi = zeros(2,2,3);
Hi(:,:,1) = [0 0
             0 0];
Hi(:,:,2) = [   0         exp(x(2))
             exp(x(2))  x(1)*exp(x(2))];
Hi(:,:,3) = [    0             2*exp(2*x(2))
              2*exp(2*x(2))  4*x(1)*exp(2*x(2))];
         
Fp = F_prime_nonlinear_LS_example(x);
F = F_nonlinear_LS_example(x);

H = Fp'*Fp + F(1)*Hi(:,:,1) + F(2)*Hi(:,:,2) + F(3)*Hi(:,:,3);
end

