# Use ParametricNDSolveValue for system of equations

I'm trying to use ParametricNDSolveValue for a system of equations. I want to have it create a function that takes in a single input and outputs a list. Here is my code thus far.

f[x_, y_] := y;
g[x_, y_] := -0.2 y - 9 Sin[x];

sol = ParametricNDSolveValue[{
x'[t] == f[x[t], y[t]],
y'[t] == g[x[t], y[t]],
x ==  x0,
y ==  y0},
{x, y},
{t, 0, tmax},
{x0, y0}];


From here, I'd like to create functions in terms of time, that outputs a list like so:

sol[x0, y0][t]
={1.234, 5.678}


However, the way I currently have the code structured, I need to do this:

sol[x0, y0][][t]
=1.234
sol[x0, y0][][t]
=5.678


I would like the sol[x0, y0] function output the list of numbers instead of having to run through each function inside of sol[x0, y0]. How can I reformat my code so that I can accomplish this?

tmax = 5;
sol = ParametricNDSolveValue[{x'[t] == f[x[t], y[t]], y'[t] == g[x[t], y[t]],
x == x0, y == y0}, {x, y}, {t, 0,  tmax}, {x0, y0}];


You can use Through:

Through @ sol[1, 2]


{-0.40324, 2.14714}

Or make function out of sol using Through:

ClearAll[soln]
soln[p0_, p1_][t_] := Through[sol[p0, p1]@t]
soln[1, 2]


{-0.40324, 2.14714}

Better yet, you can make tmax a parameter:

ClearAll[sol2, soln2, tmax]
sol2 = ParametricNDSolveValue[{x'[t] == f[x[t], y[t]], y'[t] == g[x[t], y[t]],
x == x0, y == y0}, {x, y}, {t, 0, tmax}, {x0, y0, tmax}]

soln2[p0_, p1_, tmax_][t_] := Through[sol2[p0, p1, tmax]@t]
soln2[1, 2, 5]


{-0.40324, 2.14714}

• It's related to the same question. Say, if I have {x[t], y[t]} set as a variable in ParametricNDSolve instead of {x,y}. How can I use Through @ sol[1, 2]. (note:I have to use that form because I have set my problem in {x[index,t], y[index,t]} form.) Jun 26 '20 at 16:04