function dydt = sir_deriv ( t, y )

%*****************************************************************************80
%
%% sir_deriv evaluates the right hand side of the SIR ode.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL 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 ] = sir_parameters ( );

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

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

  dydt = [ dSdt; dIdt; dRdt ];

  return
end

