Mathematica Tool 3

This Mathematica notebook is designed to be used with Activity 2 in Section 3.2

Needs["VectorFieldPlots`"]

For each value of k, we plot the numerical solutio nof the intial value problem on the slope field for the differential equatin. After that we plot all three solutions together.

For k=1:

k:=1
Slopefield=VectorFieldPlot[#/Norm[#]&[{1,-k(T-21)}],{t,-3,7},{T,0,40},Axes->True,AxesLabel->{"t","P(t)"},ColorFunction->Hue,AspectRatio-> 1];
SolutionCurve=NDSolve[{T'[t]== -k(T[t]-21),T[0]==30},T,{t,-4,8}];
Plot1=Plot[Evaluate[T[t]/.SolutionCurve],{t,-3,7},PlotRange->{{-3,7},{0,40}},PlotStyle->Thickness[0.01]];
Show[Slopefield,Plot1]

For k=0.5:

k:=.5
Slopefield=VectorFieldPlot[#/Norm[#]&[{1,-k(T-21)}],{t,-3,7},{T,0,40},Axes->True,AxesLabel->{"t","P(t)"},ColorFunction->Hue,AspectRatio-> 1];
SolutionCurve=NDSolve[{T'[t]== -k(T[t]-21),T[0]==30},T,{t,-4,8}];
Plot2=Plot[Evaluate[T[t]/.SolutionCurve],{t,-3,7},PlotRange->{{-3,7},{0,40}},PlotStyle->{Green,Thickness[0.01]}];
Show[Slopefield,Plot2]

For k=0.25:

k:=0.25
Slopefield=VectorFieldPlot[#/Norm[#]&[{1,-k(T-21)}],{t,-3,7},{T,0,40},Axes->True,AxesLabel->{"t","P(t)"},ColorFunction->Hue,AspectRatio-> 1];
SolutionCurve=NDSolve[{T'[t]== -k(T[t]-21),T[0]==30},T,{t,-4,8}];
Plot3=Plot[Evaluate[T[t]/.SolutionCurve],{t,-3,7},PlotRange->{{-3,7},{0,40}},PlotStyle->{Magenta,Thickness[0.01]}];
Show[Slopefield,Plot3]

Display all three solution curves together.

Show[Plot1,Plot2,Plot3]