1
$\begingroup$

I have a numerical solution and when I solve it with NSolve, and substitue the results in an expression, I get something like:

1 + x + x^2 if 0 < x< 10

I want to plot the expression above in a Manipulate. Is there any way of getting the range {0, 10} in above dynamically, so I can only expose valid values?

$\endgroup$
  • 1
    $\begingroup$ I don't see how you can get something like 1 + x + x^2 if 0 < x< 10, since it's not syntactially valid. Problems with code require the code for diagnosis, or an MWE exhibiting the equivalent behavior. $\endgroup$ – Michael E2 Jul 8 at 0:11
  • $\begingroup$ When I stared at my results a bit more, I asked myself the same question. :) here is the original problem: mathematica.stackexchange.com/questions/225485/… $\endgroup$ – Shb Jul 8 at 0:20
2
$\begingroup$

What you are seeing is a ConditionalExpression.

expr = ConditionalExpression[1 + x + x^2, 0 < x < 10]

enter image description here

To convert the condition to a List

(List @@ expr[[-1]])[[{2, 1, 3}]]

(* {x, 0, 10} *)

or

(List @@ expr[[-1]])[[{1, 3}]]

(* {0, 10} *)
| improve this answer | |
$\endgroup$

Your Answer

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

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