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.


1 Answer 1


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}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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