function newton_min ( )

%*****************************************************************************80
%
%% NEWTON_MIN uses a Newton iteration to seek the minimum of a function.
%
%  Discussion:
%
%    If F(X) is a minimum, then F'(X) = 0 (unless we are working in a
%    finite interval [A,B], in which case the minimizer might be at
%    the boundary, a case we can't deal with here!)
%
%    Let G(X) = F'(X), and think of Newton's method for finding a zero of G:
%
%    Start with a "reasonable" initial guess X(0), then define a sequence by
%
%      X(K+1) = X(K) - G(X(K)) / G'(X(K))
%
%    Now replace G(X) by F'(X):
%
%      X(K+1) = X(K) - F'(X(K)) / F''(X(K))
%
%    If this works, it will be fast and accurate.  But it might converge
%    to a maximizer or inflection point, and it might try to leave the
%    finite interval we need to work in.
%
  xold = 0.5;

  for i = 1 : 10

    f   =     ( x - 2 )^3 + 1.0;
    fp  = 3 * ( x - 2 )^2;
    fpp = 6 * ( x - 2 );

    xnew = xold - fp / fpp;

    fprintf ( 1, '  %f  %f  %f  %f\n', xold, f, fp, fpp );

    xold = xnew;

  end

  return
end
