I want to solve a basic differential equation with a parameter and have the resulting solutions show as a set of functions in a merged plot. I want to be able to do two things:

1- Be able to compare the solutions for several different nearby values of the parameter. (For example to see which has a larger max.) This seems to restrict me to the usual two-dimensional plot (as opposed to allocating an extra axis for the parameter).

2- Have a fixed axes, as opposed to letting the scale to change.

Perhaps I need a manipulate as a subset of the main manipulate. For example let's consider

Manipulate[{Solns = NDSolve[{u''[t] + 5*u'[t] + 6*u[t] == 0, u[0] == 2, 
 u'[0] == a}, {u}, {t, 0, 5}], Plot[{u[t] /. Solns}, {t, 0, 5}]}, {a, 0, 5}]

Here as $a$ changes the trace of older functions are erased before newer ones are drawn, and the axes change. I am looking for a design that gives some presence to the older plots, and fixes the axes. For example I could have a slider $d$ whose values I set as $d=\delta (0,1,2,...,n)$, say $d=0.00, 0.01, 0.02, 0.03, ..., 0.10$, and then plot the solutions (using different colors?) for each of the values of $a-d$ for the current value of $a$.

Any suggestion is appreciated.


1 Answer 1

pndsv = ParametricNDSolveValue[{u''[t] + 5*u'[t] + 6*u[t] == 0, 
    u[0] == 2, u'[0] == b}, u, {t, 0, 5}, {b}];
delta = .3 Range[0, 10];

 Plot[Evaluate[Table[pndsv[b][t], {b, a - delta}]], {t, 0, 5}, 
  PlotRange -> {0, 3}, ImageSize -> 400, 
  PlotStyle -> (Opacity /@ Range[0, 1, .1])], {{a, 3}, 0, 5}]

enter image description here


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.