2
$\begingroup$

Suppose I use NSolve to find the Real approximations to the intersections of two separate functions over some specified range:

NSolve[{x[n] == y[1], 0 <= n <= 5}, {n}, Reals] 

How can I parse the numerical values into the list of functions demanded by the Plot call?

Plot[{list of numerical values from NSolve},{z,0,1}] 

where z is a random variable ensuring the x-axis exists.

I want to plot a series of horizontal lines such that the above logic makes sense.

Additionally, if I had to run NSolve N times, how would I accumulate all the parsed numbers into a single list such that Plot would graph them as horizontal lines?

Thank you for your time.

$\endgroup$

1 Answer 1

3
$\begingroup$

Use Map over ReplaceAll to translate all your solutions into a list of constants.

Example using randomly selected functions that seem to work:

sols = NSolve[{10 Sin[4 n] == Exp[1], 0 <= n <= 5}, {n}, Reals]; Plot[Map[n /. # &, sols], {z, 0, 1}] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.