function retval = rosen(x)
% usage:  y = rosen(x)
% description: Returns value of Rosenbrock function
% assuming that x is a vector of length 2.
% Typical starting points for a min: (1.2,1.2),(-1.2,1).

% a little bit of bulletproofing
if (~isvector(x) | (length(x) ~= 2))
  error('rosen: needs a two-dimensional vector argument');
end
if (size(x,2) ~= 1)
  error('rosen: needs a column vector');
end 
% the actual calculation
retval = 100*(x(2)-x(1)^2)^2 + (1-x(1))^2;
