Mathematica Tool 2

This Mathematica notebook is designed for  use with Activity 3 in Section 6.2

Needs["VectorFieldPlots`"]

We begin by displaying the slope field for the differential equation
                                      (∂/(∂t))P(t)=k P(t) (M-P(t))
 with the values of k and M given below.

k=0.00009;
M=1000;
SlopeField=VectorFieldPlot[#/Norm[#]&[{1,k Y (M-Y)}],{t,0,120},{Y,0,1200},Axes->True,AxesLabel->{"t","P(t)"},ColorFunction->Hue,AspectRatio->1]

Next we set up the Euler's Method approximation and plot this on the slope field. Enter your value of (Subscript[P, 0]) in this calculation. (Note that this is the same calculation as was used in Mathematica Tool 1 in this section.)

n=40;
Δ=120/n;
P=Range[n];

(Subscript[P, 0])="???";

P[[1]]=(Subscript[P, 0]);
For[i=2,i<n+1,i++,P[[i]]=N[P[[i-1]]+(k P[[i-1]] (M-P[[i-1]])) Δ]];
Solution=Partition[Riffle[(Range[n]-1) Δ,P],2];
Euler=ListPlot[Solution,PlotStyle->PointSize[0.02],PlotRange->{{0,120},{0,1200}}];
Show[Euler,SlopeField]