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

%*****************************************************************************80
%
%% gradient_descent_vector_x(): f(x) is scalar, x is a vector.
%
%  Discusssion:
%
%    We are given a scalar nonlinear 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:
%
%    28 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 = false;

  if ( print_out )
    fprintf ( 1, '\n' )
    fprintf ( 1, '   it      ||x||               f(x)         ||f''(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 ), f ( x ), norm ( df ( x ) ) )
    end

  end

  return
end


