function predator_euler ( n )

%% predator_euler calls the Euler code for the predator-prey problem.
%

  if ( nargin < 1 )
    n = 100;
  end

  addpath ( '../scripts' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'predator_euler:\n' );

  alpha = 2.0;
  beta = 1.0;
  gamma = 1.0;
  delta = 1.0;

  duvdt = @ predator_deriv;
  tspan = [ 0.0, 250.0 ];
  u0 = 4.0;
  v0 = 2.0;
  uv0 = [ u0; v0 ];

  [ t, uv ] = euler ( duvdt, tspan, uv0, n );
%
%  Plot
%
  figure ( 1 );
  plot ( t, uv, 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- u(t), v(t) -->' );
  title ( 'Predator prey plot (euler)' );
  legend ( 'Prey=u(t)', 'Predator=v(t)' )
  print ( '-dpng', 'predator_plot_euler.png' );
%
%  Phase plane
%
  figure ( 2 );
  plot ( uv(1,:), uv(2,:), 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- u(t) -->' );
  ylabel ( '<-- v(t) -->' );
  axis ( 'equal' )
  title ( 'Predator Prey phase plane (euler).' );

  print ( '-dpng', 'predator_phase_euler.png' );
%
%  Conserved quantity
%
  u = uv(1,:);
  v = uv(2,:);
  c0 = delta * u0 - gamma * log ( u0 ) + beta * v0 - alpha * log ( v0 );
  c = delta * u - gamma * log ( u ) + beta * v - alpha * log ( v );

  inc = n / 10;
  for i = 1 : inc : n + 1
    fprintf ( 1, '%4d  %14.6g  %14.6g  %14.6g\n', i, t(i), c(i), abs ( c(i) - c0 ) );
  end

  rmpath ( '../scripts' );

  return
end

