Group Project #2
Answers

Problem 1

Clear[k,r,p,a,v,delt,t]
k=.1;
r=.5;
p=.5;
a[0]=0.;
v[0]=0.01;
delt=12;
t=0;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
t=12;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
t=24;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
t=36;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
t=48;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
t=60;
a[t+delt] = a[t] + k*v[t]*delt;
v[t+delt] = v[t] + r*v[t]*delt -p*v[t]*a[t]*delt;
table1=Table[{t,a[t],v[t]},{t,0,60,12}];
TableForm[table1,TableHeadings->{ None,{"t in hours",
"a[t]","v[t]"}}]

adata=Table[{t,a[t]},{t,0,60,12}];
vdata=Table[{t,v[t]},{t,0,60,12}];
p1=ListPlot[adata,PlotJoined->True,DisplayFunction->
Identity,PlotStyle->RGBColor[1.000, 0.158, 0.129]]
p2=ListPlot[vdata,PlotJoined->True,DisplayFunction->
Identity,PlotStyle->RGBColor[0.122, 0.101, 1.000]]
Show[p1,p2,DisplayFunction->
$DisplayFunction]

Problem 2

Clear[k,r,p,a,v,t]

k=.1;
r=0.5;
p=0.5;

delt=12;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt },
                      {t,0,60,12  }]
      
table2=Table[{t,a[t],v[t]},{t,0,60,12}];

TableForm[table2,TableHeadings->{ None,{"t in hours",
"a(t)","v(t)"}}]

Problem 3

Clear[k,r,p,a,v,t]

k=.1;
r=0.5;
p=0.5;

delt=6;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt },           {t,0,36,6}]
      
table3=Table[{t,a[t],v[t]},{t,0,36,6}];

TableForm[table3,TableHeadings->{ None,{"t in hours",
"a(t)","v(t)"}}]

dataa=Table[{t,a[t]},{t,0,36,6}];
datav=Table[{t,v[t]},{t,0,36,6}];
p1=ListPlot[dataa,PlotJoined->True,DisplayFunction->
   Identity,
   PlotStyle->RGBColor[1.000, 0.158, 0.129]]
p2=ListPlot[datav,PlotJoined->True,DisplayFunction->
   Identity,PlotStyle->RGBColor[0.122, 0.101, 1.000]]
Show[p1,p2,DisplayFunction->
   $DisplayFunction]

Clear[k,r,p,a,v,t]

k=.1;
r=0.5;
p=0.5;

delt=3;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt },  {t,0,27,3}]
       
table3=Table[{t,a[t],v[t]},{t,0,27,3}];

TableForm[table3,TableHeadings->{ None,{"t in hours",
"a(t)","v(t)"}}]

dataa=Table[{t,a[t]},{t,0,27,3}];
datav=Table[{t,v[t]},{t,0,27,3}];
p1=ListPlot[dataa,PlotJoined->True,DisplayFunction->
   Identity,
   PlotStyle->RGBColor[1.000, 0.158, 0.129]]
p2=ListPlot[datav,PlotJoined->True,DisplayFunction->
   Identity,PlotStyle->RGBColor[0.122, 0.101, 1.000]]
Show[p1,p2,DisplayFunction->
   $DisplayFunction]

Problem 4

Clear[k,r,p,a,v,t]

k=0.1; 
p=0.5;
r=1.;

delt=6;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt },  {t,0,36,6}]
       
table4a=Table[{t,a[t]},{t,0,24,6}];
table4v=Table[{t,v[t]},{t,0,24,6}]; 
table4=Table[{t,a[t],v[t]},{t,0,36,6}];
TableForm[table4]
p1=ListPlot[table4a,PlotJoined->True,
  DisplayFunction->Identity,
   PlotStyle->RGBColor[1.000, 0.158, 0.129]]
p2=ListPlot[table4v,PlotJoined->True,
   DisplayFunction->
   Identity,PlotStyle->RGBColor[0.122, 0.101, 1.000]]
Show[p1,p2,DisplayFunction->
   $DisplayFunction]

Clear[k,r,p,a,v,t]

k=0.1; 
p=0.5;
r=.1;

delt=6;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt }, 
                     {t,0,48,6 }]
      
table4=Table[{t,a[t],v[t]},{t,0,48,6}];

TableForm[table4]

Clear[k,r,p,a,v,t]

k=0.1; 
p=0.02;
r=0.5;

delt=6;

a[0]=0.;
v[0]=0.01;

Do [
    { a[t+delt] = a[t] + k*v[t]*delt,
      v[t+delt] = v[t] + r*v[t]*delt 
                    - p*v[t]*a[t]*delt }, 
                     {t,0,48,6 }]
      
table4=Table[{t,a[t],v[t]},{t,0,48,6}];

TableForm[table4]

Problem 5

k=0.1; 
p=0.5;
r=0.7;
Clear[a,v,sol5]
sol5=NDSolve[ {a'[t]==k*v[t], v'[t]==r*v[t]-p*v[t]*
  a[t],a[0]==0,v[0]==.01}, {a,v},{t,0,60}]
p7=Plot[  Evaluate[v[t] /. sol5] ,
  {t,0,60},PlotStyle->RGBColor[1.000, 0.080, 0.108],
  DisplayFunction->Identity]

Show[p7,p9,p11,p13,p15,DisplayFunction->$DisplayFunction,
   PlotRange->All]

data=Table[ {t,v[t] /. sol5}, 
{t,5.5,5.75,1/60} ]

60*.61667