Plot the equation system as is

The plot function does not want to plot the equation system as is:

eq = y == 5 + 2 x - Sqrt[-115 + 30 x + 6 x^2] ||
y == 5 + 2 x + Sqrt[-115 + 30 x + 6 x^2]
Plot[eq, {x, 0, 10}]

Out[...]=<... empty plot ...>


I can resolve that by rearrange the components:

eq = y == 5 + 2 x - Sqrt[-115 + 30 x + 6 x^2] ||
y == 5 + 2 x + Sqrt[-115 + 30 x + 6 x^2]
Subscript[y, 1][x] = eq[[1]][[2]]
Subscript[y, 2][x] = eq[[2]][[2]]
Plot[Evaluate[{Subscript[y, 1][x], Subscript[y, 2][x]}], {x, 0, 10}]


I don't want to rearrange the equation system, because it is the output from another function which depends on the input and can change unpredictably.

How to resolve that w/o splitting up the equation system on components?

In some cases you can directly "plot" a logical expression as an implicit region plot:

RegionPlot[ImplicitRegion[eq, {{x, 0, 10}, {y, 0, 40}}],
PlotPoints -> 100]


note this plot erroneously plots a line for x<~2.5 , but still may be useful to you.

• What MM version are you running? I'm running 10.4.1 on a Mac, and it doesn't produce a plot for $x \lesssim 2.5$. – Michael Seifert Apr 23 '18 at 21:31
• @MichaelSeifert I see this in 10.1\Windows and 11.1.1\Linux. – george2079 Apr 23 '18 at 21:33
• Seems 11.2 version falls into infinite loop to plot that. – Andry Apr 23 '18 at 21:38
• as you see the region functions are a bit tempermental. – george2079 Apr 23 '18 at 21:45

Let's try a little pattern matching

eq = y == 5 + 2 x - Sqrt[-115 + 30 x + 6 x^2] ||
y == 5 + 2 x + Sqrt[-115 + 30 x + 6 x^2];
neweq=List@@eq /.Equal[y,v_]->v;
Plot[neweq,{x,0,10}]

• This is another one splitup. What about more complicated equation with intervals like x > 0, y >= 0? Do I need to predict all over the place rules for that? – Andry Apr 23 '18 at 21:02
• As nicely as I can possibly put it, it is really common for a person to post a question, another person reads that, writes the answer to that and the first person responds "yah but, what if I wanted the answer to something different?" It is a difficult balancing act to find a way to express a problem that isn't too broad, vague and general and thus potentially gets no answer at all versus how to express a problem that is too narrow and limited and doesn't answer what the person really wanted. I don't know how to resolve that, not at least until MMA includes the "Do What I Mean" button. – Bill Apr 23 '18 at 21:08
• Does it means I have to manually analyze the output of each equation solution and write my own pattern-parser for it? – Andry Apr 23 '18 at 21:17
• You can learn about things like ToRules that might help you. You can explore the ever growing list of new different kinds of plotting functions that might help you. But since Plot wants to plot a simple expression or a list of simple expressions then it seems really unlikely that you will be able to make Plot work for you if you give it what may be an arbitrary collection of boolean conditions and expressions and equations and get what you seem to be hoping for. So roughly I think the answer to your latest question is: yes. – Bill Apr 23 '18 at 21:23
eq = y == 5 + 2 x - Sqrt[-115 + 30 x + 6 x^2] ||
y == 5 + 2 x + Sqrt[-115 + 30 x + 6 x^2];

Plot[Evaluate[y /. {eq // ToRules}], {x, -15, 10},
PlotLegends -> Placed["Expressions", {.25, .75}]]


Also,

ContourPlot[Evaluate[List @@ eq], {x, -15, 10}, {y, -60, 60},
PlotPoints -> 100, PlotLegends -> Placed["Expressions", {.35, .75}]]