# Constraining the parameter value range in ParametricNDSolve

I am trying to use ParametricNDSolve to solve a set of ODEs, but I want to give a range for the parameter before solving the equations. How can I constrain the range of the parameter that ParametricNDSolve should use?

For example, in the equation below, I want to try and solve the ODEs for a between 4 and 6 only.

ParametricNDSolve[{y'[t] == a y[t], y == 1}, y, {t, 0, 10}, {a}]

• Why? With sol = y /. ParametricNDSolve[....] you can just sol to have a=4 and also for other a that you're interested in. Jan 10, 2017 at 21:47

Your question seems to raise a non-issue. The parametric function returned from evaluating

 yF = ParametricNDSolveValue[{y'[t] == a y[t], y == 1}, y, {t, 0, 10}, {a}]


is good for any value of a in your range of interest. This is demonstrated by

LogPlot[Evaluate @ Table[yF[a][t], {a, 4, 6, .5}], {t, 0, 10}, PlotRange -> All] If, for further calculations, you have the need to constrain evaluation to a in the stated range, you can derive a constrained family of functions like so:

yCF[a_ /; 4 <= a <= 6] := YF[a]


yCF will only accept parameter values in stated range and return unevaluated for any other values.

• Thank you for your reply. Now if I have the code below: d = {{9.721036901*10^-7, 0.80119823*10^-6}, {9.728704323*10^-7, 0.83015194*10^-6}, {9.728577185000001*10^-7, 0.857031534*10^-6},{9.728430487000002*10^-7, 0.88804645*10^-6}, {9.733506242*10^-7, 0.914930348*10^-6}, {9.733359543*10^-7, 0.945945264*10^-6}}; b = Interpolation[d, InterpolationOrder -> 1]; bb = b[a]*10^-4; yF = ParametricNDSolveValue[{y'[t] == bb y[t], y == 1}, y, {t, 0, 10}, {a}], Mathematica is solving the DE but Ican't plot anything. Jan 10, 2017 at 22:37
• @math_enthusiast. That is an entirely different question. You need to post it as new question. Jan 10, 2017 at 23:20