function grad = exerfngrad(x)
% usage: grad = exerfngrad(x)
% description: Returns the gradient vector for
% exerfn(x). It is *assumed* that length(x) is even!

% no bulletproofing
% for adapting this problem, use c
c = 10;
m = length(x);
grad = zeros(size(x));
grad(1:2:m-1) = 2*(x(1:2:m-1)-1) - 4*c*(x(2:2:m)-x(1:2:m-1).^2).*x(1:2:m-1);
grad(2:2:m) = 2*c*(x(2:2:m)-x(1:2:m-1).^2);