3
$\begingroup$

Recently I've came across the command ParametricNDSolveValue, which allows the user to solve DEs with one or more parameters. I've tried setting

Y := ParametricNDSolveValue[{y'[x] == 1, y[x0] == y0}, 
  y, {x, -10, 10}, {x0, y0}]

and then plugging in $x_0=y_0=0$, and evaluating at $x=1$ using Y[0, 0][1]. However, the result of the latter doesn't go through as expected at all. I'm getting an output of the form

ParametricFunction[ <> ][0, 0][1]

instead of the number $1$ (or some approximation of it).

I noticed that setting $x_0$ as an external parameter to ParametricNDSolveValue, that is defining

Clear[Y]
Y[x0_] := 
 ParametricNDSolveValue[{y'[x] == 1, y[x0] == y0}, y, {x, -10, 10}, 
  y0]

and following up with Y[0][0][1] does indeed give $1.0$ as expected.

My questions are: is there really no way to use ParametricNDSolveValue with one of the parameters being the point at which the initial condition is given? If so, is my solution considered elegant? Is there a better way to go about this?

Thank you!

$\endgroup$
1
  • $\begingroup$ @MMM nope, thank you. $\endgroup$
    – user1337
    Commented Feb 8, 2017 at 8:01

1 Answer 1

2
$\begingroup$

Why don't you use NDSolve instead?

sol[x0_, y0_] := NDSolve[{y'[x] == 1, y[x0] == y0}, y, {x, -10, 10}];
yfun = First[y /. sol[0, 0]];
yfun[1]

1

$\endgroup$

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