function predator_euler ( n )

%*****************************************************************************80
%
%% predator_euler computes and plots a solution to the predator problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    08 September 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of steps to take.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'predator_euler' );
  fprintf ( 1, '  Solve predator-prey equation with Euler method\n' );
  fprintf ( 1, '  Plot the solution.\n' );

  if ( nargin < 1 )
    n = 1000000;
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Input value N not supplied.  Using N = %d\n', n );
  end

  dydt = @predator_deriv;
  tspan = [ 0.0, 50.0 ];
  y0 = [ 4.0, 2.0 ];
  [ t, y ] = euler ( dydt, tspan, y0, n );

  plot ( t, y(:,1), 'g-', t, y(:,2), 'r-', 'linewidth', 3 );
  grid ( 'on' ); 
  xlabel ( '<--T-->' );
  ylabel ( '<--R(T), F(T)-->' );
  s = sprintf ( 'Predator Euler ODE, n = %d.', n );
  title ( s );
  legend ( 'Rabbits', 'Foxes' );
  filename = sprintf ( 'predator_euler_%d.png', n );
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

