For example, I want to draw the phase portraits near the saddle points $(-\pi,0)$ and $(\pi,0)$, but the code that follows can not plot traces near those points, because $(y,\,-10 \sin x - y) = (0,\,0) at those points.

Evaluating

splot = 
  StreamPlot[{y, -10 Sin[x] - y}, {x, -10, 10}, {y, -10, 10}, 
  StreamColorFunction -> "Rainbow", StreamScale -> 0.12];

produces

enter image description here

How can I plot a phase portraits like this image (picture come from Halil, Nonlinear Systems, 3rd, Chapter 2). You can see vector field crossing the saddle points!

enter image description here

Code follows

Eq1 = x'[t] == y[t];
Eq2 = y'[t] == -10 Sin[x[t]] - y[t];
pendulum = 
  StreamPlot[{y, -10 Sin[x] - y}, {x, -10, 10}, {y, -10, 10}, 
   StreamScale -> 0.12];
man1 = Manipulate[Show[pendulum,
   ParametricPlot[
    Evaluate[
     First[{x[t], y[t]} /. 
       NDSolve[{Eq1, Eq2, Thread[{x[0], y[0]} == {-3.14, 0}]}, {x, 
         y}, {t, 1, 10}]]], {t, 1, 10}, PlotStyle -> Green],
   ParametricPlot[
    Evaluate[
     First[{x[t], y[t]} /. 
       NDSolve[{Eq1, Eq2, Thread[{x[0], y[0]} == {-3.15, 0}]}, {x, 
         y}, {t, 1, 10}]]], {t, 1, 10}, PlotStyle -> Purple], 
   ParametricPlot[
    Evaluate[
     First[{x[t], y[t]} /. 
       NDSolve[{Eq1, Eq2, Thread[{x[0], y[0]} == point]}, {x, y}, {t, 
         0, T}]]], {t, 0, T}, PlotStyle -> Red]], {{T, 0.1}, 0.1, 
   10}, {{point, {Pi, 2 Pi}}, Locator}, SaveDefinitions -> True]

Thanks for Chris's comment,Reference from How to plot the stable and unstable manifolds of a hyperbolic fixed point of a nonlinear system of differential equations?

enter image description here

  • This is still not showing the separatrices. – murray Nov 9 at 15:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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