# Hybrid Systemn Anomalous results while using ParametricNDSolveValue

The hybrid system that I am solving

pfun = ParametricNDSolveValue[{y''[t] == -9.8 bounce[t],
y[0] == height, y'[0] == 0, bounce[0] == 1,
WhenEvent[y[t] == 0,
If[Abs[y'[t]] > 10^-6,
y'[t] -> -0.7 y'[t], {bounce[t], y'[t]} -> {0, 0}]]},
y[t], {t, 0, 4}, {height}, DiscreteVariables -> bounce];
Plot[Evaluate[Table[pfun[height], {height, 1, 5, .2}]], {t, 0, 4},PlotRange -> All]


Result

Then I run the following:

Plot[Evaluate[Table[pfun'[height], {height, 1, 5, .2}]], {t, 0, 4},
PlotRange -> All]


Result:

Now I rerun

Plot[Evaluate[Table[pfun[height], {height, 1, 5, .2}]], {t, 0, 4},
PlotRange -> All]


to get

Try your second picture with this command:

Plot[Evaluate[Table[D[pfun[height], t], {height, 1, 5, .2}]], {t, 0,4}, PlotRange -> All]


Then repeating the first plot givse the same picture as it was:

Plot[Evaluate[Table[pfun[height], {height, 1, 5, .2}]], {t, 0, 4}, PlotRange -> All]


• Could you please explain what makes this different? – q than a Aug 12 '19 at 20:51
• pfun' means take derivative w.r.t. parameter, i.e. height in your case.I supposed you want to see dependance of derivative on time, so I changed this to explicit differenciation w.r.t. time t. I don't understand what's going on when you take derivative w.r.t. parameter, MMA somehow changes pfun after that. The same effect can be seen if you just take pfun'[1], then repeat first Plot---it changed. I think you better ask Wolfram support, probably this is a bug or misunderstanding. – Alx Aug 13 '19 at 4:48
• Interesting answer, thank you. But, No, I actually want the derivative with respect to the parameter height varied as a function of time.That is, (pfun' w.r.t height)[t] as a function of time. – q than a Aug 13 '19 at 14:58