function dydt = grazing_deriv ( t, y )

%*****************************************************************************80
%
%% grazing_deriv() evaluates the right hand side of grazing_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Michael Thompson, Bruce Stewart,
%    Nonlinear Dynamics and Chaos,
%    Second Edition,
%    Wiley, 2002,
%    ISBN: 0-471-87645-3,
%    LC: QA871.T47.
%
%  Input:
%
%    real T, the current time.
%
%    real Y(2), the current solution.
%
%  Output:
%
%    real DWDT(2), the right hand side.
%
  [ a, c1, c2, d1, d2, k, r1, t0, y0, tstop ] = grazing_parameters ( );

  u = y(1);
  v = y(2);

  dudt = r1 * u * ( 1.0 - u / k ) - c1 * v * ( 1.0 - exp ( - d1 * u ) );
  dvdt = - a * v                  + c2 * v * ( 1.0 - exp ( - d2 * u ) );

  dydt = [ dudt; dvdt ];

  return
end
