2.1 Solution Curves

2.1.1 Direction Fields

dy/dx slope of tangent line

Piece together bits of tangent lines to "see" solutions

Direction Field

{xMin,xMax}={-2,2};
{yMin,yMax}={0,3};
{x0,y0}={0.2,1.2};
f[x_,y_]= x Sin[x+y];
DirectionField=VectorPlot[ {1,f[x,y]},{x, xMin,xMax},{y, yMin, yMax}]

{x0,y0}={0.2,1.2};
ySol[x_]=y[x]/.NDSolve[{
y'[x]==f[x,y[x]],
y[x0]==y0
},
y[x],
{x, xMin, xMax}][[1]];
Show[
DirectionField,
Plot[ySol[x],{x,xMin,xMax},
PlotStyle->Red
],
Epilog->{PointSize[0.05],Green, Point[{x0,y0}]}
]

Fancy Stuff

Manipulate[xincr=(xmax-xmin)/(xpart-1);
yincr=(ymax-ymin)/(ypart-1);
dirvec[ComplexInfinity]:={0,1};
dirvec[Indeterminate]:={0,0};
(*The next line is based on Euler's linear element formula h=H/(2Sqrt[1+f^2 (Subscript[x,0],Subscript[y,0])]) for a segment of length H with midpoint (Subscript[x,0],Subscript[y,0]) and endpoints (Subscript[x,0]-h,Subscript[y,0]-hM) and (Subscript[x,0]+h,Subscript[y,0]+hM)for M=f (Subscript[x,0],Subscript[y,0]) being the slope of the segment.*)dirvec[x_]:={1,x}/Sqrt[1+(x/((ymax-ymin)/(xmax-xmin)))^2];
pts=Flatten[Table[N[{r,s}],{r,xmin,xmax,xincr},{s,ymin,ymax,yincr}],1];
dir=f/.{x->pts[[All,1]],y->pts[[All,2]]}//Quiet;
newdir=Map[dirvec,dir];
endpts=pts+xincr/4*newdir;
frontpts=pts-xincr/4*newdir;
(*Now find an exact solution*)ff=f/.y->y[x];
soln=Quiet@DSolve[{y'[x]==ff,y[xinit]==yinit},y[x],x];
If[soln≠{},table=Table[soln[[1,1,2]]/.C[1]->xinit];
curve=Plot[Evaluate[table],{x,xmin,xmax}];,curve={}];
Show[Graphics[Map[Line,Transpose[{frontpts,endpts}]]],If[ptflg,Graphics[Point[pts]],{}],If[solflg,curve,{}],If[solflg,Graphics[{PointSize[Medium],Point[{xinit,yinit}]},{}],{}],Axes->Automatic,PlotRange->{{xmin,xmax},{ymin,ymax}},AspectRatio->1.5/GoldenRatio,PlotLabel->Grid[{{Style[Framed[Row[{"slope field for ",y'," = ",StringForm["``",f]}]]]},{}}],ImageSize->{350,350},ImagePadding->{{25,10},{25,55}}],{{f,x-y,"f(x,y) = "},{x-y->TraditionalForm[x-y],y-x->TraditionalForm[y-x],x+y->TraditionalForm[x+y],1/y->TraditionalForm[1/y],1/x->TraditionalForm[1/x],x/y->TraditionalForm[x/y],-x/y->TraditionalForm[-x/y],-y/x->TraditionalForm[-y/x],x^2 y->TraditionalForm[x^2 y],y-1->TraditionalForm[y-1],y^2-1->TraditionalForm[y^2-1],(y+x)/(y-x)->TraditionalForm[(y+x)/(y-x)],Sin[y]->TraditionalForm[Sin[y]],Cos[x]->TraditionalForm[Cos[x]]},ControlType->PopupMenu},Delimiter,"x axis values:",{{xmin,-2},-8,-1,1,Appearance->"Labeled",ImageSize->Tiny},{{xmax,2},1,8,1,Appearance->"Labeled",ImageSize->Tiny},Delimiter,"y axis values:",{{ymin,-3},-10,-.5,.01,Appearance->"Labeled",ImageSize->Tiny},{{ymax,3},.5,10,.01,Appearance->"Labeled",ImageSize->Tiny},Delimiter,"number of sample points:",{{xpart,15,"x axis"},4,20,1,Appearance->"Labeled",ImageSize->Tiny},{{ypart,15,"y axis"},4,20,1,Appearance->"Labeled",ImageSize->Tiny},Delimiter,{{ptflg,False,Tooltip["display points","Show the midpoint of each segment."]},{True,False}},{{solflg,False,Tooltip["show exact solution","Graph a function solving the differential equation and the initial condiions."]},{True,False}},(*the next two lines can be used instead of the popup menues for initial values;
input will be limited to numeric values {{xinit,1,"initial x value "},InputField[#1,Number,FieldSize->5,Enabled->solflg]&},{{yinit,1,"initial y value "},InputField[#1,Number,FieldSize->5,Enabled->solflg]&},*){{xinit,1,"initial x value"},xmin,xmax,.1,Appearance->"Labeled",ImageSize->Tiny,Enabled->solflg},{{yinit,1,"initial y value"},ymin,ymax,.1,Appearance->"Labeled",ImageSize->Tiny,Enabled->solflg},TrackedSymbols:>Manipulate,AutorunSequencing->{1,3,5,7}]

Definitions and Observations

Autonomous y'=f[y]

y'>0 i.e. f[y]>0 means y is increasing

y'<0 i.e. f[y]<0 means y is decreasing

f[y]=0 means y is constant!

f[y]=0 means y is constant!  
Called an Equilibrium Solution

Attractor is an equilibrium solution that sucks in nearby solutions.
It is Stable

Repellor is an equilibrium solution that chases nearby solutions away.
It is unstable.

An equilibrium solution can semi-stable:  stable on one side and unstable on the

Pics

{a,b}={1,1};
pMax=2;
f[p_]:= p(a- b p);
StreamPlot[ {1,f[p]},
{t,0,4},
{p,0,pMax},
FrameLabel->{"t","p"}
]

Numerical Solutions

Clear[a,b,p,t,pSol,p0]
{a,b}={1,1};
{pMax,tMax}={2,4};
f[p_]:= p(a- b p);
p0 = 1.5;
pSol[t_]=p[t]/.NDSolve[{
p'[t]==f[p[t]],
p[0]==p0
},
p[t],
{t, 0, tMax}];
Plot[ 
pSol[t],
{t,0,4},
FrameLabel->{"t","p"}
]