0
$\begingroup$

I have faced with problem of not completely correct phase trajectories of ODE, which was produced by StreamPlot.

Next following code ends up with this plot:

 f[x_, y_] = x/(-x - 2 y)
 StreamPlot[{1, f[x, y]}, {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]

Phase trajectoies

Unfortunately, streamlines are interrupting on line $y = -\dfrac{x}{2}$, when they should go as they were. By this, I mean that there should be only clockwise directed streamlines.

Is there any straightforward way to deal with this issue? Thank you!

$\endgroup$
6
  • 2
    $\begingroup$ But are you sure this is not right? y=-x/2 is where the direction of tangent changes. Just plug in x=-1, y=1 above this line and x=-1 y=0 below this line, and you get the slope of +1 for the former case and -1 for the latter case. $\endgroup$
    – MathX
    Mar 19, 2016 at 0:38
  • $\begingroup$ What is the ODE you're trying to plot the trajectories of? $\endgroup$
    – user484
    Mar 19, 2016 at 1:34
  • $\begingroup$ @Rahul This one: $ y' = \dfrac{x}{-x-2y} $ $\endgroup$
    – RuD_wow
    Mar 20, 2016 at 13:44
  • 2
    $\begingroup$ @RuD_wow: The denominator of that ODE cannot be $y = -\dfrac{x}{2}$, else the ODE is undefined. This is a line as shown in the phase portrait, so the phase portrait you show above is is correct. $\endgroup$
    – Moo
    Mar 20, 2016 at 14:22
  • $\begingroup$ @Moo But, what if we will calculate the eigenvalues of system $\dfrac{dx}{dt}, \dfrac{dy}{dt} $ and, considering their Real values, make a conclusion that DE' s phase trajectories are logarithmic clockwise spiral? $\endgroup$
    – RuD_wow
    Mar 21, 2016 at 18:12

2 Answers 2

4
$\begingroup$

Will this do the trick:

Clear[f]
f[x_, y_] := {1, x/(-x - 2 y)};
f[x_, y_] /; y > -x/2 := -{1, x/(-x - 2 y)};
StreamPlot[f[x, y], {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]
$\endgroup$
1
  • $\begingroup$ Thank you a lot! I was thining about the same tricky way, but stucked on how to implement it. $\endgroup$
    – RuD_wow
    Mar 20, 2016 at 14:26
2
$\begingroup$

Since we're not given an ODE by the OP, it's hard to comment on which phase portrait is correct. But taking the OP's desire for clockwise flow as given and working backwards, we might reach the following system (or a positive multiple of it): $${dx \over dt} = x+2y,\ {dy \over dt} = -x \,.\tag{1}$$ In that case, the phase field is given by

Clear[f]
f[x_, y_] := {x + 2 y, -x};

StreamPlot[f[x, y], {x, -10, 10}, {y, -10, 10}, Frame -> False, 
 Axes -> True, AspectRatio -> 1/GoldenRatio, StreamStyle -> "PinDart"]

enter image description here

(If the ODE/system was ${d^2y\over dt^2} + {dy \over dt} + 2y=0$, with $x = dy/dt$, then the flow as plotted would be the same as above, because the "position" y and the "velocity" x are switched from the usual velocity versus position. If the ODE/system was $dy/dx = x/(-x-2y)$, then $dx/dt = 1 > 0$ and all trajectories move to the right; the original stream plot was correct. And if the ODE/system was a negative multiple of (1), then the phase flow is counterclockwise.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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