I give a simple function code here...

Clear[a, x, t]; 
s = ParametricNDSolve[{x'[t] + a*x[t] == 0, x[0]==1}, x, {t, 0, 100}, {a}] 
y = x[1] /. s
y[5] /. s

I tabulated the solution in a list..

r = Table[y[a] /. s, {a, 0, 15}]

Then I used Select to select

st = Select[r, -3 < # < 1 &]

Now i tried to print required $x$ with their corresponding $a$, but I could not do this.

How could I do this, And their may be a case in which their are repeated x value for common a, how to identify that.Print[s, " ", a]

For reference I attach the pic of my code and result...code and the result

  • 4
    $\begingroup$ Why not tell Solve[] at the outset your constraints on the solution? Table[x /. Solve[x^2 - a^2 == 0 && -3 < x < 3, x], {a, 1, 14}] $\endgroup$ – J. M.'s technical difficulties Mar 3 '19 at 10:05
  • $\begingroup$ Thanks, it works, but it does not work with ParametricNDSolve or other functions. Actually I wnt to do this logic for a and q parameters of Mathieu equation, without using inbuilt Mathieu functions. $\endgroup$ – Kamal Kumar Mar 3 '19 at 13:18
  • 1
    $\begingroup$ Then you oversimplified your problem; maybe come up with a more representative, yet still sufficiently simple example? $\endgroup$ – J. M.'s technical difficulties Mar 3 '19 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.