1
$\begingroup$

I have this code which manipulates the control parameters of a NDSolve integration of two coupled ODEs with multiple initial conditions and then plots the results in a ParametricPlot.

f[x_, y_, a_, b_] := a - (b + 1) x + x^2 y
g[x_, y_, a_, b_] := b x - x^2 y

Manipulate[
 Module[
  {
   sol = 
   Table[
    NDSolve[
     {
      D[x[t], t] == f[x[t], y[t], a, b]
      ,D[y[t], t] == g[x[t], y[t], a, b]
      ,x[0] == ic[[i, 1]]
      ,y[0] == ic[[i, 2]]
     }
     ,{x, y}
     ,{t, 0, tmax}
    ]
    ,{i, 1, 3}
   ]
  }
  ,
  ParametricPlot[
   Evaluate[{x[t], y[t]} /. sol], {t, 0, tmax}
   ,PlotRange -> {0, 10}
  ]
 ]
 ,{{ic, Table[{i, i}, {i, 1, 3}]}, ControlType -> Locator}
 ,{{a, 0.5}, 0, 2}
 ,{{b, 2}, 0, 3}
 ,Delimiter
 ,{{tmax, 50}, 10, 100}
 ,ControlPlacement -> Left
]

The code works fine in Mathematica 9.0 in Linux -- showing three curves in different colors -- but it shows an empty plot in Mathematica 11.0 in Windows. What can I do to make it work in both Mathematica versions so that the three curves are plotted with different colors?

Notice that the same code without the Evaluate command within the parametric plot works fine in both versions of Mathematica, but of course it plots the three curves with the same color.

I suspect the problem must be with some update from version 9 to version 11 of Mathematica (or alternatively with the way things are handled in Linux vs Windows) of how lists are evaluated within the plot command. I tried to avoid Evaluate and use the Evaluated -> True option, but it still plots the three curves with the very same color.

$\endgroup$
2
  • $\begingroup$ It works fine for me in V11.1.1, Mac. $\endgroup$
    – Michael E2
    Jun 9, 2017 at 23:15
  • $\begingroup$ Also works with v11.1.0 Mac $\endgroup$
    – Bob Hanlon
    Jun 10, 2017 at 0:57

1 Answer 1

1
$\begingroup$

Your code, as posted in your question, does not work on my system. I am running V11.0.1 on OS X 10.10.2.

I was able to get it working by modifying it to this:

f[x_, y_, a_, b_] := a - (b + 1) x + x^2 y
g[x_, y_, a_, b_] := b x - x^2 y

Manipulate[
  Dynamic[
    iFuncs =
      Table[
        NDSolveValue[
          {D[x[t], t] == f[x[t], y[t], a, b],
           D[y[t], t] == g[x[t], y[t], a, b],
           x[0] == ic[[i, 1]], y[0] == ic[[i, 2]]},
          {x, y}, {t, 0, tmax}],
        {i, 3}];
    ParametricPlot[
      Evaluate @ Table[Through[iFuncs[[i]][t]], {i, 3}], {t, 0, tmax}, 
      PlotRange -> {0, 10}]],
  {iFuncs, None},
  {{ic, Table[{i, i}, {i, 3}]}, Locator},
  {{a, 0.5}, 0, 2, Appearance -> "Labeled"},
  {{b, 2}, 0, 3, Appearance -> "Labeled"},
  Delimiter,
  {{tmax, 50}, 10, 100, Appearance -> "Labeled"}]

funcs

$\endgroup$
1
  • $\begingroup$ @JackLaVigne. You are quite right. There was a editing typo in the code. I have edited the code once more. Hope I got right this time. $\endgroup$
    – m_goldberg
    Jun 10, 2017 at 1:46

Your Answer

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

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