function x = gradient_descent_vector_f ( f, df, x, it_max, alpha )

%*****************************************************************************80
%
%% gradient_descent_vector_f(): f(x) is vector, x is a vector.
%
%  Discusssion:
%
%    We are given a nonlinear vector function f(x) of a vector argument x,
%    and want to estimate the location of a local minimizer.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 July 2022
%
%  Author:
%
%    John Burkardt.
%
%  Input:
%
%    real value = F(X): evaluates the function.
%
%    real value = DF(X): evaluates the derivative of the function.
%
%    real X(N): the initial guess for the minimizer.
%
%    integer IT_MAX: the maximum number of steps.
%
%    real ALPHA: the learning rate.
%
%  Output:
%
%    real X(N): the estimated minimizer.
%
  print_out = true;

  if ( print_out )
    fprintf ( 1, '\n' );
    fprintf ( 1, '   it      ||x||             ||f(x)||       ||J(x)||\n' );
    fprintf ( 1, '\n' );
  end

  for it = 0 : it_max

    if ( 0 < it )
      x = x - alpha * df ( x ) * f ( x );
    end

    if ( print_out )
      fprintf ( 1, '  %3d  %12.8g  %12.8g  %12.8g\n', ...
        it, ...
        norm ( x ), ...
        0.5 * ( norm ( f ( x ) ) )^2, ...
        norm ( df ( x ), 'fro' ) );
    end

  end

  return
end


