CHAPTER 12

1

1a

Define the fitness function, plot it for m2=0.05, and evaluate it for m1=0.01, m2=0.05. These calculations establish that when m2=0.05 the optimal value of m1 is about 1. Repeating this exercise for different values of m2 will show that the optimal value of m1 is 0.01 when m2 > 0.15 and is at an internal optimum with m1 round about unity when m2 < 0.05.

w[m1_,m2_]:=100(1-Exp[-(m1+m2)^2])/m1

Plot[w[m1,.05],{m1,.01,2}]

w[.01,.05]

We now find the optimal value of m1 when m2=0.01:

f[m1_,m2_]=D[w[m1,m2],m1];
FindRoot[f[m1,.01]==0,{m1,1}]

1b

See Exercise 1a.

2

I define the recurrence relation, find the equilibrium values, and the stability criteria:

f[p_]:=(1-s)p(2-p)/(1-s p(2-p))

equil=Solve[f[p]==p,p]

Simplify[D[f[p],p]/.equil]

I simulate the system with s = 0.25:

s=.25;

sim=NestList[f,.1,25];

ListPlot[sim]

3

Define the recurrence relation in Equation 8 and set s = 0.25:

f[x_]:=(a=x[[1]];b=x[[2]];c=x[[3]];d=x[[4]];
		y={(1-s)(a-0.5a d+b c),
		(1-s)(b+0.5a d+b d),
		(c+0.5a d-b c),
		(d-0.5a d-b d)};
		y/Apply[Plus,y])

s=0.25;

I first calculate the effect of one round of infection as described in the text, and show that after 20 generations virtually all individuals are infected but the frequency of uniparental individuals has increased from 0.010 to 0.013:

x={0,0,.01,.99};
x={.01x[[3]],.01x[[4]],.99x[[3]],.99x[[4]]};
res=NestList[f,x,20];

res//TableForm

I now write two programs. The first, called rep takes the existing value of x and iterates a further 20 generations. The second one, called new transfers all the infected individuals to the uninfected class and introduces a new infection.

rep:=(x=Nest[f,x,20])

new:=(x={0,0,x[[1]]+x[[3]],x[[2]]+x[[4]]};
x={.01x[[3]],.01x[[4]],.99x[[3]],.99x[[4]]})

Start with x={0,0,.01,.99} and simulate the introduction of successive new infections by using new; follow each infection by repeatedly using rep until virtually all individuals are either infected (x1 + x2 = 1) or uninfected (x3 + x4 = 1):

x={0,0,.01,.99};

new

rep

new

rep

and so on.

4

The transition matrix is

A={{p/(1-r)+(1-p)/2,1/2},{(1-p)/2,1/2}};

Find its eigenvalues and evaluate them for p = 1 and for p small:

eigen=Eigenvalues[A];

PowerExpand[Simplify[eigen/.p->1]]

PowerExpand[Simplify[Series[eigen,{p,0,1}]]]

5

Define the matrix and evaluate its eigenvalues.

6

6a

Define the Poisson distribution and evaluate it with mean = 15:

Poisson[x_,m_]:=Exp[-m] (m^x)/x!

Table[{x,10^7 Poisson[x,15.]},{x,0,50}]//TableForm

6b

Define the recursion for q[t,a] from Equations 20 and 21 and evaluate q for the appropriate values of the arguments:

q[t_,1]:=q[t,1]=Exp[q[t-1,1]-1]
q[0,1]=0.0;
q[t_,a_]:=(q[t,1])^a

Do[q[t,1],{t,2000}]

tvals={1,2,5,10,20,40,100};

Table[{t=tvals[[i]],q[t,1],q[5t,5],q[10t,10],q[20t,20]},
			{i,Length[tvals]}]//TableForm

7

I give some functions for calculating the relative advantage of sex under truncation selection.  mu[lambda,k] calculates μ  as a function of λ and k from Equation 12.29. sexad[U,k,approx] finds the relative advantage of sex from Equations 12.28, 30 and 31; it requires an approximate value for λ which must be obtained first (see example). Use sexad to verify the advantage of sex for the parameter values in Table 12.3. (The calculations for large values of k are time-consuming.)

mu[lambda_,k_]:=
Sum[lambda^i/(i-1)!,{i,k-1}]/Sum[lambda^i/i!,{i,0,k-1}]

sexad[U_,k_,approx_]:=Exp[U-lambda] Sum[lambda^i/i!,
{i,0,k-1}]  /. FindRoot[lambda==mu[lambda,k]+U,
	{lambda,approx}]

An example with U = 0.5, k = 5:

Plot[x-mu[x,5]-0.5,{x,0.5,5}]

sexad[0.5,5,2.8]

8

8a

Use pencil and paper.

8b

Define the continuous-time transition matrix and find its equilibria and their stability criteria in the standard way.

Clear[f,s]

f[1][s1_,s2_]:=s1((10^-4)(100-s1-s2)-10^-4)/100
f[2][s1_,s2_]:=s2((10^-4)(100-s1-s2)- 2 10^-4)/100

equil=Solve[f[1][s[1],s[2]]==f[2][s[1],s[2]]==0,{s[1],s[2]}]

jac=Table[D[f[i][s[1],s[2]],s[j]],{i,2},{j,2}];

Eigenvalues[jac]/.equil//N

9

Define β(x) and then follow the exercise.

beta[x_]:=1.582(1-Exp[x-1])

Plot[beta[1-x],{x,0,1}]

Plot[x+beta[x],{x,0,1}]

f=(1/x)+(D[beta[x],x]/beta[x]);
xstar=x/.FindRoot[f==0,{x,.5}]

beta[xstar]

10

Use pencil and paper.