function f = uvw(xy);
%
% uvw
% Objective function to minimize in Conjugate Gradient Homework.
% Vectorized to handle a  2 x n  input matrix xy,
% whose columns give the evaluation points in the plane.
% Returns a  1 x n  matrix of function values.
%
% Philip D. Loewen
% 25 Feb 98

x = xy(1,:);
y = xy(2,:);
y2 = y.*y;

one = ones(size(x));

u = x .* (y-one)     + 1.500*one;
v = x .* (y2-one)    + 2.250*one;
w = x .* (y2.*y-one) + 2.625*one;

f = one + 0.5*( u.*u + v.*v + w.*w );


