# Extracting parameter values from evaluation of parametric solution

I have this system of differential equations :

$\frac{dX}{dt} = (0.8+0.4c_{1})X-(0.007+0.006c_{2})XY$

$\frac{dY}{dt} = (0.048+0.004c_{3})XY-(0.4+0.2c_{4})Y$

where $c_{i}$s are parameters.

I solve the system using the follwing code :

   sol = ParametricNDSolve[{x'[t] == (0.8 + 0.4 c1) x[t] - (0.009 + 0.002 c2) x[t] y[t],
y'[t] == (0.0049 + 0.0002 c3) x[t] y[t] - (0.4 + 0.2 c4) y[t],
x == 200, y == 80}, {x, y}, {t, 0, 25}, {c1, c2, c3, c4}]


I then set the parameter values as $c_{i}=\{0,1\}$ for $i=1,2,3,4$. I tabulate the results using the following code :

xt = Flatten[Evaluate[Table[x[c1, c2, c3, c4][t] /.sol,
{c1, {0, 1}}, {c2, {0, 1}}, {c3, {0, 1}}, {c4, {0, 1}}]]] //MatrixForm


This gives the following output Question 1 How do I know which InterpolatingFunction corresponds to which particular combination of $c_{i}$ ?

Now I evaluate all the InterpolatingFunction for $t=0(0.25)25$ using this code :

mat = Table[Table[Evaluate[xt[[a]]], {t, 0, 25, 2.5}], {a,Range[Length[xt]]}] // MatrixForm


giving the following output : Question 2

Each row in the above matrix displays the evaluation of one of the InterpolatingFunction for $t=0(0.25)25$. I need to get the columnwise maximum(and minimum) for this matrix at $t=0,5,10,...,25$ and want to identify which InterpolatingFunction it comes from.

I got the maximum using

l = Min /@ Transpose[mat]


But couldn't identify which InterpolatingFunction the maximums come from.

Any help is appreciated.

• Maybe something like Flatten[Table[{{c1, c2, c3, c4}, x[c1, c2, c3, c4][t] /.sol}, {c1, {0, 1}}, {c2, {0, 1}}, {c3, {0, 1}}, {c4, {0, 1}}], 3], then? Feb 1, 2017 at 14:31
• That does it. What does the 3 at the end do? And what about the second question? Feb 1, 2017 at 14:33
• "What does the 3 at the end do?" - at this point, what you should be doing instead is to look at the docs for Flatten[]. ;) Feb 1, 2017 at 14:36
• Yeah. I should do it myself. Thanks for the heads-up though. Feb 1, 2017 at 14:45

One way to make the table from NDSolve is,

points = Permutations[{0, 1, 0, 1, 0, 1, 0, 1}, {4}];
datax = TableForm[Table[Flatten[{t,Table[{x[c1, c2, c3, c4][t] /. sol}, {c1, {0, 1}},
{c2, {0,1}}, {c3, {0, 1}}, {c4, {0, 1}}]}], {t, 0, 10, 0.5}],
TableHeadings -> {None, Prepend[Array["x", Length[points]], t]}] datay = TableForm[Table[Flatten[{t,Table[{y[c1, c2, c3, c4][t] /. sol}, {c1, {0, 1}},
{c2, {0,1}}, {c3, {0, 1}}, {c4, {0, 1}}]}], {t, 0, 10, 0.5}],
TableHeadings -> {None, Prepend[Array["y", Length[points]], t]}] I don't know, how to make the headings for the column automated.