# How to solve for y for a set of implicit (in x and y) linear equations for use in Plot?

From a matrix m={{1, 1}, {-1, 1}}, a vector b={1, 2}, and a list of variables vars={x,y} we can generate a list of linear equations using the matrix equation m.vars==b which gives {x+y,-x+y}=={1,2}. How do I transform equations into eqs={1-x,x+2}? In other words how do I solve for y = rhs but only returning the rhs? I tried different things including picking parts with Part and ReplaceAll rules and transformations but none worked.

The reason I want equations in rhs form is that I figured out how to "visualize" linear equations using Plot. All other tutorials including Wolfram documentation and published books use ContourPlot or graphics primitives Line for this which I find too cumbersome for plotting the simplest of functions derived from matrix equations. With Plot it is very easy to do Plot[eqs,{x,-10,10}].

Here is my code to facilitate a solution...

ClearAll[m,b,eqs,vars,x,y];
vars = {x,y};
m = {{1, 1}, {-1, 1}};
b = {1, 2};
eqs = m.vars == b;


the solution should be equivalent to this...

eqs = {-x+1, x+2};
Plot[eqs, {x, -10, 10}]


This does what you want, but I am not sure that it is better than a ContourPlot approach in any meaningful way:

Plot[Evaluate[y /. First@Solve[#, y] & /@ Thread@eqs], {x, -10, 10}]


• Thank you for coming through for me again. I will give your solution a green check mark (Accept) after giving others a a good full day to answer this. Commented Aug 4, 2020 at 20:06
• @JulesManson You are very welcome! Commented Aug 4, 2020 at 20:26
• I prefer Plot for its most natural appearance especially the axes placement and styles. Unless I am mistaken axes placement in ContourPlot tends to be on the frame which I don't like. Commented Aug 4, 2020 at 21:35
• @JulesManson - Frame and Axes are options for all of the 2D plotting functions. If you don't like the defaults, specify your preferences, e.g., eqs = Thread[m.vars == b]; ContourPlot[Evaluate@eqs, {x, -10, 10}, {y, -10, 10}, Frame -> False, Axes -> True] Commented Aug 4, 2020 at 22:33
• @BobHanlon thanks for the tip. Commented Aug 4, 2020 at 23:59

Not an answer,just a another thinking.

Clear["*"];
m = {{1, 1}, {-1, 1}};
vars = {x, y};
b = {1, 2};
eqs = m.vars - b // Evaluate;
ParametricPlot[{u, v}, {u, -10, 10}, {v, -10, 10},
MeshFunctions -> (Function[{x, y}, #] & /@ eqs), Mesh -> {{0}},
MeshShading -> {{LightYellow, LightGreen}, {LightCyan, LightBrown}},
PlotStyle -> None, MeshStyle -> {{Thick, Red}, {Thick, Blue}},
Frame -> False, BoundaryStyle -> None]
`

• that is beautiful work. i might steal that. Commented Aug 18, 2020 at 11:27