% [f,g] = powell(x) : evaluate Powell's function [PMO, (3.1.3)]
% By Sven Leyffer, University of Dundee, 1997.
% -------------------------------------------------------------
function [f,g,H] = powell(x)
   f = x(1)^4   + x(1)*x(2) + (1+x(2))^2;
   if nargout > 1
      g    = zeros(2,1);      % ... make sure it's a column vector
      g(1) = 4*x(1)^3 + x(2);
      g(2) =            x(1)      + 2*(1+x(2));
   end
   if nargout > 2
      H(1,1) = 12*x(1);
      H(1,2) = 1;
      H(2,1) = 1;
      H(2,2) = 2;
   end
