Consider the system:
\begin{align*} x'&=(1-x-y)x\\ y'&=(4-7x-3y)y \end{align*}
The system has a saddle point at (1/4,3/4). How can I plot the separatrices on the phase portrait having domain $\{(x,y):\ 0\le x\le 1,\ 0\le y\le 2\}$?
Here is my attempt. Start with a vector plot.
Clear[x, y];
Clear[Derivative];
f[x_, y_] = (1 - x - y) x;
g[x_, y_] = (4 - 7 x - 3 y) y;
vp = VectorPlot[{f[x, y], g[x, y]}, {x, 0, 1}, {y, 0, 2},
VectorScale -> {0.045, 0.5, None},
VectorStyle -> {GrayLevel[0.8]},
VectorPoints -> 16,
Axes -> True, AxesLabel -> {x, y}];
Get the equilibrium points.
eqpts = Solve[{f[x, y] == 0, g[x, y] == 0}, {x, y}]
There is a saddle point at (1/4,3/4). Set an eps value.
eps=1/10000;
Define a function.
sol[{x0_, y0_, tmin_, tmax_}] :=
NDSolveValue[{x'[t] == f[x[t], y[t]], y'[t] == g[x[t], y[t]],
x[0] == x0, y[0] == y0}, {x[t], y[t]}, {t, tmin, tmax}]
Spend time (brute force) adjusting arguments to sol function to plot the separatrices.
sep1 = ParametricPlot[
Evaluate@sol[{1/4 + eps, 3/4, 0, 40}], {t, 0, 40},
PlotStyle -> {Red, Thick}];
sep2 = ParametricPlot[
Evaluate@sol[{1/4 - eps, 3/4, 0, 40}], {t, 0, 40},
PlotStyle -> {Red, Thick}];
sep3 = ParametricPlot[
Evaluate@sol[{1/4 + eps, 3/4 + eps, -2.8, 0}], {t, -2.8, 0},
PlotStyle -> {Red, Thick}];
sep4 = ParametricPlot[
Evaluate@sol[{1/4 - eps, 3/4 - eps, -40, 0}], {t, -40, 0},
PlotStyle -> {Red, Thick}];
Show everything together.
Show[vp, Graphics[{Black, PointSize[Large],
Point[{x, y}] /. eqpts}], sep1, sep2, sep3, sep4]
Result:
Which worked. Just wondering if there would be a simpler approach, one that beginning students can easily understand.
P.S. All code pasted below for an easy copy and paste.
Clear[x, y];
Clear[Derivative];
f[x_, y_] = (1 - x - y) x;
g[x_, y_] = (4 - 7 x - 3 y) y;
vp = VectorPlot[{f[x, y], g[x, y]}, {x, 0, 1}, {y, 0, 2},
VectorScale -> {0.045, 0.5, None},
VectorStyle -> {GrayLevel[0.8]},
VectorPoints -> 16,
Axes -> True, AxesLabel -> {x, y}];
eqpts = Solve[{f[x, y] == 0, g[x, y] == 0}, {x, y}];
eps = 1/10000;
sol[{x0_, y0_, tmin_, tmax_}] :=
NDSolveValue[{x'[t] == f[x[t], y[t]], y'[t] == g[x[t], y[t]],
x[0] == x0, y[0] == y0}, {x[t], y[t]}, {t, tmin, tmax}];
sep1 = ParametricPlot[
Evaluate@sol[{1/4 + eps, 3/4, 0, 40}], {t, 0, 40},
PlotStyle -> {Red, Thick}];
sep2 = ParametricPlot[
Evaluate@sol[{1/4 - eps, 3/4, 0, 40}], {t, 0, 40},
PlotStyle -> {Red, Thick}];
sep3 = ParametricPlot[
Evaluate@sol[{1/4 + eps, 3/4 + eps, -2.8, 0}], {t, -2.8, 0},
PlotStyle -> {Red, Thick}];
sep4 = ParametricPlot[
Evaluate@sol[{1/4 - eps, 3/4 - eps, -40, 0}], {t, -40, 0},
PlotStyle -> {Red, Thick}];
Show[vp, Graphics[{Black, PointSize[Large],
Point[{x, y}] /. eqpts}], sep1, sep2, sep3, sep4]