function lotka_test ( )

%*****************************************************************************80
%
%% lotka_test(): midpoint_adaptive() solves lotka_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 July 2024
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    George Lindfield, John Penny,
%    Numerical Methods Using MATLAB,
%    Second Edition,
%    Prentice Hall, 1999,
%    ISBN: 0-13-012641-1,
%    LC: QA297.P45.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'lotka_test():\n' );
  fprintf ( 1, '  midpoint_adaptive() solves lotka_ode().\n' );
  fprintf ( 1, '  A pair of ordinary differential equations for a population\n' );
  fprintf ( 1, '  of predators and prey are solved using midpoint().\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The exact solution shows periodic behavior, with a fixed\n' );
  fprintf ( 1, '  period and amplitude.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Steady state at r = 5000, f = 2000.\n' );

  label = 'lotka';

  f = @ lotka_deriv;
  t0 = 0.0;
  tmax = 20.0;
  m = 2;
  y0 = [ 5000.0, 100.0 ];
  tau0 = 2.5e-2;
  reltol = 1.0e-3;
  abstol = 1.0e-3;

  [ t, y, nstep, n_rejected ] = mad_compute ( f, t0, tmax, y0, tau0, reltol, abstol );

  mad_phase_plot ( m, t, y, label );

  mad_solution_plot ( m, t, y, label );

  mad_timestep_plot ( t, label );

  mad_stats ( nstep, n_rejected, t );

  return
end

