4
$\begingroup$

I have a system of ordinary differential equations. dx/dt=-x and dy/dt=2x-2y

I am using StreamPlot to plot the phase portrait which gives me this enter image description here

I want to pic some initial condition and study that whether the solution leads to the equilibrium point(stable one) or not. I am trying a lot but didn't getting the required result as in the picture below

enter image description here

I require the blue arrowed lines that are solid and pass through the equilibrium points ie (0,0) here in the pic. Thanks in advance for the help.

$\endgroup$

3 Answers 3

5
$\begingroup$

Only part of the work. It is hope that can help you to draw the complete picture.

Here we use ParametricNDSolve to solve the curves which pass through point $(a,b)$.

We select some points such as $(1,0)$,$(2,0)$,$(3,1)$ etc.

sols = ParametricNDSolve[{D[x[t], t] == -x[t], 
    D[y[t], t] == 2 x[t] - 2 y[t], x[0] == a, y[0] == b}, {x, 
    y}, {t, -10, 10}, {a, b}];
f[a_, b_][t_] := {x[a, b][t], y[a, b][t]} /. sols;
lines1 = ParametricPlot[{f[1, 0][t], f[2, 0][t], f[3, 1][t]}, {t, -.3,
     10}, Epilog -> {Arrow[{f[1, 0][-.2], f[1, 0][-.1]}], 
     Arrow[{f[2, 0][-.2], f[2, 0][-.1]}], 
     Arrow[{f[3, 1][-.2], f[3, 1][-.1]}]}, PlotStyle -> Blue];
lines2 = ParametricPlot[{f[.2, 2][t], f[.3, 2][t], 
    f[.5, 2][t]}, {t, -.3, 10}, PlotStyle -> Red];
lines3 = ParametricPlot[{f[-1, 0][t], f[-2, 0][t], 
    f[-3, 0][t]}, {t, -.1, 10}, PlotStyle -> Green];
lines4 = ParametricPlot[{f[-.5, -2][t], f[-.8, -3][t], 
    f[-1, -3][t]}, {t, -.1, 10}, PlotStyle -> Orange];
Show[lines1, lines2, lines3, lines4, PlotRange -> All]

enter image description here

$\endgroup$
11
$\begingroup$

Move the locator to change the initial conditions.

   gr = StreamPlot[{-x, 2 x - 2 y}, {x, -2, 2}, {y, -2, 2}];
    fun[x_, x0_, y0_] = 
      y[x] /. DSolve[{y'[x] == -2 (x - y[x])/x, y[x0] == y0}, y, x];
    Manipulate[
     Show[gr, 
      Plot[fun[x, p[[1]], p[[2]]], {x, p[[1]], 0}, 
       PlotStyle -> {Red, Thickness[0.01]}], 
      Graphics[{Green, PointSize[0.02], Point[{0, 0}]}]]
     , {{p, {2, 1}}, Locator}]

enter image description here

$\endgroup$
4
$\begingroup$

I found another way that need not solved differential equation,only change the style of StreamPlot such as StreamScale and StreamPoints

(*pts=Tuples[Range[-2,2,.8],2];*)

pts = {{1, 0}, {1.5, 0}, {2, 0}, {.2, 2}, {.5, 2}, {1, 2}, {-2, 
    0}, {-1.5, 0}, {-1, 0}, {-.8, -2}, {-.5, -2}, {-.2, -2}};
stream = StreamPlot[{-x, 2 x - 2 y}, {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
   StreamScale -> {Full, Automatic, Automatic}, StreamPoints -> pts, 
   Axes -> True, Frame -> False, StreamStyle -> Blue, 
   StreamColorFunction -> False, AxesLabel -> {x, y}];
Show[Plot[x, {x, -1.8, 1.8}, PlotStyle -> Green, 
  Epilog -> {Green, Text[y == x, {2, 1.8}, Left]}, 
  AspectRatio -> Automatic, PlotRange -> 2, 
  AxesStyle -> Arrowheads[0.035], PlotRangePadding -> 1.1, 
  AxesLabel -> {x, y}], stream]

enter image description here

$\endgroup$
2
  • $\begingroup$ StreamScale -> {{0.5, 0}, 50, .025, Automatic} $\endgroup$
    – cvgmt
    Dec 20, 2020 at 4:26
  • $\begingroup$ StreamScale -> {{.4, 0}, 50, .025, # &} $\endgroup$
    – cvgmt
    Dec 20, 2020 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.