function ode_euler_test ( )

%*****************************************************************************80
%
%% ode_euler_test() tests ode_euler().
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 July 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../ode_euler' );

  timestamp ( );
  fprintf ( 1, 'ode_euler_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  ode_euler() is an interactive program which uses\n' );
  fprintf ( 1, '  the Euler method to estimate the solution of\n' );
  fprintf ( 1, '  an ordinary differential equation (ODE) of the form\n' );
  fprintf ( 1, '    y'' = f(x,y)\n' )
  fprintf ( 1, '  for a <= x <= b, with initial condition y(a)=ya\n' );
  fprintf ( 1, '  using n steps.\n' );
%
%  Use a coarse grid.
%
  a = 0.0;
  b = 2.0;
  ya = humps_fun ( a );
  n = 10;
  [ xp, yp ] = ode_euler ( 'humps_deriv(x,y)', a, b, ya, n );

  ne = 101;
  xe = linspace ( a, b, ne );
  xe = xe';
  ye = humps_fun ( xe );

  plot ( xe, ye, 'b-', xp, yp, 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- X -->' );
  ylabel ( '<-- Y -->' );
  label = sprintf ( 'Euler solution using %d steps', n );
  title ( label );
  filename = sprintf ( 'humps_%d.png', n );
  print ( '-dpng', filename );
  pause ( 5 );
%
%  Use a finer grid.
%
  a = 0.0;
  b = 2.0;
  ya = humps_fun ( a );
  n = 100;
  [ xp, yp ] = ode_euler ( 'humps_deriv(x,y)', a, b, ya, n );

  ne = 101;
  xe = linspace ( a, b, ne );
  xe = xe';
  ye = humps_fun ( xe );

  plot ( xe, ye, 'b-', xp, yp, 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- X -->' );
  ylabel ( '<-- Y -->' );
  label = sprintf ( 'Euler solution using %d steps', n );
  title ( label );
  filename = sprintf ( 'humps_%d.png', n );
  print ( '-dpng', filename );
  pause ( 5 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ode_euler_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../ode_euler' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

