
Now, let's look at the solution for a problem concerning waning immunity.

First things first, the constant waning time should be defined as 2 times the infectious time.

We can show this mathematically using the equations we have for the

derivatives of S, I, and R with their respective time.

We know that after a long period of time you want to attain a steady state situation

and there's a number of people in each portion to the population

susceptible, infected, and recover stays constant.

Since they want to find out how long people should spend in the recovered stage,

we start with the time derivative of R and set that equal to zero.

Since you know that Rdot now has an extra term added to it or actually subtracted from it

showing the number of people that are leaving the recovered population

and going back to the infected population.

We can set these to terms right here equal to zero as well.

Just to note, I've used CINF to stand for the infectious time

and CWAN to stand for the waning time.

Now with just a little bit of Algebra, we come up with the answer that R=2I.

Since we know that we want the number of recovered people to be twice the number

of infected people, we can plug in this extra information to the equation above

and end up with the answer that the waning time is equal to twice the infectious time.

This put us directly into the next part of the problem.

We defined R to S in the same way that I to R is defined except that we replace infectious time

as the waning time and I step with R step as you can see right here.

Then moving on to our recursive relations, for each element in a step plus one position,

we need to take into account the value of the previous element in the number of people

added and subtracted from the population during each time step.

We know that the one thing that has changed in this model from the standard SIR model

is that people are now moving from the recovered population back to the susceptible population.

This is why we've needed to add in this extra term R to S, which we subtract from R and add to S.

Now, let's run the program and see what we get.

Here we see we end up with this fancy graph,

which has three different series for the three different parts of the population we're looking at.

Remembering how we set the initial values for S, I, and R.

Remember that the blue line here stands for the susceptible population.

The green line stands for the infected population,

and the red line stands for the recovered population.

And the maximum time that we're looking at 60 days,

you can see that the red line is graphing twice as many people over here

as the green line is marking, which is exactly the answer that we wanted to end up with.

Congratulations on successfully completing the first problem of Unit 3.