function dydt = sir_deriv ( t, y )

%*****************************************************************************80
%
%% sir_deriv() evaluates the right hand side of sir_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T: the time.
%
%    real y(3), the susceptible, infected, and recovered populations.
%
%  Output:
%
%    real dydt(3), the values of dSdt, dIdt, dRdt.
%
  [ alpha, beta, gamma, t0, y0, tstop ] = sir_parameters ( );

  S = y(1);
  I = y(2);
  R = y(3);

  N = S + I + R;
  dSdt = - alpha * S * I / N            + gamma * R;
  dIdt =   alpha * S * I / N - beta * I;
  dRdt =                       beta * I - gamma * R;

  dydt = [ dSdt; dIdt; dRdt ];

  return
end

