function grad = rosengrad(x)
% usage: grad = rosengrad(x)
% description: Returns the gradient vector for
% rosen(x).

% 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
grad = [400*(x(1)^2-x(2))*x(1) + 2*(x(1)-1); 200*(x(2)-x(1)^2)];
