function [F, J] = rbfun2(x)

% Computes the value and Jacobian of
% Rosenbrock's function (as a sum of squares).

F = [10*(x(2) - x(1)^2);
       (1 - x(1))];

if nargout > 1  % Compute J only if it actually
                       % needs to be evaluated.
    
    J = [-20*x(1), 10; -1, 0];
        
end

% Update the table of iteration points:
global iterations
iterations = [iterations; x];