function [x,fval,exitflag,output] = aula(x)

%isto e' um comentario

xstart = [1; 0];

options = optimset('GradObj','on','Hessian','on','Display','iter','TolX',0.000000000000000001); 
[x,fval,exitflag,output] = ...
   fminunc(@f_obj,xstart,      options)

%[f,g,H] = f_obj(xstart)
%x = fminunc(@f_obj, xstart);


   function [f,g,H] = f_obj(x)
      % Evaluate the function.
      f = ( x(2)-x(1)^2 )^2 + ( 1-x(1) )^2; 
%
      % Evaluate the gradient.
      if nargout > 1
        g = zeros(2,1);
        g(1,1) = -4*x(1)*( x(2)-x(1)^2 ) - 2*x(1);
        g(2,1) = 2*( x(2)-x(1)^2 );
      end
%
      % Evaluate the symmetric Hessian matrix
      if nargout > 2
        H = zeros(2,2);
        H(1,1) = -4*x(2) + 12*x(1)^2 - 2;  
        H(1,2) = -4*x(1);  
        H(2,1) = -4*x(1);  
        H(2,2) = 2;  
      end
