Example

Solve the IVP:

x(x-2)(dy/dt)+2y=r x (x-2), y(3)=6

Solution to DE

Here is the solution to the DE which we found by the integrating factor method in class (since the DE is first order and linear in y).

DEsol=(x/(x-2))(C+r*x-2r Log[Abs[x]])

To get plots, we would need to specify values for r. This means we should use Manipulate to plot the integral curves, since they will depend on the value of r. Notice I define the integral curves as a function of r to make the plotting work!

integralcurves[r_]=DEsol/.C->{-5,-3,-1/2,0,1/2,3,5}

Manipulate[
Plot[Evaluate[integralcurves[r]],{x,-10,10},PlotRange->{{-10,10},{-10,10}},AxesLabel->{"x","y"},BaseStyle->20,PlotStyle->Thick,Exclusions->{x==0,x==2}]
,{r,-8,8,1}]

Notice some global behaviour: the integral curves always seem to pass through the origin, and always have a vertical asymptote at x=2. Also the end behaviour is different for r<0, r=0, and r>0.

Question: Is the point (0,0) a point on these curves? It looks like it is from the graphs.

Answer to Question

No! There is a hole at the origin, since the logarithmic function is not defined at x=0.

Limit[x/(x-2)(C+r*x-2r Log[Abs[x]]),x->0]

Solution to IVP

The solution to the IVP selects one curve from the set of integral curves (since the DE was linear, the integral curves represent a general solution).

IVPsol[r_]=(x/(x-2))(2-3r+2r*Log[3]+r*x-2r Log[Abs[x]])

Manipulate[
Plot[Evaluate[IVPsol[r]],{x,-10,10},PlotRange->{{-10,10},{-10,10}},AxesLabel->{"x","y"},BaseStyle->20,PlotStyle->Thick,Exclusions->{x==0,x==2}]
,{r,-8,8,1}]

Now, if we stopped here, our analysis would be incomplete. The solution to the IVP is not the curve sketched above, since the solution cannot pass over the discontinuity at x=2. Since the initial condition was at x=3, we choose the part of the curve in the interval x∈(2,∞) as the solution to the IVP. We can restrict the region of a plot by including the command RegionFunction.

Manipulate[
Plot[Evaluate[IVPsol[r]],{x,-10,10},PlotRange->{{-10,10},{-10,10}},AxesLabel->{"x","y"},BaseStyle->20,PlotStyle->Thick,Exclusions->{x==0,x==2},RegionFunction->Function[{x,y,z},x>2]]
,{r,-8,8,1}]