Calculus for Biologists Lab Math 1180-002 Spring 2012 Lab #2 - A model of disease Report due date: Tuesday, January 24, 2012 at 9 a.m. Goal: To explore a differential equation describing the dynamics of a disease within a population of susceptible and infected individuals. You will observe how the rate of infection determines what happens with the disease, and later how modifications such as vaccination change the stability of the equilibria. The disease model introduced in Section 5.3 of the text is what we call an S-I model. It consists of a population with a fraction of people who are infected (I) and the remaining fraction who are susceptible to it (S = 1 − I). Naturally, susceptible individuals can only get the disease from an infected person. Recovery from the disease does not mean immunity, and so infected people who recover are immediately susceptible to re-infection. ? Name an infectious disease that works this way. The disease model has the form ? dI = αI(1 − I) − µI , |{z} | {z } dt infection of a susceptible (1) recovery of an infected where α is the infection rate and µ (‘mu’) is the rate of recovery. Stability and Bifurcations By varying α, we can get a better idea of why the bifurcation diagram for this model looks as it does. Bifurcation diagram 1.0 0.8 I* 0.6 0.4 0.2 0.0 0.0 0.1 0.2 α 0.3 0.4 ? Create a new script, either in R (laptop) or with a text editor (Linux computers). Assuming an infection lasts for 5 days, set the recovery rate to µ = 0.2 d−1 . mu = ## delete this comment and enter value Define the function dIdt according to the right-hand side of Equation (1), so that there are two inputs: I and α. dIdt = function(I,alpha) ## delete this comment and fill in the rest Since I is a fraction, define the range of your input values to be I = seq(0,1,by=0.01) Copy and paste the following code into your script. This will set up an empty plot. Notice in the first line that I’ve specified y values of dIdt(I,0). This means I’ve chosen to plot the derivative for α = 0, except that type="n" will produce an empty plot, with a domain of I. 1 of 2 plot(I,dIdt(I,0),type="n", ylim=c(-0.2,0.1), xlab=" ", ylab="dI/dt", axes=F) axis(1,pos=0) axis(2,pos=0) text(1.03,-0.05,"I") ## ## ## ## ## ## ## ## plot dI/dt invisibly plot y=dI/dt between -0.2 and 0.1 don't label x-axis yet label y-axis don't show axes yet draw horizontal axis at 0 draw vertical axis at 0 place x-axis "label" centered at the point (1.03,-0.05) Execute your existing lines of code up to this point. You should see a plot with the x and y axes crossing each other at (0, 0), along with the labels I and dI/dt. Now comes the interesting part. You will add curves to this plot one-by-one, each time specifying a different value of α. Add the following code to your script editor: lines(I,dIdt(I,0),col="red",lwd=2) ## plot dI/dt for alpha=0 and a line width of 2 Choose 5 more alpha values to plot ranging between 0 and 0.4, repeating the above code in your script for each value. Be sure to specify a different color for each curve as well. One of your chosen values should be for α = µ. Now take all of your lines commands and execute them in R. Make sure you can identify where the equilibrium points are for each of your curves. ? How many equilibrium points do you see when α < µ? How many are there when α > µ instead? ? Develop a way to implement all of your lines commands more compactly using a for loop (now is a great time to re-acquaint yourself with loops). Verify that you get the same results. Add this code to your script, as you’ll need it for your assignment. Pick one of your previous α values and plot dI dt against I once more. You should end up with just one curve. Add a title to this plot with main = "alpha = ## insert your alpha here". Identify the intervals on which I increases and decreases based on your graph. Along the x-axis (y = 0), add text to indicate these intervals, as in the sample figure. Determine an appropriate location for placing your text, and modify and execute the command below, as many times as necessary. text(x.location, 0, "write incr. or decr.") 0.1 0.0 dx/dt 0.2 0.3 0.4 Sample figure incr. decr. 0.5 −0.1 0.0 incr. 1.0 1.5 −0.2 x Save the resulting plot to include with your assignment. ? Save your script so that you can use it for your assignment. 2 of 2