I am working on the SIR model and I am trying to plot the incidence function on a specific time interval.
(*Given parameters*)\[Gamma] = 0.1;
\[Beta] = 0.41;
tMax = 90;
n = 10^6;
(*Define the force of infection (\[Lambda])*)
\[Lambda][t] := \[Beta] i[t]/n;
(*Define the system of differential equations*)
eqns = {s'[t] == -\[Lambda][t] s[t],
i'[t] == \[Lambda][t] s[t] - \[Gamma]*i[t], r'[t] == \[Gamma]*i[t],
s[0] == 999999, i[0] == 1, r[0] == 0};
(*Solve the system*)
sol = NDSolve[eqns, {s, i, r}, {t, 0, tMax}];
(*Plot the solutions*)
Plot[Evaluate[{s[t], i[t], r[t]} /. sol], {t, 0, tMax},
PlotLegends -> {"Susceptible", "Infected", "Recovered"},
AxesLabel -> {"Time", "Population"},
PlotStyle -> {Blue, Red, Green}]
So far so simple.
But when I am trying to define and plot the incidence equation
(*Define the incidence function*)
incidence[t_] = Integrate[\[Lambda][t]*s[t], {t, 40, 50}];
(*Plot the incidence*)
Plot[incidence[t], {t, 0, tMax}, AxesLabel -> {"Time", "Incidence"},
PlotStyle -> Blue, PlotLabel -> "Incidence between t=40 and t=50"]
Could someone explain to me why I have the errors Integrate::ilim
and NIntegrate::itraw
and no plot?
tmax
or similar and the integration range be{t, 40, tmax}
or something along those lines? Also, shouldn't you inject the results of NDSolve in the definition of incidence as well? $\endgroup$incidence[t_]
is not actually a function oft
in your definition since it's just a dummy variable underIntegrate
. $\endgroup$