function predator_prey_ode_period_test ( )

%*****************************************************************************80
%
%% predator_prey_ode_period_test() tests predator_prey_ode_period().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 December 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../predator_prey_ode_period' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'predator_prey_ode_period_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Solve the predator/prey ODE for given parameters\n' );
  fprintf ( 1, '  and estimate the period P.\n' );
%
%  Restore the default parameter values.
%
  alpha = 2.0;
  beta = 0.001;
  gamma = 10.0;
  delta = 0.002;
  t0 = 0.0;
  y0 = [ 5000, 100 ];
  tstop = 10.0;
  predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Vary alpha.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '      ALPHA       Beta      Gamma      Delta    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for alpha = [ 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0 ]
%
%  Update parameters.
%
    predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Estimate period.
%
    p_nonlinear = predator_prey_period ( );
%
%  Get energy H.
%
    h = predator_prey_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p, np ] = predator_prey_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      alpha, beta, gamma, delta, np, p, p_nonlinear, tstop, h );

  end
%
%  Restore the default parameter values.
%
  alpha = 2.0;
  beta = 0.001;
  gamma = 10.0;
  delta = 0.002;
  t0 = 0.0;
  y0 = [ 5000, 100 ];
  tstop = 10.0;
  predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Vary beta.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '      Alpha       BETA      Gamma      Delta    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for beta = [ 0.0005, 0.001, 0.002, 0.005 ]
%
%  Update parameters.
%
    predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Estimate period.
%
    p_nonlinear = predator_prey_period ( );
%
%  Get energy H.
%
    h = predator_prey_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p, np ] = predator_prey_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      alpha, beta, gamma, delta, np, p, p_nonlinear, tstop, h );

  end
%
%  Restore the default parameter values.
%
  alpha = 2.0;
  beta = 0.001;
  gamma = 10.0;
  delta = 0.002;
  t0 = 0.0;
  y0 = [ 5000, 100 ];
  tstop = 10.0;
  predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Vary gamma.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '      Alpha       Beta      GAMMA      Delta    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for gamma = [ 5.0, 7.5, 10.0, 15.0 ]
%
%  Update parameters.
%
    predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Estimate period.
%
    p_nonlinear = predator_prey_period ( );
%
%  Get energy H.
%
    h = predator_prey_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p, np ] = predator_prey_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      alpha, beta, gamma, delta, np, p, p_nonlinear, tstop, h );

  end
%
%  Restore the default parameter values.
%
  alpha = 2.0;
  beta = 0.001;
  gamma = 10.0;
  delta = 0.002;
  t0 = 0.0;
  y0 = [ 5000, 100 ];
  tstop = 10.0;
  predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Vary delta.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '      Alpha       Beta      Gamma      DELTA    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for delta = [ 0.001, 0.002, 0.003, 0.004, 0.005 ]
%
%  Update parameters.
%
    predator_prey_parameters ( alpha, beta, gamma, delta, t0, y0, tstop );
%
%  Estimate period.
%
    p_nonlinear = predator_prey_period ( );
%
%  Get energy H.
%
    h = predator_prey_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p, np ] = predator_prey_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      alpha, beta, gamma, delta, np, p, p_nonlinear, tstop, h );

  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'predator_prey_ode_period_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../predator_prey_ode_period' );

  return
end
function timestamp ( )

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

  return
end

