function rosenbrock_gradient2 ( )

%*****************************************************************************80
%
%% rosenbrock_gradient2 uses gradient descent on the rosenbrock function.
%
%  Discussion:
%
%    Gradient descent for a function of 2 variables.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 October 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'rosenbrock_gradient2:\n' );
  fprintf ( 1, '  Seek minimizer of a function f(x,y).\n' );
%
%  Choose a initial guess.
% 
  x0 = [ 1.25, 1.5 ];
%
%  Choose a small learning rate.
%
  r = 0.0025;
%
%  Choose a small tolerance for the stepsize.
%
  dxtol = 0.00001;
%
%  Choose a small tolerance for the derivative.
%
  dftol = 0.001;
%
%  Maximum number of iterations
%
  itmax = 10000;

  [ x, it ] = gradient_descent2 ( @(x)rosenbrock(x), @(x)rosenbrock_df(x), x0, r, dxtol, dftol, itmax );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d gradient descent steps were taken.\n', it );
  fprintf ( 1, '  Initial x,y = (%g,%g),  f(x,y) = %g, f''(x,y) = (%g,%g)\n', ...
    x0, rosenbrock ( x0 ), rosenbrock_df ( x0 ) )
  fprintf ( 1, '  Final   x,y = (%g,%g),  f(x,y) = %g, f''(x,y) = (%g,%g)\n', ...
    x, rosenbrock ( x ), rosenbrock_df ( x ) )
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'rosenbrock_gradient2:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  return
