function parabola_critical_test ( )

%*****************************************************************************80
%
%% parabola_critical tests parabola_critical.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 September 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'parabola_critical_test\n' );
  fprintf ( 1, '  parabola_critical finds the critical point x of a parabola\n' );
  fprintf ( 1, '  specified by function values at points a, b, and c.\n' );

  a = 10.0 * randn ( );
  b = 10.0 * randn ( );
  c = 10.0 * randn ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  A: f(%g) = %g\n', a, f(a) );
  fprintf ( 1, '  B: f(%g) = %g\n', b, f(b) );
  fprintf ( 1, '  C: f(%g) = %g\n', c, f(c) );

  x = parabola_critical ( @(x)f(x), a, b, c );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated critical point: f(%g)=%g\n', x, f(x) );
  fprintf ( 1, '  f''(%g) = %g\n', x, df(x) );

  return
end
function value = f ( x )
  value = 10.0 * x.^2 - 3.0 * x + 17;
  return
end
function value = df ( x )
  value = 20.0 * x - 3.0;
  return
end

