function fsolve_test01 ( )

%*****************************************************************************80
%
%% fsolve_test01 tests fsolve() on a scalar function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2020
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../test_zero' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'fsolve_test01\n' );
  fprintf ( 1, '  Use fsolve() to solve a scalar nonlinear equation.\n' );

  x0 = p01_start ( 1 );
  x = fsolve ( @p01_fx, x0 );
  xe = p01_root ( 3 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Initial:  F(%g) = %g\n', x0, p01_fx ( x0 ) );
  fprintf ( 1, '  Final:    F(%g) = %g\n', x,  p01_fx ( x  ) );
  fprintf ( 1, '  Expected: F(%g) = %g\n', xe, p01_fx ( xe ) );

  x0 = p02_start ( 1 );
  x = fsolve ( @p02_fx, x0 );
  xe = p02_root ( 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Initial:  F(%g) = %g\n', x0, p02_fx ( x0 ) );
  fprintf ( 1, '  Final:    F(%g) = %g\n', x,  p02_fx ( x  ) );
  fprintf ( 1, '  Expected: F(%g) = %g\n', xe, p02_fx ( xe ) );

  x0 = p03_start ( 1 );
  x = fsolve ( @p03_fx, x0 );
  xe = p03_root ( 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Initial:  F(%g) = %g\n', x0, p03_fx ( x0 ) );
  fprintf ( 1, '  Final:    F(%g) = %g\n', x,  p03_fx ( x  ) );
  fprintf ( 1, '  Expected: F(%g) = %g\n', xe, p03_fx ( xe ) );

  x0 = p04_start ( 1 );
  x = fsolve ( @p04_fx, x0 );
  xe = p04_root ( 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Initial:  F(%g) = %g\n', x0, p04_fx ( x0 ) );
  fprintf ( 1, '  Final:    F(%g) = %g\n', x,  p04_fx ( x  ) );
  fprintf ( 1, '  Expected: F(%g) = %g\n', xe, p04_fx ( xe ) );

  x0 = p16_start ( 1 );
  x = fsolve ( @p16_fx, x0 );
  xe = p16_root ( 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Initial:  F(%g) = %g\n', x0, p16_fx ( x0 ) );
  fprintf ( 1, '  Final:    F(%g) = %g\n', x,  p16_fx ( x  ) );
  fprintf ( 1, '  Expected: F(%g) = %g\n', xe, p16_fx ( xe ) );
  rmpath ( '../test_zero' );

  return
end

