# ParametricNDSolve without initial condition?

For example,

ParametricNDSolve[{y'[t] == a y[t]}, y, t, {a}]


returns a ParametricFunction which is actually inexplicable: How to understand it?

Edited: It should be noticed that it differs from

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


since

ParametricNDSolve[{y'[t] == a y[t]}, y, t, {a}]
y /. sol


returns warning messages:

1. ParametricNDSolve::ndlim: Range specification t is not of the form {x, xend} or {x, xmin, xmax}.

2. ParametricNDSolve::ndnco: The number of constraints (0) (initial conditions) is not equal to the total differential order of the system plus the number of discrete variables (1).

I wonder why ParametricNDSolve runs on though there isn't any initial conditions or boundary conditions.

• To start understanding it: what happens if you try evaluating it? – J. M. will be back soon May 18 '15 at 2:56
• @J. M. Thank you for your attention! I don't know how to use it correctly. – WateSoyan May 18 '15 at 2:56
• So, try something like ytest = y /. sol, and then maybe try ytest. – J. M. will be back soon May 18 '15 at 3:04
• But help shows how to use the result? The examples all show how to use it. Is the question about how to use the result or something else? – Nasser May 18 '15 at 3:08
• @WateSoyan I don't think there is anything wrong; the ParametricFunction object is constructed without actually solving the equation. Once we try to evaluate it for a numeric value of the parameter a, we see that there is an insufficient number of initial conditions. – ilian May 18 '15 at 13:00

ParametricNDSolve is a numerical solver. You need to give it enough numerical values for the parameters and domain that the solver can come up with a unique InterpolatingFunction representing the numerical solution of your equation.

First, your differential equation of course has a family of $y(t)$ functions as solutions. How can ParametricNDSolve choose one among those? You need to give the numerical solver boundary conditions. In this case I chose y == 1 arbitrarily.

Similarly, you need to specify over which interval of the independent variable you would like a solution.

Putting those together:

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


Let us now choose an explicit value for the parameter $a$, e.g. $0.3$:

yinstance = y[0.3] /. sol


This returns: Now we can plot this InterpolatingFunction, with $t$ ranging over the $(0,10)$ interval as specified in the call to the solver:

Plot[yinstance[t], {t, 0, 10}] • Aw, I was hoping the OP would try the experiment himself of trying to evaluate a ParametricFunction[] sans initial conditions… :D (+1 nevertheless) – J. M. will be back soon May 18 '15 at 3:28
• Sorry.I have posted my comparison between that with initial conditions or boundary conditions and that without them.But I wonder why ParametricNDSolve runs on though there isn't any initial conditions or boundary conditions... – WateSoyan May 18 '15 at 3:30
• @J. M. oopsie! and here I come, like the proverbial bull in the china shop, and spoil all the fun! :-) I'll have to be honest though: those error messages are really not the most illuminating, and they have driven me up the wall a few times as well... – MarcoB May 18 '15 at 3:31
• @WateSoyan I think that the catch is that no evaluation is actually attempted until you "force" it, e.g. by asking for a value etc. Having said that, I wholeheartedly agree with you there: it could fail A LOT more gracefully than that. I guess this is one more example of what I have seen the pro's refer to as Mathematica's "late to fail" philosophy. – MarcoB May 18 '15 at 3:33
• @WateSoyan I guess that in a way it is a kind attitude from the software's standpoint. It won't fail and throw up on you until it's really sure that you are without hope ;-) – MarcoB May 18 '15 at 3:35