function y = objective (x, ord)
%OBJECTIVE  Values about the objective function
%
%   y = objective(x, ord) = d^ord y / d x^ord at point x.

%   Ling Li, Caltech
%   05/05/2001

if nargin < 2,
    ord = 0;
end

x1x2 = x(1)*x(2);
x12 = x(1)*x(1);
x22 = x(2)*x(2);
if ord == 0,
    %        4      4        2     2
    % y = 2x1  + 3x2  - 20(x1  + x2 ) + 2x1(x2-1)
    y = 2*x12*x12 + 3*x22*x22 - 20*(x12+x22) + 2*(x1x2 - x(1));

elseif ord == 1,
    % y'
    y = [8*x(1)*(x12 - 5) + 2*x(2)-2; ...
         2*x(1) + x(2)*(12*x22 - 40)];

elseif ord == 2,
    % y''
    y = [24*x12-40, 2; 2, 36*x22-40];

else
    error('ord should be 0, 1, or 2');
end
