function value = rosenbrock_f ( x, n )

%*****************************************************************************80
%
%% rosenbrock_f() evaluates the Rosenbrock function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X(N), the evaluation point.
%
%    integer N, the number of variables.
%
%  Output:
%
%    real VALUE, the function value.
%
  value = 0.0;
  for j = 1 : n
    if ( mod ( j, 2 ) == 1 )
      value = value + ( 1.0 - x(j) ) ^ 2;
    else
      value = value + 100.0 * ( x(j) - x(j-1) ^ 2 ) ^ 2;
    end
  end

  return
end
